OSDN Git Service

* libc/include/langinfo.h: New file.
authorfitzsim <fitzsim>
Fri, 23 Aug 2002 01:56:02 +0000 (01:56 +0000)
committerfitzsim <fitzsim>
Fri, 23 Aug 2002 01:56:02 +0000 (01:56 +0000)
* libc/include/wchar.h: Likewise.
* libc/include/sys/syslimits.h: Likewise.
* libc/locale/fix_grouping.c: Likewise.
* libc/locale/ldpart.c: Likewise.
* libc/locale/ldpart.h: Likewise.
* libc/locale/lmessages.c: Likewise.
* libc/locale/lmessages.h: Likewise.
* libc/locale/lmonetary.c: Likewise.
* libc/locale/lmonetary.h: Likewise.
* libc/locale/lnumeric.c: Likewise.
* libc/locale/lnumeric.h: Likewise.
* libc/locale/nl_langinfo.3: Likewise.
* libc/locale/nl_langinfo.c: Likewise.
* libc/locale/timelocal.c: Likewise.
* libc/locale/timelocal.h: Likewise.
* libc/stdlib/btowc.c: Likewise.
* libc/stdlib/mbrlen.c: Likewise.
* libc/stdlib/mbrtowc.c: Likewise.
* libc/stdlib/mbsinit.c: Likewise.
* libc/stdlib/mbsrtowcs.c: Likewise.
* libc/stdlib/wcrtomb.c: Likewise.
* libc/stdlib/wcsrtombs.c: Likewise.
* libc/stdlib/wctob.c: Likewise.
* libc/sys/linux/prof-freq.c: Likewise.
* libc/sys/linux/profile.c: Likewise.
* libc/sys/linux/machine/i386/dl-procinfo.c: Likewise.
* libc/sys/linux/machine/i386/dl-procinfo.h: Likewise.
* libc/include/stdlib.h: Change re-entrant functions to take
mbstate_t pointers.
* libc/include/sys/_types.h: Define _mbstate_t.
* libc/include/sys/config.h (MB_LEN_MAX): New macro.
* libc/include/sys/errno.h (EILSEQ): New error code.
* libc/include/sys/reent.h: Include wchar.h.  Change reentrant
structure to use mbstate_t.
* libc/locale/Makefile.am (LIB_SOURCES): Add new files.
* libc/machine/powerpc/vfprintf.c: Use mbstate_t.
* libc/machine/powerpc/vfscanf.c: Likewise.
* libc/stdio/getdelim.c: Reallocate buffer only when necessary.
* libc/stdio/vfprintf.c: Likewise.
* libc/stdio/vfscanf.c: Likewise.
* libc/stdlib/Makefile.am (LIB_SOURCES): Add new files.
* libc/stdlib/mblen.c: Use mbstate_t.
* libc/stdlib/mblen_r.c: Likewise.
* libc/stdlib/mbstowcs.c: Likewise.
* libc/stdlib/mbstowcs_r.c: Likewise.
* libc/stdlib/mbtowc.c: Likewise.
* libc/stdlib/mbtowc_r.c: Likewise.
* libc/stdlib/wcstombs.c: Likewise.
* libc/stdlib/wcstombs_r.c: Likewise.
* libc/stdlib/wctomb_r.c: Likewise.
* libc/sys/linux/Makefile.am (LIB_SOURCES): Add prof-freq.c and
profile.c.
* libc/sys/linux/machine/i386/Makefile.am (LIB_SOURCES): Add
dl-procinfo.c.
* libc/sys/linux/sys/errno.h (EILSEQ): New error code.
* libc/sys/linux/sys/types.h (off_t): Define type.
* testsuite/newlib.locale/UTF-8.c: Change locale name from UTF-8
to C-UTF-8.
* testsuite/newlib.locale/UTF-8.exp: Likewise.

67 files changed:
newlib/ChangeLog
newlib/configure.host
newlib/libc/include/langinfo.h [new file with mode: 0644]
newlib/libc/include/stdlib.h
newlib/libc/include/sys/_types.h
newlib/libc/include/sys/config.h
newlib/libc/include/sys/errno.h
newlib/libc/include/sys/reent.h
newlib/libc/include/sys/syslimits.h [new file with mode: 0644]
newlib/libc/include/wchar.h [new file with mode: 0644]
newlib/libc/locale/Makefile.am
newlib/libc/locale/Makefile.in
newlib/libc/locale/fix_grouping.c [new file with mode: 0644]
newlib/libc/locale/ldpart.c [new file with mode: 0644]
newlib/libc/locale/ldpart.h [new file with mode: 0644]
newlib/libc/locale/lmessages.c [new file with mode: 0644]
newlib/libc/locale/lmessages.h [new file with mode: 0644]
newlib/libc/locale/lmonetary.c [new file with mode: 0644]
newlib/libc/locale/lmonetary.h [new file with mode: 0644]
newlib/libc/locale/lnumeric.c [new file with mode: 0644]
newlib/libc/locale/lnumeric.h [new file with mode: 0644]
newlib/libc/locale/nl_langinfo.3 [new file with mode: 0644]
newlib/libc/locale/nl_langinfo.c [new file with mode: 0644]
newlib/libc/locale/setlocale.h [new file with mode: 0644]
newlib/libc/locale/timelocal.c [new file with mode: 0644]
newlib/libc/locale/timelocal.h [new file with mode: 0644]
newlib/libc/machine/powerpc/vfprintf.c
newlib/libc/machine/powerpc/vfscanf.c
newlib/libc/machine/sh/Makefile.in
newlib/libc/stdio/getdelim.c
newlib/libc/stdio/vfprintf.c
newlib/libc/stdio/vfscanf.c
newlib/libc/stdio64/Makefile.in
newlib/libc/stdlib/Makefile.am
newlib/libc/stdlib/Makefile.in
newlib/libc/stdlib/btowc.c [new file with mode: 0644]
newlib/libc/stdlib/mblen.c
newlib/libc/stdlib/mblen_r.c
newlib/libc/stdlib/mbrlen.c [new file with mode: 0644]
newlib/libc/stdlib/mbrtowc.c [new file with mode: 0644]
newlib/libc/stdlib/mbsinit.c [new file with mode: 0644]
newlib/libc/stdlib/mbsrtowcs.c [new file with mode: 0644]
newlib/libc/stdlib/mbstowcs.c
newlib/libc/stdlib/mbstowcs_r.c
newlib/libc/stdlib/mbtowc.c
newlib/libc/stdlib/mbtowc_r.c
newlib/libc/stdlib/wcrtomb.c [new file with mode: 0644]
newlib/libc/stdlib/wcsrtombs.c [new file with mode: 0644]
newlib/libc/stdlib/wcstombs.c
newlib/libc/stdlib/wcstombs_r.c
newlib/libc/stdlib/wctob.c [new file with mode: 0644]
newlib/libc/stdlib/wctomb_r.c
newlib/libc/sys/linux/Makefile.am
newlib/libc/sys/linux/Makefile.in
newlib/libc/sys/linux/cmath/math_private.h
newlib/libc/sys/linux/fpathconf.c
newlib/libc/sys/linux/machine/i386/Makefile.am
newlib/libc/sys/linux/machine/i386/Makefile.in
newlib/libc/sys/linux/machine/i386/dl-procinfo.c [new file with mode: 0644]
newlib/libc/sys/linux/machine/i386/dl-procinfo.h [new file with mode: 0644]
newlib/libc/sys/linux/pathconf.c
newlib/libc/sys/linux/prof-freq.c [new file with mode: 0644]
newlib/libc/sys/linux/profile.c [new file with mode: 0644]
newlib/libc/sys/linux/sys/errno.h
newlib/libc/sys/linux/sys/types.h
newlib/testsuite/newlib.locale/UTF-8.c
newlib/testsuite/newlib.locale/UTF-8.exp

index a383528..215af69 100644 (file)
@@ -1,3 +1,66 @@
+2002-08-22  Thomas Fitzsimmons  <fitzsim@redhat.com>
+
+       * libc/include/langinfo.h: New file.
+       * libc/include/wchar.h: Likewise.
+       * libc/include/sys/syslimits.h: Likewise.
+       * libc/locale/fix_grouping.c: Likewise.
+       * libc/locale/ldpart.c: Likewise.
+       * libc/locale/ldpart.h: Likewise.
+       * libc/locale/lmessages.c: Likewise.
+       * libc/locale/lmessages.h: Likewise.
+       * libc/locale/lmonetary.c: Likewise.
+       * libc/locale/lmonetary.h: Likewise.
+       * libc/locale/lnumeric.c: Likewise.
+       * libc/locale/lnumeric.h: Likewise.
+       * libc/locale/nl_langinfo.3: Likewise.
+       * libc/locale/nl_langinfo.c: Likewise.
+       * libc/locale/timelocal.c: Likewise.
+       * libc/locale/timelocal.h: Likewise.
+       * libc/stdlib/btowc.c: Likewise.
+       * libc/stdlib/mbrlen.c: Likewise.
+       * libc/stdlib/mbrtowc.c: Likewise.
+       * libc/stdlib/mbsinit.c: Likewise.
+       * libc/stdlib/mbsrtowcs.c: Likewise.
+       * libc/stdlib/wcrtomb.c: Likewise.
+       * libc/stdlib/wcsrtombs.c: Likewise.
+       * libc/stdlib/wctob.c: Likewise.
+       * libc/sys/linux/prof-freq.c: Likewise.
+       * libc/sys/linux/profile.c: Likewise.
+       * libc/sys/linux/machine/i386/dl-procinfo.c: Likewise.
+       * libc/sys/linux/machine/i386/dl-procinfo.h: Likewise.
+       * libc/include/stdlib.h: Change re-entrant functions to take
+       mbstate_t pointers.
+       * libc/include/sys/_types.h: Define _mbstate_t.
+       * libc/include/sys/config.h (MB_LEN_MAX): New macro.
+       * libc/include/sys/errno.h (EILSEQ): New error code.
+       * libc/include/sys/reent.h: Include wchar.h.  Change reentrant
+       structure to use mbstate_t.
+       * libc/locale/Makefile.am (LIB_SOURCES): Add new files.
+       * libc/machine/powerpc/vfprintf.c: Use mbstate_t.
+       * libc/machine/powerpc/vfscanf.c: Likewise.
+       * libc/stdio/getdelim.c: Reallocate buffer only when necessary.
+       * libc/stdio/vfprintf.c: Likewise.
+       * libc/stdio/vfscanf.c: Likewise.
+       * libc/stdlib/Makefile.am (LIB_SOURCES): Add new files.
+       * libc/stdlib/mblen.c: Use mbstate_t.
+       * libc/stdlib/mblen_r.c: Likewise.
+       * libc/stdlib/mbstowcs.c: Likewise.
+       * libc/stdlib/mbstowcs_r.c: Likewise.
+       * libc/stdlib/mbtowc.c: Likewise.
+       * libc/stdlib/mbtowc_r.c: Likewise.
+       * libc/stdlib/wcstombs.c: Likewise.
+       * libc/stdlib/wcstombs_r.c: Likewise.
+       * libc/stdlib/wctomb_r.c: Likewise.
+       * libc/sys/linux/Makefile.am (LIB_SOURCES): Add prof-freq.c and
+       profile.c.
+       * libc/sys/linux/machine/i386/Makefile.am (LIB_SOURCES): Add
+       dl-procinfo.c.
+       * libc/sys/linux/sys/errno.h (EILSEQ): New error code.
+       * libc/sys/linux/sys/types.h (off_t): Define type.
+       * testsuite/newlib.locale/UTF-8.c: Change locale name from UTF-8
+       to C-UTF-8.
+       * testsuite/newlib.locale/UTF-8.exp: Likewise.
+
 2002-08-20  Casper S. Hornstrup  <chorns@users.sourceforge.net>
 
         * libc/stdlib/mallocr.c: #include windows.h on Win32.
index 8874026..5220a35 100644 (file)
@@ -242,7 +242,7 @@ fi
 # Enable printf positional argument support if requested.
 
 if [ "${newlib_io_pos_args}" = "yes" ] ; then
-        newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
+       newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
 fi
 
 # Verify if shared newlib support is allowed and set appropriate variables
@@ -338,6 +338,7 @@ case "${host}" in
        ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
        ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
        ;;
