summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
commit1217289737588e65b088b3535428b27c7287d699 (patch)
tree6a292ac767d219702e26a6a2111737f84a96900c /extra
parent32b76c5ec3c257b7287913d0d1a96e0cbb2e9c6a (diff)
Add a new *scanf implementation, includeing the *wscanf functions.
Should be standards compliant and with several optional features, including support for hexadecimal float notation, locale awareness, glibc-like locale-specific digit grouping with the `'' flag, and positional arg support. I tested it pretty well (finding several bugs in glibc's scanf in the process), but it is brand new so be aware. The *wprintf functions now support floating point output. Also, a couple of bugs were squashed. Finally, %a/%A conversions are now implemented. Implement the glibc xlocale interface for thread-specific locale support. Also add the various *_l(args, locale_t loc_arg) funcs. NOTE!!! setlocale() is NOT threadsafe! NOTE!!! The strto{floating point} conversion functions are now locale aware. The also now support hexadecimal floating point notation. Add the wcsto{floating point} conversion functions. Fix a bug in mktime() related to dst. Note that unlike glibc's mktime, uClibc's version always normalizes the struct tm before attempting to determine the correct dst setting if tm_isdst == -1 on entry. Add a stub version of the libintl functions. (untested) Fixed a known memory leak in setlocale() related to the collation data. Add lots of new config options (which Erik agreed to sort out :-), including finally exposing some of the stripped down stdio configs. Be careful with those though, as they haven't been tested in a long time. (temporary) GOTCHAs... The ctype functions are currently incorrect for 8-bit locales. They will be fixed shortly. The ctype functions are now table-based, resulting in larger staticly linked binaries. I'll be adding an option to use the old approach in the stub locale configuration.
Diffstat (limited to 'extra')
-rw-r--r--extra/Configs/Config.in393
-rw-r--r--extra/locale/Makefile8
-rw-r--r--extra/locale/gen_collate.c34
-rw-r--r--extra/locale/gen_ldc.c78
-rw-r--r--extra/locale/gen_locale.c62
-rw-r--r--extra/locale/gen_wc8bit.c68
-rw-r--r--extra/locale/gen_wctype.c18
-rw-r--r--extra/locale/locale_mmap.h79
8 files changed, 570 insertions, 170 deletions
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index bbfbc854d..9de4a5e6f 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -298,12 +298,48 @@ endmenu
menu "String and Stdio Support"
+config UCLIBC_HAS_CTYPE_SIGNED
+ bool "Support Signed Characters In `ctype.h' Functions."
+ default y
+ help
+ Answer Y to enable support for passing signed char values to
+ the `ctype.h' functions. ANSI/ISO C99 and SUSv3 specify that
+ these functions are only defined for unsigned char values and
+ EOF. However, glibc allows negative signed char values as well
+ in order to support 'broken old programs'.
+
+ Most people will answer Y.
+
+choice
+ prompt "`ctype.h' Invalid Arg Behavior."
+ default UCLIBC_HAS_CTYPE_CHECKED
+ help
+ Please select the invalid arg behavior you want for the `ctype' functions.
+
+ The `ctype' functions are now implemented using table lookups, with
+ the arg being the index. This can result in incorrect memory accesses
+ or even segfaults for args outside of the allowed range.
+
+ NOTE: This only affects the `ctype' _functions_. It does not affect
+ the macro implementations.
+
+config UCLIBC_HAS_CTYPE_UNSAFE
+ bool "Do not check. (incorrect array access possible)"
+
+config UCLIBC_HAS_CTYPE_CHECKED
+ bool "Detect and handle appropriately."
+
+config UCLIBC_HAS_CTYPE_ENFORCED
+ bool "Issue a diagnostic and abort()."
+
+endchoice
+
config UCLIBC_HAS_WCHAR
bool "Wide Character Support"
default n
help
Answer Y to enable wide character support. This will make uClibc
- much larger.
+ much larger. It is also currently required for locale support.
Most people will answer N.
@@ -313,11 +349,67 @@ config UCLIBC_HAS_LOCALE
default n
help
Answer Y to enable locale support. This will make uClibc much
- bigger. uClibc's locale support is still under development, and
- should be finished in the next several weeks (November 2002).
+ bigger. uClibc's locale support is still under development.
Most people will wisely answer N.
+config UCLIBC_HAS_XLOCALE
+ bool "Extended Locale Support (experimental/incomplete)"
+ depends on UCLIBC_HAS_LOCALE
+ default n
+ help
+ Answer Y to enable extended locale support similar to that provided
+ by glibc. This is primarily intended to support libstd++ functionality.
+ However, it also allows thread-specific locale selection via uselocale().
+
+ Most people will answer N.
+
+config UCLIBC_HAS_SCANF_GLIBC_A_FLAG
+ bool "Support glibc's `a' flag for scanf string conversions"
+ default n
+ help
+ NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!!
+
+ Answer Y to enable support for glibc's `a' flag for the scanf string
+ conversions `%s', `%[', `%ls', `%l[`, and `%S'. This is used to
+ auto-allocate sufficient memory to hold the data retrieved.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_HEXADECIMAL_FLOATS
+ bool "Support hexadecimal float notation"
+ default n
+ help
+ Answer Y to enable support for hexadecimal float notation in the
+ (wchar and) char string to floating point conversion functions, as
+ well as support for the %a and %A conversion specifiers in the
+ *printf() and *scanf() functions.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_GLIBC_DIGIT_GROUPING
+ bool "Support glibc's `'' flag for allowing locale-specific digit grouping"
+ depends on UCLIBC_HAS_LOCALE
+ default n
+ help
+ Answer Y to enable support for glibc's `'' flag for allowing locale-specific
+ digit grouping in base 10 integer conversions and appropriate floating point
+ conversions in the *printf() and *scanf() functions.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING
+ bool "Do not require digit grouping when the `'' flag is specified"
+ depends on UCLIBC_HAS_GLIBC_DIGIT_GROUPING
+ default y
+ help
+ Answer Y to make digit grouping optional when the `'' flag is specified.
+ This is the standard glibc behavior. If the initial string of digits
+ exceeds the maximum group number, the input will be treated as a normal
+ non-grouped number.
+
+ Most people will answer N.
+
config USE_OLD_VFPRINTF
bool "Use the old vfprintf implementation"
default n
@@ -332,6 +424,293 @@ config USE_OLD_VFPRINTF
Most people will answer N.
+config UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS
+ int "Maximum number of positional args. Either 0 or >= 9."
+ depends on !USE_OLD_VFPRINTF
+ default 9
+ help
+ Set the maximum number of positional args supported by the printf/scanf
+ functions. The Single Unix Specification Version 3 requires a minimum
+ value of 9. Setting this to a value lower than 9 will disable positional
+ arg support and cause the NL_ARGMAX macro in limits.h to be #undef'd.
+ WARNING! The workspace to support positional args is currently allocated
+ on the stack. You probably don't want to set this to too high a value.
+
+ Most people will answer 9.
+
+
+config UCLIBC_HAS_TZ_CACHING
+ bool "Enable caching of the last valid timezone `TZ' string"
+ default y
+ help
+ Answer Y to enable caching of the last valid `TZ' string describing
+ the timezone setting. This allows a quick string compare to avoid
+ repeated parsing of unchanged `TZ' strings when tzset() is called.
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_TZ_FILE
+ bool "Enable `/etc/TZ' file support to set a default timezone (uClibc-specific)"
+ default y
+ help
+ Answer Y to enable the setting of a default timezone for uClibc.
+
+ Ordinarily, uClibc gets the timezone information exclusively from the
+ `TZ' environment variable. In particular, there is no support for
+ the zoneinfo directory tree or the /etc/timezone file used by glibc.
+
+ With this option enabled, uClibc will use the value stored in the
+ file `/etc/TZ' (default path) to obtain timezone information if the
+ `TZ' environment variable is missing or has an invalid value. The
+ file consists of a single line (newline required) of text describing
+ the timezone in the format specified for the TZ environment variable.
+
+ Simply doing `echo CST6CDT > /etc/TZ' is enough to create a valid file.
+ See
+ http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html
+ for details on valid settings of `TZ'.
+
+ Most people will answer Y.
+
+config UCLIBC_TZ_FILE_PATH
+ string "Path to the `TZ' file for setting the global timezone"
+ depends on UCLIBC_HAS_TZ_FILE
+ default "/etc/TZ"
+ help
+ This is the path to the `TZ' file.
+
+ Most people will use the default of `/etc/TZ'.
+
+config UCLIBC_HAS_TZ_FILE_READ_MANY
+ bool "Repeatedly read the `/etc/TZ' file"
+ depends on UCLIBC_HAS_TZ_FILE
+ default y
+ help
+ Answer Y to enable repeated reading of the `/etc/TZ' file even after
+ a valid value has been read. This incurs the overhead of an open/read/close
+ for each tzset() call (explicit or implied). However, setting this
+ will allows applications to update their timezone information if the contents
+ of the file change.
+
+ Most people will answer Y.
+
+choice
+ prompt "Stdio buffer size"
+ default UCLIBC_HAS_STDIO_BUFSIZ_256
+ help
+ Please select a value for BUFSIZ. This will be used by the
+ stdio subsystem as the default buffer size for a file, and
+ affects fopen(), setvbuf(), etc.
+
+ NOTE: Setting this to `none' will disable buffering completely.
+ However, BUFSIZ will still be defined in stdio.h as 256 because
+ many applications use this value.
+
+config UCLIBC_HAS_STDIO_BUFSIZ_NONE
+ bool "none (WARNING - BUFSIZ will be 256 in stdio.h)"
+ depends !UCLIBC_HAS_WCHAR
+
+config UCLIBC_HAS_STDIO_BUFSIZ_256
+ bool "256 (minimum ANSI/ISO C99 value)"
+
+config UCLIBC_HAS_STDIO_BUFSIZ_512
+ bool "512"
+
+config UCLIBC_HAS_STDIO_BUFSIZ_1024
+ bool "1024"
+
+config UCLIBC_HAS_STDIO_BUFSIZ_2048
+ bool "2048"
+
+config UCLIBC_HAS_STDIO_BUFSIZ_4096
+ bool "4096"
+
+config UCLIBC_HAS_STDIO_BUFSIZ_8192
+ bool "8192"
+
+# If you add more choices, you will need to update uClibc_stdio.h.
+
+endchoice
+
+config UCLIBC_HAS_STDIO_GETC_MACRO
+ bool "Provide a macro version of getc()"
+ depends !UCLIBC_HAS_STDIO_BUFSIZ_NONE
+ default y
+ help
+ Provide a macro version of getc().
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_STDIO_PUTC_MACRO
+ bool "Provide a macro version of putc()"
+ depends !UCLIBC_HAS_STDIO_BUFSIZ_NONE
+ default y
+ help
+ Provide a macro version of putc().
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION
+ bool "Support auto-r/w transition"
+ default y
+ help
+ Answer Y to enable the stdio subsystem to automaticly transition
+ between reading and writing. This relaxes the ANSI/ISO C99 requirement:
+
+ When a file is opened with update mode ('+' as the second or third character
+ in the list of mode argument values), both input and output may be performed
+ on the associated stream. However, output shall not be directly followed by
+ input without an intervening call to the fflush function or to a file
+ positioning function (fseek, fsetpos, or rewind), and input shall not be
+ directly followed by output without an intervening call to a file positioning
+ function, unless the input operation encounters end­of­file.
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_FOPEN_LARGEFILE_MODE
+ bool "Support an fopen() `F' flag for large file mode (uClibc-specific)"
+ depends on UCLIBC_HAS_LFS
+ default n
+ help
+ Answer Y to enable a uClibc-specific extension to allow passing an
+ additional `F' flag in the mode string for fopen() to specify that
+ the file should be open()ed with the O_LARGEFILE flag set.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
+ bool "Support an fopen() `x' flag for exclusive mode (glibc-compat)"
+ default n
+ help
+ Answer Y to support a glibc extension to allow passing
+ additional `x' flag in the mode string for fopen() to specify that
+ the file should be open()ed with the O_EXCL flag set.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_GLIBC_CUSTOM_STREAMS
+ bool "Support fmemopen(), open_memstream(), and fopencookie() (glibc-compat)"
+ default n
+ help
+ Answer Y to support the glibc `custom stream' extension functions
+ fmemopen(), open_memstream(), and fopencookie().
+
+ NOTE: There are some minor differences regarding seeking behavior.
+
+ Most people will answer N.
+
+choice
+ prompt "Stdio builtin buffer size (uClibc-specific)"
+ depends !UCLIBC_HAS_STDIO_BUFSIZ_NONE
+ default UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE
+ help
+ When a FILE is created with fopen(), an attempt is made to allocate
+ a BUFSIZ buffer for it. If the allocation fails, fopen() will still
+ succeed but the FILE will be unbuffered.
+
+ This option adds a small amount of space to each FILE to act as an
+ emergeny buffer in the event of a buffer allocation failure.
+
+ Most people will answer None.
+
+config UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE
+ bool "None"
+
+config UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4
+ bool "4"
+
+config UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8
+ bool "8"
+
+# If you add more choices, you will need to update uClibc_stdio.h.
+
+endchoice
+
+config UCLIBC_HAS_PRINTF_M_SPEC
+ bool "Support the `%m' specifier in printf format strings (glibc-compat)"
+ default n
+ help
+ Answer Y to support a glibc extension to interpret `%m' in printf
+ format strings as an instruction to output the error message string
+ (as generated by strerror) corresponding to the current value of `errno'.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
+ bool "Support glibc's register_printf_function() (glibc-compat)"
+ default n
+ help
+ Answer Y to support glibc's register_printf_function() to allow an
+ application to add its own printf conversion specifiers.
+
+ NOTE: This implementation limits the number or registered specifiers to 10.
+ NOTE: This implementation requires new conversion specifiers to be ASCII
+ characters (0-0x7f). This is to avoid problems with processing
+ format strings in locales with different multibyte conversions.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_ERRNO_MESSAGES
+ bool "Include the errno message text in the library"
+ default y
+ help
+ Answer Y if you want to include the errno message text in the
+ library. This adds about 3K to the library, but enables strerror()
+ to generate text other than `Unknown error <number>'.
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_SYS_ERRLIST
+ bool "Support sys_errlist[] (obsolete-compat)"
+ depends on UCLIBC_HAS_ERRNO_MESSAGES
+ default n
+ help
+ Answer Y if you want to support the obsolete sys_errlist[].
+ This adds about 0.5k to the library, except for the mips
+ arch where it adds over 4K.
+
+ WARNING! In the future, support for sys_errlist[] may be unavailable
+ in at least some configurations. In fact, it may be removed altogether.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_SIGNUM_MESSAGES
+ bool "Include the signum message text in the library"
+ default y
+ help
+ Answer Y if you want to include the signum message text in the
+ library. This adds about 0.5K to the library, but enables strsignal()
+ to generate text other than `Unknown signal <number>'.
+
+ Most people will answer Y.
+
+config UCLIBC_HAS_SYS_SIGLIST
+ bool "Support sys_siglist[] (bsd-compat)"
+ depends on UCLIBC_HAS_SIGNUM_MESSAGES
+ default n
+ help
+ Answer Y if you want to support sys_siglist[].
+
+ WARNING! In the future, support for sys_siglist[] may be unavailable
+ in at least some configurations. In fact, it may be removed altogether.
+
+ Most people will answer N.
+
+config UCLIBC_HAS_GETTEXT_AWARENESS
+ bool "Include gettext awareness"
+ depends on UCLIBC_HAS_LOCALE
+ default n
+ help
+ NOTE!!! Not yet integrated with strerror and strsignal. NOTE!!!
+
+ Answer Y if you want to include weak stub gettext support and
+ make the *strerror*() and strsignal() functions gettext-aware.
+
+ Currently, to get functional gettext functionality you will need
+ to use gnu gettext.
+
+ Most people will answer N.
+
endmenu
menu "Library Installation Options"
@@ -482,4 +861,12 @@ config UCLIBC_MALLOC_DEBUGGING
the size of malloc appreciably (due to strings etc), you
should say N unless you need to debug a malloc problem.
+config UCLIBC_MJN3_ONLY
+ bool "Manuel's hidden warnings"
+ default n
+ help
+ Answer Y here to see all Manuel's personal notes, warnings, and todos.
+
+ Most people will answer N.
+
endmenu
diff --git a/extra/locale/Makefile b/extra/locale/Makefile
index 983c91c30..41438dadc 100644
--- a/extra/locale/Makefile
+++ b/extra/locale/Makefile
@@ -109,13 +109,17 @@ uClibc_locale_data.h: c8tables.h wctables.h lt_defines.h locale_mmap.h
links-target: locale_data.o uClibc_locale_data.h
ln -sf ../../../extra/locale/locale_data.o ../../libc/misc/locale
- cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/
+ cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h
+
+# cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/
pregen:
$(CC) $(CFLAGS_mmap) -c locale_data.c
$(STRIPTOOL) -x -R .note -R .comment locale_data.o
ln -sf ../../../extra/locale/locale_data.o ../../libc/misc/locale
- cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/
+ cat uClibc_locale_data.h | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > ../../include/bits/uClibc_locale_data.h
+
+# cp uClibc_locale_data.h ../../libc/sysdeps/linux/common/bits/
clean:
rm -f *.[oa] *~ core
diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c
index 51b6b7383..7a524c8f7 100644
--- a/extra/locale/gen_collate.c
+++ b/extra/locale/gen_collate.c
@@ -1274,7 +1274,7 @@ static void error_msg(const char *fmt, ...)
static void pushfile(char *filename)
{
- static fbuf[PATH_MAX];
+ static char fbuf[PATH_MAX];
snprintf(fbuf, PATH_MAX, "collation/%s", filename);
@@ -2894,28 +2894,28 @@ static void finalize_base(void)
unsigned int u = 0xe40;
table_data *tbl = &table;
-#define WCctype_TI_MASK ((1 << tbl->ti_shift)-1)
-#define WCctype_TI_SHIFT (tbl->ti_shift)
-#define WCctype_TI_LEN (tbl->ti_len)
-#define WCctype_II_MASK ((1 << tbl->ii_shift)-1)
-#define WCctype_II_SHIFT (tbl->ii_shift)
-#define WCctype_II_LEN (tbl->ii_len)
+#define __LOCALE_DATA_WCctype_TI_MASK ((1 << tbl->ti_shift)-1)
+#define __LOCALE_DATA_WCctype_TI_SHIFT (tbl->ti_shift)
+#define __LOCALE_DATA_WCctype_TI_LEN (tbl->ti_len)
+#define __LOCALE_DATA_WCctype_II_MASK ((1 << tbl->ii_shift)-1)
+#define __LOCALE_DATA_WCctype_II_SHIFT (tbl->ii_shift)
+#define __LOCALE_DATA_WCctype_II_LEN (tbl->ii_len)
- sc = u & WCctype_TI_MASK;
- u >>= WCctype_TI_SHIFT;
- n = u & WCctype_II_MASK;
- u >>= WCctype_II_SHIFT;
+ sc = u & __LOCALE_DATA_WCctype_TI_MASK;
+ u >>= __LOCALE_DATA_WCctype_TI_SHIFT;
+ n = u & __LOCALE_DATA_WCctype_II_MASK;
+ u >>= __LOCALE_DATA_WCctype_II_SHIFT;
i0 = tbl->ii[u];
fprintf(stderr, "i0 = %d\n", i0);
- i0 <<= WCctype_II_SHIFT;
- i1 = tbl->ii[WCctype_II_LEN + i0 + n];
+ i0 <<= __LOCALE_DATA_WCctype_II_SHIFT;
+ i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n];
/* i1 = tbl->ti[i0 + n]; */
fprintf(stderr, "i1 = %d\n", i1);
- i1 <<= WCctype_TI_SHIFT;
- /* return *(uint16_t *)(&(tbl->ii[WCctype_II_LEN + WCctype_TI_LEN + i1 + sc])); */
- fprintf(stderr, "i2 = %d\n", WCctype_II_LEN + WCctype_TI_LEN + i1 + sc);
- fprintf(stderr, "val = %d\n", tbl->ii[WCctype_II_LEN + WCctype_TI_LEN + i1 + sc]);
+ i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT;
+ /* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */
+ fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc);
+ fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]);
/* return tbl->ut[i1 + sc]; */
diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c
index 399587d96..3ffc90efe 100644
--- a/extra/locale/gen_ldc.c
+++ b/extra/locale/gen_ldc.c
@@ -17,10 +17,10 @@
/* #define __CTYPE_HAS_8_BIT_LOCALES */
#endif
-/* #define Cctype_TBL_LEN 328 */
-/* #define Cuplow_TBL_LEN 400 */
-/* #define Cc2wc_TBL_LEN 1448 */
-/* #define Cwc2c_TBL_LEN 3744 */
+/* #define __LOCALE_DATA_Cctype_TBL_LEN 328 */
+/* #define __LOCALE_DATA_Cuplow_TBL_LEN 400 */
+/* #define __LOCALE_DATA_Cc2wc_TBL_LEN 1448 */
+/* #define __LOCALE_DATA_Cwc2c_TBL_LEN 3744 */
#define WANT_WCctype_data
#define WANT_WCuplow_data
@@ -34,9 +34,9 @@
/* #undef WANT_WCcomb_data */
/* #undef WANT_WCwidth_data */
- #define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN)
- #define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN)
- #define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs)
+ #define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
+ #define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
+ #define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs)
/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
#include "locale_collate.h"
@@ -50,7 +50,7 @@
/* #define __PASTE3(A,B,C) A ## B ## C */
-/* #define MAGIC_SIZE 64 */
+/* #define __LOCALE_DATA_MAGIC_SIZE 64 */
/* #define COMMON_MMAP(X) \ */
/* unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)]; */
@@ -69,7 +69,7 @@
offsetof(__locale_mmap_t, __PASTE3(lc_,X,_data)) \
-static const size_t common_tbl_offsets[CATEGORIES*4] = {
+static const size_t common_tbl_offsets[__LOCALE_DATA_CATEGORIES*4] = {
COMMON_OFFSETS(ctype),
COMMON_OFFSETS(numeric),
COMMON_OFFSETS(monetary),
@@ -152,9 +152,11 @@ int main(void)
{
FILE *lso; /* static object */
int i;
- unsigned char magic[MAGIC_SIZE];
+#ifdef __LOCALE_DATA_MAGIC_SIZE
+ unsigned char magic[__LOCALE_DATA_MAGIC_SIZE];
- memset(magic, 0, MAGIC_SIZE);
+ memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE);
+#endif /* __LOCALE_DATA_MAGIC_SIZE */
if (!(lso = fopen("locale_data.c", "w"))) {
printf("can't open locale_data.c!\n");
@@ -174,20 +176,22 @@ int main(void)
"#include \"locale_mmap.h\"\n\n"
"static const __locale_mmap_t locale_mmap = {\n\n"
);
- out_uc(lso, magic, MAGIC_SIZE, "magic");
+#ifdef __LOCALE_DATA_MAGIC_SIZE
+ out_uc(lso, magic, __LOCALE_DATA_MAGIC_SIZE, "magic");
+#endif /* __LOCALE_DATA_MAGIC_SIZE */
#ifdef __CTYPE_HAS_8_BIT_LOCALES
- out_uc(lso, Cctype_data, Cctype_TBL_LEN, "tbl8ctype");
- out_uc(lso, Cuplow_data, Cuplow_TBL_LEN, "tbl8uplow");
+ out_uc(lso, __LOCALE_DATA_Cctype_data, __LOCALE_DATA_Cctype_TBL_LEN, "tbl8ctype");
+ out_uc(lso, __LOCALE_DATA_Cuplow_data, __LOCALE_DATA_Cuplow_TBL_LEN, "tbl8uplow");
#ifdef __WCHAR_ENABLED
- out_u16(lso, Cc2wc_data, Cc2wc_TBL_LEN, "tbl8c2wc");
- out_uc(lso, Cwc2c_data, Cwc2c_TBL_LEN, "tbl8wc2c");
+ out_u16(lso, __LOCALE_DATA_Cc2wc_data, __LOCALE_DATA_Cc2wc_TBL_LEN, "tbl8c2wc");
+ out_uc(lso, __LOCALE_DATA_Cwc2c_data, __LOCALE_DATA_Cwc2c_TBL_LEN, "tbl8wc2c");
/* translit */
#endif /* __WCHAR_ENABLED */
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
#ifdef __WCHAR_ENABLED
- out_uc(lso, WCctype_data, WCctype_TBL_LEN, "tblwctype");
- out_uc(lso, WCuplow_data, WCuplow_TBL_LEN, "tblwuplow");
- out_i16(lso, WCuplow_diff_data, WCuplow_diff_TBL_LEN, "tblwuplow_diff");
+ out_uc(lso, __LOCALE_DATA_WCctype_data, __LOCALE_DATA_WCctype_TBL_LEN, "tblwctype");
+ out_uc(lso, __LOCALE_DATA_WCuplow_data, __LOCALE_DATA_WCuplow_TBL_LEN, "tblwuplow");
+ out_i16(lso, __LOCALE_DATA_WCuplow_diff_data, __LOCALE_DATA_WCuplow_diff_TBL_LEN, "tblwuplow_diff");
/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */
/* width?? */
#endif /* __WCHAR_ENABLED */
@@ -200,12 +204,12 @@ int main(void)
#ifdef __CTYPE_HAS_8_BIT_LOCALES
fprintf(lso, "{ /* codeset_8_bit array */\n");
- for (i = 0 ; i < NUM_CODESETS ; i++) {
+ for (i = 0 ; i < __LOCALE_DATA_NUM_CODESETS ; i++) {
fprintf(lso, "{ /* codeset_8_bit[%d] */\n", i);
- out_uc(lso, codeset_8_bit[i].idx8ctype, Cctype_IDX_LEN, "idx8ctype");
- out_uc(lso, codeset_8_bit[i].idx8uplow, Cuplow_IDX_LEN, "idx8uplow");
- out_uc(lso, codeset_8_bit[i].idx8c2wc, Cc2wc_IDX_LEN, "idx8c2wc");
- out_uc(lso, codeset_8_bit[i].idx8wc2c, Cwc2c_II_LEN, "idx8wc2c");
+ out_uc(lso, codeset_8_bit[i].idx8ctype, __LOCALE_DATA_Cctype_IDX_LEN, "idx8ctype");
+ out_uc(lso, codeset_8_bit[i].idx8uplow, __LOCALE_DATA_Cuplow_IDX_LEN, "idx8uplow");
+ out_uc(lso, codeset_8_bit[i].idx8c2wc, __LOCALE_DATA_Cc2wc_IDX_LEN, "idx8c2wc");
+ out_uc(lso, codeset_8_bit[i].idx8wc2c, __LOCALE_DATA_Cwc2c_II_LEN, "idx8wc2c");
fprintf(lso, "},\n");
}
fprintf(lso, "},\n");
@@ -237,7 +241,7 @@ int main(void)
{
- unsigned char co_buf[CATEGORIES] = {
+ unsigned char co_buf[__LOCALE_DATA_CATEGORIES] = {
__lc_ctype_item_offsets_LEN,
__lc_numeric_item_offsets_LEN,
__lc_monetary_item_offsets_LEN,
@@ -245,26 +249,26 @@ int main(void)
0,
__lc_messages_item_offsets_LEN
};
- out_uc(lso, co_buf, CATEGORIES, "lc_common_item_offsets_LEN");
+ out_uc(lso, co_buf, __LOCALE_DATA_CATEGORIES, "lc_common_item_offsets_LEN");
}
- out_size_t(lso, common_tbl_offsets, CATEGORIES * 4, "lc_common_tbl_offsets");
+ out_size_t(lso, common_tbl_offsets, __LOCALE_DATA_CATEGORIES * 4, "lc_common_tbl_offsets");
/* offsets from start of locale_mmap_t */
/* rows, item_offsets, item_idx, data */
-#ifdef NUM_LOCALES
- out_uc(lso, __locales, NUM_LOCALES * WIDTH_LOCALES, "locales");
- out_uc(lso, __locale_names5, 5 * NUM_LOCALE_NAMES, "locale_names5");
-#ifdef LOCALE_AT_MODIFIERS_LENGTH
- out_uc(lso, __locale_at_modifiers, LOCALE_AT_MODIFIERS_LENGTH, "locale_at_modifiers");
+#ifdef __LOCALE_DATA_NUM_LOCALES
+ out_uc(lso, __locales, __LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES, "locales");
+ out_uc(lso, __locale_names5, 5 * __LOCALE_DATA_NUM_LOCALE_NAMES, "locale_names5");
+#ifdef __LOCALE_DATA_AT_MODIFIERS_LENGTH
+ out_uc(lso, __locale_at_modifiers, __LOCALE_DATA_AT_MODIFIERS_LENGTH, "locale_at_modifiers");
#else
-#error LOCALE_AT_MODIFIERS_LENGTH not defined!
-#endif /* LOCALE_AT_MODIFIERS_LENGTH */
-#endif /* NUM_LOCALES */
+#error __LOCALE_DATA_AT_MODIFIERS_LENGTH not defined!
+#endif /* __LOCALE_DATA_AT_MODIFIERS_LENGTH */
+#endif /* __LOCALE_DATA_NUM_LOCALES */
- out_uc(lso, lc_names, lc_names_LEN, "lc_names");
+ out_uc(lso, lc_names, __lc_names_LEN, "lc_names");
#ifdef __CTYPE_HAS_8_BIT_LOCALES
- out_uc(lso, (const unsigned char*) CODESET_LIST, sizeof(CODESET_LIST), "codeset_list");
+ out_uc(lso, (const unsigned char*) __LOCALE_DATA_CODESET_LIST, sizeof(__LOCALE_DATA_CODESET_LIST), "codeset_list");
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
fprintf(lso,
diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c
index 1d50480ee..388f543c5 100644
--- a/extra/locale/gen_locale.c
+++ b/extra/locale/gen_locale.c
@@ -13,7 +13,7 @@
#include "c8tables.h"
-#define CATEGORIES 6
+#define __LOCALE_DATA_CATEGORIES 6
/* must agree with ordering of gen_mmap! */
static const unsigned char *lc_names[] = {
@@ -23,15 +23,15 @@ static const unsigned char *lc_names[] = {
"LC_TIME",
"LC_COLLATE",
"LC_MESSAGES",
-#if CATEGORIES == 12
+#if __LOCALE_DATA_CATEGORIES == 12
"LC_PAPER",
"LC_NAME",
"LC_ADDRESS",
"LC_TELEPHONE",
"LC_MEASUREMENT",
"LC_IDENTIFICATION",
-#elif CATEGORIES != 6
-#error unsupported CATEGORIES value!
+#elif __LOCALE_DATA_CATEGORIES != 6
+#error unsupported __LOCALE_DATA_CATEGORIES value!
#endif
};
@@ -48,8 +48,8 @@ typedef struct {
unsigned char lc_monetary_row;
unsigned char lc_messages_row;
unsigned char lc_ctype_row;
-#if CATEGORIES != 6
-#error unsupported CATEGORIES value
+#if __LOCALE_DATA_CATEGORIES != 6
+#error unsupported __LOCALE_DATA_CATEGORIES value
#endif
} locale_entry;
@@ -99,17 +99,17 @@ static void do_locale_names(void)
if (num_locales <= 1) {
/* printf("error - only C locale?\n"); */
/* exit(EXIT_FAILURE); */
- fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + CATEGORIES));
+ fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES));
fprintf(ofp, "static const unsigned char __locale_names5[5];\n");
} else {
if (default_utf8) {
fprintf(ofp, "#define __CTYPE_HAS_UTF_8_LOCALES\t\t\t1\n");
}
- fprintf(ofp, "#define CATEGORIES\t\t\t%d\n", CATEGORIES);
- fprintf(ofp, "#define WIDTH_LOCALES\t\t\t%d\n", 3+CATEGORIES);
- fprintf(ofp, "#define NUM_LOCALES\t\t\t%d\n", num_locales);
+ fprintf(ofp, "#define __LOCALE_DATA_CATEGORIES\t\t\t%d\n", __LOCALE_DATA_CATEGORIES);
+ fprintf(ofp, "#define __LOCALE_DATA_WIDTH_LOCALES\t\t\t%d\n", 3+__LOCALE_DATA_CATEGORIES);
+ fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALES\t\t\t%d\n", num_locales);
fprintf(ofp, "static const unsigned char __locales[%d] = {\n",
- (num_locales) * (3 + CATEGORIES));
+ (num_locales) * (3 + __LOCALE_DATA_CATEGORIES));
for (i=0 ; i < num_locales ; i++) {
if (memcmp(locales[i].name, locales[i-1].name, 5) != 0) {
locales[i].idx_name = uniq;
@@ -143,7 +143,7 @@ static void do_locale_names(void)
}
fprintf(ofp, "};\n\n");
- fprintf(ofp, "#define NUM_LOCALE_NAMES\t\t%d\n", uniq );
+ fprintf(ofp, "#define __LOCALE_DATA_NUM_LOCALE_NAMES\t\t%d\n", uniq );
fprintf(ofp, "static const unsigned char __locale_names5[%d] = \n\t", uniq * 5);
uniq = 0;
for (i=1 ; i < num_locales ; i++) {
@@ -167,7 +167,7 @@ static void do_locale_names(void)
p += 1 + (unsigned char) *p;
}
/* len, char, string\0 */
- fprintf(ofp, "#define LOCALE_AT_MODIFIERS_LENGTH\t\t%d\n",
+ fprintf(ofp, "#define __LOCALE_DATA_AT_MODIFIERS_LENGTH\t\t%d\n",
i + (at_strings_end - at_strings));
fprintf(ofp, "static const unsigned char __locale_at_modifiers[%d] = {",
i + (at_strings_end - at_strings));
@@ -188,41 +188,41 @@ static void do_locale_names(void)
}
{
- int pos[CATEGORIES];
- pos[0] = CATEGORIES;
- for (i=0 ; i < CATEGORIES ; i++) {
+ int pos[__LOCALE_DATA_CATEGORIES];
+ pos[0] = __LOCALE_DATA_CATEGORIES;
+ for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) {
fprintf(ofp, "#define __%s\t\t%d\n", lc_names[i], i);
- if (i + 1 < CATEGORIES) {
+ if (i + 1 < __LOCALE_DATA_CATEGORIES) {
pos[i+1] = 1 + strlen(lc_names[i]) + pos[i];
}
}
- if (pos[CATEGORIES-1] > 255) {
- printf("error - lc_names is too big (%d)\n", pos[CATEGORIES-1]);
+ if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) {
+ printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]);
exit(EXIT_FAILURE);
}
fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i);
- fprintf(ofp, "#define lc_names_LEN\t\t%d\n",
- pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1);
- total_size += pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1;
+ fprintf(ofp, "#define __lc_names_LEN\t\t%d\n",
+ pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1);
+ total_size += pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1;
fprintf(ofp, "static unsigned const char lc_names[%d] =\n",
- pos[CATEGORIES-1] + strlen(lc_names[CATEGORIES-1]) + 1);
+ pos[__LOCALE_DATA_CATEGORIES-1] + strlen(lc_names[__LOCALE_DATA_CATEGORIES-1]) + 1);
fprintf(ofp, "\t\"");
- for (i=0 ; i < CATEGORIES ; i++) {
+ for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) {
fprintf(ofp, "\\x%02x", (unsigned char) pos[i]);
}
fprintf(ofp, "\"");
- for (i=0 ; i < CATEGORIES ; i++) {
+ for (i=0 ; i < __LOCALE_DATA_CATEGORIES ; i++) {
fprintf(ofp, "\n\t\"%s\\0\"", lc_names[i]);
}
fprintf(ofp, ";\n\n");
}
printf("locale data = %d name data = %d for %d uniq\n",
- num_locales * (3 + CATEGORIES), uniq * 5, uniq);
+ num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq);
- total_size += num_locales * (3 + CATEGORIES) + uniq * 5;
+ total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5;
}
}
@@ -343,19 +343,19 @@ static void read_enable_disable(void)
} while (1);
}
-#ifdef CODESET_LIST
+#ifdef __LOCALE_DATA_CODESET_LIST
static int find_codeset_num(const char *cs)
{
int r = 2;
- char *s = CODESET_LIST;
+ char *s = __LOCALE_DATA_CODESET_LIST;
/* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */
if (strcmp(cs, "UTF-8") != 0) {
++r;
- while (*s && strcmp(CODESET_LIST+ ((unsigned char) *s), cs)) {
-/* printf("tried %s\n", CODESET_LIST + ((unsigned char) *s)); */
+ while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) {
+/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */
++r;
++s;
}
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index 0c39d0f12..75054667a 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -111,8 +111,8 @@ int main(int argc, char **argv)
fprintf(out, "#endif\n");
fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define NUM_CODESETS\t\t0\n");
- fprintf(out, "#define CODESET_LIST\t\t\"\"\n");
+ fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
fclose(out);
return EXIT_SUCCESS;
}
@@ -124,30 +124,30 @@ int main(int argc, char **argv)
if (argc == 1) {
fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define NUM_CODESETS\t\t0\n");
- fprintf(out, "#define CODESET_LIST\t\t\"\"\n");
+ fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
} else {
fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n");
}
- fprintf(out, "#define Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
- fprintf(out, "#define Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
+ fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
#ifdef CTYPE_PACKED
- fprintf(out, "#define Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
- fprintf(out, "#define Cctype_PACKED\t\t1\n");
+ fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
+ fprintf(out, "#define __LOCALE_DATA_Cctype_PACKED\t\t1\n");
#else
- fprintf(out, "#define Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
- fprintf(out, "#undef Cctype_PACKED\n");
+ fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
+ fprintf(out, "#undef __LOCALE_DATA_Cctype_PACKED\n");
#endif
- fprintf(out, "\n#define Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
- fprintf(out, "#define Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
- fprintf(out, "#define Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
+ fprintf(out, "\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
+ fprintf(out, "#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
- fprintf(out, "#define Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
- fprintf(out, "#define Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
+ fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
+ fprintf(out, "#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
#endif
fprintf(out, "\ntypedef struct {\n");
@@ -157,10 +157,10 @@ int main(int argc, char **argv)
fprintf(out, "\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN);
fprintf(out, "\tunsigned char idx8wc2c[%d];\n", II_LEN);
#endif
- fprintf(out, "} codeset_8_bit_t;\n\n");
+ fprintf(out, "} __codeset_8_bit_t;\n\n");
fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
+ fprintf(out, "static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
max_wchar = 0x7f;
numsets = 0;
@@ -514,19 +514,19 @@ int main(int argc, char **argv)
#ifdef DO_WIDE_CHAR
fprintf(out, "\n");
- fprintf(out, "#define Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
- fprintf(out, "#define Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
- fprintf(out, "#define Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
- fprintf(out, "#define Cwc2c_II_LEN\t\t%d\n", II_LEN);
- fprintf(out, "#define Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
- fprintf(out, "#define Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
+ fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
fprintf(out, "\n");
- fprintf(out, "\n#define Cwc2c_TBL_LEN\t\t%d\n",
+ fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const unsigned char Cwc2c_data[%d] = {\n",
+ fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
fprintf(out, "\t/* ti_table */\n\t");
for (i=0 ; i < ti_num << TI_SHIFT ; i++) {
@@ -548,11 +548,11 @@ int main(int argc, char **argv)
fprintf(out, "\n#endif /* WANT_DATA */\n");
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\n#define Cuplow_TBL_LEN\t\t%d\n",
+ fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",
n_uplow_rows * UPLOW_ROW_LEN);
fprintf(out, "\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char Cuplow_data[%d] = {\n",
+ fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",
n_uplow_rows * UPLOW_ROW_LEN);
p = uplow_tbl;
for (j=0 ; j < n_uplow_rows ; j++) {
@@ -566,7 +566,7 @@ int main(int argc, char **argv)
fprintf(out, "};\n");
fprintf(out, "\n#endif /* WANT_DATA */\n");
- fprintf(out, "\n#define Cctype_TBL_LEN\t\t%d\n",
+ fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
@@ -576,7 +576,7 @@ int main(int argc, char **argv)
fprintf(out, "\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char Cctype_data[%d] = {\n",
+ fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
@@ -603,11 +603,11 @@ int main(int argc, char **argv)
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define Cc2wc_TBL_LEN\t\t%d\n",
+ fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",
n_c2wc_rows * C2WC_ROW_LEN);
fprintf(out, "\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned short Cc2wc_data[%d] = {\n",
+ fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",
n_c2wc_rows * C2WC_ROW_LEN);
p = (char *) c2wc_tbl;
for (j=0 ; j < n_c2wc_rows ; j++) {
@@ -623,8 +623,8 @@ int main(int argc, char **argv)
#endif /* DO_WIDE_CHAR */
fprintf(out, "\n\n");
- fprintf(out, "#define NUM_CODESETS\t\t%d\n", numsets);
- fprintf(out, "#define CODESET_LIST \\\n\t\"");
+ fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);
+ fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");
for (i=0 ; i < numsets ; i++) {
fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);
if (((i & 7) == 7) && (i + 1 < numsets)) {
diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c
index 1c8c10c43..a9bcf614b 100644
--- a/extra/locale/gen_wctype.c
+++ b/extra/locale/gen_wctype.c
@@ -159,17 +159,17 @@ void output_table(FILE *fp, const char *name, table_data *tbl)
{
size_t i;
- fprintf(fp, "#define WC%s_II_LEN %7u\n", name, tbl->ii_len);
- fprintf(fp, "#define WC%s_TI_LEN %7u\n", name, tbl->ti_len);
- fprintf(fp, "#define WC%s_UT_LEN %7u\n", name, tbl->ut_len);
+ fprintf(fp, "#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len);
+ fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len);
+ fprintf(fp, "#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len);
- fprintf(fp, "#define WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
- fprintf(fp, "#define WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
+ fprintf(fp, "#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
+ fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
fprintf(fp, "\n#ifdef WANT_WC%s_data\n", name);
i = tbl->ii_len + tbl->ti_len + tbl->ut_len;
- fprintf(fp, "\nstatic const unsigned char WC%s_data[%zu] = {", name, i);
+ fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
for (i=0 ; i < tbl->ii_len ; i++) {
if (i % 12 == 0) {
fprintf(fp, "\n");
@@ -730,16 +730,16 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- fprintf(fp, "#define WC_TABLE_DOMAIN_MAX %#8lx\n\n",
+ fprintf(fp, "#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
(unsigned long) RANGE);
output_table(fp, "ctype", &cttable);
output_table(fp, "uplow", &ultable);
#warning fix the upper bound on the upper/lower tables... save 200 bytes or so
- fprintf(fp, "#define WCuplow_diffs %7u\n", ul_count);
+ fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n");
- fprintf(fp, "\nstatic const short WCuplow_diff_data[%zu] = {",
+ fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
2 * (size_t) ul_count);
for (i=0 ; i < ul_count ; i++) {
if (i % 4 == 0) {
diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h
index 12c4025e1..1b748239b 100644
--- a/extra/locale/locale_mmap.h
+++ b/extra/locale/locale_mmap.h
@@ -1,13 +1,16 @@
-/* #include "lt_defines.h" */
-
-/* TODO - fix */
-#define MAGIC_SIZE 64
+/* #define __LOCALE_DATA_MAGIC_SIZE 64 */
+#ifndef __WCHAR_ENABLED
+#if 0
+#warning WHOA!!! __WCHAR_ENABLED is not defined! defining it now...
+#endif
+#define __WCHAR_ENABLED
+#endif
/* TODO - fix */
#ifdef __WCHAR_ENABLED
-#define WCctype_TBL_LEN (WCctype_II_LEN + WCctype_TI_LEN + WCctype_UT_LEN)
-#define WCuplow_TBL_LEN (WCuplow_II_LEN + WCuplow_TI_LEN + WCuplow_UT_LEN)
-#define WCuplow_diff_TBL_LEN (2 * WCuplow_diffs)
+#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
+#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
+#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs)
/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
#endif
@@ -16,70 +19,72 @@
#undef __PASTE3
#define __PASTE3(A,B,C) A ## B ## C
-#define COMMON_MMAP(X) \
+#define __LOCALE_DATA_COMMON_MMAP(X) \
unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
-#define COMMON_MMIDX(X) \
+#define __LOCALE_DATA_COMMON_MMIDX(X) \
unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
typedef struct {
- unsigned char magic[MAGIC_SIZE];
+#ifdef __LOCALE_DATA_MAGIC_SIZE
+ unsigned char magic[__LOCALE_DATA_MAGIC_SIZE];
+#endif /* __LOCALE_DATA_MAGIC_SIZE */
#ifdef __CTYPE_HAS_8_BIT_LOCALES
- const unsigned char tbl8ctype[Cctype_TBL_LEN];
- const unsigned char tbl8uplow[Cuplow_TBL_LEN];
+ const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN];
+ const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
#ifdef __WCHAR_ENABLED
- const uint16_t tbl8c2wc[Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */
- const unsigned char tbl8wc2c[Cwc2c_TBL_LEN];
+ const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */
+ const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN];
/* translit */
#endif /* __WCHAR_ENABLED */
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
#ifdef __WCHAR_ENABLED
- const unsigned char tblwctype[WCctype_TBL_LEN];
- const unsigned char tblwuplow[WCuplow_TBL_LEN];
- const int16_t tblwuplow_diff[WCuplow_diff_TBL_LEN];
+ const unsigned char tblwctype[__LOCALE_DATA_WCctype_TBL_LEN];
+ const unsigned char tblwuplow[__LOCALE_DATA_WCuplow_TBL_LEN];
+ const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN];
/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */
/* width?? */
#endif /* __WCHAR_ENABLED */
- COMMON_MMAP(ctype);
- COMMON_MMAP(numeric);
- COMMON_MMAP(monetary);
- COMMON_MMAP(time);
+ __LOCALE_DATA_COMMON_MMAP(ctype);
+ __LOCALE_DATA_COMMON_MMAP(numeric);
+ __LOCALE_DATA_COMMON_MMAP(monetary);
+ __LOCALE_DATA_COMMON_MMAP(time);
/* collate is different */
- COMMON_MMAP(messages);
+ __LOCALE_DATA_COMMON_MMAP(messages);
#ifdef __CTYPE_HAS_8_BIT_LOCALES
- const codeset_8_bit_t codeset_8_bit[NUM_CODESETS];
+ const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS];
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
- COMMON_MMIDX(ctype);
- COMMON_MMIDX(numeric);
- COMMON_MMIDX(monetary);
- COMMON_MMIDX(time);
+ __LOCALE_DATA_COMMON_MMIDX(ctype);
+ __LOCALE_DATA_COMMON_MMIDX(numeric);
+ __LOCALE_DATA_COMMON_MMIDX(monetary);
+ __LOCALE_DATA_COMMON_MMIDX(time);
/* collate is different */
- COMMON_MMIDX(messages);
+ __LOCALE_DATA_COMMON_MMIDX(messages);
const uint16_t collate_data[__lc_collate_data_LEN];
- unsigned char lc_common_item_offsets_LEN[CATEGORIES];
- size_t lc_common_tbl_offsets[CATEGORIES * 4];
+ unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES];
+ size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
/* offsets from start of locale_mmap_t */
/* rows, item_offsets, item_idx, data */
-#ifdef NUM_LOCALES
- unsigned char locales[NUM_LOCALES * WIDTH_LOCALES];
- unsigned char locale_names5[5*NUM_LOCALE_NAMES];
- unsigned char locale_at_modifiers[LOCALE_AT_MODIFIERS_LENGTH];
-#endif /* NUM_LOCALES */
+#ifdef __LOCALE_DATA_NUM_LOCALES
+ unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES];
+ unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES];
+ unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH];
+#endif /* __LOCALE_DATA_NUM_LOCALES */
- unsigned char lc_names[lc_names_LEN];
+ unsigned char lc_names[__lc_names_LEN];
#ifdef __CTYPE_HAS_8_BIT_LOCALES
- unsigned char codeset_list[sizeof(CODESET_LIST)]; /* TODO - fix */
+ unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */
#endif /* __CTYPE_HAS_8_BIT_LOCALES */