From 85c165befc61d049abe3cc443c275a210c569338 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 1 Sep 1998 10:41:59 +0000 Subject: Update. 1998-09-01 10:34 Ulrich Drepper * manual/locale.texi: Almost compelte rewrite. Document more functions and functionality. * manual/arith.texi: Correct reference. * manual/string.texi: Pretty printing. * manual/texinfo.tex: Update from last available version. 1998-08-31 22:44 Ulrich Drepper * nis/nss_nis/nis-pwd.c (_nss_nis_getpwnam_r): Correct test for invalid password. (_nss_nis_getpwuid_r): Likewise. Patch by Matthew Arnison . * inet/rcmd.c: Implement netgroup support. Patch by Dick Streefland . --- BUGS | 5 +- ChangeLog | 19 ++ inet/rcmd.c | 260 +++++++++++++++------ manual/arith.texi | 2 +- manual/locale.texi | 625 ++++++++++++++++++++++++++++++++++++++++++++++---- manual/string.texi | 2 + manual/texinfo.tex | 40 ++-- manual/top-menu.texi | 11 +- nis/nss_nis/nis-pwd.c | 4 +- 9 files changed, 820 insertions(+), 148 deletions(-) diff --git a/BUGS b/BUGS index 3a2e7e53ca..6dad3db225 100644 --- a/BUGS +++ b/BUGS @@ -1,7 +1,7 @@ List of known bugs (certainly very incomplete) ---------------------------------------------- -Time-stamp: <1998-04-08T09:29:12-0700 drepper> +Time-stamp: <1998-09-01T10:40:39-0700 drepper> This following list contains those bugs which I'm aware of. Please make sure that bugs you report are not listed here. If you can fix one @@ -45,9 +45,6 @@ Severity: [ *] to [***] which are not defined in the charmap. [PR libc/229] -[ *] The rcmd() functions (more concrete: the handling of .rhosts) does - not support netgroups and wildcards (+). - [ *] When assembling a locale definition, that uses the "copy" directive, with localedef, not only the copied category is checked for errors, but the whole file containing the same diff --git a/ChangeLog b/ChangeLog index 750136ad06..c8b0b05801 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1998-09-01 10:34 Ulrich Drepper + + * manual/locale.texi: Almost compelte rewrite. Document more functions + and functionality. + * manual/arith.texi: Correct reference. + * manual/string.texi: Pretty printing. + + * manual/texinfo.tex: Update from last available version. + +1998-08-31 22:44 Ulrich Drepper + + * nis/nss_nis/nis-pwd.c (_nss_nis_getpwnam_r): Correct test for + invalid password. + (_nss_nis_getpwuid_r): Likewise. + Patch by Matthew Arnison . + + * inet/rcmd.c: Implement netgroup support. + Patch by Dick Streefland . + 1998-08-31 Ulrich Drepper * elf/dl-close.c (_dl_close): Update _dl_loaded if the first diff --git a/inet/rcmd.c b/inet/rcmd.c index 51fa34eca8..483e7b389d 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -55,8 +55,10 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include -int __ivaliduser __P((FILE *, u_int32_t, const char *, const char *)); -static int __icheckhost __P((u_int32_t, char *)) internal_function; +int __ivaliduser __P ((FILE *, u_int32_t, const char *, const char *)); +static int __ivaliduser2 __P ((FILE *, u_int32_t, const char *, const char *, + const char *)); + int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) @@ -283,7 +285,7 @@ ruserok(rhost, superuser, ruser, luser) for (ap = hp->h_addr_list; *ap; ++ap) { bcopy(*ap, &addr, sizeof(addr)); - if (iruserok(addr, superuser, ruser, luser) == 0) + if (iruserok(addr, superuser, ruser, luser, rhost) == 0) return 0; } return -1; @@ -341,11 +343,11 @@ iruserfopen (char *file, uid_t okuser) * * Returns 0 if ok, -1 if not ok. */ -int -iruserok (raddr, superuser, ruser, luser) +static int +iruserok2 (raddr, superuser, ruser, luser, rhost) u_int32_t raddr; int superuser; - const char *ruser, *luser; + const char *ruser, *luser, *rhost; { FILE *hostf = NULL; int isbad; @@ -355,7 +357,7 @@ iruserok (raddr, superuser, ruser, luser) if (hostf) { - isbad = __ivaliduser (hostf, raddr, luser, ruser); + isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost); fclose (hostf); if (!isbad) @@ -388,7 +390,7 @@ iruserok (raddr, superuser, ruser, luser) if (hostf != NULL) { - isbad = __ivaliduser (hostf, raddr, luser, ruser); + isbad = __ivaliduser2 (hostf, raddr, luser, ruser, rhost); fclose (hostf); } @@ -398,10 +400,25 @@ iruserok (raddr, superuser, ruser, luser) return -1; } +/* This is the exported version. */ +int +iruserok (raddr, superuser, ruser, luser) + u_int32_t raddr; + int superuser; + const char *ruser, *luser; +{ + return iruserok2 (raddr, superuser, ruser, luser, "-"); +} + /* * XXX * Don't make static, used by lpd(8). * + * This function is not used anymore. It is only present because lpd(8) + * calls it (!?!). We simply call __invaliduser2() with an illegal rhost + * argument. This means that netgroups won't work in .rhost/hosts.equiv + * files. If you want lpd to work with netgroups, fix lpd to use ruserok() + * or PAM. * Returns 0 if ok, -1 if not ok. */ int @@ -410,87 +427,194 @@ __ivaliduser(hostf, raddr, luser, ruser) u_int32_t raddr; const char *luser, *ruser; { - register char *user, *p; - int ch; - char *buf = NULL; - char *cp; - size_t bufsize = 0; - ssize_t nread; - - while ((nread = __getline (&buf, &bufsize, hostf)) > 0) { - buf[bufsize - 1] = '\0'; /* Make sure it's terminated. */ - /* Because the file format does not know any form of quoting we - can search forward for the next '#' character and if found - make it terminating the line. */ - cp = strchr (buf, '#'); - if (cp != NULL) - *cp = '\0'; - p = buf; - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - *p = isupper(*p) ? tolower(*p) : *p; - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && - *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - if (__icheckhost(raddr, buf) && - strcmp(ruser, *user ? user : luser) == 0) { - free (buf); - return 0; - } - } - if (buf != NULL) - free (buf); - return -1; + return __ivaliduser2(hostf, raddr, luser, ruser, "-"); } -/* - * Returns "true" if match, 0 if no match. - */ + +/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ static int internal_function -__icheckhost(raddr, lhost) +__icheckhost (raddr, lhost, rhost) u_int32_t raddr; - register char *lhost; + char *lhost; + const char *rhost; { struct hostent hostbuf, *hp; size_t buflen; char *buffer; - register u_int32_t laddr; - register char **pp; int herr; + int save_errno; + u_int32_t laddr; + int negate=1; /* Multiply return with this to get -1 instead of 1 */ + char **pp, *user; + + /* Check nis netgroup. */ + if (strncmp ("+@", lhost, 2) == 0) + return innetgr (&lhost[2], rhost, NULL, NULL); + + if (strncmp ("-@", lhost, 2) == 0) + return -innetgr (&lhost[2], rhost, NULL, NULL); + + /* -host */ + if (strncmp ("-", lhost,1) == 0) { + negate = -1; + lhost++; + } else if (strcmp ("+",lhost) == 0) { + return 1; /* asking for trouble, but ok.. */ + } /* Try for raw ip address first. */ - if (isdigit(*lhost) && (int32_t)(laddr = inet_addr(lhost)) != -1) - return raddr == laddr; + if (isdigit (*lhost) && (long) (laddr = inet_addr (lhost)) != -1) + return negate * (! (raddr ^ laddr)); /* Better be a hostname. */ buflen = 1024; buffer = __alloca (buflen); + save_errno = errno; while (__gethostbyname_r (lhost, &hostbuf, buffer, buflen, &hp, &herr) < 0) - if (herr != NETDB_INTERNAL || errno != ERANGE) - return 0; - else - { - /* Enlarge the buffer. */ - buflen *= 2; - buffer = __alloca (buflen); - } + if (herr != NETDB_INTERNAL || errno != ERANGE) + return (0); + else { + /* Enlarge the buffer. */ + buflen *= 2; + buffer = __alloca (buflen); + __set_errno (0); + } + __set_errno (save_errno); + if (hp == NULL) + return 0; /* Spin through ip addresses. */ for (pp = hp->h_addr_list; *pp; ++pp) - if (!memcmp(&raddr, *pp, sizeof(u_int32_t))) - return 1; + if (!memcmp (&raddr, *pp, sizeof (u_int32_t))) + return negate; /* No match. */ - return 0; + return (0); +} + +/* Returns 1 on positive match, 0 on no match, -1 on negative match. */ +static int +internal_function +__icheckuser (luser, ruser) + const char *luser, *ruser; +{ + /* + luser is user entry from .rhosts/hosts.equiv file + ruser is user id on remote host + */ + char *user; + + /* [-+]@netgroup */ + if (strncmp ("+@", luser, 2) == 0) + return innetgr (&luser[2], NULL, ruser, NULL); + + if (strncmp ("-@", luser,2) == 0) + return -innetgr (&luser[2], NULL, ruser, NULL); + + /* -user */ + if (strncmp ("-", luser, 1) == 0) + return -(strcmp (&luser[1], ruser) == 0); + + /* + */ + if (strcmp ("+", luser) == 0) + return 1; + + /* simple string match */ + return strcmp (ruser, luser) == 0; +} + +/* + * Returns 1 for blank lines (or only comment lines) and 0 otherwise + */ +static int +__isempty(p) + char *p; +{ + while (*p && isspace (*p)) { + ++p; + } + + return (*p == '\0' || *p == '#') ? 1 : 0 ; +} + +/* + * Returns 0 if positive match, -1 if _not_ ok. + */ +static int +__ivaliduser2(hostf, raddr, luser, ruser, rhost) + FILE *hostf; + u_int32_t raddr; + const char *luser, *ruser, *rhost; +{ + register const char *user; + register char *p; + int hcheck, ucheck; + char *buf = NULL; + size_t bufsize = 0; + + while (__getline (&buf, &bufsize, hostf) > 0) { + buf[bufsize - 1] = '\0'; /* Make sure it's terminated. */ + p = buf; + + /* Skip empty or comment lines */ + if (__isempty (p)) { + continue; + } + + /* Skip lines that are too long. */ + if (strchr (p, '\n') == NULL) { + int ch = getc (hostf); + + while (ch != '\n' && ch != EOF) + ch = getc (hostf); + continue; + } + + for (;*p && !isspace(*p); ++p) { + *p = tolower (*p); + } + + /* Next we want to find the permitted name for the remote user. */ + if (*p == ' ' || *p == '\t') { + /* terminate hostname and skip spaces */ + for (*p++='\0'; *p && isspace (*p); ++p); + + user = p; /* this is the user's name */ + while (*p && !isspace (*p)) + ++p; /* find end of user's name */ + } else + user = p; + + *p = '\0'; /* terminate username (+host?) */ + + /* buf -> host(?) ; user -> username(?) */ + + /* First check host part */ + hcheck = __icheckhost (raddr, buf, rhost); + + if (hcheck < 0) + return -1; + + if (hcheck) { + /* Then check user part */ + if (! (*user)) + user = luser; + + ucheck = __icheckuser (user, ruser); + + /* Positive 'host user' match? */ + if (ucheck > 0) + return 0; + + /* Negative 'host -user' match? */ + if (ucheck < 0) + return -1; + + /* Neither, go on looking for match */ + } + } + + return -1; } diff --git a/manual/arith.texi b/manual/arith.texi index bb7ec34793..79bbcfdce7 100644 --- a/manual/arith.texi +++ b/manual/arith.texi @@ -1908,7 +1908,7 @@ An optional plus or minus sign (@samp{+} or @samp{-}). @item A nonempty sequence of digits optionally containing a decimal-point character---normally @samp{.}, but it depends on the locale -(@pxref{Numeric Formatting}). +(@pxref{General Numeric}). @item An optional exponent part, consisting of a character @samp{e} or diff --git a/manual/locale.texi b/manual/locale.texi index f4fa3a71a5..0c13d068cf 100644 --- a/manual/locale.texi +++ b/manual/locale.texi @@ -29,8 +29,8 @@ will follow the conventions preferred by the user. * Setting the Locale:: How a program specifies the locale with library functions. * Standard Locales:: Locale names available on all systems. -* Numeric Formatting:: How to format numbers according to the - chosen locale. +* Locale Information:: How to access the information for the locale. +* Formatting Numbers:: A dedicated functions to format numbers. @end menu @node Effects of Locale, Choosing Locale, , Locales @@ -54,14 +54,14 @@ The collating sequence for the local language and character set (@pxref{Collation Functions}). @item -Formatting of numbers and currency amounts (@pxref{Numeric Formatting}). +Formatting of numbers and currency amounts (@pxref{General Numeric}). @item Formatting of dates and times (@pxref{Formatting Date and Time}). @item -What language to use for output, including error messages. -(The C library doesn't yet help you implement this.) +What language to use for output, including error messages +(@pxref{Message Translation}). @item What language to use for user answers to yes-or-no questions. @@ -80,8 +80,8 @@ Other aspects of locales are beyond the comprehension of the library. For example, the library can't automatically translate your program's output messages into other languages. The only way you can support output in the user's favorite language is to program this more or less -by hand. (Eventually, we hope to provide facilities to make this -easier.) +by hand. The C library provides functions to handle translations for +multiple languages easily. This chapter discusses the mechanism by which you can modify the current locale. The effects of the current locale on specific library functions @@ -99,7 +99,8 @@ most of Spain. The set of locales supported depends on the operating system you are using, and so do their names. We can't make any promises about what locales will exist, except for one standard locale called @samp{C} or -@samp{POSIX}. +@samp{POSIX}. Later we will describe how to construct locales XXX. +@comment (@pxref{Building Locale Files}). @cindex combining locales A user also has the option of specifying different locales for different @@ -127,18 +128,16 @@ independently. Here is a table of categories; each name is both an environment variable that a user can set, and a macro name that you can use as an argument to @code{setlocale}. -@table @code +@vtable @code @comment locale.h @comment ISO @item LC_COLLATE -@vindex LC_COLLATE This category applies to collation of strings (functions @code{strcoll} and @code{strxfrm}); see @ref{Collation Functions}. @comment locale.h @comment ISO @item LC_CTYPE -@vindex LC_CTYPE This category applies to classification and conversion of characters, and to multibyte and wide characters; see @ref{Character Handling} and @ref{Extended Characters}. @@ -146,47 +145,52 @@ see @ref{Character Handling} and @ref{Extended Characters}. @comment locale.h @comment ISO @item LC_MONETARY -@vindex LC_MONETARY -This category applies to formatting monetary values; see @ref{Numeric -Formatting}. +This category applies to formatting monetary values; see @ref{General Numeric}. @comment locale.h @comment ISO @item LC_NUMERIC -@vindex LC_NUMERIC This category applies to formatting numeric values that are not -monetary; see @ref{Numeric Formatting}. +monetary; see @ref{General Numeric}. @comment locale.h @comment ISO @item LC_TIME -@vindex LC_TIME This category applies to formatting date and time values; see @ref{Formatting Date and Time}. @comment locale.h @comment XOPEN @item LC_MESSAGES -@vindex LC_MESSAGES -This category applies to selecting the language used in the user interface -for message translation. -@ignore see @ref{gettext} and @ref{catgets} -@end ignore +This category applies to selecting the language used in the user +interface for message translation (@ref{The Uniforum approach} and +@ref{Message catalogs a la X/Open}). @comment locale.h @comment ISO @item LC_ALL -@vindex LC_ALL This is not an environment variable; it is only a macro that you can use -with @code{setlocale} to set a single locale for all purposes. +with @code{setlocale} to set a single locale for all purposes. Setting +this environment variable overwrites all selections by the other +@code{LC_*} variables or @code{LANG}. @comment locale.h @comment ISO @item LANG -@vindex LANG If this environment variable is defined, its value specifies the locale to use for all purposes except as overridden by the variables above. -@end table +@end vtable + +@vindex LANGUAGE +When developing the message translation functions it was felt that the +functionality provided by the variables above is not sufficient. E.g., it +should be possible to specify more than one locale name. For an example +take a Swedish user who better speaks German than English, the programs +messages by default are written in English. Then it should be possible +to specify that the first choice for the language is Swedish, the second +choice is German, and if this also fails English is used. This is +possible with the variable @code{LANGUAGE}. For further description of +this GNU extension see @ref{Using gettextized software}. @node Setting the Locale, Standard Locales, Locale Categories, Locales @section How Programs Set the Locale @@ -203,7 +207,8 @@ setlocale (LC_ALL, ""); @end smallexample @noindent -to select a locale based on the appropriate environment variables. +to select a locale based on the user choice of the appropriate +environment variables. @cindex changing the locale @cindex locale, changing @@ -245,6 +250,10 @@ don't make any promises about what it looks like. But if you specify the same ``locale name'' with @code{LC_ALL} in a subsequent call to @code{setlocale}, it restores the same combination of locale selections. +To ensure to be able to use the string encoding the currently selected +locale at a later time one has to make a copy of the string. It is not +guaranteed that the return value stays valid all the time. + When the @var{locale} argument is not a null pointer, the string returned by @code{setlocale} reflects the newly modified locale. @@ -252,6 +261,9 @@ If you specify an empty string for @var{locale}, this means to read the appropriate environment variable and use its value to select the locale for @var{category}. +If a nonempty string is given for @var{locale} the locale with this name +is used, if this is possible. + If you specify an invalid locale name, @code{setlocale} returns a null pointer and leaves the current locale unchanged. @end deftypefun @@ -291,10 +303,11 @@ with_other_locale (char *new_locale, @end smallexample @strong{Portability Note:} Some @w{ISO C} systems may define additional -locale categories. For portability, assume that any symbol beginning -with @samp{LC_} might be defined in @file{locale.h}. +locale categories and future versions of the library will do so. For +portability, assume that any symbol beginning with @samp{LC_} might be +defined in @file{locale.h}. -@node Standard Locales, Numeric Formatting, Setting the Locale, Locales +@node Standard Locales, Locale Information, Setting the Locale, Locales @section Standard Locales The only locale names you can count on finding on all operating systems @@ -317,10 +330,10 @@ The empty name says to select a locale based on environment variables. Defining and installing named locales is normally a responsibility of the system administrator at your site (or the person who installed the -GNU C library). Some systems may allow users to create locales, but -we don't discuss that here. -@c ??? If we give the GNU system that capability, this place will have -@c ??? to be changed. +GNU C library). It is also possible for the user to create private +locales. All this will be discussed later when describing the tool to +do so XXX. +@comment (@pxref{Building Locale Files}). If your program needs to use something other than the @samp{C} locale, it will be more portable if you use whatever locale the user specifies @@ -328,13 +341,52 @@ with the environment, rather than trying to specify some non-standard locale explicitly by name. Remember, different machines might have different sets of locales installed. -@node Numeric Formatting, , Standard Locales, Locales -@section Numeric Formatting +@node Locale Information, Formatting Numbers, Standard Locales, Locales +@section Accessing the Locale Information + +There are several ways to access the locale information. The simplest +way is to let the C library itself do the work. Several of the +functions in this library access implicitly the locale data and use +what information is available in the currently selected locale. This is +how the locale model is meant to work normally. + +As an example take the @code{strftime} function which is meant to nicely +format date and time information (@pxref{Formatting Date and Time}). +Part of the standard information contained in the @code{LC_TIME} +category are, e.g., the names of the months. Instead of requiring the +programmer to take care of providing the translations the +@code{strftime} function does this all by itself. When using @code{%A} +in the format string this will be replaced by the appropriate weekday +name of the locale currently selected for @code{LC_TIME}. This is the +easy part and wherever possible functions do things automatically as in +this case. + +But there are quite often situations when there is simply no functions +to perform the task or it is simply not possible to do the work +automatically. For these cases it is necessary to access the +information in the locale directly. To do this the C library provides +two functions: @code{localeconv} and @code{nl_langinfo}. The former is +part of @w{ISO C} and therefore portable, but has a brain-damaged +interface. The second is part of the Unix interface and is portable in +as far as the system follows the Unix standards. -When you want to format a number or a currency amount using the -conventions of the current locale, you can use the function -@code{localeconv} to get the data on how to do it. The function -@code{localeconv} is declared in the header file @file{locale.h}. +@menu +* The Lame Way to Locale Data:: ISO C's @code{localeconv}. +* The Elegant and Fast Way:: X/Open's @code{nl_langinfo}. +@end menu + +@node The Lame Way to Locale Data, The Elegant and Fast Way, ,Locale Information +@subsection @code{localeconv}: It's portable but @dots{} + +Together with the @code{setlocale} function the @w{ISO C} people +invented @code{localeconv} function. It is a masterpiece of misdesign. +It is expensive to use, it is not extendable, and does not generally +usable as it provides access only to the @code{LC_MONETARY} and +@code{LC_NUMERIC} related information. If it is applicable for a +certain situation it should nevertheless be used since it is very +portable. In general it is better to use the function @code{strfmon} +which can be used to format monetary amounts correctly according to the +selected locale by implicitly using this information. @pindex locale.h @cindex monetary value formatting @cindex numeric value formatting @@ -346,7 +398,7 @@ The @code{localeconv} function returns a pointer to a structure whose components contain information about how numeric and monetary values should be formatted in the current locale. -You shouldn't modify the structure or its contents. The structure might +You should not modify the structure or its contents. The structure might be overwritten by subsequent calls to @code{localeconv}, or by calls to @code{setlocale}, but no other function in the library overwrites this value. @@ -355,7 +407,8 @@ value. @comment locale.h @comment ISO @deftp {Data Type} {struct lconv} -This is the data type of the value returned by @code{localeconv}. +This is the data type of the value returned by @code{localeconv}. Its +elements are described in the following subsections. @end deftp If a member of the structure @code{struct lconv} has type @code{char}, @@ -371,8 +424,8 @@ no value for that parameter. for a monetary amount, if one exists. @end menu -@node General Numeric, Currency Symbol, , Numeric Formatting -@subsection Generic Numeric Formatting Parameters +@node General Numeric, Currency Symbol, , The Lame Way to Locale Data +@subsubsection Generic Numeric Formatting Parameters These are the standard members of @code{struct lconv}; there may be others. @@ -440,8 +493,8 @@ fractional digits. (This locale also specifies the empty string for confusing!) @end table -@node Currency Symbol, Sign of Money Amount, General Numeric, Numeric Formatting -@subsection Printing the Currency Symbol +@node Currency Symbol, Sign of Money Amount, General Numeric, The Lame Way to Locale Data +@subsubsection Printing the Currency Symbol @cindex currency symbols These members of the @code{struct lconv} structure specify how to print @@ -538,8 +591,8 @@ Based on what we know now, we recommend you ignore these members when printing international currency symbols, and print no extra space. @end table -@node Sign of Money Amount, , Currency Symbol, Numeric Formatting -@subsection Printing the Sign of an Amount of Money +@node Sign of Money Amount, , Currency Symbol, The Lame Way to Locale Data +@subsubsection Printing the Sign of an Amount of Money These members of the @code{struct lconv} structure specify how to print the sign (if any) in a monetary value. @@ -599,3 +652,479 @@ international currency format or not. POSIX says you should, but intuition plus the examples in the @w{ISO C} standard suggest you should not. We hope that someone who knows well the conventions for formatting monetary quantities will tell us what we should recommend. + +@node The Elegant and Fast Way, , The Lame Way to Locale Data, Locale Information +@subsection Pinpoint Access to Locale Data + +When writing the X/Open Portability Guide the authors realized that +implicit used added to by the @code{localeconv} function is not enough +to provide reasonable access to the locale information. The +information which was meant to be available in the locale (as later +specified in the POSIX.1 standard) requires more possibilities to access +it. Therefore the @code{nl_langinfo} function was introduced. + +@comment langinfo.h +@comment XOPEN +@deftypefun {char *} nl_langinfo (nl_item @var{item}) +The @code{nl_langinfo} function can be used to access individual +elements of the locale categories. I.e., unlike the @code{localeconv} +function which always returns all the information @code{nl_langinfo} +lets the caller select what information is necessary. This is a very +fast and it is no problem to call this function multiple times. + +The second advantage is that not only the numeric and monetary +formatting information is available. Also the information of the +@code{LC_TIME} and @code{LC_MESSAGES} categories is available. + +The type @code{nl_type} is defined in @file{nl_types.h}. +The argument @var{item} is a numeric values which must be one of the +values defined in the header @file{langinfo.h}. The X/Open standard +defines the following values: + +@vtable @code +@item ABDAY_1 +@itemx ABDAY_2 +@itemx ABDAY_3 +@itemx ABDAY_4 +@itemx ABDAY_5 +@itemx ABDAY_6 +@itemx ABDAY_7 +@code{nl_langinfo} returns the abbreviated weekday name. @code{ABDAY_1} +corresponds to Sunday. +@item DAY_1 +@itemx DAY_2 +@itemx DAY_3 +@itemx DAY_4 +@itemx DAY_5 +@itemx DAY_6 +@itemx DAY_7 +Similar to @code{ABDAY_1} etc, but here the return value are the +unabbreviated weekday names. +@item ABMON_1 +@itemx ABMON_2 +@itemx ABMON_3 +@itemx ABMON_4 +@itemx ABMON_5 +@itemx ABMON_6 +@itemx ABMON_7 +@itemx ABMON_8 +@itemx ABMON_9 +@itemx ABMON_10 +@itemx ABMON_11 +@itemx ABMON_12 +The return value are abbreviated names for the month names. @code{ABMON_1} +corresponds to January. +@item MON_1 +@itemx MON_2 +@itemx MON_3 +@itemx MON_4 +@itemx MON_5 +@itemx MON_6 +@itemx MON_7 +@itemx MON_8 +@itemx MON_9 +@itemx MON_10 +@itemx MON_11 +@itemx MON_12 +Similar to @code{ABMON_1} etc but here the month names are not abbreviated. +Here the first value @code{MON_1} also corresponds to January. +@item AM_STR +@itemx PM_STR +The return values are strings which can be used in the time representation +which uses to American 1 to 12 hours plus am/pm representation. + +Please note that in locales which do not know this time representation +these strings actually might be empty and therefore the am/pm format +cannot be used at all. +@item D_T_FMT +The return value can be used as a format string for @code{strftime} to +represent time and date in a locale specific way. +@item D_FMT +The return value can be used as a format string for @code{strftime} to +represent a date in a locale specific way. +@item T_FMT +The return value can be used as a format string for @code{strftime} to +represent time in a locale specific way. +@item T_FMT_AMPM +The return value can be used as a format string for @code{strftime} to +represent time using the American-style am/pm format. + +Please note that if the am/pm format does not make any sense for the +selected locale the returned value might be the same as the one for +@code{T_FMT}. +@item ERA +The return value is value representing the eras of time used in the +current locale. + +Most locales do not define this value. An example for a locale which +does define this value is the Japanese. Here the traditional data +representation is based on the eras measured by the reigns of the +emperors. + +Normally it should not be necessary to use this value directly. Using +the @code{E} modifier for its formats the @code{strftime} functions can +be made to use this information. The format of the returned string +is not specified and therefore one should not generalize the knowledge +about the representation on one system. +@item ERA_YEAR +The return value describes the name years for the eras of this locale. +As for @code{ERA} it should not be necessary to use this value directly. +@item ERA_D_T_FMT +This return value can be used as a format string for @code{strftime} to +represent time and date using the era representation in a locale +specific way. +@item ERA_D_FMT +This return value can be used as a format string for @code{strftime} to +represent a date using the era representation in a locale specific way. +@item ERA_T_FMT +This return value can be used as a format string for @code{strftime} to +represent time using the era representation in a locale specific way. +@item ALT_DIGITS +The return value is a representation of up to @math{100} values used to +represent the values @math{0} to @math{99}. As for @code{ERA} this +value is not intended to be used directly, but instead indirectly +through the @code{strftime} function. When the modifier @code{O} is +used for format which would use numerals to represent hours, minutes, +seconds, weekdays, months, or weeks the appropriate value for this +locale values is used instead of the number. +@item INT_CURR_SYMBOL +This value is the same as returned by @code{localeconv} in the +@code{int_curr_symbol} element of the @code{struct lconv}. +@item CURRENCY_SYMBOL +@itemx CRNCYSTR +This value is the same as returned by @code{localeconv} in the +@code{currency_symbol} element of the @code{struct lconv}. + +@code{CRNCYSTR} is a deprecated alias, still required by Unix98. +@item MON_DECIMAL_POINT +This value is the same as returned by @code{localeconv} in the +@code{mon_decimal_point} element of the @code{struct lconv}. +@item MON_THOUSANDS_SEP +This value is the same as returned by @code{localeconv} in the +@code{mon_thousands_sep} element of the @code{struct lconv}. +@item MON_GROUPING +This value is the same as returned by @code{localeconv} in the +@code{mon_grouping} element of the @code{struct lconv}. +@item POSITIVE_SIGN +This value is the same as returned by @code{localeconv} in the +@code{positive_sign} element of the @code{struct lconv}. +@item NEGATIVE_SIGN +This value is the same as returned by @code{localeconv} in the +@code{negative_sign} element of the @code{struct lconv}. +@item INT_FRAC_DIGITS +This value is the same as returned by @code{localeconv} in the +@code{int_frac_digits} element of the @code{struct lconv}. +@item FRAC_DIGITS +This value is the same as returned by @code{localeconv} in the +@code{frac_digits} element of the @code{struct lconv}. +@item P_CS_PRECEDES +This value is the same as returned by @code{localeconv} in the +@code{p_cs_precedes} element of the @code{struct lconv}. +@item P_SEP_BY_SPACE +This value is the same as returned by @code{localeconv} in the +@code{p_sep_by_space} element of the @code{struct lconv}. +@item N_CS_PRECEDES +This value is the same as returned by @code{localeconv} in the +@code{n_cs_precedes} element of the @code{struct lconv}. +@item N_SEP_BY_SPACE +This value is the same as returned by @code{localeconv} in the +@code{n_sep_by_space} element of the @code{struct lconv}. +@item P_SIGN_POSN +This value is the same as returned by @code{localeconv} in the +@code{p_sign_posn} element of the @code{struct lconv}. +@item N_SIGN_POSN +This value is the same as returned by @code{localeconv} in the +@code{n_sign_posn} element of the @code{struct lconv}. +@item DECIMAL_POINT +@itemx RADIXCHAR +This value is the same as returned by @code{localeconv} in the +@code{decimal_point} element of the @code{struct lconv}. + +The name @code{RADIXCHAR} is a deprecated alias still used in Unix98. +@item THOUSANDS_SEP +@itemx THOUSEP +This value is the same as returned by @code{localeconv} in the +@code{thousands_sep} element of the @code{struct lconv}. + +The name @code{THOUSEP} is a deprecated alias still used in Unix98. +@item GROUPING +This value is the same as returned by @code{localeconv} in the +@code{grouping} element of the @code{struct lconv}. +@item YESEXPR +The return value is a regular expression which can be used with the +@code{regex} function to recognize a positive response to a yes/no +question. +@item NOEXPR +The return value is a regular expression which can be used with the +@code{regex} function to recognize a negative response to a yes/no +question. +@item YESSTR +The return value is a locale specific translation of the positive response +to a yes/no question. + +Using this value is deprecated since it is a very special case of +message translation and this better can be handled using the message +translation functions (@pxref{Message Translation}). +@item NOSTR +The return value is a locale specific translation of the negative response +to a yes/no question. What is said for @code{YESSTR} is also true here. +@end vtable + +The file @file{langinfo.h} defines a lot more symbols but none of them +is official. Using them is completely unportable and the format of the +return values might change. Therefore it is highly requested to not use +them in any situation. + +Please note that the return value for any valid argument can be used for +in all situations (with the possible exception of the am/pm time format +related values). If the user has not selected any locale for the +appropriate category @code{nl_langinfo} returns the information from the +@code{"C"} locale. It is therefore possible to use this function as +shown in the example below. + +If the argument @var{item} is not valid the global variable @var{errno} +is set to @code{EINVAL} and a @code{NULL} pointer is returned. +@end deftypefun + +An example for the use of @code{nl_langinfo} is a function which has to +print a given date and time in the locale specific way. At first one +might think the since @code{strftime} internally uses the locale +information writing something like the following is enough: + +@smallexample +size_t +i18n_time_n_data (char *s, size_t len, const struct tm *tp) +@{ + return strftime (s, len, "%X %D", tp); +@} +@end smallexample + +The format contains no weekday or month names and therefore is +internationally usable. Wrong! The output produced is something like +@code{"hh:mm:ss MM/DD/YY"}. This format is only recognizable in the +USA. Other countries use different formats. Therefore the function +should be rewritten like this: + +@smallexample +size_t +i18n_time_n_data (char *s, size_t len, const struct tm *tp) +@{ + return strftime (s, len, nl_langinfo (D_T_FMT), tp); +@} +@end smallexample + +Now the date and time format which is explicitly selected for the locale +in place when the program runs is used. If the user selects the locale +correctly there should never be a misunderstanding over the time and +date format. + +@node Formatting Numbers, , Locale Information, Locales +@section A dedicated functions to format numbers + +We have seen the the structure returned by @code{localeconv} as well as +the values given to @code{nl_langinfo} allow to retrieve the various +pieces of locale specific information to format numbers and monetary +amounts. But we have also seen that the rules underlying this +information are quite complex. + +Therefore the X/Open standards introduce a function which uses this +information from the locale and so makes it is for the user to format +numbers according to these rules. + +@deftypefun ssize_t strfmon (char *@var{s}, size_t @var{maxsize}, const char *@var{format}, @dots{}) +The @code{strfmon} function is similar to the @code{strftime} function +in that it takes a description of a buffer (with size), a format string +and values to write into a buffer a textual representation of the values +according to the format string. As for @code{strftime} the function +also returns the number of bytes written into the buffer. + +There are two difference: @code{strfmon} can take more than one argument +and of course the format specification is different. The format string +consists as for @code{strftime} of normal text which is simply printed +and format specifiers, which here are also introduced using @samp{%}. +Following the @samp{%} the function allows similar to @code{printf} a +sequence of flags and other specifications before the format character: + +@itemize @bullet +@item +Immediately following the @samp{%} there can be one or more of the +following flags: +@table @asis +@item @samp{=@var{f}} +The single byte character @var{f} is used for this field as the numeric +fill character. By default this character is a space character. +Filling with this character is only performed if a left precision +is specified. It is not just to fill to the given field width. +@item @samp{^} +The number is printed without grouping the digits using the rules of the +current locale. By default grouping is enabled. +@item @samp{+}, @samp{(} +At most one of these flags must be used. They select which format to +represent the sign of currency amount is used. By default and if +@samp{+} is used the locale equivalent to @math{+}/@math{-} is used. If +@samp{(} is used negative amounts are enclosed in parentheses. The +exact format is determined by the values of the @code{LC_MONETARY} +category of the locale selected at program runtime. +@item @samp{!} +The output will not contain the currency symbol. +@item @samp{-} +The output will be formatted right-justified instead left-justified if +the output does not fill the entire field width. +@end table +@end itemize + +The next part of a specification is an, again optional, specification of +the field width. The width is given by digits following the flags. If +no width is specified it is assumed to be @math{0}. The width value is +used after it is determined how much space the printed result needs. If +it does not require fewer characters than specified by the width value +nothing happens. Otherwise the output is extended to use as many +characters as the width says by filling with spaces. At which side +depends on whether the @samp{-} flag was given or not. If it was given, +the spaces are added at the right, making the output right-justified and +vice versa. + +So far the format looks familiar as it is similar to @code{printf} or +@code{strftime} formats. But the next two fields introduce something +new. The first one, if available, is introduced by a @samp{#} character +which is followed by a decimal digit string. The value of the digit +string specifies the width the formatted digits left to the radix +character. This does @emph{not} include the grouping character needed +if the @samp{^} flag is not given. If the space needed to print the +number does not fill the whole width the field is padded at the left +side with the fill character which can be selected using the @samp{=} +flag and which by default is a space. For example, if the field width +is selected as 6 and the number is @math{123}, the fill character is +@samp{*} the result will be @samp{***123}. + +The next field is introduced by a @samp{.} (period) and consists of +another decimal digit string. Its value describes the number of +characters printed after the radix character. The default is +selected from the current locale (@code{frac_digits}, +@code{int_frac_digits}, see @pxref{General Numeric}). If the exact +representation needs more digits than those specified by the field width +the displayed value is rounded. In case the number of fractional digits +is selected to be zero, no radix character is printed. + +As a GNU extension the @code{strfmon} implementation in the GNU libc +allows as the next field an optional @samp{L} as a format modifier. If +this modifier is given the argument is expected to be a @code{long +double} instead of a @code{double} value. + +Finally as the last component of the format there must come a format +specifying. There are three specifiers defined: + +@table @asis +@item @samp{i} +The argument is formatted according to the locale's rules to format an +international currency value. +@item @samp{n} +The argument is formatted according to the locale's rules to format an +national currency value. +@item @samp{%} +Creates a @samp{%} in the output. There must be no flag, width +specifier or modifier given, only @samp{%%} is allowed. +@end table + +As it is done for @code{printf}, the function read the format string +from left to right and uses the value passed to the function following +the format string. The value are expected to be either of type +@code{double} or @code{long double}, depending in the presence of the +modifier @samp{L}. The result is stored in the buffer pointed to by +@var{s}. At most @var{maxsize} characters are stored. + +The return value of the function is the number of characters stored in +@var{s}, including the terminating NUL byte.. If the number of +characters stored would exceed @var{maxsize} the function returns +@math{-1} and the content of the buffer @var{s} is unspecified. In this +case @code{errno} is set to @code{E2BIG}. +@end deftypefun + +A few examples should make the clear how to use this function. It is +assumed that all the following pieces of code are executed in a program +which uses the locale valid for the USA (@code{en_US}). The simplest +form of the format is this: + +@smallexample +strfmon (buf, 100, "@@%n@@%n@@%n@@", 123.45, -567.89, 12345.678); +@end smallexample + +@noindent +The output produced is +@smallexample +"@@$123.45@@-$123.45@@$12,345.68@@" +@end smallexample + +We can notice several things here. First, the width for all formats is +different. We have not specified a width in the format string and so +this is no wonder. Second, the third number is printed using thousands +separators. The thousands separator for the @code{en_US} locale is a +comma. Beside this the number is rounded. The @math{.678} are rounded +to @math{.68} since the format does not specify a precision and the +default value in the locale is @math{2}. A last thing is that the +national currency symbol is printed since @samp{%n} was used, not +@samp{i}. The next example shows how we can align the output. + +@smallexample +strfmon (buf, 100, "@@%=*11n@@%=*11n@@%=*11n@@", 123.45, -567.89, 12345.678); +@end smallexample + +@noindent +The output this time is: + +@smallexample +"@@ $123.45@@ -$123.45@@ $12,345.68@@" +@end smallexample + +Two things stand out. First, all fields have the same width (eleven +characters) since this is the width given in the format and since no +number required more characters to be printed. The second important +point is that the fill character is not used. This is correct since the +white space was not used to fill the space specified by the right +precision, but instead it is used to fill to the given width. The +difference becomes obvious if we now add a right width specification. + +@smallexample +strfmon (buf, 100, "@@%=*11#5n@@%=*11#5n@@%=*11#5n@@", + 123.45, -567.89, 12345.678); +@end smallexample + +@noindent +The output is + +@smallexample +"@@ $***123.45@@-$***567.89@@ $12,456.68@@" +@end smallexample + +Here we can see that all the currency symbols are now aligned and the +space between the currency sign and the number is filled with the +selected fill character. Please note that although the right precision +is selected to be @math{5} and @math{123.45} has three characters right +of the radix character, the space is filled with three asterisks. This +is correct since as explained above, the right precision does not count +the characters used for the thousands separators in. One last example +should explain the remaining functionality. + +@smallexample +strfmon (buf, 100, "@@%=0(16#5.3i@@%=0(16#5.3i@@%=0(16#5.3i@@", + 123.45, -567.89, 12345.678); +@end smallexample + +@noindent +This rather complex format string produces the following output: + +@smallexample +"@@ USD 000123,450 @@(USD 000567.890)@@ USD 12,345.678 @@" +@end smallexample + +The most noticeable change is the use of the alternative style to +represent negative numbers. In financial circles it is often done using +braces and this is what the @samp{(} flag selected. The fill character +is now @samp{0}. Please note that this @samp{0} character is not +regarded as a numeric zero and therefore the first and second number are +not printed using a thousands separator. Since we use in the format the +specifier @samp{i} instead of @samp{n} no the international form of the +currency symbol is used. This is a four letter string, in this case +@code{"USD "}. The last point is that since the left precision is +selected to be three the first and second number are printed with and +extra zero and the end and the third number is printed unrounded. diff --git a/manual/string.texi b/manual/string.texi index 2bbc238bed..c6bca05d1c 100644 --- a/manual/string.texi +++ b/manual/string.texi @@ -633,6 +633,7 @@ determined by the currently selected locale. In the standard @code{"C"} locale the characters @"A and @"a do not match but in a locale which regards these characters as parts of the alphabet they do match. +@noindent @code{strcasecmp} is derived from BSD. @end deftypefun @@ -643,6 +644,7 @@ This function is like @code{strncmp}, except that differences in case are ignored. Like @code{strcasecmp}, it is locale dependent how uppercase and lowercase characters are related. +@noindent @code{strncasecmp} is a GNU extension. @end deftypefun diff --git a/manual/texinfo.tex b/manual/texinfo.tex index 0d6e2890ba..2f55a4a339 100644 --- a/manual/texinfo.tex +++ b/manual/texinfo.tex @@ -1,5 +1,5 @@ % texinfo.tex -- TeX macros to handle Texinfo files. -% $Id: texinfo.tex,v 2.219 1998/08/15 02:38:13 drepper Exp $ +% $Id: texinfo.tex,v 2.220 1998/09/01 10:37:39 drepper Exp $ % % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98 % Free Software Foundation, Inc. @@ -27,7 +27,7 @@ % reports; you can get the latest version from: % ftp://ftp.gnu.org/pub/gnu/texinfo.tex % /home/gd/gnu/doc/texinfo.tex on the GNU machines. -% (and all GNU mirrors, see ftp://ftp.gnu.org/pub/gnu/GNUinfo/FTP) +% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) % ftp://tug.org/tex/texinfo.tex % ftp://ctan.org/macros/texinfo/texinfo.tex % (and all CTAN mirrors, finger ctan@ctan.org for a list). @@ -58,7 +58,7 @@ % This automatically updates the version number based on RCS. \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} -\deftexinfoversion$Revision: 2.219 $ +\deftexinfoversion$Revision: 2.220 $ \message{Loading texinfo package [Version \texinfoversion]:} % If in a .fmt file, print the version number @@ -343,11 +343,11 @@ %% Call \inENV within environments (after a \begingroup) \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} \def\ENVcheck{% -\ifENV\errmessage{Still within an environment. Type Return to continue.} +\ifENV\errmessage{Still within an environment; press RETURN to continue} \endgroup\fi} % This is not perfect, but it should reduce lossage % @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Type to continue.} +\newhelp\EMsimple{Press RETURN to continue.} \outer\def\begin{\parsearg\beginxxx} @@ -1841,15 +1841,13 @@ July\or August\or September\or October\or November\or December\fi \itemxneedsnegativevskipfalse \else % The item text fits into the space. Start a paragraph, so that the - % following text (if any) will end up on the same line. Since that - % text will be indented by \tableindent, we make the item text be in - % a zero-width box. + % following text (if any) will end up on the same line. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent - \dimen0 = \itemmax \advance\dimen0 by -\wd0 + \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup @@ -3997,20 +3995,18 @@ width0pt\relax} \fi % outside the @def... \dimen2=\leftskip \advance\dimen2 by -\defbodyindent -\dimen3=\rightskip -\advance\dimen3 by -\defbodyindent -\noindent % +\noindent \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 % +\parshape 2 0in \dimen0 \defargsindent \dimen1 % Now output arg 2 ("Function" or some such) % ending at \deftypemargin from the right margin, % but stuck inside a box of width 0 so it does not interfere with linebreaking {% Adjust \hsize to exclude the ambient margins, % so that \rightline will obey them. -\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 -\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% +\advance \hsize by -\dimen2 +\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% % Make all lines underfull and no complaints: \tolerance=10000 \hbadness=10000 \advance\leftskip by -\defbodyindent @@ -4031,7 +4027,7 @@ width0pt\relax} \fi \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % 61 is `=' @@ -4049,7 +4045,7 @@ width0pt\relax} \fi \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}}} @@ -4067,7 +4063,7 @@ width0pt\relax} \fi \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} @@ -4079,7 +4075,7 @@ width0pt\relax} \fi \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#5}}} @@ -4094,7 +4090,7 @@ width0pt\relax} \fi \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\spacesplit#3}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % @@ -4111,7 +4107,7 @@ width0pt\relax} \fi \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% \parindent=0in - \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent + \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines } @@ -4156,7 +4152,7 @@ width0pt\relax} \fi \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\spacesplit{#3{##2}}}% \parindent=0in -\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\advance\leftskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\spacesplit{#3{#5}}} diff --git a/manual/top-menu.texi b/manual/top-menu.texi index fa94127260..dacb1a937d 100644 --- a/manual/top-menu.texi +++ b/manual/top-menu.texi @@ -227,10 +227,15 @@ Locales * Setting the Locale:: How a program specifies the locale with library functions. * Standard Locales:: Locale names available on all systems. -* Numeric Formatting:: How to format numbers according to the - chosen locale. +* Locale Information:: How to access the information for the locale. +* Formatting Numbers:: A dedicated functions to format numbers. -Numeric Formatting +Locale Information + +* The Lame Way to Locale Data:: ISO C's @code{localeconv}. +* The Elegant and Fast Way:: X/Open's @code{nl_langinfo}. + +The Lame Way to Locale Data * General Numeric:: Parameters for formatting numbers and currency amounts. diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c index 614637a173..c0acaa13e5 100644 --- a/nis/nss_nis/nis-pwd.c +++ b/nis/nss_nis/nis-pwd.c @@ -254,7 +254,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd, char *endp; size_t restlen; - if (encrypted != NULL + if (encrypted == NULL || (endp = strchr (++encrypted, ':')) == NULL || (p = strchr (p + 1, ':')) == NULL) { @@ -358,7 +358,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd, char *endp; size_t restlen; - if (encrypted != NULL + if (encrypted == NULL || (endp = strchr (++encrypted, ':')) == NULL || (p = strchr (p + 1, ':')) == NULL) { -- cgit 1.4.1