+
   m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
        ;;
 
@@ -500,8 +501,8 @@ case "${host}" in
        syscall_dir=syscalls
        ;;
   m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
-        newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
-        ;;
+       newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
+       ;;
   mcore-*-*)
        newlib_cflags="${newlib_cflags}"
        syscall_dir=syscalls
diff --git a/newlib/libc/include/langinfo.h b/newlib/libc/include/langinfo.h
new file mode 100644 (file)
index 0000000..33ae8d0
--- /dev/null
@@ -0,0 +1,140 @@
+/*-
+ * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/include/langinfo.h,v 1.5 2002/03/23 17:24:53 imp Exp $
+ */
+
+#ifndef _LANGINFO_H_
+#define        _LANGINFO_H_
+
+#include <sys/cdefs.h>
+
+typedef int nl_item;
+
+/* Extract the category and item index from a constructed `nl_item' value.  */
+#define _NL_ITEM_CATEGORY(item)                ((int) (item) >> 16)
+#define _NL_ITEM_INDEX(item)           ((int) (item) & 0xffff)
+
+#define        CODESET         0       /* codeset name */
+#define        D_T_FMT         1       /* string for formatting date and time */
+#define        D_FMT           2       /* date format string */
+#define        T_FMT           3       /* time format string */
+#define        T_FMT_AMPM      4       /* a.m. or p.m. time formatting string */
+#define        AM_STR          5       /* Ante Meridian affix */
+#define        PM_STR          6       /* Post Meridian affix */
+
+/* week day names */
+#define        DAY_1           7
+#define        DAY_2           8
+#define        DAY_3           9
+#define        DAY_4           10
+#define        DAY_5           11
+#define        DAY_6           12
+#define        DAY_7           13
+
+/* abbreviated week day names */
+#define        ABDAY_1         14
+#define        ABDAY_2         15
+#define        ABDAY_3         16
+#define        ABDAY_4         17
+#define        ABDAY_5         18
+#define        ABDAY_6         19
+#define        ABDAY_7         20
+
+/* month names */
+#define        MON_1           21
+#define        MON_2           22
+#define        MON_3           23
+#define        MON_4           24
+#define        MON_5           25
+#define        MON_6           26
+#define        MON_7           27
+#define        MON_8           28
+#define        MON_9           29
+#define        MON_10          30
+#define        MON_11          31
+#define        MON_12          32
+
+/* abbreviated month names */
+#define        ABMON_1         33
+#define        ABMON_2         34
+#define        ABMON_3         35
+#define        ABMON_4         36
+#define        ABMON_5         37
+#define        ABMON_6         38
+#define        ABMON_7         39
+#define        ABMON_8         40
+#define        ABMON_9         41
+#define        ABMON_10        42
+#define        ABMON_11        43
+#define        ABMON_12        44
+
+#define        ERA             45      /* era description segments */
+#define        ERA_D_FMT       46      /* era date format string */
+#define        ERA_D_T_FMT     47      /* era date and time format string */
+#define        ERA_T_FMT       48      /* era time format string */
+#define        ALT_DIGITS      49      /* alternative symbols for digits */
+
+#define        RADIXCHAR       50      /* radix char */
+#define        THOUSEP         51      /* separator for thousands */
+
+#define        YESEXPR         52      /* affirmative response expression */
+#define        NOEXPR          53      /* negative response expression */
+#define        YESSTR          54      /* affirmative response for yes/no queries */
+#define        NOSTR           55      /* negative response for yes/no queries */
+
+#define        CRNCYSTR        56      /* currency symbol */
+
+#define        D_MD_ORDER      57      /* month/day order (local extension) */
+
+#define _NL_CTYPE_TRANSLIT_TAB_SIZE 58
+#define _NL_CTYPE_TRANSLIT_FROM_IDX 59
+#define _NL_CTYPE_TRANSLIT_FROM_TBL 60
+#define _NL_CTYPE_TRANSLIT_TO_IDX 61
+#define _NL_CTYPE_TRANSLIT_TO_TBL 62
+#define _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN 63
+#define _NL_CTYPE_TRANSLIT_DEFAULT_MISSING 64
+#define _NL_CTYPE_TRANSLIT_IGNORE_LEN 65
+#define _NL_CTYPE_TRANSLIT_IGNORE 66
+#define _NL_CTYPE_EXTRA_MAP_1 70
+#define _NL_CTYPE_EXTRA_MAP_2 71
+#define _NL_CTYPE_EXTRA_MAP_3 72
+#define _NL_CTYPE_EXTRA_MAP_4 73
+#define _NL_CTYPE_EXTRA_MAP_5 74
+#define _NL_CTYPE_EXTRA_MAP_6 75
+#define _NL_CTYPE_EXTRA_MAP_7 76
+#define _NL_CTYPE_EXTRA_MAP_8 77
+#define _NL_CTYPE_EXTRA_MAP_9 78
+#define _NL_CTYPE_EXTRA_MAP_10 79
+#define _NL_CTYPE_EXTRA_MAP_11 80
+#define _NL_CTYPE_EXTRA_MAP_12 81
+#define _NL_CTYPE_EXTRA_MAP_13 82
+#define _NL_CTYPE_EXTRA_MAP_14 83
+
+__BEGIN_DECLS
+char   *nl_langinfo(nl_item);
+__END_DECLS
+
+#endif /* !_LANGINFO_H_ */
index d7401ec..d7246c3 100644 (file)
@@ -72,15 +72,15 @@ long        _EXFUN(labs,(long));
 ldiv_t _EXFUN(ldiv,(long __numer, long __denom));
 _PTR   _EXFUN(malloc,(size_t __size));
 int    _EXFUN(mblen,(const char *, size_t));
-int    _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, int *));
+int    _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *));
 int    _EXFUN(mbtowc,(wchar_t *, const char *, size_t));
-int    _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, int *));
+int    _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
 int    _EXFUN(wctomb,(char *, wchar_t));
-int    _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, int *));
+int    _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *));
 size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t));
-size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, int *));
+size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
 size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t));
-size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, int *));
+size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *));
 #ifndef __STRICT_ANSI__
 #ifndef _REENT_ONLY
 int     _EXFUN(mkstemp,(char *));
index a487676..9f3b05b 100644 (file)
@@ -18,4 +18,29 @@ typedef int _ssize_t;
 typedef long _ssize_t;
 #endif
 
+#define __need_wint_t
+#include <stddef.h>
+
+#ifndef _MBSTATE_T
+#define _MBSTATE_T
+/* Conversion state information.  */
+typedef struct
+{
+  int __count;
+  union
+  {
+    wint_t __wch;
+    char __wchb[4];
+  } __value;           /* Value so far.  */
+} _mbstate_t;
+#endif /* _MBSTATE_T */
+
+#ifdef __CYGWIN__
+# ifndef MBSTATE_T
+#  define MBSTATE_T
+typedef _mbstate_t mbstate_t;
+# endif /* MBSTATE_T */
+# define WEOF (0xffffffffu)
+#endif /* __CYGWIN__ */
+
 #endif /* _SYS__TYPES_H */
index 89abbfd..d8bdc9c 100644 (file)
@@ -3,6 +3,10 @@
 
 #include <machine/ieeefp.h>  /* floating point macros */
 
+/* Length of longest possible multibyte sequence among all supported
+   locales. */
+#define MB_LEN_MAX 8
+
 /* exceptions first */
 #if defined(__H8300__) || defined(__H8500__) || defined (__H8300H__) ||  defined(__W65__) || defined (__H8300S__)
 #define __SMALL_BITFIELDS
index 17a5611..f88d563 100644 (file)
@@ -146,6 +146,7 @@ extern __IMPORT int sys_nerr;
 #define ENOMEDIUM 135   /* No medium (in tape drive) */
 #define ENOSHARE 136    /* No such host or network path */
 #define ECASECLASH 137  /* Filename exists with different case */
+#define EILSEQ 138
 
 /* From cygwin32.  */
 #define EWOULDBLOCK EAGAIN     /* Operation would block */
index 4b570ce..ebdf32a 100644 (file)
@@ -307,9 +307,9 @@ struct _misc_reent
 {
   /* miscellaneous reentrant data */
   char *_strtok_last;
-  int _mblen_state;
-  int _wctomb_state;
-  int _mbtowc_state;
+  _mbstate_t _mblen_state;
+  _mbstate_t _wctomb_state;
+  _mbstate_t _mbtowc_state;
   char _l64a_buf[8];
   int _getdate_err;
 };
@@ -463,9 +463,12 @@ struct _reent
 #define _REENT_INIT_MISC(var) do { \
   struct _reent *_r = (var); \
   _r->_misc->_strtok_last = _NULL; \
-  _r->_misc->_mblen_state = 0; \
-  _r->_misc->_wctomb_state = 0; \
-  _r->_misc->_mbtowc_state = 0; \
+  _r->_misc->_mblen_state.__count = 0; \
+  _r->_misc->_mblen_state.__value.__wch = 0; \
+  _r->_misc->_wctomb_state.__count = 0; \
+  _r->_misc->_wctomb_state.__value.__wch = 0; \
+  _r->_misc->_mbtowc_state.__count = 0; \
+  _r->_misc->_mbtowc_state.__value.__wch = 0; \
   _r->_misc->_l64a_buf[0] = '\0'; \
   _r->_misc->_getdate_err = 0; \
 } while (0)
@@ -537,9 +540,9 @@ struct _reent
           int _gamma_signgam;
           __extension__ unsigned long long _rand_next;
           struct _rand48 _r48;
-          int _mblen_state;
-          int _mbtowc_state;
-          int _wctomb_state;
+          _mbstate_t _mblen_state;
+          _mbstate_t _mbtowc_state;
+          _mbstate_t _wctomb_state;
           char _l64a_buf[8];
           char _signal_buf[_REENT_SIGNAL_SIZE];
           int _getdate_err;  
@@ -575,7 +578,7 @@ struct _reent
     { 0,0,0,0,0,0,0,0}, 0, 1, \
     {{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \
      {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD}, \
-    0, 0, 0, "", "", 0} } }
+    {0, {0}}, {0, {0}}, {0, {0}}, "", "", 0} } }
 
 #define _REENT_INIT_PTR(var) \
   { int i; \
@@ -612,9 +615,12 @@ struct _reent
     var->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
     var->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
     var->_new._reent._r48._add = _RAND48_ADD; \
-    var->_new._reent._mblen_state = 0; \
-    var->_new._reent._mbtowc_state = 0; \
-    var->_new._reent._wctomb_state = 0; \
+    var->_new._reent._mblen_state.__count = 0; \
+    var->_new._reent._mblen_state.__value.__wch = 0; \
+    var->_new._reent._mbtowc_state.__count = 0; \
+    var->_new._reent._mbtowc_state.__value.__wch = 0; \
+    var->_new._reent._wctomb_state.__count = 0; \
+    var->_new._reent._wctomb_state.__value.__wch = 0; \
     var->_new._reent._l64a_buf[0] = '\0'; \
     var->_new._reent._signal_buf[0] = '\0'; \
     var->_new._reent._getdate_err = 0; \
diff --git a/newlib/libc/include/sys/syslimits.h b/newlib/libc/include/sys/syslimits.h
new file mode 100644 (file)
index 0000000..ba9dbd6
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)syslimits.h 8.1 (Berkeley) 6/2/93
+ * $FreeBSD: src/sys/sys/syslimits.h,v 1.10 2001/06/18 20:24:54 wollman Exp $
+ */
+
+#ifndef _SYS_SYSLIMITS_H_
+#define _SYS_SYSLIMITS_H_
+
+#define        ARG_MAX                 65536   /* max bytes for an exec function */
+#ifndef CHILD_MAX
+#define        CHILD_MAX                  40   /* max simultaneous processes */
+#endif
+#define        LINK_MAX                32767   /* max file link count */
+#define        MAX_CANON                 255   /* max bytes in term canon input line */
+#define        MAX_INPUT                 255   /* max bytes in terminal input */
+#define        NAME_MAX                  255   /* max bytes in a file name */
+#define        NGROUPS_MAX                16   /* max supplemental group id's */
+#ifndef OPEN_MAX
+#define        OPEN_MAX                   64   /* max open files per process */
+#endif
+#define        PATH_MAX                 1024   /* max bytes in pathname */
+#define        PIPE_BUF                  512   /* max bytes for atomic pipe writes */
+#define        IOV_MAX                  1024   /* max elements in i/o vector */
+
+#define        BC_BASE_MAX                99   /* max ibase/obase values in bc(1) */
+#define        BC_DIM_MAX               2048   /* max array elements in bc(1) */
+#define        BC_SCALE_MAX               99   /* max scale value in bc(1) */
+#define        BC_STRING_MAX            1000   /* max const string length in bc(1) */
+#define        COLL_WEIGHTS_MAX            0   /* max weights for order keyword */
+#define        EXPR_NEST_MAX              32   /* max expressions nested in expr(1) */
+#define        LINE_MAX                 2048   /* max bytes in an input line */
+#define        RE_DUP_MAX                255   /* max RE's in interval notation */
+
+#endif
diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h
new file mode 100644 (file)
index 0000000..41b8fdc
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _WCHAR_H_
+#define _WCHAR_H_
+
+#define __need_size_t
+#define __need_wchar_t
+#define __need_wint_t
+#include <stddef.h>
+
+/* For _mbstate_t definition. */
+#include <sys/_types.h>
+
+#ifndef WEOF
+# define WEOF (0xffffffffu)
+#endif
+
+#ifndef MBSTATE_T
+#define MBSTATE_T
+typedef _mbstate_t mbstate_t;
+#endif /* MBSTATE_T */
+
+wint_t btowc (int c);
+int wctob (wint_t c);
+int mbsinit(const mbstate_t *ps);
+size_t mbrlen(const char *s, size_t n, mbstate_t *ps);
+size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
+size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps);
+size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps);
+
+#endif /* _WCHAR_H_ */
index 71a400a..7b7098f 100644 (file)
@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = cygnus
 
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
-LIB_SOURCES = locale.c
+LIB_SOURCES = timelocal.h timelocal.c ldpart.h ldpart.c fix_grouping.c locale.c nl_langinfo.c lnumeric.h lnumeric.c lmonetary.h lmonetary.c lmessages.h lmessages.c
 
 liblocale_la_LDFLAGS = -Xcompiler -nostdlib
 
