+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
if (do_version)
{
fprintf (stderr, "%s - GNU %s %s\n", program_invocation_name,
- PACKAGE, VERSION);
+ "libc", VERSION);
exit (EXIT_SUCCESS);
}
-/* 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
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
/* 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. */
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) \
__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. */
/* 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;
/* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo
instead. */
char *newp;
-
+
__close (fd);
newp = (char *) alloca (strlen (file->filename)
}
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]);
}
free ((void *) data);
}
-
-
#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) \
--- /dev/null
+/* 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;
+ }
+}
-/* 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
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>
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);
!= EOF)
switch (optchar)
{
- case '\0':
+ case '\0': /* Long option. */
break;
case 'a':
do_all = 1;
/* 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);
}
{
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\
\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);
}
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);
}
/* 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;
/* 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;
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)
/* 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);
}
{
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
- program_name);
+ program_invocation_name);
else
printf (_("\
Usage: %s [OPTION]... name\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);
}
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;
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)
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;
}
{
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:
/* 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),
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);
#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_ */
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[] =
{ "_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 ();
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);
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;
}
#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. */
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,
#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
#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
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
/* 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
/* 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'. */
#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. */
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
/* 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,
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
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
/* 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
/* 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
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));
/* 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
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. */
#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
#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,
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>
#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)
{
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;
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>
/* Get the value of the system variable NAME. */
long int
-DEFUN(__sysconf, (name), int name)
+__sysconf (name)
+ int name;
{
switch (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:
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:
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:
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
#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
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
--- /dev/null
+/* 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)
/* 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));
{ 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));
#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. */
/* 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,
--- /dev/null
+/* 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)