diff options
author | Roland McGrath <roland@gnu.org> | 1996-07-26 04:35:31 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-07-26 04:35:31 +0000 |
commit | 036cc82fbc47a632c1ed3a310a1a29365fe48d3d (patch) | |
tree | 3822092b5e9f64de600329bca9d6b0a0bbadf0eb | |
parent | 1e16111cf1abdcc2d6a617e7ba48a80ce1556797 (diff) | |
download | glibc-036cc82fbc47a632c1ed3a310a1a29365fe48d3d.tar.gz |
Fri Jul 26 04:41:28 1996 Ulrich Drepper <drepper@cygnus.com>
* intl/libintl.h: Define optimizing macros if __OPTIMIZE__ is
defined, not __OPTIMIZED.
(_nl_msg_cat_cntr): Move declaration outside macro definition
to prevent "nested extern" warning.
(dcgettext): Rename local variable `result' to `__result'.
Thu Jul 25 22:46:30 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* locale/programs/localedef.c (__progname): Remove decl.
(main): Use program_invocation_short_name instead of __progname.
(usage): Use program_invocation_name instead of __progname.
Fri Jul 26 03:46:08 1996 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Use "libc" instead of PACKAGE.
* locale/localedef.c: Ditto.
* locale/locale.c: Ditto.
* locale/findlocale.c (_nl_find_locale): Little optimization.
Use new function `strndup'.
* locale/loadlocale.c: Little optimization. Use constant value
from `_nl_category_num_items' instead of byte-order dependend
value from file.
* locale/programs/ld-time.c (time_add): Correct string constant.
* locale/programs/locale-spec.c: New file.
* locale/programs/locale.c: Call `locale_special' function if
no other field matches.
* locale/programs/localedef.c: No need to define `program_name'.
Use global variable `__progname'.
* locale/programs/locfile.c (write_locale_data): Always write
LC_MESSAGES data in LC_MESSAGES/SYS_LC_MESSAGES file. This is
necessary since message catalogs are also installed in the
LC_MESSAGES/ directory.
* locale/programs/stringtrans.c (ADDC): Correctly use `encode_char'
function instead of writing single bytes.
(encode_char): Also handle little endian.
* locale/setlocale.c (new_composite_name): Little optimization.
Use return value of `memcpy'.
* misc/ttyent.h: Pretty print prototypes, add missing parameter
names, prepend parameter names with __ and use `__const' instead
of `const'.
* posix/unistd.h: Ditto.
* stdlib/stdlib.h: Ditto.
* string/string.h: Ditto.
* posix/getconf.c: De-ASNI-fy. Recognize POSIX.2 constant names.
Use `error' function instead of doing it by hand.
* sysdeps/posix/sysconf.c: De-ANSI-fy.
Handle _SC_COLL_WEIGHTS_MAX.
* sysdeps/stub/sysconf.c: Handle _SC_CHARCLASS_NAME_MAX,
_SC_COLL_WEIGHTS_MAX, _SC_EQUIV_CLASS_MAX, _SC_2_LOCALEDEF
since these do depend on the platform.
Add POSIX.4 symbols.
* posix/posix2_lim.h: Add missing definition of
_POSIX2_COLL_WEIGHTS_MAX.
Change _POSIX2_EQUIV_CLASS_MAX and _POSIX2_CHARCLASS_NAME_MAX
to high values since we have no fixed limit.
* sysdeps/generic/confname.h: Add _SC_PAGE_SIZE as alias for
_SC_PAGESIZE for buggy systems (= HP UX) out there.
* wcsmbs/Makefile (routines): Add mbsnrtowcs and wcsnrtombs.
* wcsmbs/mbsnrtowcs.c: New file. Non-standard implementation.
* wcsmbs/wcsnrtombs.c: Ditto.
* wcsmbs/wchar.h [__USE_GNU]: Add prototypes for mbsnrtowcs and
wcsnrtombs.
Thu Jul 25 00:25:54 Richard Henderson <rth@tamu.edu>
* nss/nss_db/db-XXX.c: Kill trailing ; from lock defn as a matter of
course.
* nss/getXXent_r.c: Likewise.
* nss/nsswitch.c: Likewise.
* nss/nss_files/files-XXX.c: Likewise.
* sysdeps/mach/hurd/dirstream.h (struct __dirstream): Likewise.
* sysdeps/unix/bsd/telldir.c (struct record): Likewise.
* sysdeps/unix/dirstream.h (struct __dirstream): Likewise.
-rw-r--r-- | ChangeLog | 89 | ||||
-rw-r--r-- | catgets/gencat.c | 2 | ||||
-rw-r--r-- | intl/libintl.h | 37 | ||||
-rw-r--r-- | locale/findlocale.c | 12 | ||||
-rw-r--r-- | locale/loadlocale.c | 9 | ||||
-rw-r--r-- | locale/programs/ld-time.c | 2 | ||||
-rw-r--r-- | locale/programs/locale-spec.c | 95 | ||||
-rw-r--r-- | locale/programs/locale.c | 32 | ||||
-rw-r--r-- | locale/programs/localedef.c | 16 | ||||
-rw-r--r-- | locale/programs/locfile.c | 21 | ||||
-rw-r--r-- | locale/programs/stringtrans.c | 58 | ||||
-rw-r--r-- | locale/setlocale.c | 11 | ||||
-rw-r--r-- | misc/ttyent.h | 10 | ||||
-rw-r--r-- | posix/getconf.c | 69 | ||||
-rw-r--r-- | posix/posix2_lim.h | 18 | ||||
-rw-r--r-- | posix/unistd.h | 21 | ||||
-rw-r--r-- | stdlib/stdlib.h | 26 | ||||
-rw-r--r-- | string/string.h | 38 | ||||
-rw-r--r-- | sysdeps/generic/confname.h | 1 | ||||
-rw-r--r-- | sysdeps/posix/sysconf.c | 15 | ||||
-rw-r--r-- | sysdeps/stub/sysconf.c | 48 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/configure | 25 | ||||
-rw-r--r-- | wcsmbs/Makefile | 1 | ||||
-rw-r--r-- | wcsmbs/mbsnrtowcs.c | 143 | ||||
-rw-r--r-- | wcsmbs/wchar.h | 27 | ||||
-rw-r--r-- | wcsmbs/wcsnrtombs.c | 129 |
26 files changed, 756 insertions, 199 deletions
@@ -1,3 +1,92 @@ +Fri Jul 26 04:41:28 1996 Ulrich Drepper <drepper@cygnus.com> + + * intl/libintl.h: Define optimizing macros if __OPTIMIZE__ is + defined, not __OPTIMIZED. + (_nl_msg_cat_cntr): Move declaration outside macro definition + to prevent "nested extern" warning. + (dcgettext): Rename local variable `result' to `__result'. + +Thu Jul 25 22:46:30 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> + + * locale/programs/localedef.c (__progname): Remove decl. + (main): Use program_invocation_short_name instead of __progname. + (usage): Use program_invocation_name instead of __progname. + +Fri Jul 26 03:46:08 1996 Ulrich Drepper <drepper@cygnus.com> + + * catgets/gencat.c: Use "libc" instead of PACKAGE. + * locale/localedef.c: Ditto. + * locale/locale.c: Ditto. + + * locale/findlocale.c (_nl_find_locale): Little optimization. + Use new function `strndup'. + + * locale/loadlocale.c: Little optimization. Use constant value + from `_nl_category_num_items' instead of byte-order dependend + value from file. + + * locale/programs/ld-time.c (time_add): Correct string constant. + + * locale/programs/locale-spec.c: New file. + * locale/programs/locale.c: Call `locale_special' function if + no other field matches. + + * locale/programs/localedef.c: No need to define `program_name'. + Use global variable `__progname'. + + * locale/programs/locfile.c (write_locale_data): Always write + LC_MESSAGES data in LC_MESSAGES/SYS_LC_MESSAGES file. This is + necessary since message catalogs are also installed in the + LC_MESSAGES/ directory. + + * locale/programs/stringtrans.c (ADDC): Correctly use `encode_char' + function instead of writing single bytes. + (encode_char): Also handle little endian. + + * locale/setlocale.c (new_composite_name): Little optimization. + Use return value of `memcpy'. + + * misc/ttyent.h: Pretty print prototypes, add missing parameter + names, prepend parameter names with __ and use `__const' instead + of `const'. + * posix/unistd.h: Ditto. + * stdlib/stdlib.h: Ditto. + * string/string.h: Ditto. + + * posix/getconf.c: De-ASNI-fy. Recognize POSIX.2 constant names. + Use `error' function instead of doing it by hand. + * sysdeps/posix/sysconf.c: De-ANSI-fy. + Handle _SC_COLL_WEIGHTS_MAX. + * sysdeps/stub/sysconf.c: Handle _SC_CHARCLASS_NAME_MAX, + _SC_COLL_WEIGHTS_MAX, _SC_EQUIV_CLASS_MAX, _SC_2_LOCALEDEF + since these do depend on the platform. + Add POSIX.4 symbols. + + * posix/posix2_lim.h: Add missing definition of + _POSIX2_COLL_WEIGHTS_MAX. + Change _POSIX2_EQUIV_CLASS_MAX and _POSIX2_CHARCLASS_NAME_MAX + to high values since we have no fixed limit. + + * sysdeps/generic/confname.h: Add _SC_PAGE_SIZE as alias for + _SC_PAGESIZE for buggy systems (= HP UX) out there. + + * wcsmbs/Makefile (routines): Add mbsnrtowcs and wcsnrtombs. + * wcsmbs/mbsnrtowcs.c: New file. Non-standard implementation. + * wcsmbs/wcsnrtombs.c: Ditto. + * wcsmbs/wchar.h [__USE_GNU]: Add prototypes for mbsnrtowcs and + wcsnrtombs. + +Thu Jul 25 00:25:54 Richard Henderson <rth@tamu.edu> + + * nss/nss_db/db-XXX.c: Kill trailing ; from lock defn as a matter of + course. + * nss/getXXent_r.c: Likewise. + * nss/nsswitch.c: Likewise. + * nss/nss_files/files-XXX.c: Likewise. + * sysdeps/mach/hurd/dirstream.h (struct __dirstream): Likewise. + * sysdeps/unix/bsd/telldir.c (struct record): Likewise. + * sysdeps/unix/dirstream.h (struct __dirstream): Likewise. + Thu Jul 25 00:53:06 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * sysdeps/unix/sysv/linux/configure.in (LIBC_LINUX_VERSION): New diff --git a/catgets/gencat.c b/catgets/gencat.c index 9924cb9161..a193606027 100644 --- a/catgets/gencat.c +++ b/catgets/gencat.c @@ -165,7 +165,7 @@ main (int argc, char *argv[]) if (do_version) { fprintf (stderr, "%s - GNU %s %s\n", program_invocation_name, - PACKAGE, VERSION); + "libc", VERSION); exit (EXIT_SUCCESS); } diff --git a/intl/libintl.h b/intl/libintl.h index effb7c2e81..dca41df647 100644 --- a/intl/libintl.h +++ b/intl/libintl.h @@ -1,6 +1,6 @@ -/* libgettext.h -- Message catalogs for internationalization. -Copyright (C) 1995 Free Software Foundation, Inc. -Contributed by Ulrich Drepper. +/* libintl.h -- Message catalogs for internationalization. +Copyright (C) 1995, 1996 Free Software Foundation, Inc. +Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. This file is derived from the file libgettext.h in the GNU gettext package. This file is part of the GNU C Library. Its master source is NOT part of @@ -22,14 +22,10 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _LIBINTL_H + #define _LIBINTL_H 1 #include <features.h> -#include <locale.h> - -#define __need_NULL -#include <stddef.h> - /* We define an additional symbol to signal that we use the GNU implementation of gettext. */ #define __USE_GNU_GETTEXT 1 @@ -72,8 +68,16 @@ extern char *__bindtextdomain __P ((__const char *__domainname, /* Optimized version of the function above. */ -#if defined __OPTIMIZED -/* These must be a macro. Inlined functions are useless because the +#if defined __OPTIMIZE__ + +/* We need NULL for `gettext'. */ +#define __need_NULL +#include <stddef.h> + +/* We need LC_MESSAGES for `dgettext'. */ +# include <locale.h> + +/* These must be macros. Inlined functions are useless because the `__builtin_constant_p' predicate in dcgettext would always return false. */ @@ -83,13 +87,16 @@ extern char *__bindtextdomain __P ((__const char *__domainname, dcgettext (domainname, msgid, LC_MESSAGES) # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +/* Variable defined in loadmsgcat.c which gets incremented every time a + new catalog is loaded. */ +extern int _nl_msg_cat_cntr; + # define dcgettext(domainname, msgid, category) \ (__extension__ \ ({ \ - char *result; \ + char *__result; \ if (__builtin_constant_p (msgid)) \ { \ - extern int _nl_msg_cat_cntr; \ static char *__translation__; \ static int __catalog_counter__; \ if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr) \ @@ -98,11 +105,11 @@ extern char *__bindtextdomain __P ((__const char *__domainname, __dcgettext ((domainname), (msgid), (category)); \ __catalog_counter__ = _nl_msg_cat_cntr; \ } \ - result = __translation__; \ + __result = __translation__; \ } \ else \ - result = __dcgettext ((domainname), (msgid), (category)); \ - result; \ + __result = __dcgettext ((domainname), (msgid), (category)); \ + __result; \ })) # endif #endif /* Optimizing. */ diff --git a/locale/findlocale.c b/locale/findlocale.c index 5e87a33886..2bcc11193f 100644 --- a/locale/findlocale.c +++ b/locale/findlocale.c @@ -170,21 +170,17 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len, /* Determine the locale name for which loading succeeded. This information comes from the file name. The form is - <path>/<locale>/LC_foo. We must extract this <locale> part. */ + <path>/<locale>/LC_foo. We must extract the <locale> part. */ if (((struct locale_data *) locale_file->data)->name == NULL) { - char *newp, *cp, *endp; + char *cp, *endp; endp = strrchr (locale_file->filename, '/'); cp = endp - 1; while (cp[-1] != '/') --cp; - newp = (char *) malloc (endp - cp + 1); - if (newp == NULL) - return NULL; - memcpy (newp, cp, endp - cp); - newp[endp - cp] = '\0'; - ((struct locale_data *) locale_file->data)->name = newp; + ((struct locale_data *) locale_file->data)->name = __strndup (cp, + endp - cp); } *name = (char *) ((struct locale_data *) locale_file->data)->name; diff --git a/locale/loadlocale.c b/locale/loadlocale.c index b7eee2e735..464f8ba33f 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -94,7 +94,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) /* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo instead. */ char *newp; - + __close (fd); newp = (char *) alloca (strlen (file->filename) @@ -189,14 +189,15 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) } newdata = malloc (sizeof *newdata + - W (filedata->nstrings) * sizeof (union locale_data_value)); + (_nl_category_num_items[category] + * sizeof (union locale_data_value))); if (! newdata) goto puntmap; newdata->name = NULL; /* This will be filled if necessary in findlocale.c. */ newdata->filedata = (void *) filedata; newdata->filesize = st.st_size; - newdata->nstrings = W (filedata->nstrings); + newdata->nstrings = _nl_category_num_items[category]; for (cnt = 0; cnt < newdata->nstrings; ++cnt) { off_t idx = W (filedata->strindex[cnt]); @@ -234,5 +235,3 @@ _nl_free_locale (const struct locale_data *data) } free ((void *) data); } - - diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c index e031b24edc..00f288f69b 100644 --- a/locale/programs/ld-time.c +++ b/locale/programs/ld-time.c @@ -257,7 +257,7 @@ time_add (struct linereader *lr, struct localedef_t *locale, #define STRARR_ELEM(cat, max) \ case tok_##cat: \ if (time->cur_num_##cat >= max) \ - lr_error (lr, _(" \ + lr_error (lr, _("\ too many values for field `%s' in category `LC_TIME'"), \ #cat, "LC_TIME"); \ else if (code->val.str.start == NULL) \ diff --git a/locale/programs/locale-spec.c b/locale/programs/locale-spec.c new file mode 100644 index 0000000000..e408421656 --- /dev/null +++ b/locale/programs/locale-spec.c @@ -0,0 +1,95 @@ +/* Handle special requests. +Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <string.h> +#include <wchar.h> + +#include "localeinfo.h" + + +/* We provide support for some special names. This helps debugging + and may be useful for advanced usage of the provided information + outside C. */ +void +locale_special (const char *name, int show_category_name, + int show_keyword_name) +{ + /* "collate-elements": print collation elements of locale. */ + if (strcmp (name, "collate-elements") == 0) + { + size_t nelem = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_ELEM_HASH_SIZE); + + if (show_category_name) + puts ("LC_COLLATE"); + if (show_keyword_name) + fputs ("collate-elements=", stdout); + + if (nelem != 0) + { + int first = 1; + size_t cnt; + + for (cnt = 0; cnt < nelem; ++cnt) + if (__collate_element_hash[2 * cnt] != (~((u_int32_t) 0))) + { + size_t idx = __collate_element_hash[2 * cnt]; + + printf ("%s<%s>", first ? "" : ";", + &__collate_element_strings[idx]); + +#if 0 + /* We don't print the string. This is only confusing + because only the programs have to know the + encoding. The code is left in place because it + shows how to get the information. */ + { + const wchar_t *wp; + + idx = __collate_element_hash[2 * cnt + 1]; + wp = &__collate_element_values[idx]; + while (*wp != L'\0') + { + /********************************************\ + |* XXX The element values are really wide *| + |* chars. But we are currently not able to *| + |* print these so fake here. *| + \********************************************/ + int ch = wctob (*wp++); + if (ch != EOF) + putchar (ch); + else + fputs ("<???>", stdout); + } + + putchar ('"'); + } +#endif + first = 0; + } + } + putchar ('\n'); + return; + } +} diff --git a/locale/programs/locale.c b/locale/programs/locale.c index 5196fa51fe..a9e415d6b7 100644 --- a/locale/programs/locale.c +++ b/locale/programs/locale.c @@ -1,4 +1,7 @@ -/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. +/* locale - Implementation of the locale program according to POSIX 1003.2 +Copyright (C) 1995, 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -12,8 +15,8 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H # include <config.h> @@ -105,14 +108,21 @@ struct category static struct category category[] = { #define DEFINE_CATEGORY(category, name, items, postload, in, check, out) \ - { _NL_NUM_##category, name, NELEMS (category##_desc) - 1, \ - category##_desc }, + [category] = { _NL_NUM_##category, name, NELEMS (category##_desc), \ + category##_desc }, #include "categories.def" #undef DEFINE_CATEGORY }; #define NCATEGORIES NELEMS (category) +/* Automatically set variable. */ +extern const char *__progname; + +/* helper function for extended name handling. */ +extern void locale_special (const char *name, int show_category_name, + int show_keyword_name); + /* Prototypes for local functions. */ static void usage (int status) __attribute__ ((noreturn)); static void write_locales (void); @@ -146,7 +156,7 @@ main (int argc, char *argv[]) != EOF) switch (optchar) { - case '\0': + case '\0': /* Long option. */ break; case 'a': do_all = 1; @@ -173,7 +183,7 @@ main (int argc, char *argv[]) /* Version information is requested. */ if (do_version) { - fprintf (stderr, "GNU %s %s\n", PACKAGE, VERSION); + fprintf (stderr, "%s - GNU %s %s\n", __progname, "libc", VERSION); exit (EXIT_SUCCESS); } @@ -222,7 +232,7 @@ usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, gettext ("Try `%s --help' for more information.\n"), - program_invocation_name); + __progname); else printf (gettext ("\ Usage: %s [OPTION]... name\n\ @@ -235,7 +245,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ -c, --category-name write names of selected categories\n\ -k, --keyword-name write names of selected keywords\n"), - program_invocation_name); + __progname); exit (status); } @@ -424,4 +434,8 @@ show_info (const char *name) return; } } + + /* When we get to here the name is not standard ones. For testing + and perhpas advanced use we allow some more symbols. */ + locale_special (name, show_category_name, show_keyword_name); } diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index e9fb6d57a6..7a12ac87a5 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -67,9 +67,6 @@ struct copy_def_list_t *copy_list; /* If this is defined be POSIX conform. */ int posix_conformance; -/* Name of the running program. */ -const char *program_name; - /* If not zero give a lot more messages. */ int verbose; @@ -118,7 +115,6 @@ main (int argc, char *argv[]) /* Set initial values for global varaibles. */ copy_list = NULL; posix_conformance = getenv ("POSIXLY_CORRECT") != NULL; - program_name = argv[0]; error_print_progname = error_print; verbose = 0; @@ -128,12 +124,7 @@ main (int argc, char *argv[]) setlocale (LC_CTYPE, ""); /* Initialize the message catalog. */ -#if 0 - /* In the final version for glibc we can use the variable. */ textdomain (_libc_intl_domainname); -#else - textdomain ("SYS_libc"); -#endif while ((optchar = getopt_long (argc, argv, "cf:hi:u:vV", long_options, NULL)) != EOF) @@ -182,7 +173,8 @@ main (int argc, char *argv[]) /* Version information is requested. */ if (do_version) { - fprintf (stderr, "%s - GNU %s %s\n", program_name, PACKAGE, VERSION); + fprintf (stderr, "%s - GNU %s %s\n", program_invocation_short_name, + "libc", VERSION); exit (0); } @@ -389,7 +381,7 @@ usage (int status) { if (status != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), - program_name); + program_invocation_name); else printf (_("\ Usage: %s [OPTION]... name\n\ @@ -405,7 +397,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\ \n\ System's directory for character maps: %s\n\ locale files : %s\n"), - program_name, CHARMAP_PATH, LOCALE_PATH); + program_invocation_name, CHARMAP_PATH, LOCALE_PATH); exit (status); } diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 69d976160b..436df2e976 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -935,16 +935,29 @@ write_locale_data (const char *output_path, const char *category, int fd; char *fname; - asprintf (&fname, "%s%s", output_path, category); - fd = creat (fname, 0666); + fname = malloc (strlen (output_path) + strlen (category) + 6); + if (fname == NULL) + error (5, errno, _("memory exhausted")); + + /* Normally we write to the directory pointed to by the OUTPUT_PATH. + But for LC_MESSAGES we have to take care for the translation + data. This means we need to have a directory LC_MESSAGES in + which we place the file under the name SYS_LC_MESSAGES. */ + if (strcmp (category, "LC_MESSAGES") == 0) + fd = -1; + else + { + sprintf (fname, "%s%s", output_path, category); + fd = creat (fname, 0666); + } + if (fd == -1) { int save_err = errno; if (errno == EISDIR) { - free (fname); - asprintf (&fname, "%1$s%2$s/SYS_%2$s", output_path, category); + sprintf (fname, "%1$s%2$s/SYS_%2$s", output_path, category); fd = creat (fname, 0666); if (fd == -1) save_err = errno; diff --git a/locale/programs/stringtrans.c b/locale/programs/stringtrans.c index 10b04fa62e..6958dd2df8 100644 --- a/locale/programs/stringtrans.c +++ b/locale/programs/stringtrans.c @@ -36,16 +36,23 @@ void *xmalloc (size_t __n); void *xrealloc (void *__p, size_t __n); -#define ADDC(ch) \ - do \ - { \ - if (bufact == bufmax) \ - { \ - bufmax *= 2; \ - buf = xrealloc (buf, bufmax); \ - } \ - buf[bufact++] = (ch); \ - } \ +#define ADDC(ch) \ + do \ + { \ + char *cp; \ + if (bufact + (encoding_method == ENC_UCS4 ? 4 : 1) >= bufmax) \ + { \ + bufmax *= 2; \ + buf = xrealloc (buf, bufmax); \ + } \ + cp = &buf[bufact]; \ + if (encode_char (ch, &cp) < 0) \ + { \ + free (buf); \ + return NULL; \ + } \ + bufact = cp - buf; \ + } \ while (0) @@ -92,31 +99,15 @@ translate_string (char *str, struct charset_t *charset) return NULL; } else - { - /* Encode string using current method. */ - char *cp; - - if (bufmax - bufact < 8) - { - bufmax *= 2; - buf = (char *) xrealloc (buf, bufmax); - } - - cp = &buf[bufact]; - if (encode_char (value, &cp) < 0) - { - free (buf); - return NULL; - } - bufact = cp - buf; - } + /* Encode string using current method. */ + ADDC (value); str = &tp[1]; } ADDC ('\0'); - return buf;; + return buf; } @@ -127,15 +118,22 @@ encode_char (unsigned int value, char **cpp) { case ENC_UCS1: if (value > 255) - return -11; + return -1; *(*cpp)++ = (char) value; break; case ENC_UCS4: +#if __BYTE_ORDER == __BIG_ENDIAN *(*cpp)++ = (char) (value >> 24); *(*cpp)++ = (char) ((value >> 16) & 0xff); *(*cpp)++ = (char) ((value >> 8) & 0xff); *(*cpp)++ = (char) (value & 0xff); +#else + *(*cpp)++ = (char) (value & 0xff); + *(*cpp)++ = (char) ((value >>= 8) & 0xff); + *(*cpp)++ = (char) ((value >>= 8) & 0xff); + *(*cpp)++ = (char) ((value >>= 8) & 0xff); +#endif break; default: diff --git a/locale/setlocale.c b/locale/setlocale.c index eab1a33f89..a32fab330e 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -53,12 +53,12 @@ static const struct locale_data * *const _nl_current[] = /* Array indexed by category of pointers to _nl_C_CATEGORY slots. Elements are zero for categories whose data is never used. */ const struct locale_data *const _nl_C[] = -{ + { #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \ - [category] = &_nl_C_##category, + [category] = &_nl_C_##category, #include "categories.def" #undef DEFINE_CATEGORY -}; + }; /* Define an array of category names (also the environment variable names), @@ -169,11 +169,8 @@ new_composite_name (int category, char *newnames[LC_ALL]) return (char *) _nl_C_name; new = malloc (last_len + 1); - if (new == NULL) - return NULL; - memcpy (new, newnames[0], last_len + 1); - return new; + return new == NULL ? NULL : memcpy (new, newnames[0], last_len + 1); } new = malloc (cumlen); diff --git a/misc/ttyent.h b/misc/ttyent.h index e95db259ca..fb3f952e04 100644 --- a/misc/ttyent.h +++ b/misc/ttyent.h @@ -57,10 +57,12 @@ struct ttyent { #include <sys/cdefs.h> __BEGIN_DECLS -struct ttyent *getttyent __P((void)); -struct ttyent *getttynam __P((const char *)); -int setttyent __P((void)); -int endttyent __P((void)); + +struct ttyent *getttyent __P ((void)); +struct ttyent *getttynam __P ((__const char *)); +int setttyent __P ((void)); +int endttyent __P ((void)); + __END_DECLS #endif /* !_TTYENT_H_ */ diff --git a/posix/getconf.c b/posix/getconf.c index 699cf67bfe..6d78205a88 100644 --- a/posix/getconf.c +++ b/posix/getconf.c @@ -16,18 +16,19 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <unistd.h> #include <errno.h> +#include <error.h> +#include <libintl.h> #include <string.h> #include <stdlib.h> #include <stdio.h> struct conf { - CONST char *name; - CONST int call_name; - CONST enum { SYSCONF, CONFSTR, PATHCONF } call; + const char *name; + const int call_name; + const enum { SYSCONF, CONFSTR, PATHCONF } call; }; static struct conf vars[] = @@ -82,31 +83,43 @@ static struct conf vars[] = { "_POSIX_PII_OSI_CLTS", _SC_PII_OSI_CLTS, SYSCONF }, { "_POSIX_PII_OSI_M", _SC_PII_OSI_M, SYSCONF }, { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF }, + /* POSIX.2 */ + { "BC_BASE_MAX", _SC_BC_BASE_MAX, SYSCONF }, + { "BC_DIM_MAX", _SC_BC_DIM_MAX, SYSCONF }, + { "BC_SCALE_MAX", _SC_BC_SCALE_MAX, SYSCONF }, + { "BC_STRING_MAX", _SC_BC_STRING_MAX, SYSCONF }, + { "COLL_WEIGHTS_MAX", _SC_COLL_WEIGHTS_MAX, SYSCONF }, + { "EQUIV_CLASS_MAX", _SC_EQUIV_CLASS_MAX, SYSCONF }, + { "EXPR_NEST_MAX", _SC_EXPR_NEST_MAX, SYSCONF }, + { "LINE_MAX", _SC_LINE_MAX, SYSCONF }, + { "RE_DUP_MAX", _SC_RE_DUP_MAX, SYSCONF }, + { "CHARCLASS_NAME_MAX", _SC_CHARCLASS_NAME_MAX }, + { "POSIX2_C_BIND", _SC_2_C_BIND, SYSCONF }, + { "POSIX2_C_DEV", _SC_2_C_DEV, SYSCONF }, + { "POSIX2_FORT_DEV", _SC_2_FORT_DEV, SYSCONF }, + { "POSIX2_FORT_RUN", _SC_2_FORT_RUN, SYSCONF }, + { "POSIX2_LOCALEDEF", _SC_2_LOCALEDEF, SYSCONF }, + { "POSIX2_SW_DEV", _SC_2_SW_DEV, SYSCONF }, { "PATH", _CS_PATH, CONFSTR }, { NULL, 0, SYSCONF } }; -static CONST char *program; +extern const char *__progname; + static void -DEFUN_VOID(usage) +usage (void) { - fprintf (stderr, _("Usage: %s variable_name [pathname]\n"), program); + fprintf (stderr, _("Usage: %s variable_name [pathname]\n"), __progname); exit (2); } int -DEFUN(main, (argc, argv), int argc AND char **argv) +main (int argc, char *argv[]) { - register CONST struct conf *c; - - program = strrchr (argv[0], '/'); - if (program == NULL) - program = argv[0]; - else - ++program; + register const struct conf *c; if (argc < 2 || argc > 3) usage (); @@ -124,11 +137,8 @@ DEFUN(main, (argc, argv), int argc AND char **argv) usage (); value = pathconf (argv[2], c->call_name); if (value == -1) - { - fprintf (stderr, "%s: pathconf: %s: %s\n", - program, argv[2], strerror (errno)); - exit (3); - } + error (3, errno, "pathconf: %s", argv[2]); + printf ("%ld\n", value); exit (0); @@ -145,22 +155,17 @@ DEFUN(main, (argc, argv), int argc AND char **argv) clen = confstr (c->call_name, (char *) NULL, 0); cvalue = (char *) malloc (clen); if (cvalue == NULL) - { - fprintf (stderr, "%s: malloc: %s\n", - program, strerror (errno)); - exit (3); - } + error (3, 0, _("memory exhausted")); + if (confstr (c->call_name, cvalue, clen) != clen) - { - fprintf (stderr, "%s: confstr: %s\n", - program, strerror (errno)); - exit (3); - } + error (3, errno, "confstr"); + printf ("%.*s\n", (int) clen, cvalue); exit (0); } } - fprintf (stderr, _("%s: Unrecognized variable `%s'\n"), program, argv[1]); - exit (2); + error (2, 0, _("Unrecognized variable `%s'"), argv[1]); + /* NOTREACHED */ + return 2; } diff --git a/posix/posix2_lim.h b/posix/posix2_lim.h index 8dda66dad4..b81dfd0694 100644 --- a/posix/posix2_lim.h +++ b/posix/posix2_lim.h @@ -34,8 +34,14 @@ Cambridge, MA 02139, USA. */ #define _POSIX2_BC_STRING_MAX 1000 /* The maximum number of weights that can be assigned to an entry of - the LC_COLLATE category `order' keyword in a locale definition. */ -#define _POSIX2_EQUIV_CLASS_MAX 2 + the LC_COLLATE `order' keyword in the locale definition file. + We have no fixed limit, 255 is very high. */ +#define _POSIX2_COLL_WEIGHTS_MAX 255 + +/* The maximum number of weights that can be assigned to an entry of + the LC_COLLATE category `order' keyword in a locale definition. + We have no fixed limit, 255 is a high number. */ +#define _POSIX2_EQUIV_CLASS_MAX 255 /* The maximum number of expressions that can be nested within parentheses by the `expr' utility. */ @@ -48,8 +54,9 @@ Cambridge, MA 02139, USA. */ permitted when using the interval notation `\{M,N\}'. */ #define _POSIX2_RE_DUP_MAX 255 -/* The manimum number of bytes in a character class name. */ -#define _POSIX2_CHARCLASS_NAME_MAX 14 +/* The maximum number of bytes in a character class name. We have no + fixed limit, 2048 is a high number. */ +#define _POSIX2_CHARCLASS_NAME_MAX 2048 /* These values are implementation-specific, @@ -68,6 +75,9 @@ Cambridge, MA 02139, USA. */ #ifndef BC_STRING_MAX #define BC_STRING_MAX _POSIX2_BC_STRING_MAX #endif +#ifndef COLL_WEIGHTS_MAX +#define COLL_WEIGHTS_MAX _POSIX2_COLL_WEIGHTS_MAX +#endif #ifndef EQUIV_CLASS_MAX #define EQUIV_CLASS_MAX _POSIX2_EQUIV_CLASS_MAX #endif diff --git a/posix/unistd.h b/posix/unistd.h index 0c4ddccb20..1247728121 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -216,7 +216,7 @@ extern unsigned int sleep __P ((unsigned int __seconds)); #ifdef __USE_BSD /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked or ignored. Return value is not necessarily useful. */ -extern unsigned int usleep __P ((unsigned __useconds)); +extern unsigned int usleep __P ((unsigned int __useconds)); #endif @@ -270,7 +270,7 @@ extern char *get_current_dir_name __P ((void)); NULL, an array is allocated with `malloc'; the array is SIZE bytes long, unless SIZE <= 0, in which case it is as big as necessary. */ -char *__canonicalize_directory_name_internal __P ((const char *__thisdir, +char *__canonicalize_directory_name_internal __P ((__const char *__thisdir, char *__buf, size_t __size)); #endif @@ -307,7 +307,7 @@ extern int execve __P ((__const char *__path, char *__const __argv[], /* Execute the file FD refers to, overlaying the running program image. ARGV and ENVP are passed to the new program, as for `execve'. */ extern int fexecve __P ((int __fd, - char *const __argv[], char *const __envp[])); + char *__const __argv[], char *__const __envp[])); #endif @@ -317,11 +317,11 @@ extern int execv __P ((__const char *__path, char *__const __argv[])); /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ -extern int execle __P ((__const char *__path, __const char *__arg,...)); +extern int execle __P ((__const char *__path, __const char *__arg, ...)); /* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. */ -extern int execl __P ((__const char *__path, __const char *__arg,...)); +extern int execl __P ((__const char *__path, __const char *__arg, ...)); /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. */ @@ -415,7 +415,7 @@ extern __pid_t setsid __P ((void)); #ifdef __USE_GNU /* Return the session ID of the given process. */ -extern __pid_t getsid __P ((__pid_t)); +extern __pid_t getsid __P ((__pid_t __pid)); #endif /* Get the real user ID of the calling process. */ @@ -659,7 +659,7 @@ extern int sync __P ((void)); extern int vhangup __P ((void)); /* Revoke the access of all descriptors currently open on FILE. */ -extern int revoke __P ((const char *__file)); +extern int revoke __P ((__const char *__file)); /* Enable statistical profiling, writing samples of the PC into at most @@ -689,7 +689,7 @@ extern void setusershell __P ((void)); /* Rewind and re-read the file. */ /* Prompt with PROMPT and read a string from the terminal without echoing. Uses /dev/tty if possible; otherwise stderr and stdin. */ -extern char *getpass __P ((const char *__prompt)); +extern char *getpass __P ((__const char *__prompt)); /* Put the program in the background, and dissociate from the controlling terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, @@ -770,10 +770,11 @@ extern int lockf __P ((int __fd, int __cmd, __off_t __len)); set to EINTR. */ #define TEMP_FAILURE_RETRY(expression) \ - ({ long int __result; \ + (__extension__ \ + ({ long int __result; \ do __result = (long int) (expression); \ while (__result == -1L && errno == EINTR); \ - __result; }) + __result; })) \ #endif diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 5e7f8386b8..ae1507eae5 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -194,8 +194,8 @@ extern __inline long int atol (__const char *__nptr) next call. */ extern char *l64a __P ((long int __n)); -/* Read a number from a string in base 64 as above. */ -extern long int a64l __P ((const char *)); +/* Read a number from a string S in base 64 as above. */ +extern long int a64l __P ((__const char *__s)); #endif @@ -457,12 +457,12 @@ extern lldiv_t lldiv __P ((long long int __numer, long long int __denom)) __attr /* Convert VALUE to a string with NDIGIT digits and return a pointer to this. Set *DECPT with the position of the decimal character and *SIGN with the sign of the number. */ -char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *sign)); +char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *__sign)); /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT with the position of the decimal character and *SIGN with the sign of the number. */ -char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *sign)); +char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *__sign)); /* If possible convert VALUE to a string with NDIGIT significant digits. Otherwise use exponential representation. The resulting string will @@ -471,24 +471,24 @@ char *gcvt __P ((double __value, int __ndigit, char *__buf)); /* Long double versions of above functions. */ char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt, - int *sign)); + int *__sign)); char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt, - int *sign)); + int *__sign)); char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf)); #ifdef __USE_REENTRANT /* Reentrant version of the functions above which provide their own buffers. */ -int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign, +int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign, char *__buf, size_t __len)); -int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign, +int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign, char *__buf, size_t __len)); int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt, - int *sign, char *__buf, size_t __len)); + int *__sign, char *__buf, size_t __len)); int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt, - int *sign, char *__buf, size_t __len)); + int *__sign, char *__buf, size_t __len)); #endif #endif @@ -498,7 +498,7 @@ int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt, extern int mblen __P ((__const char *__s, size_t __n)); /* Return the length of the given multibyte character, putting its `wchar_t' representation in *PWC. */ -extern int mbtowc __P ((wchar_t * __pwc, __const char *__s, size_t __n)); +extern int mbtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n)); /* Put the multibyte character represented by WCHAR in S, returning its length. */ extern int wctomb __P ((char *__s, wchar_t __wchar)); @@ -510,9 +510,9 @@ extern __inline int mblen (__const char *__s, size_t __n) /* Convert a multibyte string to a wide char string. */ -extern size_t mbstowcs __P ((wchar_t * __pwcs, __const char *__s, size_t __n)); +extern size_t mbstowcs __P ((wchar_t *__pwcs, __const char *__s, size_t __n)); /* Convert a wide char string to multibyte string. */ -extern size_t wcstombs __P ((char *__s, __const wchar_t * __pwcs, size_t __n)); +extern size_t wcstombs __P ((char *__s, __const wchar_t *__pwcs, size_t __n)); #ifdef __USE_SVID diff --git a/string/string.h b/string/string.h index da26a6f496..45071b8560 100644 --- a/string/string.h +++ b/string/string.h @@ -89,30 +89,32 @@ extern char *__strdup __P ((__const char *__s)); extern char *strdup __P ((__const char *__s)); #endif -#if defined (__USE_GNU) && defined (__GNUC__) -/* Duplicate S, returning an identical alloca'd string. */ -#define strdupa(s) \ -({ \ - __const char *__old = (s); \ - size_t __len = strlen (__old) + 1; \ - memcpy (__builtin_alloca (__len), __old, __len); \ -}) - /* Return a malloc'd copy of at most N bytes of STRING. The resultant string is terminated even if no null terminator appears before STRING[N]. */ extern char *strndup __P ((__const char *__string, size_t __n)); +#if defined (__USE_GNU) && defined (__GNUC__) +/* Duplicate S, returning an identical alloca'd string. */ +#define strdupa(s) \ + (__extension__ \ + ({ \ + __const char *__old = (s); \ + size_t __len = strlen (__old) + 1; \ + char *__new = __builtin_alloca (__len); \ + memcpy (__new, __old, __len); \ + })) + /* Return an alloca'd copy of at most N bytes of string. */ #define strndupa(s, n) \ -({ \ - __const char *__old = (s); \ - char *__new; \ - size_t __len = strnlen (__old, (n)); \ - __new = memcpy (__builtin_alloca (__len + 1), __old, __len); \ - __new[__len] = '\0'; \ - __new; \ -}) + (__extension__ \ + ({ \ + __const char *__old = (s); \ + size_t __len = strnlen (__old, (n)); \ + char *__new = __builtin_alloca (__len + 1); \ + __new[__len] = '\0'; \ + memcpy (__new, __old, __len); \ + })) #endif /* Find the first occurrence of C in S. */ @@ -231,7 +233,7 @@ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n)); #ifdef __USE_MISC /* Return the file name within directory of FILENAME. */ -extern char *basename __P ((__const char *filename)); +extern char *basename __P ((__const char *__filename)); #endif __END_DECLS diff --git a/sysdeps/generic/confname.h b/sysdeps/generic/confname.h index 3bc6b27652..fb2679fb45 100644 --- a/sysdeps/generic/confname.h +++ b/sysdeps/generic/confname.h @@ -112,6 +112,7 @@ enum #define _SC_VERSION _SC_VERSION _SC_PAGESIZE, #define _SC_PAGESIZE _SC_PAGESIZE +#define _SC_PAGE_SIZE _SC_PAGESIZE _SC_RTSIG_MAX, #define _SC_RTSIG_MAX _SC_RTSIG_MAX _SC_SEM_NSEMS_MAX, diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c index f0dbc23606..dda72a3591 100644 --- a/sysdeps/posix/sysconf.c +++ b/sysdeps/posix/sysconf.c @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <limits.h> #include <unistd.h> @@ -24,12 +23,13 @@ Cambridge, MA 02139, USA. */ #include <stdio.h> #include <time.h> -extern int EXFUN(__getdtablesize, (NOARGS)); -extern size_t EXFUN(__getpagesize, (NOARGS)); +extern int __getdtablesize __P ((void)); +extern size_t __getpagesize __P ((void)); /* Get the value of the system variable NAME. */ long int -DEFUN(__sysconf, (name), int name) +__sysconf (name) + int name; { switch (name) { @@ -301,6 +301,13 @@ DEFUN(__sysconf, (name), int name) return -1; #endif + case _SC_COLL_WEIGHTS_MAX: +#ifdef COLL_WEIGHTS_MAX + return COLL_WEIGHTS_MAX; +#else + return -1; +#endif + case _SC_EQUIV_CLASS_MAX: #ifdef EQUIV_CLASS_MAX return EQUIV_CLASS_MAX; diff --git a/sysdeps/stub/sysconf.c b/sysdeps/stub/sysconf.c index 816724ef52..f3b0c352ca 100644 --- a/sysdeps/stub/sysconf.c +++ b/sysdeps/stub/sysconf.c @@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <ansidecl.h> #include <errno.h> #include <unistd.h> #include <time.h> @@ -25,7 +24,8 @@ Cambridge, MA 02139, USA. */ /* Get the value of the system variable NAME. */ long int -DEFUN(__sysconf, (name), int name) +__sysconf (name) + int name; { switch (name) { @@ -36,11 +36,40 @@ DEFUN(__sysconf, (name), int name) case _SC_TZNAME_MAX: return __tzname_max (); + case _SC_CHARCLASS_NAME_MAX: +#ifdef CHARCLASS_NAME_MAX + return CHARCLASS_NAME_MAX; +#else + return -1; +#endif + + case _SC_COLL_WEIGHTS_MAX: +#ifdef COLL_WEIGHTS_MAX + return COLL_WEIGHTS_MAX; +#else + return -1; +#endif + + case _SC_EQUIV_CLASS_MAX: +#ifdef EQUIV_CLASS_MAX + return EQUIV_CLASS_MAX; +#else + return -1; +#endif + + case _SC_2_LOCALEDEF: +#ifdef _POSIX2_LOCALEDEF + return _POSIX2_LOCALEDEF; +#else + return -1; +#endif + case _SC_ARG_MAX: case _SC_CHILD_MAX: case _SC_CLK_TCK: case _SC_NGROUPS_MAX: case _SC_OPEN_MAX: + case _SC_STREAM_MAX: case _SC_JOB_CONTROL: case _SC_SAVED_IDS: case _SC_REALTIME_SIGNALS: @@ -57,7 +86,20 @@ DEFUN(__sysconf, (name), int name) case _SC_MESSAGE_PASSING: case _SC_SEMAPHORES: case _SC_SHARED_MEMORY_OBJECTS: + + case _SC_AIO_LIST_MAX: + case _SC_AIO_MAX: + case _SC_AIO_PRIO_DELTA_MAX: + case _SC_DELAYTIME_MAX: + case _SC_MQ_OPEN_MAX: + case _SC_MQ_PRIO_MAX: case _SC_VERSION: + case _SC_PAGESIZE: + case _SC_RTSIG_MAX: + case _SC_SEM_NSEMS_MAX: + case _SC_SEM_VALUE_MAX: + case _SC_SIGQUEUE_MAX: + case _SC_TIMER_MAX: case _SC_PII: case _SC_PII_XTI: @@ -77,11 +119,9 @@ DEFUN(__sysconf, (name), int name) case _SC_BC_DIM_MAX: case _SC_BC_SCALE_MAX: case _SC_BC_STRING_MAX: - case _SC_EQUIV_CLASS_MAX: case _SC_EXPR_NEST_MAX: case _SC_LINE_MAX: case _SC_RE_DUP_MAX: - case _SC_CHARCLASS_NAME_MAX: case _SC_2_VERSION: case _SC_2_C_BIND: case _SC_2_C_DEV: diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure index fd72c092ad..51b50f9be6 100644 --- a/sysdeps/unix/sysv/linux/configure +++ b/sysdeps/unix/sysv/linux/configure @@ -8,7 +8,7 @@ test $stdio = default && stdio=libio inhibit_glue=yes echo $ac_n "checking installed Linux kernel header files""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'libc_cv_linux201'+set}'`\" = set"; then +if eval "test \"`echo '$''{'libc_cv_linux203'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF @@ -17,28 +17,29 @@ else #include <linux/version.h> int main() { return 0; } int t() { -#if LINUX_VERSION_CODE < (2 *65536+ 0 *256+ 1) /* 2.0.1 */ +#if LINUX_VERSION_CODE < (2 *65536+ 0 *256+ 3) /* 2.0.3 */ eat flaming death #endif ; return 0; } EOF if { (eval echo configure:26: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* - libc_cv_linux201='2.0.1 or later' + libc_cv_linux203='2.0.3 or later' else rm -rf conftest* - libc_cv_linux201='TOO OLD!' + libc_cv_linux203='TOO OLD!' fi rm -f conftest* fi -echo "$ac_t""$libc_cv_linux201" 1>&6 -if test "$libc_cv_linux201" != '2.0.1 or later'; then - { echo "configure: error: GNU libc requires kernel header files from Linux 2.0.1 -or later to be installed before configuring. The kernel header files -are found usually in /usr/include/asm and /usr/include/linux; make sure -these directories use files from Linux 2.0.1 or later. This check uses -<linux/version.h>, so make sure that file was built correctly when -installing the kernel header files." 1>&2; exit 1; } +echo "$ac_t""$libc_cv_linux203" 1>&6 +if test "$libc_cv_linux203" != '2.0.3 or later'; then + { echo "configure: error: GNU libc requires kernel header files from +Linux 2.0.3 or later to be installed before configuring. +The kernel header files are found usually in /usr/include/asm and +/usr/include/linux; make sure these directories use files from +Linux 2.0.3 or later. This check uses <linux/version.h>, so +make sure that file was built correctly when installing the kernel header +files." 1>&2; exit 1; } fi diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index f713892ae1..120f8690a9 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -29,6 +29,7 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \ wmemcmp wmemcpy wmemmove wmemset wcpcpy wcpncpy \ btowc wctob mbsinit \ mbrlen mbrtowc wcrtomb mbsrtowcs wcsrtombs \ + mbsnrtowcs wcsnrtombs \ wcstol wcstoul wcstoq wcstouq wcstod wcstold wcstof \ wcscoll wcsxfrm \ wcwidth wcswidth diff --git a/wcsmbs/mbsnrtowcs.c b/wcsmbs/mbsnrtowcs.c new file mode 100644 index 0000000000..27906957e9 --- /dev/null +++ b/wcsmbs/mbsnrtowcs.c @@ -0,0 +1,143 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <wchar.h> + +#ifndef EILSEQ +#define EILSEQ EINVAL +#endif + + +/* We don't need the state really because we don't have shift states + to maintain between calls to this function. */ +static mbstate_t internal; + +/* This is a non-standard function but it is very useful in the + implementation of stdio because we have to deal with unterminated + buffers. At most NMC bytes will be converted. */ +size_t +__mbsnrtowcs (dst, src, nmc, len, ps) + wchar_t *dst; + const char **src; + size_t nmc; + size_t len; + mbstate_t *ps; +{ + size_t written = 0; + const char *run = *src; + const char *last = run + nmc; + + if (ps == NULL) + ps = &internal; + + if (dst == NULL) + /* The LEN parameter has to be ignored if we don't actually write + anything. */ + len = ~0; + + /* Copy all words. */ + while (written < len && run < last) + { + wchar_t value; + size_t count; + unsigned char byte = *run++; + + /* We expect a start of a new multibyte character. */ + if (byte < 0x80) + { + /* One byte sequence. */ + count = 0; + value = byte; + } + else if ((byte & 0xe0) == 0xc0) + { + count = 1; + value = byte & 0x1f; + } + else if ((byte & 0xf0) == 0xe0) + { + /* We expect three bytes. */ + count = 2; + value = byte & 0x0f; + } + else if ((byte & 0xf8) == 0xf0) + { + /* We expect four bytes. */ + count = 3; + value = byte & 0x07; + } + else if ((byte & 0xfc) == 0xf8) + { + /* We expect five bytes. */ + count = 4; + value = byte & 0x03; + } + else if ((byte & 0xfe) == 0xfc) + { + /* We expect six bytes. */ + count = 5; + value = byte & 0x01; + } + else + { + /* This is an illegal encoding. */ + errno = EILSEQ; + return (size_t) -1; + } + + /* Read the possible remaining bytes. */ + while (count-- > 0) + { + byte = *run++; + + if ((byte & 0xc0) != 0x80) + { + /* This is an illegal encoding. */ + errno = EILSEQ; + return (size_t) -1; + } + + value <<= 6; + value |= byte & 0x3f; + } + + /* Store value is required. */ + if (dst != NULL) + *dst++ = value; + + /* The whole sequence is read. Check whether end of string is + reached. */ + if (value == L'\0') + { + /* Found the end of the string. */ + *src = NULL; + return written; + } + + /* Increment counter of produced words. */ + ++written; + } + + /* Store address of next byte to process. */ + *src = run; + + return written; +} +weak_alias (__mbsnrtowcs, mbsnrtowcs) diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 806bafa655..0346364b44 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -131,7 +131,7 @@ extern wchar_t *wmemcpy __P ((wchar_t *__s1, __const wchar_t *__s2, /* Copy N bytes of SRC to DEST, guaranteeing correct behavior for overlapping strings. */ extern wchar_t *wmemmove __P ((wchar_t *__s1, __const wchar_t *__s2, - size_t __N)); + size_t __n)); /* Set N bytes of S to C. */ extern wchar_t *wmemset __P ((wchar_t *__s, wchar_t __c, size_t __n)); @@ -168,8 +168,8 @@ extern __inline size_t mbrlen (__const char *s, size_t n, mbstate_t *ps) { return ps != NULL ? mbrtowc (NULL, s, n, ps) : __mbrlen (s, n, NULL); } #endif -/* Write wide character representation of multibyte chracter string SRC - to DST. */ +/* Write wide character representation of multibyte character string + SRC to DST. */ extern size_t mbsrtowcs __P ((wchar_t *__dst, __const char **__src, size_t __len, mbstate_t *__ps)); @@ -180,6 +180,21 @@ extern size_t wcsrtombs __P ((char *__dst, __const wchar_t **__src, #ifdef __USE_GNU +/* Write wide character representation of at most NMC bytes of the + multibyte character string SRC to DST. */ +extern size_t __mbsnrtowcs __P ((wchar_t *__dst, __const char **__src, + size_t __nmc, size_t __len, mbstate_t *__ps)); +extern size_t mbsnrtowcs __P ((wchar_t *__dst, __const char **__src, + size_t __nmc, size_t __len, mbstate_t *__ps)); + +/* Write multibyte character representation of at most NWC characters + from the wide character string SRC to DST. */ +extern size_t __wcsnrtombs __P ((char *__dst, __const wchar_t **__src, + size_t __nwc, size_t __len, mbstate_t *__ps)); +extern size_t wcsnrtombs __P ((char *__dst, __const wchar_t **__src, + size_t __nwc, size_t __len, mbstate_t *__ps)); + + /* The following functions are extensions found in X/Open CAE. */ /* Determine number of column positions required for C. */ @@ -229,11 +244,11 @@ extern unsigned long long int wcstouq __P ((__const wchar_t *__nptr, /* The internal entry points for `wcstoX' take an extra flag argument saying whether or not to parse locale-dependent number grouping. */ extern double __wcstod_internal __P ((__const wchar_t *__nptr, - wchar_t **_endptr, int __group)); + wchar_t **__endptr, int __group)); extern float __wcstof_internal __P ((__const wchar_t *__nptr, - wchar_t **_endptr, int __group)); + wchar_t **__endptr, int __group)); extern __long_double_t __wcstold_internal __P ((__const wchar_t *__nptr, - wchar_t **_endptr, + wchar_t **__endptr, int __group)); extern long int __wcstol_internal __P ((__const wchar_t *__nptr, diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c new file mode 100644 index 0000000000..fb50a11732 --- /dev/null +++ b/wcsmbs/wcsnrtombs.c @@ -0,0 +1,129 @@ +/* Copyright (C) 1996 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <wchar.h> + +#ifndef EILSEQ +#define EILSEQ EINVAL +#endif + + +static const wchar_t encoding_mask[] = +{ + ~0x7ff, ~0xffff, ~0x1fffff, ~0x3ffffff +}; + +static const unsigned char encoding_byte[] = +{ + 0xc0, 0xe0, 0xf0, 0xf8, 0xfc +}; + +/* We don't need the state really because we don't have shift states + to maintain between calls to this function. */ +static mbstate_t internal; + +/* This is a non-standard function but it is very useful in the + implementation of stdio because we have to deal with unterminated + buffers. At most NWC wide character will be converted. */ +size_t +__wcsnrtombs (dst, src, nwc, len, ps) + char *dst; + const wchar_t **src; + size_t nwc; + size_t len; + mbstate_t *ps; +{ + size_t written = 0; + const wchar_t *run = *src; + + if (ps == NULL) + ps = &internal; + + if (dst == NULL) + /* The LEN parameter has to be ignored if we don't actually write + anything. */ + len = ~0; + + while (written < len && nwc-- > 0) + { + wchar_t wc = *run++; + + if (wc < 0 || wc > 0x7fffffff) + { + /* This is no correct ISO 10646 character. */ + errno = EILSEQ; + return (size_t) -1; + } + + if (wc == L'\0') + { + /* Found the end. */ + if (dst != NULL) + *dst = '\0'; + *src = NULL; + return written; + } + else if (wc < 0x80) + { + /* It's an one byte sequence. */ + if (dst != NULL) + *dst++ = (char) wc; + ++written; + } + else + { + size_t step; + + for (step = 2; step < 6; ++step) + if ((wc & encoding_mask[step - 2]) == 0) + break; + + if (written + step >= len) + /* Too long. */ + break; + + if (dst != NULL) + { + size_t cnt = step; + + dst[0] = encoding_byte[cnt - 2]; + + --cnt; + do + { + dst[cnt] = 0x80 | (wc & 0x3f); + wc >>= 6; + } + while (--cnt > 0); + dst[0] |= wc; + + dst += step; + } + + written += step; + } + } + + /* Store position of first unprocessed word. */ + *src = run; + + return written; +} +weak_alias (__wcsnrtombs, wcsnrtombs) |