index c640e46..f314b70 100644 (file)
@@ -110,7 +110,7 @@ AUTOMAKE_OPTIONS = cygnus
 
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
-LIB_SOURCES = locale.c
+LIB_SOURCES = timelocal.h timelocal.c ldpart.h ldpart.c fix_grouping.c locale.c nl_langinfo.c lnumeric.h lnumeric.c lmonetary.h lmonetary.c lmessages.h lmessages.c
 
 liblocale_la_LDFLAGS = -Xcompiler -nostdlib
 
@@ -139,11 +139,16 @@ DEFS = @DEFS@ -I. -I$(srcdir)
 CPPFLAGS = @CPPFLAGS@
 LIBS = @LIBS@
 lib_a_LIBADD = 
-@USE_LIBTOOL_FALSE@lib_a_OBJECTS =  locale.$(OBJEXT)
+@USE_LIBTOOL_FALSE@lib_a_OBJECTS =  timelocal.$(OBJEXT) ldpart.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@fix_grouping.$(OBJEXT) locale.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@nl_langinfo.$(OBJEXT) lnumeric.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@lmonetary.$(OBJEXT) lmessages.$(OBJEXT)
 LTLIBRARIES =  $(noinst_LTLIBRARIES)
 
 liblocale_la_LIBADD = 
