Re: For review: newlocale.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mike,

On Thu, Mar 13, 2014 at 9:13 AM, Mike Frysinger <vapier@xxxxxxxxxx> wrote:
> On Wed 12 Mar 2014 16:47:43 Michael Kerrisk wrote:
>> .SH DESCRIPTION
>> The
>> .BR newlocale ()
>> function creates a new locale object, or modifies an existing object,
>> returning a reference to the new or modified object as the function result.
>> Whether the call creates a new object or modifies an existing object
>> is determined by the value of
>> .IR base :
>
> you discuss the value of |base| first ...
>
>> .PP
>> The
>> .I category_mask
>
> ... then the |category_mask| ...
>
>> The following preset values of
>> .I locale
>
> ... then the |locale| ...
>
> (side note: shouldn't there be a .PP to start this portion ?)

Yup, better. Added.

>> .PP
>> If
>> .I base
>
> ... then back to |base| ?  generally i expect the discussion of each argument
> to be together rather than split across paragraphs.  if i were referring to
> this for programming, i probably wouldn't have even made it this far.

Okay -- I moved that para to go with the rest of the description of 'base'.

>> .B EINVAL
>> One or more bits in
>> .I category_mask
>> does not correspond to a valid locale category.
>
> does->do

Fixed.

>> Having created and initialized the locale object,
>> the program then applies it using
>> .BR uselocale (),
>
> shouldn't that be (3) ?

Yup.

>> Te Paraire, te 07 o Poutū-te-rangi, 2014 00:38:44 CET
>> .fi
>> .in
>>
>> .in +4n
>> .nf
>>
>> .fi
>> .in
>> .SS Program source
>
> this ends up rendering 3 blank lines before "Program source" when really only
> one is needed

Funny, id didn't render that way for me. However, the above piece is
obviously cruft, and I removed it ;-).

>> .nf
>> #define _XOPEN_SOURCE 700
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <locale.h>
>> #include <time.h>
>>
>> #define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \\
>>                         } while (0)
>
> not sure what standard you're aiming for, but if you include err.h, you don't
> need this macro.  you can just call err(1, msg).

I tend to avoid those functions because they're nonstandard (some of
the examples in man pages do compile and sun on non-Linux systems).
So, I just roll my own short macros.

>>     if (argc > 2) {
>>         nloc = newlocale(LC_TIME_MASK, argv[2], loc);
>>         if (loc == (locale_t) 0)
>
> shouldn't you be testing nloc ?

Yup!

> if you're just going to exit on error, i wonder why even bother with nloc
> indirection

More to illustrate the point that this is how to do things generally
(i.e., we might be doing something other than exiting on error). I've
added a comment explaining this.

>>     s = strftime(buf, BUF_SIZE, "%c", tm);
>
> why not sizeof(buf) ?  avoids needing BUF_SIZE at all.

Yes, simpler. Done.

Thanks for the comments, Mike.

Cheers,

Michael



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux