diff options
author | Roland McGrath <roland@gnu.org> | 1995-02-18 01:27:10 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1995-02-18 01:27:10 +0000 |
commit | 28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch) | |
tree | 15f07c4c43d635959c6afee96bde71fb1b3614ee /locale | |
download | glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.bz2 |
initial import
Diffstat (limited to 'locale')
-rw-r--r-- | locale/.cvsignore | 4 | ||||
-rw-r--r-- | locale/C-collate.c | 7 | ||||
-rw-r--r-- | locale/C-ctype.c | 14 | ||||
-rw-r--r-- | locale/C-ctype_ct.c | 793 | ||||
-rw-r--r-- | locale/C-ctype_mb.c | 9 | ||||
-rw-r--r-- | locale/C-monetary.c | 22 | ||||
-rw-r--r-- | locale/C-numeric.c | 12 | ||||
-rw-r--r-- | locale/C-response.c | 12 | ||||
-rw-r--r-- | locale/C-time.c | 25 | ||||
-rw-r--r-- | locale/Makefile | 31 | ||||
-rw-r--r-- | locale/locale.h | 97 | ||||
-rw-r--r-- | locale/localeconv.c | 51 | ||||
-rw-r--r-- | locale/localeinfo.h | 208 | ||||
-rw-r--r-- | locale/setlocale.c | 45 |
14 files changed, 1330 insertions, 0 deletions
diff --git a/locale/.cvsignore b/locale/.cvsignore new file mode 100644 index 0000000..1f69fd9 --- /dev/null +++ b/locale/.cvsignore @@ -0,0 +1,4 @@ +*.gz *.Z *.tar *.tgz +=* +TODO COPYING* AUTHORS copyr-* copying.* +glibc-* diff --git a/locale/C-collate.c b/locale/C-collate.c new file mode 100644 index 0000000..eddcafa --- /dev/null +++ b/locale/C-collate.c @@ -0,0 +1,7 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct collate_info __collate_C = { 0, NULL, NULL, NULL }; +CONST struct collate_info *_collate_info = &__collate_C; diff --git a/locale/C-ctype.c b/locale/C-ctype.c new file mode 100644 index 0000000..7131a6f --- /dev/null +++ b/locale/C-ctype.c @@ -0,0 +1,14 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +extern CONST struct ctype_ctype_info __ctype_ctype_C; +extern CONST struct ctype_mbchar_info __ctype_mbchar_C; +CONST struct ctype_info __ctype_C = + { + (struct ctype_ctype_info*)&__ctype_ctype_C, + (struct ctype_mbchar_info*) &__ctype_mbchar_C + }; + +CONST struct ctype_info *_ctype_info = &__ctype_C; diff --git a/locale/C-ctype_ct.c b/locale/C-ctype_ct.c new file mode 100644 index 0000000..b77e809 --- /dev/null +++ b/locale/C-ctype_ct.c @@ -0,0 +1,793 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> +#include <ctype.h> + +CONST unsigned short int __ctype_b_C[] = + { + 0, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl|_ISspace|_ISblank, + _IScntrl|_ISspace, + _IScntrl|_ISspace, + _IScntrl|_ISspace, + _IScntrl|_ISspace, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _ISspace|_NOgraph|_ISblank, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISdigit|_IShex, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper|_IShex, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISalpha|_ISupper, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower|_IShex, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISalpha|_ISlower, + _ISpunct, + _ISpunct, + _ISpunct, + _ISpunct, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + _IScntrl, + }; +CONST short int __ctype_tolower_C[] = + { + -1, + 0000, + 0001, + 0002, + 0003, + 0004, + 0005, + 0006, + 0007, + 0010, + 0011, + 0012, + 0013, + 0014, + 0015, + 0016, + 0017, + 0020, + 0021, + 0022, + 0023, + 0024, + 0025, + 0026, + 0027, + 0030, + 0031, + 0032, + 0033, + 0034, + 0035, + 0036, + 0037, + 0040, + '!', + '"', + '#', + '$', + '%', + '&', + '\'', + '(', + ')', + '*', + '+', + ',', + '-', + '.', + '/', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + ':', + ';', + '<', + '=', + '>', + '?', + '@', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'o', + 'p', + 'q', + 'r', + 's', + 't', + 'u', + 'v', + 'w', + 'x', + 'y', + 'z', + '[', + '\\', + ']', + '^', + '_', + '`', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'o', + 'p', + 'q', + 'r', + 's', + 't', + 'u', + 'v', + 'w', + 'x', + 'y', + 'z', + '{', + '|', + '}', + '~', + 0177, + 0200, + 0201, + 0202, + 0203, + 0204, + 0205, + 0206, + 0207, + 0210, + 0211, + 0212, + 0213, + 0214, + 0215, + 0216, + 0217, + 0220, + 0221, + 0222, + 0223, + 0224, + 0225, + 0226, + 0227, + 0230, + 0231, + 0232, + 0233, + 0234, + 0235, + 0236, + 0237, + 0240, + 0241, + 0242, + 0243, + 0244, + 0245, + 0246, + 0247, + 0250, + 0251, + 0252, + 0253, + 0254, + 0255, + 0256, + 0257, + 0260, + 0261, + 0262, + 0263, + 0264, + 0265, + 0266, + 0267, + 0270, + 0271, + 0272, + 0273, + 0274, + 0275, + 0276, + 0277, + 0300, + 0301, + 0302, + 0303, + 0304, + 0305, + 0306, + 0307, + 0310, + 0311, + 0312, + 0313, + 0314, + 0315, + 0316, + 0317, + 0320, + 0321, + 0322, + 0323, + 0324, + 0325, + 0326, + 0327, + 0330, + 0331, + 0332, + 0333, + 0334, + 0335, + 0336, + 0337, + 0340, + 0341, + 0342, + 0343, + 0344, + 0345, + 0346, + 0347, + 0350, + 0351, + 0352, + 0353, + 0354, + 0355, + 0356, + 0357, + 0360, + 0361, + 0362, + 0363, + 0364, + 0365, + 0366, + 0367, + 0370, + 0371, + 0372, + 0373, + 0374, + 0375, + 0376, + 0377, + }; +CONST short int __ctype_toupper_C[] = + { + -1, + 0000, + 0001, + 0002, + 0003, + 0004, + 0005, + 0006, + 0007, + 0010, + 0011, + 0012, + 0013, + 0014, + 0015, + 0016, + 0017, + 0020, + 0021, + 0022, + 0023, + 0024, + 0025, + 0026, + 0027, + 0030, + 0031, + 0032, + 0033, + 0034, + 0035, + 0036, + 0037, + 0040, + '!', + '"', + '#', + '$', + '%', + '&', + '\'', + '(', + ')', + '*', + '+', + ',', + '-', + '.', + '/', + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + ':', + ';', + '<', + '=', + '>', + '?', + '@', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + '[', + '\\', + ']', + '^', + '_', + '`', + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + '{', + '|', + '}', + '~', + 0177, + 0200, + 0201, + 0202, + 0203, + 0204, + 0205, + 0206, + 0207, + 0210, + 0211, + 0212, + 0213, + 0214, + 0215, + 0216, + 0217, + 0220, + 0221, + 0222, + 0223, + 0224, + 0225, + 0226, + 0227, + 0230, + 0231, + 0232, + 0233, + 0234, + 0235, + 0236, + 0237, + 0240, + 0241, + 0242, + 0243, + 0244, + 0245, + 0246, + 0247, + 0250, + 0251, + 0252, + 0253, + 0254, + 0255, + 0256, + 0257, + 0260, + 0261, + 0262, + 0263, + 0264, + 0265, + 0266, + 0267, + 0270, + 0271, + 0272, + 0273, + 0274, + 0275, + 0276, + 0277, + 0300, + 0301, + 0302, + 0303, + 0304, + 0305, + 0306, + 0307, + 0310, + 0311, + 0312, + 0313, + 0314, + 0315, + 0316, + 0317, + 0320, + 0321, + 0322, + 0323, + 0324, + 0325, + 0326, + 0327, + 0330, + 0331, + 0332, + 0333, + 0334, + 0335, + 0336, + 0337, + 0340, + 0341, + 0342, + 0343, + 0344, + 0345, + 0346, + 0347, + 0350, + 0351, + 0352, + 0353, + 0354, + 0355, + 0356, + 0357, + 0360, + 0361, + 0362, + 0363, + 0364, + 0365, + 0366, + 0367, + 0370, + 0371, + 0372, + 0373, + 0374, + 0375, + 0376, + 0377, + }; + + +CONST struct ctype_ctype_info __ctype_ctype_C = + { + (unsigned short int *) __ctype_b_C, + (short int *) __ctype_tolower_C, + (short int *) __ctype_toupper_C + }; diff --git a/locale/C-ctype_mb.c b/locale/C-ctype_mb.c new file mode 100644 index 0000000..fb2309a --- /dev/null +++ b/locale/C-ctype_mb.c @@ -0,0 +1,9 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct ctype_mbchar_info __ctype_mbchar_C = + { + 0, NULL + }; diff --git a/locale/C-monetary.c b/locale/C-monetary.c new file mode 100644 index 0000000..1e5990f --- /dev/null +++ b/locale/C-monetary.c @@ -0,0 +1,22 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct monetary_info __monetary_C = + { + (char *) "", (char *) "", + (char *) "", (char *) "", + (char *) "", + (char *) "", (char *) "", + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX + }; + +CONST struct monetary_info *_monetary_info = &__monetary_C; diff --git a/locale/C-numeric.c b/locale/C-numeric.c new file mode 100644 index 0000000..890ab37 --- /dev/null +++ b/locale/C-numeric.c @@ -0,0 +1,12 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct numeric_info __numeric_C = + { + (char *) ".", (char *) "", + (char *) "" + }; + +CONST struct numeric_info *_numeric_info = &__numeric_C; diff --git a/locale/C-response.c b/locale/C-response.c new file mode 100644 index 0000000..d823886 --- /dev/null +++ b/locale/C-response.c @@ -0,0 +1,12 @@ +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct response_info __response_C = + { + (char *) "[yY][[:alpha:]]", + (char *) "[nN][[:alpha:]]" + }; + +CONST struct response_info *_response_info = &__response_C; diff --git a/locale/C-time.c b/locale/C-time.c new file mode 100644 index 0000000..4393061 --- /dev/null +++ b/locale/C-time.c @@ -0,0 +1,25 @@ +/* Built-in time information for `C' locale, + generated Thu Jan 1 00:00:00 1970 by li2c. */ + +#include <ansidecl.h> +#include <localeinfo.h> +#include <stddef.h> + + +CONST struct time_info __time_C = + { + { +(char *) "Sun", (char *) "Mon", (char *) "Tue", (char *) "Wed", (char *) "Thu", (char *) "Fri", (char *) "Sat", }, + + { +(char *) "Sunday", (char *) "Monday", (char *) "Tuesday", (char *) "Wednesday", (char *) "Thursday", (char *) "Friday", (char *) "Saturday", }, + { +(char *) "Jan", (char *) "Feb", (char *) "Mar", (char *) "Apr", (char *) "May", (char *) "Jun", (char *) "Jul", (char *) "Aug", (char *) "Sep", (char *) "Oct", (char *) "Nov", (char *) "Dec", }, + { +(char *) "January", (char *) "February", (char *) "March", (char *) "April", (char *) "May", (char *) "June", (char *) "July", (char *) "August", (char *) "September", (char *) "October", (char *) "November", (char *) "December", }, + { (char *) "AM", (char *) "PM" }, + (char *) "%a %b %d %H:%M:%S %Y", (char *) "%m/%d/%y", (char *) "%H:%M:%S", + (char *) "GMT", (char *) "" + }; + +CONST struct time_info *_time_info = &__time_C; diff --git a/locale/Makefile b/locale/Makefile new file mode 100644 index 0000000..630b960 --- /dev/null +++ b/locale/Makefile @@ -0,0 +1,31 @@ +# Copyright (C) 1991, 1992 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 Library General Public License as +# published by the Free Software Foundation; either version 2 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If +# not, write to the Free Software Foundation, Inc., 675 Mass Ave, +# Cambridge, MA 02139, USA. + +# +# Makefile for locales. +# +subdir := locale + +headers := locale.h localeinfo.h + +routines := setlocale localeconv +aux := C-collate C-ctype C-ctype_ct C-ctype_mb \ + C-monetary C-numeric C-response C-time + + +include ../Rules diff --git a/locale/locale.h b/locale/locale.h new file mode 100644 index 0000000..80f9f90 --- /dev/null +++ b/locale/locale.h @@ -0,0 +1,97 @@ +/* Copyright (C) 1991, 1992 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* + * ANSI Standard: 4.4 LOCALIZATION <locale.h> + */ + +#ifndef _LOCALE_H + +#define _LOCALE_H 1 +#include <features.h> + +__BEGIN_DECLS + +/* These are the possibilities for the first argument to setlocale. + Note that although they are bit masks, they cannot be OR'd together + to form a new argument to pass. They must be used one at a time. */ +#define LC_COLLATE (1 << 0) +#define LC_CTYPE (1 << 1) +#define LC_MONETARY (1 << 2) +#define LC_NUMERIC (1 << 3) +#define LC_TIME (1 << 4) +#define LC_RESPONSE (1 << 5) +#define LC_ALL (LC_COLLATE|LC_CTYPE|LC_MONETARY|LC_NUMERIC|LC_TIME|\ + LC_RESPONSE) + + +/* Structure giving information about numeric and monetary notation. */ +struct lconv +{ + /* Numeric (non-monetary) information. */ + + char *decimal_point; /* Decimal point character. */ + char *thousands_sep; /* Thousands separator. */ + /* Each element is the number of digits in each group; + elements with higher indices are farther left. + An element with value CHAR_MAX means that no further grouping is done. + An element with value 0 means that the previous element is used + for all groups farther left. */ + char *grouping; + + /* Monetary information. */ + + /* First three chars are a currency symbol from ISO 4217. + Fourth char is the separator. Fifth char is '\0'. */ + char *int_curr_symbol; + char *currency_symbol; /* Local currency symbol. */ + char *mon_decimal_point; /* Decimal point character. */ + char *mon_thousands_sep; /* Thousands separator. */ + char *mon_grouping; /* Like `grouping' element (above). */ + char *positive_sign; /* Sign for positive values. */ + char *negative_sign; /* Sign for negative values. */ + char int_frac_digits; /* Int'l fractional digits. */ + char frac_digits; /* Local fractional digits. */ + /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ + char p_cs_precedes; + /* 1 iff a space separates currency_symbol from a positive value. */ + char p_sep_by_space; + /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ + char n_cs_precedes; + /* 1 iff a space separates currency_symbol from a negative value. */ + char n_sep_by_space; + /* Positive and negative sign positions: + 0 Parentheses surround the quantity and currency_symbol. + 1 The sign string precedes the quantity and currency_symbol. + 2 The sign string succedes the quantity and currency_symbol. + 3 The sign string immediately precedes the currency_symbol. + 4 The sign string immediately succedes the currency_symbol. */ + char p_sign_posn; + char n_sign_posn; +}; + + +/* Set and/or return the current locale. */ +extern char *setlocale __P ((int __category, __const char *__locale)); + +/* Return the numeric/monetary information for the current locale. */ +extern struct lconv *localeconv __P ((void)); + +__END_DECLS + +#endif /* locale.h */ diff --git a/locale/localeconv.c b/locale/localeconv.c new file mode 100644 index 0000000..1f15165 --- /dev/null +++ b/locale/localeconv.c @@ -0,0 +1,51 @@ +/* Copyright (C) 1991, 1992 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include <ansidecl.h> +#include <localeinfo.h> +#include <locale.h> + + +/* Return monetary and numeric information about the current locale. */ +struct lconv * +DEFUN_VOID(localeconv) +{ + static struct lconv result; + + result.decimal_point = (char *) _numeric_info->decimal_point; + result.thousands_sep = (char *) _numeric_info->thousands_sep; + result.grouping = (char *) _numeric_info->grouping; + + result.int_curr_symbol = (char *) _monetary_info->int_curr_symbol; + result.currency_symbol = (char *) _monetary_info->currency_symbol; + result.mon_decimal_point = (char *) _monetary_info->mon_decimal_point; + result.mon_thousands_sep = (char *) _monetary_info->mon_thousands_sep; + result.mon_grouping = (char *) _monetary_info->mon_grouping; + result.positive_sign = (char *) _monetary_info->positive_sign; + result.negative_sign = (char *) _monetary_info->negative_sign; + result.int_frac_digits = _monetary_info->int_frac_digits; + result.frac_digits = _monetary_info->frac_digits; + result.p_cs_precedes = _monetary_info->p_cs_precedes; + result.p_sep_by_space = _monetary_info->p_sep_by_space; + result.n_cs_precedes = _monetary_info->p_cs_precedes; + result.n_sep_by_space = _monetary_info->n_sep_by_space; + result.p_sign_posn = _monetary_info->p_sign_posn; + result.n_sign_posn = _monetary_info->n_sign_posn; + + return &result; +} diff --git a/locale/localeinfo.h b/locale/localeinfo.h new file mode 100644 index 0000000..5ba5fef --- /dev/null +++ b/locale/localeinfo.h @@ -0,0 +1,208 @@ +/* Copyright (C) 1991, 1992 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Locale-specific information. */ + +#ifndef _LOCALEINFO_H + +#define _LOCALEINFO_H 1 + +#define __need_size_t +#define __need_wchar_t +#include <stddef.h> +#include <limits.h> + + +/* Change these if the `wchar_t' type is changed. */ +#define WCHAR_MAX ((wchar_t) UCHAR_MAX) + + +/* Used by multibyte char functions. */ +typedef struct +{ + char *string; /* Bytes. */ + size_t len; /* # of bytes. */ + long int shift; /* # of mb_char's to shift. */ +} mb_char; + +struct ctype_mbchar_info +{ + size_t mb_max; /* Max MB char length. */ + mb_char *mb_chars; /* MB chars. */ +}; + +struct ctype_ctype_info +{ + unsigned short int *ctype_b; /* Characteristics. */ + short int *ctype_tolower; /* Case mappings. */ + short int *ctype_toupper; /* Case mappings. */ +}; + +struct ctype_info +{ + struct ctype_ctype_info *ctype; + struct ctype_mbchar_info *mbchar; +}; + +extern __const struct ctype_info *_ctype_info; + +/* These are necessary because they are used in a header file. */ +extern __const unsigned short int *__ctype_b; +extern __const short int *__ctype_tolower; +extern __const short int *__ctype_toupper; + + +/* Used by strcoll and strxfrm. */ +typedef struct +{ + unsigned char *values; + size_t nvalues; +} literal_value; + +typedef struct +{ + union + { + literal_value literal; + /* %%% This may become a regex_t in the future. */ + char *regexp; + } replace, with; + unsigned int regexp:1; +} subst; + +struct collate_info +{ + size_t nsubsts; + subst *substs; + + unsigned char *values; + unsigned char *offsets; +}; + +extern __const struct collate_info *_collate_info; + + +/* Used by strtod, atof. */ +struct numeric_info +{ + char *decimal_point; + char *thousands_sep; + char *grouping; +}; + +extern __const struct numeric_info *_numeric_info; + + +/* Used in the return value of localeconv. */ +struct monetary_info +{ + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +extern __const struct monetary_info *_monetary_info; + + +/* Used by strftime, asctime. */ +struct time_info +{ + char *abbrev_wkday[7]; /* Short weekday names. */ + char *full_wkday[7]; /* Full weekday names. */ + char *abbrev_month[12]; /* Short month names. */ + char *full_month[12]; /* Full month names. */ + char *ampm[2]; /* "AM" and "PM" strings. */ + + char *date_time; /* Appropriate date and time format. */ + char *date; /* Appropriate date format. */ + char *time; /* Appropriate time format. */ + + char *ut0; /* Name for GMT. */ + char *tz; /* Default TZ value. */ +}; + +extern __const struct time_info *_time_info; + +struct response_info +{ + /* Regexp for affirmative answers. */ + char *yesexpr; + + /* Regexp for negative answers. */ + char *noexpr; +}; + +extern __const struct response_info *_response_info; + +/* Locale structure. */ +typedef struct +{ + char *name; + int categories; + + unsigned int allocated:1; + + int subcategories; + size_t num_sublocales; + struct sub_locale *sublocales; + + __ptr_t *info; +} locale; + +typedef struct sub_locale +{ + unsigned int pointer:1; + + int categories; + char *name; + + locale *locale; +} sublocale; + + +/* This is the magic number that localeinfo object files begin with. + In case you're wondering why I chose the value 0x051472CA, it's + because I was born on 05-14-72 in Oakland, CA. */ +#define LIMAGIC 0x051472CA +/* This is the magic number that precedes each category-specific section + of a localeinfo object file. It's the arbitrary magic number above, + but modified by the category so that it's different from the per-file + magic number and unique for each category. */ +#define CATEGORY_MAGIC(x) (LIMAGIC ^ (x)) + +extern __const char *__lidir, *__lidefault; + +extern locale *__find_locale __P ((int categories, __const char *name)); +extern locale *__new_locale __P ((locale *)); +extern locale *__localefile __P ((__const char *file)); +extern void __free_locale __P ((locale *)); + + +#endif /* localeinfo.h */ diff --git a/locale/setlocale.c b/locale/setlocale.c new file mode 100644 index 0000000..784ccb1 --- /dev/null +++ b/locale/setlocale.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1991, 1992 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include <ansidecl.h> +#include <localeinfo.h> +#include <errno.h> +#include <locale.h> +#include <string.h> + + +/* Switch to the locale called NAME in CATEGORY. + Return a string describing the locale. This string can + be used as the NAME argument in a later call. + If NAME is NULL, don't switch locales, but return the current one. + If NAME is "", switch to a locale based on the environment variables, + as per POSIX. Return NULL on error. */ +char * +DEFUN(setlocale, (category, name), int category AND CONST char *name) +{ + /* Braindead implementation until I finish the fancy one. */ + + if (name == NULL || name[0] == '\0') + return (char *) "C"; + + if (!strcmp(name, "C") || !strcmp(name, "POSIX")) + return (char *) name; + + errno = EINVAL; + return NULL; +} |