-@USE_LIBTOOL_TRUE@liblocale_la_OBJECTS =  locale.lo
+@USE_LIBTOOL_TRUE@liblocale_la_OBJECTS =  timelocal.lo ldpart.lo \
+@USE_LIBTOOL_TRUE@fix_grouping.lo locale.lo nl_langinfo.lo lnumeric.lo \
+@USE_LIBTOOL_TRUE@lmonetary.lo lmessages.lo
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
diff --git a/newlib/libc/locale/fix_grouping.c b/newlib/libc/locale/fix_grouping.c
new file mode 100644 (file)
index 0000000..c44fc33
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <ctype.h>
+#include <limits.h>
+#include <stddef.h>
+
+static const char nogrouping[] = { CHAR_MAX, '\0' };
+
+/*
+ * "3;3;-1" -> "\003\003\177"
+ */
+
+const char *
+__fix_locale_grouping_str(const char *str) {
+
+       char *src, *dst;
+       char n;
+
+       if (str == NULL || *str == '\0') {
+               return nogrouping;
+       }
+
+       for (src = (char*)str, dst = (char*)str; *src != '\0'; src++) {
+
+               /* input string examples: "3;3", "3;2;-1" */
+               if (*src == ';')
+                       continue;
+       
+               if (*src == '-' && *(src+1) == '1') {
+                       *dst++ = CHAR_MAX;
+                       src++;
+                       continue;
+               }
+
+               if (!isdigit((unsigned char)*src)) {
+                       /* broken grouping string */
+                       return nogrouping;
+               }
+
+               /* assume all numbers <= 99 */
+               n = *src - '0';
+               if (isdigit((unsigned char)*(src+1))) {
+                       src++;
+                       n *= 10;
+                       n += *src - '0';
+               }
+
+               *dst = n;
+               /* NOTE: assume all input started with "0" as 'no grouping' */
+               if (*dst == '\0')
+                       return (dst == (char*)str) ? nogrouping : str;
+               dst++;
+       }
+       *dst = '\0';
+       return str;
+}
diff --git a/newlib/libc/locale/ldpart.c b/newlib/libc/locale/ldpart.c
new file mode 100644 (file)
index 0000000..1721f7b
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/syslimits.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "setlocale.h"
+#include "ldpart.h"
+
+static int split_lines(char *, const char *);
+static void set_from_buf(const char *, int, const char **);
+
+int
+__part_load_locale(const char *name,
+               int *using_locale,
+               char *locale_buf,
+               const char *category_filename,
+               int locale_buf_size_max,
+               int locale_buf_size_min,
+               const char **dst_localebuf) {
+
+       static char             locale_buf_C[] = "C";
+       static int              num_lines;
+
+       int                      fd;
+       char                    *lbuf;
+       char                    *p;
+       const char              *plim;
+       char                     filename[PATH_MAX];
+       struct stat              st;
+       size_t                   namesize;
+       size_t                   bufsize;
+       int                      save_using_locale;
+        char *nptr;
+
+       save_using_locale = *using_locale;
+       *using_locale = 0;
+
+       if (name == NULL)
+               goto no_locale;
+
+       if (!strcmp(name, "C") || !strcmp(name, "POSIX"))
+               return 0;
+
+       /*
+        * If the locale name is the same as our cache, use the cache.
+        */
+       lbuf = locale_buf;
+       if (lbuf != NULL && strcmp(name, lbuf) == 0) {
+               set_from_buf(lbuf, num_lines, dst_localebuf);
+               *using_locale = 1;
+               return 0;
+       }
+
+       /*
+        * Slurp the locale file into the cache.
+        */
+       namesize = strlen(name) + 1;
+
+       if (!_PathLocale)
+               goto no_locale;
+       /* Range checking not needed, 'name' size is limited */
+       strcpy(filename, _PathLocale);
+       strcat(filename, "/");
+       strcat(filename, name);
+       strcat(filename, "/");
+       strcat(filename, category_filename);
+       fd = open(filename, O_RDONLY);
+       if (fd < 0)
+               goto no_locale;
+       if (fstat(fd, &st) != 0)
+               goto bad_locale;
+       if (st.st_size <= 0)
+               goto bad_locale;
+       bufsize = namesize + st.st_size;
+       locale_buf = NULL;
+
+        if (lbuf == NULL || lbuf == locale_buf_C)
+          {
+            lbuf = malloc(bufsize);
+          }
+        else
+          { 
+            nptr = realloc(lbuf, bufsize);
+            if (!nptr && lbuf)
+              free (lbuf);
+            lbuf = nptr;
+          }
+
+       if (lbuf == NULL)
+               goto bad_locale;
+       (void) strcpy(lbuf, name);
+       p = lbuf + namesize;
+       plim = p + st.st_size;
+       if (read(fd, p, (size_t) st.st_size) != st.st_size)
+               goto bad_lbuf;
+       if (close(fd) != 0)
+               goto bad_lbuf;
+       /*
+        * Parse the locale file into localebuf.
+        */
+       if (plim[-1] != '\n')
+               goto bad_lbuf;
+       num_lines = split_lines(p, plim);
+       if (num_lines >= locale_buf_size_max)
+               num_lines = locale_buf_size_max;
+       else if (num_lines >= locale_buf_size_min)
+               num_lines = locale_buf_size_min;
+       else
+               goto reset_locale;
+       set_from_buf(lbuf, num_lines, dst_localebuf);
+       /*
+        * Record the successful parse in the cache.
+        */
+       locale_buf = lbuf;
+
+       *using_locale = 1;
+       return 0;
+
+reset_locale:
+       locale_buf = locale_buf_C;
+       save_using_locale = 0;
+bad_lbuf:
+       free(lbuf);
+bad_locale:
+       (void)close(fd);
+no_locale:
+       *using_locale = save_using_locale;
+       return -1;
+}
+
+static int
+split_lines(char *p, const char *plim) {
+
+       int i;
+
+       for (i = 0; p < plim; i++) {
+               p = strchr(p, '\n');
+               *p++ = '\0';
+       }
+       return i;
+}
+
+static void
+set_from_buf(const char *p, int num_lines, const char **dst_localebuf) {
+
+       const char **ap;
+       int i;
+
+       for (ap = dst_localebuf, i = 0; i < num_lines; ++ap, ++i)
+               *ap = p += strlen(p) + 1;
+}
+
diff --git a/newlib/libc/locale/ldpart.h b/newlib/libc/locale/ldpart.h
new file mode 100644 (file)
index 0000000..86031fd
--- /dev/null
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/locale/ldpart.h,v 1.4 2001/12/20 18:28:52 phantom Exp $
+ */
+
+#ifndef _LDPART_H_
+#define        _LDPART_H_
+
+int    __part_load_locale(const char *, int*, char *, const char *,
+                   int, int, const char **);
+
+#endif /* !_LDPART_H_ */
diff --git a/newlib/libc/locale/lmessages.c b/newlib/libc/locale/lmessages.c
new file mode 100644 (file)
index 0000000..9a4bb79
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <stddef.h>
+
+#include "lmessages.h"
+#include "ldpart.h"
+
+#define LCMESSAGES_SIZE_FULL (sizeof(struct lc_messages_T) / sizeof(char *))
+#define LCMESSAGES_SIZE_MIN \
+               (offsetof(struct lc_messages_T, yesstr) / sizeof(char *))
+
+static char empty[] = "";
+
+static const struct lc_messages_T _C_messages_locale = {
+       "^[yY]" ,       /* yesexpr */
+       "^[nN]" ,       /* noexpr */
+       "yes" ,         /* yesstr */
+       "no"            /* nostr */
+};
+
+static struct lc_messages_T _messages_locale;
+static int     _messages_using_locale;
+static char    *_messages_locale_buf;
+
+int
+__messages_load_locale(const char *name) {
+
+       /*
+        * Propose that we can have incomplete locale file (w/o "{yes,no}str").
+        * Initialize them before loading.  In case of complete locale, they'll
+        * be initialized to loaded value, otherwise they'll not be touched.
+        */
+       _messages_locale.yesstr = empty;
+       _messages_locale.nostr = empty;
+
+       return __part_load_locale(name, &_messages_using_locale,
+               _messages_locale_buf, "LC_MESSAGES",
+               LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN,
+               (const char **)&_messages_locale);
+}
+
+struct lc_messages_T *
+__get_current_messages_locale(void) {
+
+       return (_messages_using_locale
+               ? &_messages_locale
+               : (struct lc_messages_T *)&_C_messages_locale);
+}
+
+#ifdef LOCALE_DEBUG
+void
+msgdebug() {
+printf(        "yesexpr = %s\n"
+       "noexpr = %s\n"
+       "yesstr = %s\n"
+       "nostr = %s\n",
+       _messages_locale.yesexpr,
+       _messages_locale.noexpr,
+       _messages_locale.yesstr,
+       _messages_locale.nostr
+);
+}
+#endif /* LOCALE_DEBUG */
diff --git a/newlib/libc/locale/lmessages.h b/newlib/libc/locale/lmessages.h
new file mode 100644 (file)
index 0000000..ee690ae
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/locale/lmessages.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
+ */
+
+#ifndef _LMESSAGES_H_
+#define        _LMESSAGES_H_
+
+struct lc_messages_T {
+       const char      *yesexpr;
+       const char      *noexpr;
+       const char      *yesstr;
+       const char      *nostr;
+};
+
+struct lc_messages_T *__get_current_messages_locale(void);
+int    __messages_load_locale(const char *);
+
+#endif /* !_LMESSAGES_H_ */
diff --git a/newlib/libc/locale/lmonetary.c b/newlib/libc/locale/lmonetary.c
new file mode 100644 (file)
index 0000000..d31e88c
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <limits.h>
+#include <stdlib.h>
+#include "lmonetary.h"
+#include "ldpart.h"
+
+extern int __mlocale_changed;
+extern const char * __fix_locale_grouping_str(const char *);
+
+#define LCMONETARY_SIZE (sizeof(struct lc_monetary_T) / sizeof(char *))
+
+static char    empty[] = "";
+static char    numempty[] = { CHAR_MAX, '\0'};
+
+static const struct lc_monetary_T _C_monetary_locale = {
+       empty,          /* int_curr_symbol */
+       empty,          /* currency_symbol */
+       empty,          /* mon_decimal_point */
+       empty,          /* mon_thousands_sep */
+       numempty,       /* mon_grouping */
+       empty,          /* positive_sign */
+       empty,          /* negative_sign */
+       numempty,       /* int_frac_digits */
+       numempty,       /* frac_digits */
+       numempty,       /* p_cs_precedes */
+       numempty,       /* p_sep_by_space */
+       numempty,       /* n_cs_precedes */
+       numempty,       /* n_sep_by_space */
+       numempty,       /* p_sign_posn */
+       numempty        /* n_sign_posn */
+};
+
+static struct lc_monetary_T _monetary_locale;
+static int     _monetary_using_locale;
+static char    *_monetary_locale_buf;
+
+static char
+cnv(const char *str) {
+       int i = strtol(str, NULL, 10);
+       if (i == -1)
+               i = CHAR_MAX;
+       return (char)i;
+}
+
+int
+__monetary_load_locale(const char *name) {
+
+       int ret;
+       __mlocale_changed = 1;
+       ret = __part_load_locale(name, &_monetary_using_locale,
+               _monetary_locale_buf, "LC_MONETARY",
+               LCMONETARY_SIZE, LCMONETARY_SIZE,
+               (const char **)&_monetary_locale);
+       if (ret == 0 && _monetary_using_locale) {
+               _monetary_locale.mon_grouping =
+                    __fix_locale_grouping_str(_monetary_locale.mon_grouping);
+
+#define M_ASSIGN_CHAR(NAME) (((char *)_monetary_locale.NAME)[0] = \
+                            cnv(_monetary_locale.NAME))
+
+               M_ASSIGN_CHAR(int_frac_digits);
+               M_ASSIGN_CHAR(frac_digits);
+               M_ASSIGN_CHAR(p_cs_precedes);
+               M_ASSIGN_CHAR(p_sep_by_space);
+               M_ASSIGN_CHAR(n_cs_precedes);
+               M_ASSIGN_CHAR(n_sep_by_space);
+               M_ASSIGN_CHAR(p_sign_posn);
+               M_ASSIGN_CHAR(n_sign_posn);
+       }
+       return ret;
+}
+
+struct lc_monetary_T *
+__get_current_monetary_locale(void) {
+
+       return (_monetary_using_locale
+               ? &_monetary_locale
+               : (struct lc_monetary_T *)&_C_monetary_locale);
+}
+
+#ifdef LOCALE_DEBUG
+void
+monetdebug() {
+printf(        "int_curr_symbol = %s\n"
+       "currency_symbol = %s\n"
+       "mon_decimal_point = %s\n"
+       "mon_thousands_sep = %s\n"
+       "mon_grouping = %s\n"
+       "positive_sign = %s\n"
+       "negative_sign = %s\n"
+       "int_frac_digits = %d\n"
+       "frac_digits = %d\n"
+       "p_cs_precedes = %d\n"
+       "p_sep_by_space = %d\n"
+       "n_cs_precedes = %d\n"
+       "n_sep_by_space = %d\n"
+       "p_sign_posn = %d\n"
+       "n_sign_posn = %d\n",
+       _monetary_locale.int_curr_symbol,
+       _monetary_locale.currency_symbol,
+       _monetary_locale.mon_decimal_point,
+       _monetary_locale.mon_thousands_sep,
+       _monetary_locale.mon_grouping,
+       _monetary_locale.positive_sign,
+       _monetary_locale.negative_sign,
+       _monetary_locale.int_frac_digits[0],
+       _monetary_locale.frac_digits[0],
+       _monetary_locale.p_cs_precedes[0],
+       _monetary_locale.p_sep_by_space[0],
+       _monetary_locale.n_cs_precedes[0],
+       _monetary_locale.n_sep_by_space[0],
+       _monetary_locale.p_sign_posn[0],
+       _monetary_locale.n_sign_posn[0]
+);
+}
+#endif /* LOCALE_DEBUG */
diff --git a/newlib/libc/locale/lmonetary.h b/newlib/libc/locale/lmonetary.h
new file mode 100644 (file)
index 0000000..bbe77db
--- /dev/null
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/locale/lmonetary.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
+ */
+
+#ifndef _LMONETARY_H_
+#define        _LMONETARY_H_
+
+struct lc_monetary_T {
+       const char      *int_curr_symbol;
+       const char      *currency_symbol;
+       const char      *mon_decimal_point;
+       const char      *mon_thousands_sep;
+       const char      *mon_grouping;
+       const char      *positive_sign;
+       const char      *negative_sign;
+       const char      *int_frac_digits;
+       const char      *frac_digits;
+       const char      *p_cs_precedes;
+       const char      *p_sep_by_space;
+       const char      *n_cs_precedes;
+       const char      *n_sep_by_space;
+       const char      *p_sign_posn;
+       const char      *n_sign_posn;
+};
+
+struct lc_monetary_T *__get_current_monetary_locale(void);
+int    __monetary_load_locale(const char *);
+
+#endif /* !_LMONETARY_H_ */
diff --git a/newlib/libc/locale/lnumeric.c b/newlib/libc/locale/lnumeric.c
new file mode 100644 (file)
index 0000000..90b404c
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <limits.h>
+#include "lnumeric.h"
+#include "ldpart.h"
+
+extern int __nlocale_changed;
+extern const char *__fix_locale_grouping_str(const char *);
+
+#define LCNUMERIC_SIZE (sizeof(struct lc_numeric_T) / sizeof(char *))
+
+static char    numempty[] = { CHAR_MAX, '\0' };
+
+static const struct lc_numeric_T _C_numeric_locale = {
+       ".",            /* decimal_point */
+       "",             /* thousands_sep */
+       numempty        /* grouping */
+};
+
+static struct lc_numeric_T _numeric_locale;
+static int     _numeric_using_locale;
+static char    *_numeric_locale_buf;
+
+int
+__numeric_load_locale(const char *name) {
+
+       int ret;
+
+       __nlocale_changed = 1;
+       ret = __part_load_locale(name, &_numeric_using_locale,
+               _numeric_locale_buf, "LC_NUMERIC",
+               LCNUMERIC_SIZE, LCNUMERIC_SIZE,
+               (const char **)&_numeric_locale);
+       if (ret == 0 && _numeric_using_locale)
+               _numeric_locale.grouping =
+                       __fix_locale_grouping_str(_numeric_locale.grouping);
+       return ret;
+}
+
+struct lc_numeric_T *
+__get_current_numeric_locale(void) {
+
+       return (_numeric_using_locale
+               ? &_numeric_locale
+               : (struct lc_numeric_T *)&_C_numeric_locale);
+}
+
+#ifdef LOCALE_DEBUG
+void
+numericdebug(void) {
+printf(        "decimal_point = %s\n"
+       "thousands_sep = %s\n"
+       "grouping = %s\n",
+       _numeric_locale.decimal_point,
+       _numeric_locale.thousands_sep,
+       _numeric_locale.grouping
+);
+}
+#endif /* LOCALE_DEBUG */
diff --git a/newlib/libc/locale/lnumeric.h b/newlib/libc/locale/lnumeric.h
new file mode 100644 (file)
index 0000000..9678c1f
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/locale/lnumeric.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
+ */
+
+#ifndef _LNUMERIC_H_
+#define        _LNUMERIC_H_
+
+struct lc_numeric_T {
+       const char      *decimal_point;
+       const char      *thousands_sep;
+       const char      *grouping;
+};
+
+struct lc_numeric_T *__get_current_numeric_locale(void);
+int    __numeric_load_locale(const char *);
+
+#endif /* !_LNUMERIC_H_ */
diff --git a/newlib/libc/locale/nl_langinfo.3 b/newlib/libc/locale/nl_langinfo.3
new file mode 100644 (file)
index 0000000..96819e1
--- /dev/null
@@ -0,0 +1,90 @@
+.\" Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/lib/libc/locale/nl_langinfo.3,v 1.4 2002/04/13 04:25:56 dd Exp $
+.\"
+.Dd May 3, 2001
+.Dt NL_LANGINFO 3
+.Os
+.Sh NAME
+.Nm nl_langinfo
+.Nd language information
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In langinfo.h
+.Ft char *
+.Fn nl_langinfo "nl_item item"
+.Sh DESCRIPTION
+The
+.Fn nl_langinfo
+function returns a pointer to a string containing information relevant to
+the particular language or cultural area defined in the program's locale.
+The manifest constant names and values of
+.Fa item
+are defined in
+.Aq Pa langinfo.h .
+.Pp
+Calls to
+.Fn setlocale
+with a category corresponding to the category of
+.Fa item ,
+or to the
+category
+.Dv LC_ALL ,
+may overwrite buffer pointed by the return value.
+.Sh EXAMPLES
+For example:
+.Pp
+.Dl nl_langinfo(ABDAY_1)
+.Pp
+would return a pointer to the string
+.Qq Li Dom
+if the identified language was
+Portuguese, and
+.Qq Li Sun
+if the identified language was English.
+.Sh RETURN VALUES
+In a locale where langinfo data is not defined,
+.Fn nl_langinfo
+returns a pointer to the corresponding string in the
+.Tn POSIX
+locale.
+In all locales,
+.Fn nl_langinfo
+returns a pointer to an empty string if
+.Fa item
+contains an invalid setting.
+.Sh SEE ALSO
+.Xr setlocale 3
+.Sh STANDARDS
+The
+.Fn nl_langinfo
+function conforms to
+.St -susv2 .
+.Sh HISTORY
+The
+.Fn nl_langinfo
+function first appeared in
+.Fx 4.6 .
diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c
new file mode 100644 (file)
index 0000000..e762799
--- /dev/null
@@ -0,0 +1,213 @@
+/*-
+ * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <locale.h>
+#include <langinfo.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "timelocal.h"
+#include "lnumeric.h"
+#include "lmonetary.h"
+#include "lmessages.h"
+
+#define TRANSITION_PERIOD_HACK
+
+#define _REL(BASE) ((int)item-BASE)
+
+char *
+nl_langinfo(nl_item item) {
+
+   char *ret, *s, *cs;
+   static char *csym = NULL;
+#ifdef TRANSITION_PERIOD_HACK
+   static char *cset = NULL;
+#endif /* TRANSITION_PERIOD_HACK */
+   char *nptr;
+
+   switch (item) {
+       case CODESET:
+               ret = "";
+               if ((s = setlocale(LC_CTYPE, NULL)) != NULL) {
+                       if ((cs = strchr(s, '.')) != NULL) {
+                               ret = cs + 1;
+#ifdef TRANSITION_PERIOD_HACK
+                               if (strncmp(ret, "ISO_", 4) == 0) {
+                                       int slen = strlen(ret);
+
+                                        nptr = realloc(cset, slen);
+
+                                        if (!nptr && cset)
+                                          free (cset);
+
+                                        cset = nptr;
+                                       if (cset != NULL) {
+                                               strcpy(cset, "ISO");
+                                               strcat(cset, ret + 4);
+                                               ret = cset;
+                                       } else
+                                               ret = "";
+                               } else if (strcmp(ret, "EUC") == 0) {
+                                       if (strncmp(s, "ja_JP", 5) == 0)
+                                               ret = "eucJP";
+                                       else if (strncmp(s, "ko_KR", 5) == 0)
+                                               ret = "eucKR";
+                                       else if (strncmp(s, "zh_CN", 5) == 0)
+                                               ret = "eucCN";
+                               } else if (strcmp(ret, "ASCII") == 0)
+                                       ret = "US-ASCII";
+#endif /* TRANSITION_PERIOD_HACK */
+                       } else if (strcmp(s, "C") == 0 ||
+                                  strcmp(s, "POSIX") == 0
+#ifdef TRANSITION_PERIOD_HACK
+                                  || strstr(s, "ASCII") != NULL
+#endif /* TRANSITION_PERIOD_HACK */
+                                 )
+                               ret = "US-ASCII";
+               }
+               break;
+       case D_T_FMT:
+               ret = (char *) __get_current_time_locale()->c_fmt;
+               break;
+       case D_FMT:
+               ret = (char *) __get_current_time_locale()->x_fmt;
+               break;
+       case T_FMT:
+               ret = (char *) __get_current_time_locale()->X_fmt;
+               break;
+       case T_FMT_AMPM:
+               ret = (char *) __get_current_time_locale()->ampm_fmt;
+               break;
+       case AM_STR:
+               ret = (char *) __get_current_time_locale()->am;
+               break;
+       case PM_STR:
+               ret = (char *) __get_current_time_locale()->pm;
+               break;
+       case DAY_1: case DAY_2: case DAY_3:
+       case DAY_4: case DAY_5: case DAY_6: case DAY_7:
+               ret = (char*) __get_current_time_locale()->weekday[_REL(DAY_1)];
+               break;
+       case ABDAY_1: case ABDAY_2: case ABDAY_3:
+       case ABDAY_4: case ABDAY_5: case ABDAY_6: case ABDAY_7:
+               ret = (char*) __get_current_time_locale()->wday[_REL(ABDAY_1)];
+               break;
+       case MON_1: case MON_2: case MON_3: case MON_4:
+       case MON_5: case MON_6: case MON_7: case MON_8:
+       case MON_9: case MON_10: case MON_11: case MON_12:
+               ret = (char*) __get_current_time_locale()->month[_REL(MON_1)];
+               break;
+       case ABMON_1: case ABMON_2: case ABMON_3: case ABMON_4:
+       case ABMON_5: case ABMON_6: case ABMON_7: case ABMON_8:
+       case ABMON_9: case ABMON_10: case ABMON_11: case ABMON_12:
+               ret = (char*) __get_current_time_locale()->mon[_REL(ABMON_1)];
+               break;
+       case ERA:
+               /* XXX: need to be implemented  */
+               ret = "";
+               break;
+       case ERA_D_FMT:
+               /* XXX: need to be implemented  */
+               ret = "";
+               break;
+       case ERA_D_T_FMT:
+               /* XXX: need to be implemented  */
+               ret = "";
+               break;
+       case ERA_T_FMT:
+               /* XXX: need to be implemented  */
+               ret = "";
+               break;
+       case ALT_DIGITS:
+               /* XXX: need to be implemented  */
+               ret = "";
+               break;
+       case RADIXCHAR:
+               ret = (char*) __get_current_numeric_locale()->decimal_point;
+               break;
+       case THOUSEP:
+               ret = (char*) __get_current_numeric_locale()->thousands_sep;
+               break;
+       case YESEXPR:
+               ret = (char*) __get_current_messages_locale()->yesexpr;
+               break;
+       case NOEXPR:
+               ret = (char*) __get_current_messages_locale()->noexpr;
+               break;
+       /*
+        * All items marked with LEGACY are available, but not recomended
+        * by SUSv2 to be used in portable applications since they're subject
+        * to remove in future specification editions
+        */
+       case YESSTR:            /* LEGACY  */
+               ret = (char*) __get_current_messages_locale()->yesstr;
+               break;
+       case NOSTR:             /* LEGACY  */
+               ret = (char*) __get_current_messages_locale()->nostr;
+               break;
+       case CRNCYSTR:
+               ret = "";
+               cs = (char*) __get_current_monetary_locale()->currency_symbol;
+               if (*cs != '\0') {
+                       char pos = localeconv()->p_cs_precedes;
+
+                       if (pos == localeconv()->n_cs_precedes) {
+                               char psn = '\0';
+
+                               if (pos == CHAR_MAX) {
+                                       if (strcmp(cs, __get_current_monetary_locale()->mon_decimal_point) == 0)
+                                               psn = '.';
+                               } else
+                                       psn = pos ? '-' : '+';
+                               if (psn != '\0') {
+                                       int clen = strlen(cs);
+
+                                        nptr = realloc(csym, clen + 2);
+                                        if (!nptr && csym)
+                                          free (csym);
+
+                                        csym = nptr;
+
+                                       if (csym != NULL) {
+                                               *csym = psn;
+                                               strcpy(csym + 1, cs);
+                                               ret = csym;
+                                       }
+                               }
+                       }
+               }
+               break;
+       case D_MD_ORDER:        /* local extension */
+               ret = (char *) __get_current_time_locale()->md_order;
+               break;
+       default:
+               ret = "";
+   }
+   return (ret);
+}
diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocale.h
new file mode 100644 (file)
index 0000000..3eb7698
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (C) 1997 by Andrey A. Chernov, Moscow, Russia.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/locale/setlocale.h,v 1.4 2001/12/20 18:28:52 phantom Exp $
+ */
+
+#ifndef _SETLOCALE_H_
+#define        _SETLOCALE_H_
+
+#define ENCODING_LEN 31
+#define CATEGORY_LEN 11
+
+extern char *_PathLocale;
+
+#endif /* !_SETLOCALE_H_ */
diff --git a/newlib/libc/locale/timelocal.c b/newlib/libc/locale/timelocal.c
new file mode 100644 (file)
index 0000000..5b097ad
--- /dev/null
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
+ * Copyright (c) 1997 FreeBSD Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <stddef.h>
+
+#include "ldpart.h"
+#include "timelocal.h"
+
+static struct lc_time_T _time_locale;
+static int _time_using_locale;
+static char *time_locale_buf;
+
+#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
+
+static const struct lc_time_T  _C_time_locale = {
+       {
+               "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+       }, {
+               "January", "February", "March", "April", "May", "June",
+               "July", "August", "September", "October", "November", "December"
+       }, {
+               "Sun", "Mon", "Tue", "Wed",
+               "Thu", "Fri", "Sat"
+       }, {
+               "Sunday", "Monday", "Tuesday", "Wednesday",
+               "Thursday", "Friday", "Saturday"
+       },
+
+       /* X_fmt */
+       "%H:%M:%S",
+
+       /*
+        * x_fmt
+        * Since the C language standard calls for
+        * "date, using locale's date format," anything goes.
+        * Using just numbers (as here) makes Quakers happier;
+        * it's also compatible with SVR4.
+        */
+       "%m/%d/%y",
+
+       /*
+        * c_fmt
+        */
+       "%a %b %e %H:%M:%S %Y",
+
+       /* am */
+       "AM",
+
+       /* pm */
+       "PM",
+
+       /* date_fmt */
+       "%a %b %e %H:%M:%S %Z %Y",
+       
+       /* alt_month
+        * Standalone months forms for %OB
+        */
+       {
+               "January", "February", "March", "April", "May", "June",
+               "July", "August", "September", "October", "November", "December"
+       },
+
+       /* md_order
+        * Month / day order in dates
+        */
+       "md",
+
+       /* ampm_fmt
+        * To determine 12-hour clock format time (empty, if N/A)
+        */
+       "%I:%M:%S %p"
+};
+
+struct lc_time_T *
+__get_current_time_locale(void) {
+       return (_time_using_locale
+               ? &_time_locale
+               : (struct lc_time_T *)&_C_time_locale);
+}
+
+int
+__time_load_locale(const char *name) {
+
+       int     ret;
+
+       ret = __part_load_locale(name, &_time_using_locale,
+                       time_locale_buf, "LC_TIME",
+                       LCTIME_SIZE, LCTIME_SIZE,
+                       (const char **)&_time_locale);
+
+       return (ret);
+}
diff --git a/newlib/libc/locale/timelocal.h b/newlib/libc/locale/timelocal.h
new file mode 100644 (file)
index 0000000..0b0a59a
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1997-2002 FreeBSD Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD: src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $
+ */
+
+#ifndef _TIMELOCAL_H_
+#define        _TIMELOCAL_H_
+
+/*
+ * Private header file for the strftime and strptime localization
+ * stuff.
+ */
+struct lc_time_T {
+       const char      *mon[12];
+       const char      *month[12];
+       const char      *wday[7];
+       const char      *weekday[7];
+       const char      *X_fmt;
+       const char      *x_fmt;
+       const char      *c_fmt;
+       const char      *am;
+       const char      *pm;
+       const char      *date_fmt;
+       const char      *alt_month[12];
+       const char      *md_order;
+       const char      *ampm_fmt;
+};
+
+struct lc_time_T *__get_current_time_locale(void);
+int    __time_load_locale(const char *);
+
+#endif /* !_TIMELOCAL_H_ */
index 8204617..ff3a4f6 100644 (file)
@@ -166,6 +166,7 @@ static char *rcsid = "$Id$";
 #include <stdlib.h>
 #include <string.h>
 #include <reent.h>
+#include <wchar.h>
 #include <string.h>
 #ifdef __ALTIVEC__
 #include <altivec.h>
@@ -388,7 +389,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
        int vec_print_count;    /* number of vector chunks remaining */
        vec_16_byte_union vec_tmp;
 #endif /* __ALTIVEC__ */ 
-        int state;              /* mbtowc calls from library must not change state */
+        mbstate_t state;          /* mbtowc calls from library must not change state */
 
        /*
         * Choose PADSIZE to trade efficiency vs. size.  If larger printf
index 323a438..f4481ef 100644 (file)
@@ -107,6 +107,7 @@ Supporting OS subroutines required:
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <wchar.h>
 #include <string.h>
 #ifdef _HAVE_STDC
 #include <stdarg.h>
@@ -278,7 +279,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
   vec_union vec_buf;
   char *lptr;                   /* literal pointer */
 #ifdef MB_CAPABLE
-  int state;                    /* value to keep track of multibyte state */
+  mbstate_t state;                /* value to keep track of multibyte state */
 #endif
 
   char *ch_dest;
index d6dc919..5fe7080 100644 (file)
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
index 8ec9d40..64f60ee 100644 (file)
@@ -109,21 +109,24 @@ __getdelim (bufptr, n, delim, fp)
             }
         }
 
-      /* Buffer is too small so reallocate a larger buffer.  */
-      pos = ptr - buf;
-      newsize = (*n << 1);
-      buf = realloc (buf, newsize);
-      if (buf == NULL)
+      if (cont)
         {
-          cont = 0;
-          break;
-        }
+          /* Buffer is too small so reallocate a larger buffer.  */
+          pos = ptr - buf;
+          newsize = (*n << 1);
+          buf = realloc (buf, newsize);
+          if (buf == NULL)
+            {
+              cont = 0;
+              break;
+            }
 
-      /* After reallocating, continue in new buffer */          
-      *bufptr = buf;
-      *n = newsize;
-      ptr = buf + pos;
-      numbytes = newsize - pos;
+          /* After reallocating, continue in new buffer */          
+          *bufptr = buf;
+          *n = newsize;
+          ptr = buf + pos;
+          numbytes = newsize - pos;
+        }
     }
 
   _funlockfile (fp);
index 8e1efd7..3fa2349 100644 (file)
@@ -184,6 +184,8 @@ static char *rcsid = "$Id$";
 #include <stdlib.h>
 #include <string.h>
 #include <reent.h>
+#include <wchar.h>
+#include <string.h>
 
 #ifdef _HAVE_STDC
 #include <stdarg.h>
