summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/ChangeLog.eglibc86
-rw-r--r--libc/Makerules25
-rw-r--r--libc/iconv/Makefile10
-rw-r--r--libc/iconv/gconv_db.c2
-rw-r--r--libc/iconv/iconv_prog.c7
-rw-r--r--libc/intl/Makefile8
-rw-r--r--libc/intl/dcigettext.c8
-rw-r--r--libc/libidn/Makefile6
-rw-r--r--libc/libidn/toutf8.c6
-rw-r--r--libc/libio/Makefile4
-rw-r--r--libc/locale/Makefile44
-rw-r--r--libc/locale/catnames.c48
-rw-r--r--libc/locale/dummy-setlocale.c33
-rw-r--r--libc/locale/setlocale.c30
-rw-r--r--libc/locale/xlocale.c36
-rw-r--r--libc/localedata/Makefile10
-rw-r--r--libc/option-groups.def19
-rw-r--r--libc/option-groups.defaults1
-rw-r--r--libc/posix/Makefile15
-rw-r--r--libc/stdio-common/Makefile15
-rw-r--r--libc/stdio-common/printf_fp.c10
-rw-r--r--libc/stdio-common/printf_fphex.c5
-rw-r--r--libc/stdlib/Makefile13
-rw-r--r--libc/string/Makefile11
-rw-r--r--libc/string/strerror_l.c4
-rw-r--r--libc/time/Makefile14
-rw-r--r--libc/time/strftime_l.c8
-rw-r--r--libc/time/strptime_l.c11
-rw-r--r--libc/wcsmbs/Makefile12
-rw-r--r--libc/wcsmbs/wcsmbsload.c12
30 files changed, 429 insertions, 84 deletions
diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc
index bf2a56d6c..b03bee0ba 100644
--- a/libc/ChangeLog.eglibc
+++ b/libc/ChangeLog.eglibc
@@ -1,5 +1,91 @@
2007-05-26 Jim Blandy <jimb@codesourcery.com>
+ Add the OPTION_EGLIBC_LOCALE_CODE option group.
+
+ * option-groups.def (OPTION_EGLIBC_LOCALE_CODE): New entry.
+ * option-groups.defaults (OPTION_EGLIBC_LOCALE_CODE): Initialize.
+ * Makerules (test-srcs): Add in value of test-srcs-y.
+ (static-only-routines): Add in value of static-only-routines-y.
+ * stdlib/Makefile: Include ../option-groups.mak.
+ (routines): Move rpmatch, strfmon, and strfmon_l into the group.
+ (tests): Move tst-strtod3 into the group.
+ * wcsmbs/Makefile: Include ../option-groups.mak.
+ (tests): Move tst-btowc, tst-mbrtowc, tst-mbrtowc2, and
+ tst-wcrtomb into the option group.
+ (CFLAGS-wcsmbsload.c): Define OPTION_EGLIBC_LOCALE_CODE as
+ appropriate.
+ * wcsmbs/wcsmbsload.c (__wcsmbs_load_conv): If the group is not
+ enabled, simply abort.
+ * time/Makefile: Include ../option-groups.mak.
+ (aux): Move alt_digit, era, and lc-time-cleanup into the group.
+ (tests): Move tst-strptime into the group.
+ (CFLAGS-strftime_l.c, CFLAGS-strptime_l.c): Define
+ OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * time/strftime_l.c, time/strptime_l.c: Support eras and custom
+ digits only when the group is enabled.
+ * libio/Makefile (tests): Move tst-swscanf into the group.
+ * intl/Makefile (CFLAGS-dcigettext.c): Define
+ OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * intl/dcigettext.c (DCIGETTEXT): If the group is not enabled,
+ assume the "C" locale.
+ * string/Makefile: Include ../option-groups.mak.
+ (tests): Move tst-strxfrm and bug-strcoll1 into the option group.
+ (CFLAGS-strerror_l.c): Define OPTION_EGLIBC_LOCALE_CODE as
+ appropriate.
+ * string/strerror_l.c (translate): Don't translate unless the
+ group is enabled.
+ * iconv/Makefile: Include ../option-groups.mak.
+ (CFLAGS-gconv_db.c, CFLAGS-iconv_prog.c): Define
+ OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * iconv/gconv_db.c (libc_freeres_fn): If group is disabled, no
+ need to free locale memory first.
+ * iconv/iconv_prog.c (main): If the group is disabled, the default
+ codeset is always ASCII.
+ * locale/Makefile: Include ../option-groups.mak.
+ (distribute): Mention new dummy-setlocale.c.
+ (routines): Include mb_cur_max and the new catnames unconditionally;
+ put setlocale, findlocale, loadlocale, loadarchive, localeconv,
+ nl_langinfo, nl_langinfo_l, newlocale, duplocale, freelocale, and
+ uselocale in the group. If the group is disabled, use
+ dummy-setlocale.
+ (tests): Put tst-C-locale in the group.
+ (aux): Move all C categories other than C-ctype and C-time into
+ the group, along with all the load-locale routines, and
+ localename.
+ (others, install-bin, extra-objs): Put localedef and locale in the
+ group.
+ (extra-libs, extra-libs-other): Put libBrokenLocale in the group.
+ (CFLAGS-xlocale.c): Define OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * locale/xlocale.c: If the group is disabled, make the references
+ here to the omitted category data weak. Furthermore, in the
+ NL_CURRENT_INDIRECT case, define the _nl_current_##CATEGORY
+ variables here.
+ * locale/setlocale.c (_nl_category_names, _nl_category_name_idxs)
+ (_nl_category_name_sizes): Move these from here...
+ * locale/catnames.c: ... to here. New file.
+ * locale/dummy-setlocale.c: New file.
+ * intl/Makefile: Include ../option-groups.mak.
+ (tests): Move tst-translit, tst-gettext2, tst-codeset,
+ tst-gettext3, tst-gettext4, tst-gettext5, and mtrace-tst-gettext
+ into the OPTION_EGLIBC_LOCALES option group.
+ * localedata/Makefile (tests): Move all tests into the
+ OPTION_EGLIBC_LOCALES group.
+ * posix/Makefile (tests): Move tst-fnmatch, tst-regex,
+ tst-regexloc, bug-regex1, bug-regex5, bug-regex19, bug-regex22,
+ and bug-regex25 into the group.
+ * stdio-common/Makefile: Include ../option-groups.mak.
+ (tests): Move tst-sscanf, tst-swprintf, bug15, and test-vfprintf
+ into the option group.
+ (CFLAGS-printf_fp.c, CFLAGS-printf_fphex.c): Define
+ OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * stdio-common/printf_fp.c (__printf_fp): Hard-code values from
+ the 'C' locale.
+ * stdio-common/printf_fphex.c (__printf_fphex): Same.
+ * libidn/Makefile: Include ../option-groups.mak.
+ (CFLAGS-toutf8.c): Define OPTION_EGLIBC_LOCALE_CODE as appropriate.
+ * libidn/toutf8.c (stringprep_locale_charset): If the group is
+ disabled, assume ASCII.
+
* Makefile (TAGS): Avoid backslashes in single-quoted strings.
2007-05-13 Jim Blandy <jimb@codesourcery.com>
diff --git a/libc/Makerules b/libc/Makerules
index bdb345666..fcd8c8d0c 100644
--- a/libc/Makerules
+++ b/libc/Makerules
@@ -406,18 +406,19 @@ endef
endif
# Include targets in the selected option groups.
-aux += $(aux-y)
-extra-libs += $(extra-libs-y)
-extra-libs-others += $(extra-libs-others-y)
-extra-objs += $(extra-objs-y)
-install-bin += $(install-bin-y)
-install-others += $(install-others-y)
-install-sbin += $(install-sbin-y)
-others += $(others-y)
-routines += $(routines-y)
-test-srcs += $(test-srcs-y)
-tests += $(tests-y)
-xtests += $(xtests-y)
+aux += $(aux-y)
+extra-libs += $(extra-libs-y)
+extra-libs-others += $(extra-libs-others-y)
+extra-objs += $(extra-objs-y)
+install-bin += $(install-bin-y)
+install-others += $(install-others-y)
+install-sbin += $(install-sbin-y)
+others += $(others-y)
+routines += $(routines-y)
+static-only-routines += $(static-only-routines-y)
+test-srcs += $(test-srcs-y)
+tests += $(tests-y)
+xtests += $(xtests-y)
# Modify the list of routines we build for different targets
diff --git a/libc/iconv/Makefile b/libc/iconv/Makefile
index f2a81253b..b69e29a27 100644
--- a/libc/iconv/Makefile
+++ b/libc/iconv/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for iconv.
#
+include ../option-groups.mak
+
subdir := iconv
include ../Makeconfig
@@ -35,13 +37,19 @@ CFLAGS-gconv_cache.c = -DSTATIC_GCONV
CFLAGS-gconv_simple.c = -DSTATIC_GCONV
endif
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-gconv_db.c += $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+
vpath %.c ../locale/programs ../intl
iconv_prog-modules = iconv_charmap charmap charmap-dir linereader \
dummy-repertoire simple-hash xstrdup xmalloc
iconvconfig-modules = strtab xmalloc hash-string
extra-objs = $(iconv_prog-modules:=.o) $(iconvconfig-modules:=.o)
-CFLAGS-iconv_prog.c = -I../locale/programs
+CFLAGS-iconv_prog.c = -I../locale/programs \
+ $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
CFLAGS-iconv_charmap.c = -I../locale/programs
CFLAGS-dummy-repertoire.c = -I../locale/programs
CFLAGS-charmap.c = -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
diff --git a/libc/iconv/gconv_db.c b/libc/iconv/gconv_db.c
index 6540cc393..0c6dfbf1b 100644
--- a/libc/iconv/gconv_db.c
+++ b/libc/iconv/gconv_db.c
@@ -826,9 +826,11 @@ free_modules_db (struct gconv_module *node)
/* Free all resources if necessary. */
libc_freeres_fn (free_mem)
{
+#ifdef OPTION_EGLIBC_LOCALE_CODE
/* First free locale memory. This needs to be done before freeing derivations,
as ctype cleanup functions dereference steps arrays which we free below. */
_nl_locale_subfreeres ();
+#endif
/* finddomain.c has similar problem. */
extern void _nl_finddomain_subfreeres (void) attribute_hidden;
diff --git a/libc/iconv/iconv_prog.c b/libc/iconv/iconv_prog.c
index 84493af68..a783a7ecd 100644
--- a/libc/iconv/iconv_prog.c
+++ b/libc/iconv/iconv_prog.c
@@ -229,10 +229,17 @@ main (int argc, char *argv[])
bool to_wrong =
(iconv_open (to_code, "UTF-8") == (iconv_t) -1
&& errno == EINVAL);
+#ifdef OPTION_EGLIBC_LOCALE_CODE
const char *from_pretty =
(from_code[0] ? from_code : nl_langinfo (CODESET));
const char *to_pretty =
(orig_to_code[0] ? orig_to_code : nl_langinfo (CODESET));
+#else
+ const char *from_pretty =
+ (from_code[0] ? from_code : "ANSI_X3.4-1968");
+ const char *to_pretty =
+ (orig_to_code[0] ? orig_to_code : "ANSI_X3.4-1968");
+#endif
if (from_wrong)
{
diff --git a/libc/intl/Makefile b/libc/intl/Makefile
index dd66f1815..f4b6499b5 100644
--- a/libc/intl/Makefile
+++ b/libc/intl/Makefile
@@ -17,6 +17,7 @@
# 02111-1307 USA.
# Makefile for intl subdirectory: message handling code from GNU gettext.
+include ../option-groups.mak
subdir = intl
headers = libintl.h
@@ -62,7 +63,7 @@ $(objpfx)plural.o: plural.c
include ../Rules
# eglibc: ifeq (no,$(cross-compiling))
-ifeq (yes,$(build-shared))
+ifeq (yyes,$(OPTION_EGLIBC_LOCALES)$(build-shared))
ifneq ($(strip $(MSGFMT)),:)
tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \
$(objpfx)tst-codeset.out $(objpfx)tst-gettext3.out
@@ -101,6 +102,11 @@ $(objpfx)msgs.h: po2test.sed ../po/de.po
$(make-target-directory)
LC_ALL=C sed -f $^ > $@
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-dcigettext.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+
CFLAGS-tst-gettext.c = -DTESTSTRS_H=\"$(objpfx)msgs.h\"
CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\"
CFLAGS-tst-gettext2.c = -DOBJPFX=\"$(objpfx)\"
diff --git a/libc/intl/dcigettext.c b/libc/intl/dcigettext.c
index cb2b1813a..2b826582c 100644
--- a/libc/intl/dcigettext.c
+++ b/libc/intl/dcigettext.c
@@ -464,7 +464,11 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
search->category = category;
# ifdef HAVE_PER_THREAD_LOCALE
# ifdef _LIBC
+# ifdef OPTION_EGLIBC_LOCALE_CODE
localename = __current_locale_name (category);
+# else
+ localename = "C";
+# endif
# endif
search->localename = localename;
# endif
@@ -1302,7 +1306,11 @@ guess_category_value (category, categoryname)
`LC_xxx', and `LANG'. On some systems this can be done by the
`setlocale' function itself. */
#ifdef _LIBC
+# ifdef OPTION_EGLIBC_LOCALE_CODE
retval = __current_locale_name (category);
+# else
+ retval = "C";
+# endif
#else
retval = _nl_locale_name (category, categoryname);
#endif
diff --git a/libc/libidn/Makefile b/libc/libidn/Makefile
index 3a4d1b342..ee72c8c6b 100644
--- a/libc/libidn/Makefile
+++ b/libc/libidn/Makefile
@@ -17,6 +17,7 @@
# 02111-1307 USA.
# Makefile for libidn subdirectory of GNU C Library.
+include ../option-groups.mak
subdir := libidn
@@ -38,3 +39,8 @@ libcidn-inhibit-o = $(filter-out .os,$(object-suffixes))
include $(..)Rules
$(objpfx)libcidn.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
+
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-toutf8.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
diff --git a/libc/libidn/toutf8.c b/libc/libidn/toutf8.c
index dad47c9af..e5090ae2a 100644
--- a/libc/libidn/toutf8.c
+++ b/libc/libidn/toutf8.c
@@ -49,7 +49,11 @@
#endif
#ifdef _LIBC
-# define stringprep_locale_charset() nl_langinfo (CODESET)
+# ifdef OPTION_EGLIBC_LOCALE_CODE
+# define stringprep_locale_charset() nl_langinfo (CODESET)
+# else
+# define stringprep_locale_charset() "ANSI_X3.4-1968"
+# endif
#else
/**
* stringprep_locale_charset - return charset used in current locale
diff --git a/libc/libio/Makefile b/libc/libio/Makefile
index b0d59bbe8..08af69390 100644
--- a/libc/libio/Makefile
+++ b/libc/libio/Makefile
@@ -49,7 +49,7 @@ routines := \
tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc \
- tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-swscanf tst-sscanf \
+ tst-fgetws tst-ungetwc1 tst-ungetwc2 tst-sscanf \
tst-mmap-setvbuf bug-ungetwc1 bug-ungetwc2 tst-atime tst-eof \
tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \
tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \
@@ -59,6 +59,8 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
tst-wmemstream1 tst-wmemstream2 \
bug-memstream1 bug-wmemstream1 \
tst-setvbuf1
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-swscanf
test-srcs = test-freopen
all: # Make this the default target; it will be defined in Rules.
diff --git a/libc/locale/Makefile b/libc/locale/Makefile
index d9ab1947e..a7964a829 100644
--- a/libc/locale/Makefile
+++ b/libc/locale/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for locales.
#
+include ../option-groups.mak
+
subdir := locale
headers = locale.h bits/locale.h langinfo.h xlocale.h
@@ -26,7 +28,7 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \
iso-4217.def weight.h weightwc.h strlen-hash.h elem-hash.h \
indigits.h indigitswc.h outdigits.h outdigitswc.h \
coll-lookup.h C-translit.h.in C-translit.h gen-translit.pl \
- locarchive.h hashval.h \
+ locarchive.h hashval.h dummy-setlocale.c \
$(addprefix programs/, \
locale.c localedef.c \
$(localedef-modules:=.c) $(locale-modules:=.c) \
@@ -35,22 +37,36 @@ distribute = localeinfo.h categories.def iso-639.def iso-3166.def \
locfile-kw.gperf locfile-kw.h linereader.h \
locfile.h charmap.h repertoire.h localedef.h \
3level.h charmap-dir.h locarchive.c)
-routines = setlocale findlocale loadlocale loadarchive \
- localeconv nl_langinfo nl_langinfo_l mb_cur_max \
- newlocale duplocale freelocale uselocale
-tests = tst-C-locale
+# catnames is needed by OPTION_EGLIBC_LOCALE_CODE and by the 'intl' code.
+# If we put the latter in an option group, too, we can omit catnames
+# when both option groups are disabled. libstdc++-v3 needs mb_cur_max.
+routines-y := catnames mb_cur_max
+routines-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += setlocale findlocale loadlocale loadarchive \
+ localeconv nl_langinfo nl_langinfo_l \
+ newlocale duplocale freelocale uselocale
+ifneq (y,$(OPTION_EGLIBC_LOCALE_CODE))
+routines-y += dummy-setlocale
+endif
+tests-$(OPTION_EGLIBC_LOCALE_CODE) += tst-C-locale
categories = ctype messages monetary numeric time paper name \
address telephone measurement identification collate
-aux = $(categories:%=lc-%) $(categories:%=C-%) SYS_libc C_name \
- xlocale localename global-locale coll-lookup
-others = localedef locale
+# C-messages belongs in an intl option group.
+aux-y := C-ctype C-time \
+ SYS_libc C_name xlocale global-locale coll-lookup
+aux-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += $(filter-out $(aux-y), \
+ $(categories:%=lc-%) $(categories:%=C-%)) \
+ localename
+others-$(OPTION_EGLIBC_LOCALE_CODE) = localedef locale
#others-static = localedef locale
-install-bin = localedef locale
-extra-objs = $(localedef-modules:=.o) $(localedef-aux:=.o) \
+install-bin = $(others-y)
+extra-objs-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = $(localedef-modules:=.o) $(localedef-aux:=.o) \
$(locale-modules:=.o) $(lib-modules:=.o)
-extra-libs = libBrokenLocale
-extra-libs-others = $(extra-libs)
+extra-libs-$(OPTION_EGLIBC_LOCALE_CODE) = libBrokenLocale
+extra-libs-others = $(extra-libs-y)
libBrokenLocale-routines = broken_cur_max
@@ -98,6 +114,10 @@ locale-CPPFLAGS := -DLOCALE_PATH='$(localepath)' \
-DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
-Iprograms
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-xlocale.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts
CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts
CFLAGS-charmap-dir.c = -Wno-write-strings
diff --git a/libc/locale/catnames.c b/libc/locale/catnames.c
new file mode 100644
index 000000000..9fad357db
--- /dev/null
+++ b/libc/locale/catnames.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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. */
+
+#include "localeinfo.h"
+
+/* Define an array of category names (also the environment variable names). */
+const union catnamestr_t _nl_category_names attribute_hidden =
+ {
+ {
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ category_name,
+#include "categories.def"
+#undef DEFINE_CATEGORY
+ }
+ };
+
+const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
+ {
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)),
+#include "categories.def"
+#undef DEFINE_CATEGORY
+ };
+
+/* An array of their lengths, for convenience. */
+const uint8_t _nl_category_name_sizes[] attribute_hidden =
+ {
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ [category] = sizeof (category_name) - 1,
+#include "categories.def"
+#undef DEFINE_CATEGORY
+ [LC_ALL] = sizeof ("LC_ALL") - 1
+ };
diff --git a/libc/locale/dummy-setlocale.c b/libc/locale/dummy-setlocale.c
new file mode 100644
index 000000000..219964ace
--- /dev/null
+++ b/libc/locale/dummy-setlocale.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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. */
+
+#include <string.h>
+#include <locale.h>
+
+char *
+setlocale (int category, const char *locale)
+{
+ if (! locale
+ || locale[0] == '\0'
+ || strcmp (locale, "C") == 0
+ || strcmp (locale, "POSIX") == 0)
+ return (char *) "C";
+ else
+ return NULL;
+}
+libc_hidden_def (setlocale)
diff --git a/libc/locale/setlocale.c b/libc/locale/setlocale.c
index c1b8c3fae..f7a9eb361 100644
--- a/libc/locale/setlocale.c
+++ b/libc/locale/setlocale.c
@@ -66,36 +66,6 @@ static char *const _nl_current_used[] =
#endif
-/* Define an array of category names (also the environment variable names). */
-const union catnamestr_t _nl_category_names attribute_hidden =
- {
- {
-#define DEFINE_CATEGORY(category, category_name, items, a) \
- category_name,
-#include "categories.def"
-#undef DEFINE_CATEGORY
- }
- };
-
-const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
- {
-#define DEFINE_CATEGORY(category, category_name, items, a) \
- [category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)),
-#include "categories.def"
-#undef DEFINE_CATEGORY
- };
-
-/* An array of their lengths, for convenience. */
-const uint8_t _nl_category_name_sizes[] attribute_hidden =
- {
-#define DEFINE_CATEGORY(category, category_name, items, a) \
- [category] = sizeof (category_name) - 1,
-#include "categories.def"
-#undef DEFINE_CATEGORY
- [LC_ALL] = sizeof ("LC_ALL") - 1
- };
-
-
#ifdef NL_CURRENT_INDIRECT
# define WEAK_POSTLOAD(postload) weak_extern (postload)
#else
diff --git a/libc/locale/xlocale.c b/libc/locale/xlocale.c
index 4573e6f39..63036852c 100644
--- a/libc/locale/xlocale.c
+++ b/libc/locale/xlocale.c
@@ -26,6 +26,19 @@ extern struct locale_data _nl_C_##category;
#include "categories.def"
#undef DEFINE_CATEGORY
+/* If the locale support code isn't enabled, don't generate strong
+ reference to the C locale_data structures here; let the Makefile
+ decide which ones to include. (In the static linking case, the
+ strong reference to the 'class', 'toupper', and 'tolower' tables
+ will cause C-ctype.o to be brought in, as it should be, even when
+ the reference to _nl_C_LC_CTYPE will be weak.) */
+#ifndef OPTION_EGLIBC_LOCALE_CODE
+# define DEFINE_CATEGORY(category, category_name, items, a) \
+ weak_extern (_nl_C_##category)
+# include "categories.def"
+# undef DEFINE_CATEGORY
+#endif
+
/* Defined in locale/C-ctype.c. */
extern const char _nl_C_LC_CTYPE_class[] attribute_hidden;
extern const char _nl_C_LC_CTYPE_toupper[] attribute_hidden;
@@ -53,3 +66,26 @@ const struct __locale_struct _nl_C_locobj attribute_hidden =
.__ctype_tolower = (const int *) _nl_C_LC_CTYPE_tolower + 128,
.__ctype_toupper = (const int *) _nl_C_LC_CTYPE_toupper + 128
};
+
+
+#ifndef OPTION_EGLIBC_LOCALE_CODE
+/* When locale code is enabled, these are each defined in the
+ appropriate lc-CATEGORY.c file, so that static links (when __thread
+ is supported) bring in only those lc-CATEGORY.o files for
+ categories the program actually uses; look for NL_CURRENT_INDIRECT
+ in localeinfo.h.
+
+ When locale code is disabled, the _nl_C_CATEGORY objects are the
+ only possible referents. At the moment, there isn't a way to get
+ OPTION_EGLIBC_LOCALE_CODE defined in every compilation unit that
+ #includes localeinfo.h, so we can't just turn off
+ NL_CURRENT_INDIRECT. So we'll define the _nl_current_CATEGORY
+ pointers here. */
+#if defined (NL_CURRENT_INDIRECT)
+#define DEFINE_CATEGORY(category, category_name, items, a) \
+ __thread struct locale_data * const *_nl_current_##category \
+ attribute_hidden = &_nl_C_locobj.__locales[category];
+#include "categories.def"
+#undef DEFINE_CATEGORY
+#endif
+#endif /* OPTION_EGLIBC_LOCALE_CODE */
diff --git a/libc/localedata/Makefile b/libc/localedata/Makefile
index 53eae9e47..31e9205da 100644
--- a/libc/localedata/Makefile
+++ b/libc/localedata/Makefile
@@ -102,10 +102,14 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \
tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
tst_wctype tst_wcwidth
-tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
+# Since these tests build their own locale files, they're not
+# dependent on the OPTION_EGLIBC_LOCALES option group. But they do
+# need the locale functions to be present.
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
tst-leaks tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale \
tst-strfmon1 tst-sscanf
-ifeq (yes,$(build-shared))
+ifeq (yesy,$(build-shared)$(OPTION_EGLIBC_LOCALE_CODE))
ifneq (no,$(PERL))
tests: $(objpfx)mtrace-tst-leaks
endif
@@ -166,10 +170,12 @@ $(addprefix $(objpfx),$(CTYPE_FILES)): %: \
$(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
$(addprefix $(objpfx),$(CTYPE_FILES))
+ifeq (y,$(OPTION_EGLIBC_LOCALE_CODE))
tests: $(objpfx)sort-test.out $(objpfx)tst-fmon.out $(objpfx)tst-locale.out \
$(objpfx)tst-rpmatch.out $(objpfx)tst-trans.out \
$(objpfx)tst-mbswcs.out $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out \
$(objpfx)tst-langinfo.out $(objpfx)tst-numeric.out
+endif
$(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
$(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
diff --git a/libc/option-groups.def b/libc/option-groups.def
index 7e615752f..62156d36f 100644
--- a/libc/option-groups.def
+++ b/libc/option-groups.def
@@ -50,6 +50,25 @@ config OPTION_EGLIBC_LOCALES
that for the "C" locale. If this option group is omitted, then
only the "C" locale is supported.
+
+config OPTION_EGLIBC_LOCALE_CODE
+ bool "Locale functions"
+ help
+ This option group includes locale support functions, programs,
+ and libraries. With OPTION_EGLIBC_LOCALE_FUNCTIONS disabled,
+ EGLIBC supports only the 'C' locale (also known as 'POSIX'),
+ and ignores the settings of the 'LANG' and 'LC_*' environment
+ variables.
+
+ With OPTION_EGLIBC_LOCALE_CODE disabled, the following
+ functions are omitted from libc:
+
+ duplocale localeconv nl_langinfo rpmatch strfmon_l
+ freelocale newlocale nl_langinfo_l strfmon uselocale
+
+ Furthermore, only the LC_CTYPE and LC_TIME categories of the
+ standard "C" locale are available.
+
config OPTION_EGLIBC_LIBM
bool "libm (math library)"
help
diff --git a/libc/option-groups.defaults b/libc/option-groups.defaults
index 335bd3ed3..8eedad4e3 100644
--- a/libc/option-groups.defaults
+++ b/libc/option-groups.defaults
@@ -10,5 +10,6 @@
# By default, all option groups are enabled.
OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_LOCALES = y
+OPTION_EGLIBC_LOCALE_CODE = y
OPTION_EGLIBC_LIBM = y
OPTION_EGLIBC_INET = y
diff --git a/libc/posix/Makefile b/libc/posix/Makefile
index 663783ea2..48d475e56 100644
--- a/libc/posix/Makefile
+++ b/libc/posix/Makefile
@@ -78,14 +78,14 @@ aux := init-posix environ
tests := tstgetopt testfnm runtests runptests \
tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
tst-getlogin tst-mmap tst-truncate \
- tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
- tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
- tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
+ tst-truncate64 tst-fork tst-dir \
+ tst-chmod bug-regex2 bug-regex3 bug-regex4 \
+ tst-gnuglob bug-regex6 bug-regex7 \
bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
- bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
- bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
- bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
+ bug-regex17 bug-regex18 bug-regex20 \
+ bug-regex21 bug-regex23 bug-regex24 \
+ bug-regex26 bug-regex27 bug-regex28 \
tst-nice tst-nanosleep tst-regex2 \
transbug tst-rxspencer tst-pcre tst-boost \
tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
@@ -95,6 +95,9 @@ tests := tstgetopt testfnm runtests runptests \
tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
tst-execvp3 tst-execvp4 \
tst-fnmatch2 tst-cpucount
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-fnmatch tst-regex tst-regexloc bug-regex1 bug-regex5 \
+ bug-regex19 bug-regex22 bug-regex25
tests-$(OPTION_EGLIBC_INET) \
+= tst-getaddrinfo bug-ga1 tst-getaddrinfo2 \
tst-rfc3484 tst-rfc3484-2 tst-getaddrinfo3
diff --git a/libc/stdio-common/Makefile b/libc/stdio-common/Makefile
index d71b89fac..14f86aa14 100644
--- a/libc/stdio-common/Makefile
+++ b/libc/stdio-common/Makefile
@@ -19,6 +19,8 @@
#
# Specific makefile for stdio-common.
#
+include ../option-groups.mak
+
subdir := stdio-common
headers := stdio_ext.h printf.h bits/printf-ldbl.h
@@ -50,11 +52,13 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 bug12 bug13 \
tfformat tiformat tllformat tstdiomisc tst-printfsz tst-wc-printf \
scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
- scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \
- tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
- tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
+ scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf \
+ tst-fseek tst-fmemopen tst-gets \
+ tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16 bug17 tst-swscanf
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-sscanf tst-swprintf bug15 test-vfprintf
test-srcs = tst-unbputc tst-printf
@@ -76,12 +80,17 @@ $(objpfx)tst-printf.out: $(objpfx)tst-printf tst-printf.sh
$(SHELL) -e tst-printf.sh $(common-objpfx) '$(run-program-prefix)'
# eglibc: endif
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
CFLAGS-vfprintf.c = -Wno-uninitialized
CFLAGS-tst-printf.c = -Wno-format
CFLAGS-tstdiomisc.c = -Wno-format
CFLAGS-scanf4.c = -Wno-format
CFLAGS-scanf7.c = -Wno-format
CFLAGS-tst-printfsz.c = -Wno-format
+CFLAGS-printf_fp.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+CFLAGS-printf_fphex.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
CFLAGS-tmpfile.c = -fexceptions
CFLAGS-tmpfile64.c = -fexceptions
diff --git a/libc/stdio-common/printf_fp.c b/libc/stdio-common/printf_fp.c
index 6e5ff5855..cadba38c1 100644
--- a/libc/stdio-common/printf_fp.c
+++ b/libc/stdio-common/printf_fp.c
@@ -262,6 +262,7 @@ ___printf_fp (FILE *fp,
/* Figure out the decimal point character. */
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (info->extra == 0)
{
decimal = _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
@@ -281,7 +282,13 @@ ___printf_fp (FILE *fp,
/* The decimal point character must not be zero. */
assert (*decimal != '\0');
assert (decimalwc != L'\0');
+#else
+ /* Hard-code values from 'C' locale. */
+ decimal = ".";
+ decimalwc = L'.';
+#endif
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (info->group)
{
if (info->extra == 0)
@@ -325,6 +332,9 @@ ___printf_fp (FILE *fp,
}
else
grouping = NULL;
+#else
+ grouping = NULL;
+#endif
/* Fetch the argument value. */
#ifndef __NO_LONG_DOUBLE_MATH
diff --git a/libc/stdio-common/printf_fphex.c b/libc/stdio-common/printf_fphex.c
index 4e30d94c6..98696da80 100644
--- a/libc/stdio-common/printf_fphex.c
+++ b/libc/stdio-common/printf_fphex.c
@@ -148,6 +148,7 @@ __printf_fphex (FILE *fp,
/* Figure out the decimal point character. */
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (info->extra == 0)
{
decimal = _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
@@ -161,6 +162,10 @@ __printf_fphex (FILE *fp,
}
/* The decimal point character must never be zero. */
assert (*decimal != '\0' && decimalwc != L'\0');
+#else
+ decimal = ".";
+ decimalwc = L'.';
+#endif
/* Fetch the argument value. */
diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile
index ec5526127..3c0a42500 100644
--- a/libc/stdlib/Makefile
+++ b/libc/stdlib/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for stdlib routines
#
+include ../option-groups.mak
+
subdir := stdlib
headers := stdlib.h bits/stdlib.h bits/stdlib-ldbl.h \
@@ -28,7 +30,7 @@ headers := stdlib.h bits/stdlib.h bits/stdlib-ldbl.h \
ucontext.h sys/ucontext.h \
alloca.h fmtmsg.h
-routines := \
+routines-y := \
atof atoi atol atoll \
abort \
bsearch qsort msort \
@@ -49,9 +51,11 @@ routines := \
strtof_l strtod_l strtold_l \
system canonicalize \
a64l l64a \
- rpmatch strfmon strfmon_l getsubopt xpg_basename fmtmsg \
+ getsubopt xpg_basename fmtmsg \
strtoimax strtoumax wcstoimax wcstoumax \
getcontext setcontext makecontext swapcontext
+routines-$(OPTION_EGLIBC_LOCALE_CODE) += \
+ rpmatch strfmon strfmon_l
aux = grouping groupingwc
# These routines will be omitted from the libc shared object.
@@ -67,9 +71,10 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
tst-xpg-basename tst-random tst-random2 tst-bsearch \
tst-limits tst-rand48 bug-strtod tst-setcontext \
test-a64l tst-qsort tst-system testmb2 bug-strtod2 \
- tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
+ tst-atof1 tst-atof2 tst-strtod2 tst-rand48-2 \
tst-makecontext tst-strtod4
-
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-strtod3
include ../Makeconfig
ifeq ($(build-shared),yes)
diff --git a/libc/string/Makefile b/libc/string/Makefile
index 734c96690..ffb4ce66b 100644
--- a/libc/string/Makefile
+++ b/libc/string/Makefile
@@ -19,6 +19,8 @@
#
# Sub-makefile for string portion of library.
#
+include ../option-groups.mak
+
subdir := string
headers := string.h strings.h memory.h endian.h bits/endian.h \
@@ -52,14 +54,21 @@ strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \
tests := tester inl-tester noinl-tester testcopy test-ffs \
tst-strlen stratcliff tst-svc tst-inlcall \
bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \
- tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \
+ tst-strtok tst-strfry \
bug-strtok1 $(addprefix test-,$(strop-tests)) \
bug-envz1 tst-strxfrm2
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-strxfrm bug-strcoll1
distribute := memcopy.h pagecopy.h tst-svc.expect test-string.h
include ../Rules
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-strerror_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+
tester-ENV = LANGUAGE=C
inl-tester-ENV = LANGUAGE=C
noinl-tester-ENV = LANGUAGE=C
diff --git a/libc/string/strerror_l.c b/libc/string/strerror_l.c
index 32a004ee7..689e46e17 100644
--- a/libc/string/strerror_l.c
+++ b/libc/string/strerror_l.c
@@ -30,10 +30,14 @@ static __thread char *last_value;
static const char *
translate (const char *str, locale_t loc)
{
+#ifdef OPTION_EGLIBC_LOCALE_CODE
locale_t oldloc = __uselocale (loc);
const char *res = _(str);
__uselocale (oldloc);
return res;
+#else
+ return str;
+#endif
}
diff --git a/libc/time/Makefile b/libc/time/Makefile
index 8ce34e456..6851be69f 100644
--- a/libc/time/Makefile
+++ b/libc/time/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for time routines
#
+include ../option-groups.mak
+
subdir := time
headers := time.h sys/time.h sys/timeb.h bits/time.h
@@ -30,13 +32,15 @@ routines := offtime asctime clock ctime ctime_r difftime \
stime dysize timegm ftime \
getdate strptime strptime_l \
strftime wcsftime strftime_l wcsftime_l
-aux := era alt_digit lc-time-cleanup
+aux-$(OPTION_EGLIBC_LOCALE_CODE) += alt_digit era lc-time-cleanup
distribute := datemsk
-tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
+tests := test_time clocktest tst-posixtz tst_wcsftime \
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
tst-strptime3
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-strptime
include ../Rules
@@ -48,6 +52,12 @@ CFLAGS-tzfile.c = $(tz-cflags)
CFLAGS-tzset.c = $(tz-cflags)
CFLAGS-getdate.c = -fexceptions
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+
+CFLAGS-strftime_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+CFLAGS-strptime_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+
# Don't warn about Y2k problem in strftime format string.
CFLAGS-test_time.c = -Wno-format
diff --git a/libc/time/strftime_l.c b/libc/time/strftime_l.c
index 0fd3f7764..8e3c197e0 100644
--- a/libc/time/strftime_l.c
+++ b/libc/time/strftime_l.c
@@ -883,7 +883,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
goto bad_format;
if (modifier == L_('E'))
{
-#if HAVE_STRUCT_ERA_ENTRY
+#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
if (era)
{
@@ -956,7 +956,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
if (modifier == L_('O') && 0 <= number_value)
{
-#ifdef _NL_CURRENT
+#if defined (OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
/* Get the locale specific alternate representation of
the number NUMBER_VALUE. If none exist NULL is returned. */
const CHAR_T *cp = nl_get_alt_digit (number_value
@@ -1261,7 +1261,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
case L_('Y'):
if (modifier == 'E')
{
-#if HAVE_STRUCT_ERA_ENTRY
+#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
if (era)
{
@@ -1286,7 +1286,7 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
case L_('y'):
if (modifier == L_('E'))
{
-#if HAVE_STRUCT_ERA_ENTRY
+#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
if (era)
{
diff --git a/libc/time/strptime_l.c b/libc/time/strptime_l.c
index 443a6fa88..4cb206aec 100644
--- a/libc/time/strptime_l.c
+++ b/libc/time/strptime_l.c
@@ -93,7 +93,7 @@ localtime_r (t, tp)
if (val < from || val > to) \
return NULL; \
} while (0)
-#ifdef _NL_CURRENT
+#if defined (OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
# define get_alt_number(from, to, n) \
({ \
__label__ do_normal; \
@@ -760,6 +760,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
want_xday = 1;
break;
case 'C':
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (*decided != raw)
{
if (era_cnt >= 0)
@@ -796,10 +797,12 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
*decided = raw;
}
+#endif
/* The C locale has no era information, so use the
normal representation. */
goto match_century;
case 'y':
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (*decided != raw)
{
get_number(0, 9999, 4);
@@ -858,9 +861,10 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
*decided = raw;
}
-
+#endif
goto match_year_in_century;
case 'Y':
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (*decided != raw)
{
num_eras = _NL_CURRENT_WORD (LC_TIME,
@@ -889,6 +893,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
*decided = raw;
}
+#endif
get_number (0, 9999, 4);
tm->tm_year = val - 1900;
want_century = 0;
@@ -1050,6 +1055,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
tm->tm_year = (century - 19) * 100;
}
+#ifdef OPTION_EGLIBC_LOCALE_CODE
if (era_cnt != -1)
{
era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
@@ -1064,6 +1070,7 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
tm->tm_year = era->start_date[0];
}
else
+#endif
if (want_era)
{
/* No era found but we have seen an E modifier. Rectify some
diff --git a/libc/wcsmbs/Makefile b/libc/wcsmbs/Makefile
index 7a289a8dc..aa56435dd 100644
--- a/libc/wcsmbs/Makefile
+++ b/libc/wcsmbs/Makefile
@@ -20,6 +20,8 @@
#
# Sub-makefile for wcsmbs portion of the library.
#
+include ../option-groups.mak
+
subdir := wcsmbs
headers := wchar.h bits/wchar.h bits/wchar2.h bits/wchar-ldbl.h
@@ -40,8 +42,10 @@ routines := wcscat wcschr wcscmp wcscpy wcscspn wcsdup wcslen wcsncat \
wcscasecmp wcsncase wcscasecmp_l wcsncase_l \
wcsmbsload mbsrtowcs_l
-tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
- tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2
+tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen \
+ tst-wcpncpy tst-mbsrtowcs tst-wchar-h
+tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-btowc tst-mbrtowc tst-mbrtowc2 tst-wcrtomb
include ../Rules
@@ -65,6 +69,10 @@ CFLAGS-wcstold_l.c = $(strtox-CFLAGS)
CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
CFLAGS-tst-wchar-h.c = -D_FORTIFY_SOURCE=2
+OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
+ = -DOPTION_EGLIBC_LOCALE_CODE
+CFLAGS-wcsmbsload.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+
# We need to find the default version of strtold_l in stdlib.
CPPFLAGS-wcstold_l.c = -I../stdlib
diff --git a/libc/wcsmbs/wcsmbsload.c b/libc/wcsmbs/wcsmbsload.c
index e82b1ffaf..97ca0a240 100644
--- a/libc/wcsmbs/wcsmbsload.c
+++ b/libc/wcsmbs/wcsmbsload.c
@@ -144,6 +144,7 @@ __wcsmbs_getfct (const char *to, const char *from, size_t *nstepsp)
})
+#ifdef OPTION_EGLIBC_LOCALE_CODE
/* Some of the functions here must not be used while setlocale is called. */
__libc_lock_define (extern, __libc_setlocale_lock attribute_hidden)
@@ -213,6 +214,17 @@ __wcsmbs_load_conv (struct locale_data *new_category)
__libc_lock_unlock (__libc_setlocale_lock);
}
+#else
+void
+internal_function
+__wcsmbs_load_conv (struct locale_data *new_category)
+{
+ /* When OPTION_EGLIBC_LOCALE_CODE is disabled, we should never reach
+ this point: there is no way to change locales, so every locale
+ passed to get_gconv_fcts should be _nl_C_LC_CTYPE. */
+ abort ();
+}
+#endif
/* Clone the current conversion function set. */