diff options
Diffstat (limited to 'newlib/libc/locale')
-rw-r--r-- | newlib/libc/locale/Makefile.am | 25 | ||||
-rw-r--r-- | newlib/libc/locale/Makefile.in | 49 | ||||
-rw-r--r-- | newlib/libc/locale/fix_grouping.c | 82 | ||||
-rw-r--r-- | newlib/libc/locale/ldpart.c | 187 | ||||
-rw-r--r-- | newlib/libc/locale/ldpart.h | 35 | ||||
-rw-r--r-- | newlib/libc/locale/lmessages.c | 89 | ||||
-rw-r--r-- | newlib/libc/locale/lmessages.h | 42 | ||||
-rw-r--r-- | newlib/libc/locale/lmonetary.c | 143 | ||||
-rw-r--r-- | newlib/libc/locale/lmonetary.h | 53 | ||||
-rw-r--r-- | newlib/libc/locale/lnumeric.c | 85 | ||||
-rw-r--r-- | newlib/libc/locale/lnumeric.h | 41 | ||||
-rw-r--r-- | newlib/libc/locale/locale.c | 155 | ||||
-rw-r--r-- | newlib/libc/locale/locale.tex | 26 | ||||
-rw-r--r-- | newlib/libc/locale/nl_langinfo.3 | 90 | ||||
-rw-r--r-- | newlib/libc/locale/nl_langinfo.c | 214 | ||||
-rw-r--r-- | newlib/libc/locale/setlocale.h | 37 | ||||
-rw-r--r-- | newlib/libc/locale/timelocal.c | 119 | ||||
-rw-r--r-- | newlib/libc/locale/timelocal.h | 55 |
18 files changed, 54 insertions, 1473 deletions
diff --git a/newlib/libc/locale/Makefile.am b/newlib/libc/locale/Makefile.am index 31229b117..71a400ab0 100644 --- a/newlib/libc/locale/Makefile.am +++ b/newlib/libc/locale/Makefile.am @@ -4,35 +4,17 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h - -## The following interfaces are EL/IX level 2 -if ELIX_LEVEL_1 -LIB_OBJS = -else -LIB_OBJS = \ - fix_grouping.$(oext) \ - ldpart.$(oext) \ - lmessages.$(oext) \ - lnumeric.$(oext) \ - lmonetary.$(oext) \ - nl_langinfo.$(oext) \ - timelocal.$(oext) -endif +LIB_SOURCES = locale.c liblocale_la_LDFLAGS = -Xcompiler -nostdlib if USE_LIBTOOL noinst_LTLIBRARIES = liblocale.la -liblocale_la_SOURCES = $(GENERAL_SOURCES) -liblocale_la_LIBADD = $(LIB_OBJS) -liblocale_la_DEPENDENCIES = $(LIB_OBJS) +liblocale_la_SOURCES = $(LIB_SOURCES) noinst_DATA = objectlist.awk.in else noinst_LIBRARIES = lib.a -lib_a_SOURCES = $(GENERAL_SOURCES) -lib_a_LIBADD = $(LIB_OBJS) -lib_a_DEPENDENCIES = $(LIB_OBJS) +lib_a_SOURCES = $(LIB_SOURCES) noinst_DATA = endif # USE_LIBTOOL @@ -54,4 +36,3 @@ doc: $(CHEWOUT_FILES) cat $(srcdir)/locale.tex >> $(TARGETDOC) CLEANFILES = $(CHEWOUT_FILES) *.ref - diff --git a/newlib/libc/locale/Makefile.in b/newlib/libc/locale/Makefile.in index c1e84805c..dbc53800e 100644 --- a/newlib/libc/locale/Makefile.in +++ b/newlib/libc/locale/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p6 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. @@ -58,32 +58,20 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -build_alias = @build_alias@ -build_triplet = @build@ host_alias = @host_alias@ host_triplet = @host@ -target_alias = @target_alias@ -target_triplet = @target@ AR = @AR@ AS = @AS@ CC = @CC@ CPP = @CPP@ CRT0 = @CRT0@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ LDFLAGS = @LDFLAGS@ -LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ -LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ -LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ -LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ LIBC_SYS_LIB = @LIBC_SYS_LIB@ LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ @@ -93,13 +81,10 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ -STRIP = @STRIP@ VERSION = @VERSION@ aext = @aext@ -extra_dir = @extra_dir@ libm_machine_dir = @libm_machine_dir@ machine_dir = @machine_dir@ newlib_basedir = @newlib_basedir@ @@ -110,22 +95,16 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages.h -@ELIX_LEVEL_1_TRUE@LIB_OBJS = -@ELIX_LEVEL_1_FALSE@LIB_OBJS = fix_grouping.$(oext) ldpart.$(oext) lmessages.$(oext) lnumeric.$(oext) lmonetary.$(oext) nl_langinfo.$(oext) timelocal.$(oext) +LIB_SOURCES = locale.c liblocale_la_LDFLAGS = -Xcompiler -nostdlib -@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = liblocale.la -@USE_LIBTOOL_TRUE@liblocale_la_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_TRUE@liblocale_la_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@liblocale_la_DEPENDENCIES = $(LIB_OBJS) -@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in +@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = @USE_LIBTOOL_TRUE@liblocale.la +@USE_LIBTOOL_TRUE@liblocale_la_SOURCES = @USE_LIBTOOL_TRUE@$(LIB_SOURCES) +@USE_LIBTOOL_TRUE@noinst_DATA = @USE_LIBTOOL_TRUE@objectlist.awk.in @USE_LIBTOOL_FALSE@noinst_DATA = -@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a -@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES) -@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIB_OBJS) -@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIB_OBJS) +@USE_LIBTOOL_FALSE@noinst_LIBRARIES = @USE_LIBTOOL_FALSE@lib.a +@USE_LIBTOOL_FALSE@lib_a_SOURCES = @USE_LIBTOOL_FALSE@$(LIB_SOURCES) CHEWOUT_FILES = locale.def @@ -144,9 +123,11 @@ LIBRARIES = $(noinst_LIBRARIES) DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LIBS = @LIBS@ -@USE_LIBTOOL_FALSE@lib_a_OBJECTS = locale.$(OBJEXT) +lib_a_LIBADD = +@USE_LIBTOOL_FALSE@lib_a_OBJECTS = locale.o LTLIBRARIES = $(noinst_LTLIBRARIES) +liblocale_la_LIBADD = @USE_LIBTOOL_TRUE@liblocale_la_OBJECTS = locale.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -167,7 +148,7 @@ OBJECTS = $(lib_a_OBJECTS) $(liblocale_la_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .def .lo .o .obj .s +.SUFFIXES: .S .c .def .lo .o .s $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(srcdir)/../../Makefile.shared cd $(top_srcdir) && $(AUTOMAKE) --cygnus locale/Makefile @@ -188,11 +169,6 @@ maintainer-clean-noinstLIBRARIES: .c.o: $(COMPILE) -c $< -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - .s.o: $(COMPILE) -c $< @@ -201,7 +177,6 @@ maintainer-clean-noinstLIBRARIES: mostlyclean-compile: -rm -f *.o core *.core - -rm -f *.$(OBJEXT) clean-compile: diff --git a/newlib/libc/locale/fix_grouping.c b/newlib/libc/locale/fix_grouping.c deleted file mode 100644 index c44fc331e..000000000 --- a/newlib/libc/locale/fix_grouping.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 deleted file mode 100644 index a284b9db2..000000000 --- a/newlib/libc/locale/ldpart.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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; -#ifdef __USE_INTERNAL_STAT64 - if (fstat64(fd, &st) != 0) -#else - if (fstat(fd, &st) != 0) -#endif - 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 deleted file mode 100644 index 86031fd33..000000000 --- a/newlib/libc/locale/ldpart.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * 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 deleted file mode 100644 index 9a4bb799a..000000000 --- a/newlib/libc/locale/lmessages.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 deleted file mode 100644 index ee690ae7c..000000000 --- a/newlib/libc/locale/lmessages.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * 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 deleted file mode 100644 index d31e88ccd..000000000 --- a/newlib/libc/locale/lmonetary.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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 deleted file mode 100644 index bbe77db42..000000000 --- a/newlib/libc/locale/lmonetary.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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 deleted file mode 100644 index 90b404ca2..000000000 --- a/newlib/libc/locale/lnumeric.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9678c1f02..000000000 --- a/newlib/libc/locale/lnumeric.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * 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/locale.c b/newlib/libc/locale/locale.c index d48a53a87..e1f45335a 100644 --- a/newlib/libc/locale/locale.c +++ b/newlib/libc/locale/locale.c @@ -42,17 +42,16 @@ execution environment for international collating and formatting information; <<localeconv>> reports on the settings of the current locale. -This is a minimal implementation, supporting only the required <<"C">> +This is a minimal implementation, supporting only the required <<``C''>> value for <[locale]>; strings representing other locales are not -honored unless _MB_CAPABLE is defined in which case three new -extensions are allowed for LC_CTYPE or LC_MESSAGES only: <<"C-JIS">>, -<<"C-EUCJP">>, <<"C-SJIS">>, or <<"C-ISO-8859-1">>. (<<"">> is -also accepted; it represents the default locale -for an implementation, here equivalent to <<"C">>.) +honored unless MB_CAPABLE is defined in which case three new +extensions are allowed for LC_CTYPE only: <<''C-JIS''>>, <<''C-EUCJP''>>, +and <<''C-SJIS''>>. (<<``''>> is also accepted; it represents the default locale +for an implementation, here equivalent to <<``C''>>.) If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a pointer to the string representing the current locale (always -<<"C">> in this implementation). The acceptable values for +<<``C''>> in this implementation). The acceptable values for <[category]> are defined in `<<locale.h>>' as macros beginning with <<"LC_">>, but this implementation does not check the values you pass in the <[category]> argument. @@ -67,7 +66,7 @@ in effect. RETURNS <<setlocale>> returns either a pointer to a string naming the locale -currently in effect (always <<"C">> for this implementation, or, if +currently in effect (always <<``C''>> for this implementation, or, if the locale request cannot be honored, <<NULL>>. <<localeconv>> returns a pointer to a structure of type <<lconv>>, @@ -86,7 +85,6 @@ No supporting OS subroutines are required. * (Only "C" or null supported). */ -#include <newlib.h> #include <locale.h> #include <string.h> #include <limits.h> @@ -98,10 +96,6 @@ int __declspec(dllexport) __mb_cur_max = 1; int __mb_cur_max = 1; #endif -int __nlocale_changed = 0; -int __mlocale_changed = 0; -char *_PathLocale = NULL; - static _CONST struct lconv lconv = { ".", "", "", "", "", "", "", "", "", "", @@ -110,18 +104,13 @@ static _CONST struct lconv lconv = }; -char * _EXFUN(__locale_charset,(_VOID)); - -static char *charset = "ISO-8859-1"; -char __lc_ctype[12] = "C"; - char * _DEFUN(_setlocale_r, (p, category, locale), struct _reent *p _AND int category _AND _CONST char *locale) { -#ifndef _MB_CAPABLE +#ifndef MB_CAPABLE if (locale) { if (strcmp (locale, "C") && strcmp (locale, "")) @@ -131,136 +120,49 @@ _DEFUN(_setlocale_r, (p, category, locale), } return "C"; #else - static char last_lc_ctype[12] = "C"; - static char lc_messages[12] = "C"; - static char last_lc_messages[12] = "C"; + static char lc_ctype[8] = "C"; + static char last_lc_ctype[8] = "C"; if (locale) { - char *locale_name = (char *)locale; - if (category != LC_CTYPE && category != LC_MESSAGES) + if (category != LC_CTYPE) { if (strcmp (locale, "C") && strcmp (locale, "")) return 0; if (category == LC_ALL) { - strcpy (last_lc_ctype, __lc_ctype); - strcpy (__lc_ctype, "C"); - strcpy (last_lc_messages, lc_messages); - strcpy (lc_messages, "C"); + strcpy (last_lc_ctype, lc_ctype); + strcpy (lc_ctype, locale); __mb_cur_max = 1; } } else - { - if (locale[0] == 'C' && locale[1] == '-') - { - switch (locale[2]) - { - case 'U': - if (strcmp (locale, "C-UTF-8")) - return 0; - break; - case 'J': - if (strcmp (locale, "C-JIS")) - return 0; - break; - case 'E': - if (strcmp (locale, "C-EUCJP")) - return 0; - break; - case 'S': - if (strcmp (locale, "C-SJIS")) - return 0; - break; - case 'I': - if (strcmp (locale, "C-ISO-8859-1")) - return 0; - break; - default: - return 0; - } - } - else - { - if (strcmp (locale, "C") && strcmp (locale, "")) - return 0; - locale_name = "C"; /* C is always the default locale */ - } + { + if (strcmp (locale, "C") && strcmp (locale, "") && + strcmp (locale, "C") && strcmp (locale, "C-JIS") && + strcmp (locale, "C-EUCJP") && strcmp (locale, "C-SJIS")) + return 0; - if (category == LC_CTYPE) - { - strcpy (last_lc_ctype, __lc_ctype); - strcpy (__lc_ctype, locale_name); + strcpy (last_lc_ctype, lc_ctype); + strcpy (lc_ctype, locale); - __mb_cur_max = 1; - if (locale[1] == '-') - { - switch (locale[2]) - { - case 'U': - __mb_cur_max = 6; - break; - case 'J': - __mb_cur_max = 8; - break; - case 'E': - __mb_cur_max = 2; - break; - case 'S': - __mb_cur_max = 2; - break; - case 'I': - default: - __mb_cur_max = 1; - } - } - } + if (!strcmp (locale, "C-JIS")) + __mb_cur_max = 8; + else if (strlen (locale) > 1) + __mb_cur_max = 2; else - { - strcpy (last_lc_messages, lc_messages); - strcpy (lc_messages, locale_name); - - charset = "ISO-8859-1"; - if (locale[1] == '-') - { - switch (locale[2]) - { - case 'U': - charset = "UTF-8"; - break; - case 'J': - charset = "JIS"; - break; - case 'E': - charset = "EUCJP"; - break; - case 'S': - charset = "SJIS"; - break; - case 'I': - charset = "ISO-8859-1"; - break; - default: - return 0; - } - } - } + __mb_cur_max = 1; } p->_current_category = category; p->_current_locale = locale; if (category == LC_CTYPE) return last_lc_ctype; - else if (category == LC_MESSAGES) - return last_lc_messages; } else { if (category == LC_CTYPE) - return __lc_ctype; - else if (category == LC_MESSAGES) - return lc_messages; + return lc_ctype; } return "C"; @@ -268,11 +170,6 @@ _DEFUN(_setlocale_r, (p, category, locale), } -char * -_DEFUN_VOID(__locale_charset) -{ - return charset; -} struct lconv * _DEFUN(_localeconv_r, (data), diff --git a/newlib/libc/locale/locale.tex b/newlib/libc/locale/locale.tex index 20dc5d2bc..7958a98a2 100644 --- a/newlib/libc/locale/locale.tex +++ b/newlib/libc/locale/locale.tex @@ -6,10 +6,10 @@ collating sequences and formatting conventions) that may be different depending on location or culture. The @code{"C"} locale is the only one defined in the ANSI C standard. -This is a minimal implementation, supporting only the required @code{"C"} +This is a minimal implementation, supporting only the required @code{``C''} value for locale; strings representing other locales are not -honored. (@code{""} is also accepted; it represents the default locale -for an implementation, here equivalent to @code{"C"}. +honored. (@code{``''} is also accepted; it represents the default locale +for an implementation, here equivalent to @code{``C''}. @file{locale.h} defines the structure @code{lconv} to collect the @@ -18,13 +18,13 @@ information on a locale, with the following fields: @table @code @item char *decimal_point The decimal point character used to format ``ordinary'' numbers (all -numbers except those referring to amounts of money). @code{"."} in the +numbers except those referring to amounts of money). @code{``.''} in the C locale. @item char *thousands_sep The character (if any) used to separate groups of digits, when formatting ordinary numbers. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *grouping Specifications for how many digits to group (if any grouping is done at @@ -33,36 +33,36 @@ character in the string represents the number of digits for the next group, and a value of @code{0} (that is, the string's trailing @code{NULL}) means to continue grouping digits using the last value specified. Use @code{CHAR_MAX} to indicate that no further grouping is -desired. @code{""} in the C locale. +desired. @code{``''} in the C locale. @item char *int_curr_symbol The international currency symbol (first three characters), if any, and the character used to separate it from numbers. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *currency_symbol The local currency symbol, if any. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *mon_decimal_point The symbol used to delimit fractions in amounts of money. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *mon_thousands_sep Similar to @code{thousands_sep}, but used for amounts of money. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *mon_grouping Similar to @code{grouping}, but used for amounts of money. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *positive_sign A string to flag positive amounts of money when formatting. -@code{""} in the C locale. +@code{``''} in the C locale. @item char *negative_sign A string to flag negative amounts of money when formatting. -@code{""} in the C locale. +@code{``''} in the C locale. @item char int_frac_digits The number of digits to display when formatting amounts of money to diff --git a/newlib/libc/locale/nl_langinfo.3 b/newlib/libc/locale/nl_langinfo.3 deleted file mode 100644 index 96819e1c7..000000000 --- a/newlib/libc/locale/nl_langinfo.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" 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 deleted file mode 100644 index b2923bd65..000000000 --- a/newlib/libc/locale/nl_langinfo.c +++ /dev/null @@ -1,214 +0,0 @@ -/*- - * 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 * -_DEFUN(nl_langinfo, (item), - 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 deleted file mode 100644 index 3eb769863..000000000 --- a/newlib/libc/locale/setlocale.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * 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 deleted file mode 100644 index 5b097ad7c..000000000 --- a/newlib/libc/locale/timelocal.c +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * 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 deleted file mode 100644 index 0b0a59a48..000000000 --- a/newlib/libc/locale/timelocal.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * 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_ */ |