@@ -426,7 +428,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
        struct __siov iov[NIOV];/* ... and individual io vectors */
        char buf[BUF];          /* space for %c, %[diouxX], %[eEfgG] */
        char ox[2];             /* space for 0x hex-prefix */
-        int state = 0;          /* mbtowc calls from library must not change state */
+        mbstate_t state;          /* mbtowc calls from library must not change state */
 
        /*
         * Choose PADSIZE to trade efficiency vs. size.  If larger printf
@@ -439,6 +441,7 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap),
        static _CONST char zeroes[PADSIZE] =
         {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
 
+        memset (&state, '\0', sizeof (state));
        /*
         * BEWARE, these `goto error' on error, and PAD uses `n'.
         */
@@ -1367,7 +1370,7 @@ get_arg (int n, char *fmt, va_list *ap, int *numargs_p, union arg_val *args,
   STATE state, next_state;
   ACTION action;
   int pos, last_arg;
-  int wc_state = 0;
+  mbstate_t wc_state;
   int max_pos_arg = n;
   enum types { INT, LONG_INT, SHORT_INT, QUAD_INT, CHAR, CHAR_PTR, DOUBLE, LONG_DOUBLE };
   
@@ -1375,6 +1378,8 @@ get_arg (int n, char *fmt, va_list *ap, int *numargs_p, union arg_val *args,
   if (*last_fmt != NULL)
     fmt = *last_fmt;
 
+  memset (&wc_state, '\0', sizeof (wc_state));
+
   /* we need to process either to end of fmt string or until we have actually
      read the desired parameter from the vararg list. */
   while (*fmt && n >= numargs)
index f6c3c93..61a901e 100644 (file)
@@ -107,6 +107,8 @@ Supporting OS subroutines required:
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <wchar.h>
+#include <string.h>
 #ifdef _HAVE_STDC
 #include <stdarg.h>
 #else
@@ -257,7 +259,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
   char buf[BUF];               /* buffer for numeric conversions */
   char *lptr;                   /* literal pointer */
 #ifdef MB_CAPABLE
-  int state = 0;                /* value to keep track of multibyte state */
+  mbstate_t state;                /* value to keep track of multibyte state */
 #endif
 
   short *sp;
@@ -283,6 +285,7 @@ __svfscanf_r (rptr, fp, fmt0, ap)
 #ifndef MB_CAPABLE
       wc = *fmt;
 #else
+      memset (&state, '\0', sizeof (state));
       nbytes = _mbtowc_r (rptr, &wc, fmt, MB_CUR_MAX, &state);
 #endif
       fmt += nbytes;
index 78c72c1..d403afa 100644 (file)
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
index 13608ea..baf3de9 100644 (file)
@@ -79,7 +79,15 @@ LIB_SOURCES = \
        wcstombs.c      \
        wcstombs_r.c    \
        wctomb.c        \
-       wctomb_r.c
+       wctomb_r.c      \
+       btowc.c         \
+       mbrlen.c        \
+       mbrtowc.c       \
+       mbsinit.c       \
+       mbsrtowcs.c     \
+       wcrtomb.c       \
+       wcsrtombs.c     \
+       wctob.c
 
 # Because of how libtool moves objects around, mallocr must be built last.
 LIBADD_OBJS = freer.$(oext) reallocr.$(oext) callocr.$(oext) cfreer.$(oext) malignr.$(oext) \
index 98b64b8..6f7cd98 100644 (file)
@@ -185,7 +185,15 @@ LIB_SOURCES = \
        wcstombs.c      \
        wcstombs_r.c    \
        wctomb.c        \
-       wctomb_r.c
+       wctomb_r.c      \
+       btowc.c         \
+       mbrlen.c        \
+       mbrtowc.c       \
+       mbsinit.c       \
+       mbsrtowcs.c     \
+       wcrtomb.c       \
+       wcsrtombs.c     \
+       wctob.c
 
 
 # Because of how libtool moves objects around, mallocr must be built last.
@@ -294,7 +302,10 @@ LIBS = @LIBS@
 @USE_LIBTOOL_FALSE@strtoull_r.$(OBJEXT) system.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@valloc.$(OBJEXT) wcstombs.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@wcstombs_r.$(OBJEXT) wctomb.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT)
+@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT) btowc.$(OBJEXT) mbrlen.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@mbrtowc.$(OBJEXT) mbsinit.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@mbsrtowcs.$(OBJEXT) wcrtomb.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@wcsrtombs.$(OBJEXT) wctob.$(OBJEXT)
 LTLIBRARIES =  $(noinst_LTLIBRARIES)
 
 @USE_LIBTOOL_TRUE@libstdlib_la_DEPENDENCIES =  freer.$(oext) \
@@ -318,7 +329,8 @@ LTLIBRARIES =  $(noinst_LTLIBRARIES)
 @USE_LIBTOOL_TRUE@strtod.lo strtol.lo strtoll.lo strtoll_r.lo \
 @USE_LIBTOOL_TRUE@strtoul.lo strtoull.lo strtoull_r.lo system.lo \
 @USE_LIBTOOL_TRUE@valloc.lo wcstombs.lo wcstombs_r.lo wctomb.lo \
-@USE_LIBTOOL_TRUE@wctomb_r.lo
+@USE_LIBTOOL_TRUE@wctomb_r.lo btowc.lo mbrlen.lo mbrtowc.lo mbsinit.lo \
+@USE_LIBTOOL_TRUE@mbsrtowcs.lo wcrtomb.lo wcsrtombs.lo wctob.lo
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
diff --git a/newlib/libc/stdlib/btowc.c b/newlib/libc/stdlib/btowc.c
new file mode 100644 (file)
index 0000000..a1ea920
--- /dev/null
@@ -0,0 +1,27 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+
+wint_t
+btowc (int c)
+{
+  mbstate_t mbs;
+  int retval = 0;
+  wchar_t pwc;
+  unsigned char b;
+
+  b = (unsigned char)c;
+
+  /* Put mbs in initial state. */
+  memset (&mbs, '\0', sizeof (mbs));
+
+  _REENT_CHECK_MISC(_REENT);
+
+  retval = _mbtowc_r (_REENT, &pwc, &b, 1, &mbs);
+
+  if (c == EOF || retval != 1)
+    return WEOF;
+  else
+    return (wint_t)pwc;
+}
index c85a6a7..a0ed29a 100644 (file)
@@ -44,6 +44,7 @@ effects vary with the locale.
 #ifndef _REENT_ONLY
 
 #include <stdlib.h>
+#include <wchar.h>
 
 int
 _DEFUN (mblen, (s, n), 
@@ -51,9 +52,15 @@ _DEFUN (mblen, (s, n),
         size_t n)
 {
 #ifdef MB_CAPABLE
+        int retval = 0;
         _REENT_CHECK_MISC(_REENT);
 
-        return _mbtowc_r (_REENT, NULL, s, n, &(_REENT_MBLEN_STATE(_REENT)));
+        retval = _mbtowc_r (_REENT, NULL, s, n, &(_REENT_MBLEN_STATE(_REENT)));
+        if (retval < 0)
+          return -1;
+        else
+          return retval;
+
 #else /* not MB_CAPABLE */
         if (s == NULL || *s == '\0')
                 return 0;
index 22d1d40..cff7395 100644 (file)
@@ -44,13 +44,14 @@ effects vary with the locale.
 */
 
 #include <stdlib.h>
+#include <wchar.h>
 
 int
 _DEFUN (_mblen_r, (r, s, n, state), 
         struct _reent *r    _AND
         const char *s _AND
         size_t n _AND
-        int *state)
+        mbstate_t *state)
 {
 #ifdef MB_CAPABLE
 
diff --git a/newlib/libc/stdlib/mbrlen.c b/newlib/libc/stdlib/mbrlen.c
new file mode 100644 (file)
index 0000000..8f0c648
--- /dev/null
@@ -0,0 +1,13 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+size_t
+mbrlen(const char *s, size_t n, mbstate_t *ps)
+{
+  mbstate_t internal;
+
+  return mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);
+}
diff --git a/newlib/libc/stdlib/mbrtowc.c b/newlib/libc/stdlib/mbrtowc.c
new file mode 100644 (file)
index 0000000..7934ca1
--- /dev/null
@@ -0,0 +1,29 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+#include <string.h>
+
+size_t
+mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+  int retval = 0;
+  _REENT_CHECK_MISC(_REENT);
+
+  if (s == NULL)
+    retval = _mbtowc_r (_REENT, pwc, "", 1, ps);
+  else
+    retval = _mbtowc_r (_REENT, pwc, s, n, ps);
+
+  if (*pwc == NULL)
+    memset (ps, '\0', sizeof (mbstate_t));
+
+  if (retval == -1)
+    {
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+}
diff --git a/newlib/libc/stdlib/mbsinit.c b/newlib/libc/stdlib/mbsinit.c
new file mode 100644 (file)
index 0000000..a353cb1
--- /dev/null
@@ -0,0 +1,14 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+int
+mbsinit(const mbstate_t *ps)
+{
+  if (ps == NULL || ps->__count == 0)
+    return 1;
+  else
+    return 0;
+}
diff --git a/newlib/libc/stdlib/mbsrtowcs.c b/newlib/libc/stdlib/mbsrtowcs.c
new file mode 100644 (file)
index 0000000..256ab0d
--- /dev/null
@@ -0,0 +1,24 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+size_t
+mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps)
+{
+  int retval = 0;
+  mbstate_t internal;
+
+  _REENT_CHECK_MISC(_REENT);
+
+  retval = _mbstowcs_r (_REENT, dst, *src, len, ps != NULL ? ps : &internal);
+
+  if (retval == -1)
+    {
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+}
index fee621a..eb0ccd7 100644 (file)
@@ -50,6 +50,7 @@ effects vary with the locale.
 #ifndef _REENT_ONLY
 
 #include <stdlib.h>
+#include <wchar.h>
 
 size_t
 _DEFUN (mbstowcs, (pwcs, s, n),
@@ -58,7 +59,8 @@ _DEFUN (mbstowcs, (pwcs, s, n),
         size_t n)
 {
 #ifdef MB_CAPABLE
-        int state = 0;
+        mbstate_t state;
+        state.__count = 0;
 
         return _mbstowcs_r (_REENT, pwcs, s, n, &state);
 #else /* not MB_CAPABLE */
index 5478849..89cda03 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <wchar.h>
 
 size_t
 _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
@@ -6,7 +7,7 @@ _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
         wchar_t       *pwcs _AND
         const char    *s    _AND
         size_t         n    _AND
-        int           *state)
+        mbstate_t     *state)
 {
   wchar_t *ptr = pwcs;
   size_t max = n;
@@ -16,7 +17,7 @@ _DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
   while (n > 0)
     {
       bytes = _mbtowc_r (r, ptr, t, MB_CUR_MAX, state);
-      if (bytes == -1)
+      if (bytes < 0)
         return -1;
       else if (bytes == 0)
         return ptr - pwcs;
index 0d16f0d..6da735a 100644 (file)
@@ -60,9 +60,15 @@ _DEFUN (mbtowc, (pwc, s, n),
         size_t n)
 {
 #ifdef MB_CAPABLE
+        int retval = 0;
         _REENT_CHECK_MISC(_REENT);
 
-        return _mbtowc_r (_REENT, pwc, s, n, &(_REENT_MBTOWC_STATE(_REENT)));
+        retval = _mbtowc_r (_REENT, pwc, s, n, &(_REENT_MBTOWC_STATE(_REENT)));
+
+        if (retval < 0)
+          return -1;
+        else
+          return retval;
 #else /* not MB_CAPABLE */
         if (s == NULL)
                 return 0;
index 866789f..b7909d3 100644 (file)
@@ -1,6 +1,8 @@
 #include <stdlib.h>
 #include <locale.h>
 #include "mbctype.h"
+#include <wchar.h>
+#include <string.h>
 
 #ifdef MB_CAPABLE
 typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J, 
@@ -51,7 +53,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
         wchar_t       *pwc _AND 
         const char    *s   _AND        
         size_t         n   _AND
-        int           *state)
+        mbstate_t      *state)
 {
   wchar_t dummy;
   unsigned char *t = (unsigned char *)s;
@@ -60,13 +62,13 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
     pwc = &dummy;
 
   if (s != NULL && n == 0)
-    return -1;
+    return -2;
 
 #ifdef MB_CAPABLE
   if (r->_current_locale == NULL ||
       (strlen (r->_current_locale) <= 1))
     { /* fall-through */ }
-  else if (!strcmp (r->_current_locale, "UTF-8"))
+  else if (!strcmp (r->_current_locale, "C-UTF-8"))
     {
       wchar_t char1 = 0;
 
@@ -139,7 +141,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
                 return 3;
             }
           else
-            return -1;
+            return -2;
         }
       else if (char1 >= 0xf0 && char1 <= 0xf7)
         {
@@ -172,7 +174,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
               return 4;
             }
           else
-            return -1;
+            return -2;
         }
       else if (char1 >= 0xf8 && char1 <= 0xfb)
         {
@@ -208,7 +210,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
               return 5;
             }
           else
-            return -1;
+            return -2;
         }
       else if (char1 >= 0xfc && char1 <= 0xfd)
         {
@@ -248,7 +250,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
               return 6;
             }
           else
