[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] Further savings in OPTION_EGLIBC_LOCALE_CODE option group
- To: patches@xxxxxxxxxx
- Subject: [patches] Further savings in OPTION_EGLIBC_LOCALE_CODE option group
- From: Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
- Date: Thu, 21 Jun 2007 17:21:12 -0700
I've committed the following, which increases the savings brought by
omitting the EGLIBC_OPTION_LOCALE_CODE option group from 3% to 7%, by
omitting all but the simplest transliteration information.
Transliteration is an undocumented feature of GLIBC, whereby selected
ISO-10646 characters not representable in the output locale's
character set get transcribed into characters that are. For example,
the following program prints 'EUR' on my Fedora Core 6 machine:
#include <wchar.h>
int
main (int argc, char **argv)
{
putwchar (L'\x20ac');
putwchar (L'\n');
}
'\x20ac' is the ISO-10646 Euro currency symbol. Transliteration
handles things like alternative numerals; unified CJK characters get
printed as '?'.
With this patch applied and OPTION_EGLIBC_LOCALE_CODE disabled, this
program prints '?'.
ChangeLog.eglibc:
2007-06-21 Jim Blandy <jimb@xxxxxxxxxxxxxxxx>
* locale/C-ctype.c: If OPTION_EGLIBC_LOCALE_CODE is not enabled,
provide only minimal transliteration.
* locale/Makefile (CFLAGS-C-ctype.c): Define
OPTION_EGLIBC_LOCALE_CODE as appropriate.
* iconv/gconv_trans.c (__gconv_transliterate): Don't bother trying
to look up transliteration table information.
* iconv/Makefile (CFLAGS-gconv_trans.c.c): Define
OPTION_EGLIBC_LOCALE_CODE as appropriate.
Index: iconv/Makefile
===================================================================
--- iconv/Makefile (revision 2578)
+++ iconv/Makefile (working copy)
@@ -41,6 +41,7 @@
= -DOPTION_EGLIBC_LOCALE_CODE
CFLAGS-gconv_db.c += $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+CFLAGS-gconv_trans.c += $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
vpath %.c ../locale/programs ../intl
Index: iconv/gconv_trans.c
===================================================================
--- iconv/gconv_trans.c (revision 2578)
+++ iconv/gconv_trans.c (working copy)
@@ -60,6 +60,7 @@
PTR_DEMANGLE (fct);
#endif
+#ifdef OPTION_EGLIBC_LOCALE_CODE
/* If there is no transliteration information in the locale don't do
anything and return the error. */
size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_TAB_SIZE);
@@ -192,6 +193,7 @@
sorted. */
break;
}
+#endif
/* One last chance: use the default replacement. */
if (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN) != 0)
Index: locale/Makefile
===================================================================
--- locale/Makefile (revision 2578)
+++ locale/Makefile (working copy)
@@ -119,6 +119,7 @@
OPTION_POSIX_REGEXP-CFLAGS-$(OPTION_POSIX_REGEXP) \
= -DOPTION_POSIX_REGEXP
+CFLAGS-C-ctype.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
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
Index: locale/C-ctype.c
===================================================================
--- locale/C-ctype.c (revision 2578)
+++ locale/C-ctype.c (working copy)
@@ -20,7 +20,9 @@
#include "localeinfo.h"
#include <endian.h>
+#ifdef OPTION_EGLIBC_LOCALE_CODE
#include "C-translit.h"
+#endif
/* This table's entries are taken from POSIX.2 Table 2-6
``LC_CTYPE Category Definition in the POSIX Locale''.
@@ -647,6 +649,7 @@
{ .word = L'7' },
{ .word = L'8' },
{ .word = L'9' },
+#ifdef OPTION_EGLIBC_LOCALE_CODE
/* _NL_CTYPE_TRANSLIT_TAB_SIZE */
{ .word = NTRANSLIT },
/* _NL_CTYPE_TRANSLIT_FROM_IDX */
@@ -657,6 +660,22 @@
{ .wstr = translit_to_idx },
/* _NL_CTYPE_TRANSLIT_TO_TBL */
{ .wstr = (uint32_t *) translit_to_tbl },
+#else
+ /* If the locale code isn't enabled, we don't have the
+ transliteration code in iconv/gconv_trans.c anyway, so there's
+ no need for the transliteration tables here. We'll fall back
+ on the default missing replacement, '?'. */
+ /* _NL_CTYPE_TRANSLIT_TAB_SIZE */
+ { .word = 0 },
+ /* _NL_CTYPE_TRANSLIT_FROM_IDX */
+ { .wstr = NULL },
+ /* _NL_CTYPE_TRANSLIT_FROM_TBL */
+ { .wstr = NULL },
+ /* _NL_CTYPE_TRANSLIT_TO_IDX */
+ { .wstr = NULL },
+ /* _NL_CTYPE_TRANSLIT_TO_TBL */
+ { .wstr = NULL },
+#endif
/* _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN */
{ .word = 1 },
/* _NL_CTYPE_TRANSLIT_DEFAULT_MISSING */