-            return -1;
+            return -2;
         }
       else
         return -1;
@@ -263,7 +265,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
         {
           int char2 = t[1];
           if (n <= 1)
-            return -1;
+            return -2;
           if (_issjis2 (char2))
             {
               *pwc = (((wchar_t)*t) << 8) + (wchar_t)(*(t+1));
@@ -283,7 +285,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
         {
           int char2 = t[1];     
           if (n <= 1)
-            return -1;
+            return -2;
           if (_iseucjp (char2))
             {
               *pwc = (((wchar_t)*t) << 8) + (wchar_t)(*(t+1));
@@ -303,11 +305,11 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
  
       if (s == NULL)
         {
-          *state = 0;
+          state->__count = 0;
           return 1;  /* state-dependent */
         }
 
-      curr_state = (*state == 0 ? ASCII : JIS);
+      curr_state = (state->__count == 0 ? ASCII : JIS);
       ptr = t;
 
       for (i = 0; i < n; ++i)
@@ -351,19 +353,19 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
             case NOOP:
               break;
             case EMPTY:
-              *state = 0;
+              state->__count = 0;
               *pwc = (wchar_t)0;
               return i;
             case COPY_A:
-             *state = 0;
+             state->__count = 0;
               *pwc = (wchar_t)*ptr;
               return (i + 1);
             case COPY_J:
-              *state = 0;
+              state->__count = 0;
               *pwc = (((wchar_t)*ptr) << 8) + (wchar_t)(*(ptr+1));
               return (i + 1);
             case COPY_J2:
-              *state = 1;
+              state->__count = 1;
               *pwc = (((wchar_t)*ptr) << 8) + (wchar_t)(*(ptr+1));
               return (ptr - t) + 2;
             case MAKE_A:
@@ -377,7 +379,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
 
         }
 
-      return -1;  /* n < bytes needed */
+      return -2;  /* n < bytes needed */
     }
 #endif /* MB_CAPABLE */               
 
@@ -392,4 +394,3 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
 
   return 1;
 }
-
diff --git a/newlib/libc/stdlib/wcrtomb.c b/newlib/libc/stdlib/wcrtomb.c
new file mode 100644 (file)
index 0000000..f68533c
--- /dev/null
@@ -0,0 +1,25 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+size_t
+wcrtomb(char *s, wchar_t wc, mbstate_t *ps)
+{
+  int retval = 0;
+  _REENT_CHECK_MISC(_REENT);
+
+  if (s == NULL)
+    retval = _wctomb_r (_REENT, "", wc, ps);
+  else
+    retval = _wctomb_r (_REENT, s, wc, ps);
+
+  if (retval == -1)
+    {
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+}
diff --git a/newlib/libc/stdlib/wcsrtombs.c b/newlib/libc/stdlib/wcsrtombs.c
new file mode 100644 (file)
index 0000000..22512c0
--- /dev/null
@@ -0,0 +1,22 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+#include <errno.h>
+
+size_t
+wcsrtombs (char *dst, const wchar_t **src, size_t len, mbstate_t *ps)
+{
+  int retval = 0;
+  _REENT_CHECK_MISC(_REENT);
+
+  retval = _wcstombs_r (_REENT, dst, *src, len, ps);
+
+  if (retval == -1)
+    {
+      _REENT->_errno = EILSEQ;
+      return (size_t)(-1);
+    }
+  else
+    return (size_t)retval;
+}
index ca99f2e..c984746 100644 (file)
@@ -51,6 +51,7 @@ effects vary with the locale.
 #ifndef _REENT_ONLY
 
 #include <stdlib.h>
+#include <wchar.h>
 
 size_t
 _DEFUN (wcstombs, (s, pwcs, n),
@@ -59,7 +60,8 @@ _DEFUN (wcstombs, (s, pwcs, n),
         size_t         n)
 {
 #ifdef MB_CAPABLE
-        int state = 0;
+        mbstate_t state;
+        state.__count = 0;
 
         return _wcstombs_r (_REENT, s, pwcs, n, &state);
 #else /* not MB_CAPABLE */
index 69c82d4..70f680a 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <wchar.h>
 
 size_t
 _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
@@ -6,7 +7,7 @@ _DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
         char          *s    _AND
         const wchar_t *pwcs _AND
         size_t         n    _AND
-        int           *state)
+        mbstate_t     *state)
 {
   char *ptr = s;
   size_t max = n;
diff --git a/newlib/libc/stdlib/wctob.c b/newlib/libc/stdlib/wctob.c
new file mode 100644 (file)
index 0000000..4288c54
--- /dev/null
@@ -0,0 +1,25 @@
+#include <wchar.h>
+#include <wchar.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <reent.h>
+
+int
+wctob (wint_t c)
+{
+  mbstate_t mbs;
+  int retval = 0;
+  unsigned char pwc;
+
+  /* Put mbs in initial state. */
+  memset (&mbs, '\0', sizeof (mbs));
+
+  _REENT_CHECK_MISC(_REENT);
+
+  retval = _wctomb_r (_REENT, &pwc, c, &mbs);
+
+  if (c == EOF || retval != 1)
+    return WEOF;
+  else
+    return (int)pwc;
+}
index 991e0a6..7cd84b6 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
+#include <wchar.h>
 #include <locale.h>
 #include "mbctype.h"
 
@@ -8,11 +9,11 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
         struct _reent *r     _AND 
         char          *s     _AND
         wchar_t        wchar _AND
-        int           *state)
+        mbstate_t     *state)
 {
   if (strlen (r->_current_locale) <= 1)
     { /* fall-through */ }
-  else if (!strcmp (r->_current_locale, "UTF-8"))
+  else if (!strcmp (r->_current_locale, "C-UTF-8"))
     {
       if (s == NULL)
         return 0; /* UTF-8 encoding is not state-dependent */
@@ -125,10 +126,10 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
         /* first byte is non-zero..validate multi-byte char */
           if (_isjis (char1) && _isjis (char2)) 
             {
-              if (*state == 0)
+              if (state->__count == 0)
                 {
                   /* must switch from ASCII to JIS state */
-                  *state = 1;
+                  state->__count = 1;
                   *s++ = ESC_CHAR;
                   *s++ = '$';
                   *s++ = 'B';
@@ -143,10 +144,10 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
         }
       else
         {
-          if (*state != 0)
+          if (state->__count != 0)
             {
               /* must switch from JIS to ASCII state */
-              *state = 0;
+              state->__count = 0;
               *s++ = ESC_CHAR;
               *s++ = '(';
               *s++ = 'B';
index 7e967f0..55845d4 100644 (file)
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = cygnus
 
-INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) $(INCLTDL)
 
 SUBDIRS = machine \
        cmath \
@@ -76,6 +76,8 @@ LIB_SOURCES = \
        pread.c \
        pread64.c \
        process.c \
+       prof-freq.c \
+       profile.c \
        psignal.c \
        pvallocr.c \
        pwrite.c \
@@ -165,8 +167,19 @@ lib.a:  $(ADD_OBJS) $(lib_a_OBJECTS)
 
 endif # USE_LIBTOOL
 
-
-include $(srcdir)/../../../Makefile.shared
+objectlist.awk.in: $(noinst_LTLIBRARIES) $(SUBLIBS)
+       -rm -f objectlist.awk.in
+       for i in `ls *.lo` ; \
+         do \
+           echo $$i `pwd`/$$i >> objectlist.awk.in ; \
+       done
+       for j in $(SUBLIBS) ; \
+         do \
+           export i=`echo $$j | sed -e 's,\(.*\)\/[^\/]*$$,\1,'`; \
+           if test $$i != "." && test -f $$i/objectlist.awk.in; then \
+               cat $$i/objectlist.awk.in >> objectlist.awk.in ; \
+           fi; \
+       done
 
 all: crt0.o crt1.o
 
index 701cf27..33eb704 100644 (file)
@@ -11,7 +11,6 @@
 # PARTICULAR PURPOSE.
 
 
-
 SHELL = @SHELL@
 
 srcdir = @srcdir@
@@ -97,7 +96,7 @@ sys_dir = @sys_dir@
 
 AUTOMAKE_OPTIONS = cygnus
 
-INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+INCLUDES = -I$(srcdir)/include $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) $(INCLTDL)
 
 SUBDIRS = machine \
        cmath \
@@ -173,6 +172,8 @@ LIB_SOURCES = \
        pread.c \
        pread64.c \
        process.c \
+       prof-freq.c \
+       profile.c \
        psignal.c \
        pvallocr.c \
        pwrite.c \
@@ -287,6 +288,7 @@ LIBS = @LIBS@
 @USE_LIBTOOL_FALSE@mstats.$(OBJEXT) mtrim.$(OBJEXT) mtrimr.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@ntp_gettime.$(OBJEXT) pathconf.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@pread.$(OBJEXT) pread64.$(OBJEXT) process.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@prof-freq.$(OBJEXT) profile.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@psignal.$(OBJEXT) pvallocr.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@pwrite.$(OBJEXT) pwrite64.$(OBJEXT) raise.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@readdir64.$(OBJEXT) realloc.$(OBJEXT) \
@@ -325,10 +327,10 @@ LTLIBRARIES =  $(noinst_LTLIBRARIES)
 @USE_LIBTOOL_TRUE@mq_open.lo mq_receive.lo mq_send.lo mq_setattr.lo \
 @USE_LIBTOOL_TRUE@mq_unlink.lo msize.lo msizer.lo mstats.lo mtrim.lo \
 @USE_LIBTOOL_TRUE@mtrimr.lo ntp_gettime.lo pathconf.lo pread.lo \
-@USE_LIBTOOL_TRUE@pread64.lo process.lo psignal.lo pvallocr.lo \
-@USE_LIBTOOL_TRUE@pwrite.lo pwrite64.lo raise.lo readdir64.lo \
-@USE_LIBTOOL_TRUE@realloc.lo reallocr.lo realpath.lo rename.lo \
-@USE_LIBTOOL_TRUE@resource.lo scandir64.lo sched.lo select.lo \
+@USE_LIBTOOL_TRUE@pread64.lo process.lo prof-freq.lo profile.lo \
+@USE_LIBTOOL_TRUE@psignal.lo pvallocr.lo pwrite.lo pwrite64.lo raise.lo \
+@USE_LIBTOOL_TRUE@readdir64.lo realloc.lo reallocr.lo realpath.lo \
+@USE_LIBTOOL_TRUE@rename.lo resource.lo scandir64.lo sched.lo select.lo \
 @USE_LIBTOOL_TRUE@seteuid.lo sethostname.lo setrlimit64.lo shm_open.lo \
 @USE_LIBTOOL_TRUE@shm_unlink.lo sig.lo sigaction.lo sigqueue.lo \
 @USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo sigset.lo sigwait.lo \
@@ -357,7 +359,7 @@ OBJECTS = $(lib_a_OBJECTS) $(liblinux_la_OBJECTS)
 all: all-redirect
 .SUFFIXES:
 .SUFFIXES: .S .c .lo .o .obj .s
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../../Makefile.shared
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
        cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
 
 Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
@@ -688,11 +690,18 @@ maintainer-clean
 @USE_LIBTOOL_FALSE@    $(RANLIB) $@
 @USE_LIBTOOL_FALSE@    rm -rf tmp
 
-objectlist.awk.in: $(noinst_LTLIBRARIES)
+objectlist.awk.in: $(noinst_LTLIBRARIES) $(SUBLIBS)
        -rm -f objectlist.awk.in
        for i in `ls *.lo` ; \
-       do \
-         echo $$i `pwd`/$$i >> objectlist.awk.in ; \
+         do \
+           echo $$i `pwd`/$$i >> objectlist.awk.in ; \
+       done
+       for j in $(SUBLIBS) ; \
+         do \
+           export i=`echo $$j | sed -e 's,\(.*\)\/[^\/]*$$,\1,'`; \
+           if test $$i != "." && test -f $$i/objectlist.awk.in; then \
+               cat $$i/objectlist.awk.in >> objectlist.awk.in ; \
+           fi; \
        done
 
 all: crt0.o crt1.o
index 48258ec..6c4a472 100644 (file)
@@ -200,6 +200,8 @@ extern int32_t __ieee754_rem_pio2 (double,double*);
 extern double __ieee754_scalb (double,double);
 #endif
 
+/* This is necessary because the hardware accelerated version of libm
+   does not provide the __ieee754 functions. */
 #define __ieee754_sinh   sinh
 #define __ieee754_hypot  hypot
 #define __ieee754_hypotf hypotf
index dc7aaec..6d006a1 100644 (file)
@@ -215,7 +215,7 @@ posix_fpathconf (fd, name)
        /* AIO is only allowed on regular files and block devices.  */
        struct stat64 st;
 
-       if (__fxstat64 (_STAT_VER, fd, &st) < 0
+       if (fstat64 (fd, &st) < 0
            || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
          return -1;
        else
index c72644d..4a49d8f 100644 (file)
@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = cygnus
 
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
-LIB_SOURCES = get_clockfreq.c getpagesize.c hp-timing.c setjmp.S sigaction.c
+LIB_SOURCES = get_clockfreq.c getpagesize.c hp-timing.c setjmp.S sigaction.c dl-procinfo.c
 
 liblinuxi386_la_LDFLAGS = -Xcompiler -nostdlib
 
index a898350..980544f 100644 (file)
@@ -98,7 +98,7 @@ AUTOMAKE_OPTIONS = cygnus
 
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 
-LIB_SOURCES = get_clockfreq.c getpagesize.c hp-timing.c setjmp.S sigaction.c
+LIB_SOURCES = get_clockfreq.c getpagesize.c hp-timing.c setjmp.S sigaction.c dl-procinfo.c
 
 liblinuxi386_la_LDFLAGS = -Xcompiler -nostdlib
 
@@ -124,12 +124,14 @@ LIBS = @LIBS@
 lib_a_LIBADD = 
 @USE_LIBTOOL_FALSE@lib_a_OBJECTS =  get_clockfreq.$(OBJEXT) \
 @USE_LIBTOOL_FALSE@getpagesize.$(OBJEXT) hp-timing.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@setjmp.$(OBJEXT) sigaction.$(OBJEXT)
+@USE_LIBTOOL_FALSE@setjmp.$(OBJEXT) sigaction.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@dl-procinfo.$(OBJEXT)
 LTLIBRARIES =  $(noinst_LTLIBRARIES)
 
 liblinuxi386_la_LIBADD = 
 @USE_LIBTOOL_TRUE@liblinuxi386_la_OBJECTS =  get_clockfreq.lo \
-@USE_LIBTOOL_TRUE@getpagesize.lo hp-timing.lo setjmp.lo sigaction.lo
+@USE_LIBTOOL_TRUE@getpagesize.lo hp-timing.lo setjmp.lo sigaction.lo \
+@USE_LIBTOOL_TRUE@dl-procinfo.lo
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
diff --git a/newlib/libc/sys/linux/machine/i386/dl-procinfo.c b/newlib/libc/sys/linux/machine/i386/dl-procinfo.c
new file mode 100644 (file)
index 0000000..75732b4
--- /dev/null
@@ -0,0 +1,38 @@
+/* Data for Linux/i386 version of processor capability information.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This information must be kept in sync with the _DL_HWCAP_COUNT and
+   _DL_PLATFORM_COUNT definitions in procinfo.h.  */
+
+
+/* If anything should be added here check whether the size of each string
+   is still ok with the given array size.  */
+const char _dl_x86_cap_flags[][7] =
+  {
+    "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+    "cx8", "apic", "10", "sep", "mtrr", "pge", "mca", "cmov",
+    "pat", "pse36", "psn", "19", "20", "21", "22", "mmx",
+    "osfxsr", "xmm", "xmm2", "27", "28", "29", "30", "amd3d"
+  };
+
+const char _dl_x86_platforms[][5] =
+  {
+    "i386", "i486", "i586", "i686"
+  };
diff --git a/newlib/libc/sys/linux/machine/i386/dl-procinfo.h b/newlib/libc/sys/linux/machine/i386/dl-procinfo.h
new file mode 100644 (file)
index 0000000..d1658fa
--- /dev/null
@@ -0,0 +1,132 @@
+/* Linux/i386 version of processor capability information handling macros.
+   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _DL_PROCINFO_H
+#define _DL_PROCINFO_H 1
+
+#include <ldsodefs.h>
+
+/* If anything should be added here check whether the size of each string
+   is still ok with the given array size.  */
+extern const char _dl_x86_cap_flags[][7];
+#define _DL_HWCAP_COUNT 32
+
+extern const char _dl_x86_platforms[][5];
+#define _DL_PLATFORMS_COUNT    4
+
+/* Start at 48 to reserve some space.  */
+#define _DL_FIRST_PLATFORM     48
+/* Mask to filter out platforms.  */
+#define _DL_HWCAP_PLATFORM     (7ULL << _DL_FIRST_PLATFORM)
+
+
+static inline int
+__attribute__ ((unused))
+_dl_procinfo (int word)
+{
+  /* This table should match the information from arch/i386/kernel/setup.c
+     in the kernel sources.  */
+  int i;
+
+  _dl_printf ("AT_HWCAP:   ");
+
+  for (i = 0; i < _DL_HWCAP_COUNT; ++i)
+    if (word & (1 << i))
+      _dl_printf (" %s", _dl_x86_cap_flags[i]);
+
+  _dl_printf ("\n");
+
+  return 0;
+}
+
+static inline const char *
+__attribute__ ((unused))
+_dl_hwcap_string (int idx)
+{
+  return _dl_x86_cap_flags[idx];
+};
+
+static inline const char *
+__attribute__ ((unused))
+_dl_platform_string (int idx)
+{
+  return _dl_x86_platforms [idx - _DL_FIRST_PLATFORM];
+};
+
+enum
+{
+  HWCAP_I386_FPU   = 1 << 0,
+  HWCAP_I386_VME   = 1 << 1,
+  HWCAP_I386_DE    = 1 << 2,
+  HWCAP_I386_PSE   = 1 << 3,
+  HWCAP_I386_TSC   = 1 << 4,
+  HWCAP_I386_MSR   = 1 << 5,
+  HWCAP_I386_PAE   = 1 << 6,
+  HWCAP_I386_MCE   = 1 << 7,
+  HWCAP_I386_CX8   = 1 << 8,
+  HWCAP_I386_APIC  = 1 << 9,
+  HWCAP_I386_SEP   = 1 << 11,
+  HWCAP_I386_MTRR  = 1 << 12,
+  HWCAP_I386_PGE   = 1 << 13,
+  HWCAP_I386_MCA   = 1 << 14,
+  HWCAP_I386_CMOV  = 1 << 15,
+  HWCAP_I386_FCMOV = 1 << 16,
+  HWCAP_I386_MMX   = 1 << 23,
+  HWCAP_I386_OSFXSR = 1 << 24,
+  HWCAP_I386_XMM   = 1 << 25,
+  HWCAP_I386_XMM2  = 1 << 26,
+  HWCAP_I386_AMD3D = 1 << 31,
+
+  /* XXX Which others to add here?  */
+  HWCAP_IMPORTANT = (HWCAP_I386_MMX)
+
+};
+
+static inline int
+__attribute__ ((unused))
+_dl_string_hwcap (const char *str)
+{
+  int i;
+
+  for (i = 0; i < _DL_HWCAP_COUNT; i++)
+    {
+      if (strcmp (str, _dl_x86_cap_flags[i]) == 0)
+       return i;
+    }
+  return -1;
+};
+
+
+static inline int
+__attribute__ ((unused))
+_dl_string_platform (const char *str)
+{
+  int i;
+
+  if (str != NULL)
+    for (i = 0; i < _DL_PLATFORMS_COUNT; ++i)
+      {
+       if (strcmp (str, _dl_x86_platforms[i]) == 0)
+         return _DL_FIRST_PLATFORM + i;
+      }
+  return -1;
+};
+
+#endif /* dl-procinfo.h */
index bbdb618..7969459 100644 (file)
@@ -212,7 +212,7 @@ posix_pathconf (const char *path, int name)
        /* AIO is only allowed on regular files and block devices.  */
        struct stat64 st;
 
-       if (__xstat64 (_STAT_VER, path, &st) < 0
+       if (stat64 (path, &st) < 0
            || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
          return -1;
        else
diff --git a/newlib/libc/sys/linux/prof-freq.c b/newlib/libc/sys/linux/prof-freq.c
new file mode 100644 (file)
index 0000000..829979b
--- /dev/null
@@ -0,0 +1,54 @@
+/* Return frequency of ticks reported by profil.  Generic version. */
+/*-
+ * Copyright (c) 1983, 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <libc-internal.h>
+
+int
+__profile_frequency (void)
+{
+  /*
+   * Discover the tick frequency of the machine if something goes wrong,
+   * we return 0, an impossible hertz.
+   */
+  struct itimerval tim;
+
+  tim.it_interval.tv_sec = 0;
+  tim.it_interval.tv_usec = 1;
+  tim.it_value.tv_sec = 0;
+  tim.it_value.tv_usec = 0;
+  setitimer(ITIMER_REAL, &tim, 0);
+  setitimer(ITIMER_REAL, 0, &tim);
+  if (tim.it_interval.tv_usec < 2)
+    return 0;
+  return (1000000 / tim.it_interval.tv_usec);
+}
diff --git a/newlib/libc/sys/linux/profile.c b/newlib/libc/sys/linux/profile.c
new file mode 100644 (file)
index 0000000..f36e2c7
--- /dev/null
@@ -0,0 +1,12 @@
+/* libc/sys/linux/profile.c - profiling system call */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <machine/syscall.h>
+
+#define __NR_profil 98
+
+int  profil(u_short  *buf,  size_t  bufsiz, size_t offset,
+            u_int scale);
+
+_syscall4(int,profil,unsigned short *,buf,size_t,bufsiz,size_t,offset,unsigned int, scale)
index aaf9d36..82c84c9 100644 (file)
@@ -29,5 +29,6 @@ extern __IMPORT int _sys_nerr;
 
 #define ENOTSUP EOPNOTSUPP
 #define EFTYPE          79              /* Inappropriate file type or format */
+#define EILSEQ          84
 
 #endif
index 4287a81..5541f09 100644 (file)
@@ -149,6 +149,7 @@ typedef __ino64_t ino64_t;
 typedef __uint32_t uintptr_t;
 typedef __int32_t intptr_t;
 typedef __off64_t off64_t;
+typedef __off_t off_t;
 
 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
 typedef        struct _physadr {
index 36213af..3e56267 100644 (file)
@@ -139,13 +139,13 @@ int main()
     int retval;
     int i;
 
-    if (!setlocale(LC_CTYPE, "UTF-8"))
+    if (!setlocale(LC_CTYPE, "C-UTF-8"))
       {
-        printf("Failed to set UTF-8 locale.\n");
+        printf("Failed to set C-UTF-8 locale.\n");
         return 1;
       }
     else
-      printf("Set UTF-8 locale.\n");
+      printf("Set C-UTF-8 locale.\n");
 
     /* 2  Boundary condition test cases */
     /* 2.1  First possible sequence of a certain length */
index e97c963..e823a4f 100644 (file)
@@ -7,7 +7,7 @@
 load_lib checkoutput.exp
 
 set expected_output {
-"Set UTF-8 locale."
+"Set C-UTF-8 locale."
 "* U-00000000"
 "* U-00000080"
 "* U-00000800"