From: solar Date: Wed, 29 Dec 2010 13:19:53 +0000 (+0000) Subject: Moved ctype info into struct lconv. X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=31bc073732a9303dd6f4813f0408cb2b9fcd0add Moved ctype info into struct lconv. --- diff --git a/functions/_PDCLIB/Readme.txt b/functions/_PDCLIB/Readme.txt old mode 100755 new mode 100644 diff --git a/functions/ctype/isalnum.c b/functions/ctype/isalnum.c index d6e217b..f4969fa 100644 --- a/functions/ctype/isalnum.c +++ b/functions/ctype/isalnum.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isalnum( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & ( _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT ) ); + return ( _PDCLIB_lconv.ctype[c].flags & ( _PDCLIB_CTYPE_ALPHA | _PDCLIB_CTYPE_DIGIT ) ); } #endif diff --git a/functions/ctype/isalpha.c b/functions/ctype/isalpha.c index 2bde755..9dad397 100644 --- a/functions/ctype/isalpha.c +++ b/functions/ctype/isalpha.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isalpha( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_ALPHA ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_ALPHA ); } #endif diff --git a/functions/ctype/isblank.c b/functions/ctype/isblank.c index 0ad1ca1..cc29fa8 100644 --- a/functions/ctype/isblank.c +++ b/functions/ctype/isblank.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isblank( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_BLANK ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_BLANK ); } #endif diff --git a/functions/ctype/iscntrl.c b/functions/ctype/iscntrl.c index 583ccb3..8c0a4f3 100644 --- a/functions/ctype/iscntrl.c +++ b/functions/ctype/iscntrl.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int iscntrl( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_CNTRL ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_CNTRL ); } #endif diff --git a/functions/ctype/isdigit.c b/functions/ctype/isdigit.c index eeeffb8..b122f7e 100644 --- a/functions/ctype/isdigit.c +++ b/functions/ctype/isdigit.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isdigit( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_DIGIT ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_DIGIT ); } #endif diff --git a/functions/ctype/isgraph.c b/functions/ctype/isgraph.c index b2cccc8..d623485 100644 --- a/functions/ctype/isgraph.c +++ b/functions/ctype/isgraph.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isgraph( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_GRAPH ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_GRAPH ); } #endif diff --git a/functions/ctype/islower.c b/functions/ctype/islower.c index d98069a..db0649d 100644 --- a/functions/ctype/islower.c +++ b/functions/ctype/islower.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int islower( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_LOWER ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_LOWER ); } #endif diff --git a/functions/ctype/isprint.c b/functions/ctype/isprint.c index f057e00..50b0ad8 100644 --- a/functions/ctype/isprint.c +++ b/functions/ctype/isprint.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isprint( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_GRAPH ) || ( c == ' ' ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_GRAPH ) || ( c == ' ' ); } #endif diff --git a/functions/ctype/ispunct.c b/functions/ctype/ispunct.c index 2859efc..4dfd52a 100644 --- a/functions/ctype/ispunct.c +++ b/functions/ctype/ispunct.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int ispunct( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_PUNCT ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_PUNCT ); } #endif diff --git a/functions/ctype/isspace.c b/functions/ctype/isspace.c index 90b6dc5..b443f6f 100644 --- a/functions/ctype/isspace.c +++ b/functions/ctype/isspace.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isspace( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_SPACE ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_SPACE ); } #endif diff --git a/functions/ctype/isupper.c b/functions/ctype/isupper.c index 76c1ff1..5953946 100644 --- a/functions/ctype/isupper.c +++ b/functions/ctype/isupper.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isupper( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_UPPER ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_UPPER ); } #endif diff --git a/functions/ctype/isxdigit.c b/functions/ctype/isxdigit.c index 55818df..7f5dfec 100644 --- a/functions/ctype/isxdigit.c +++ b/functions/ctype/isxdigit.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int isxdigit( int c ) { - return ( _PDCLIB_locale_info.ctype[c].flags & _PDCLIB_CTYPE_XDIGT ); + return ( _PDCLIB_lconv.ctype[c].flags & _PDCLIB_CTYPE_XDIGT ); } #endif diff --git a/functions/ctype/tolower.c b/functions/ctype/tolower.c index 530abf2..d051ba5 100644 --- a/functions/ctype/tolower.c +++ b/functions/ctype/tolower.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int tolower( int c ) { - return _PDCLIB_locale_info.ctype[c].lower; + return _PDCLIB_lconv.ctype[c].lower; } #endif diff --git a/functions/ctype/toupper.c b/functions/ctype/toupper.c index 00cb203..801c8ef 100644 --- a/functions/ctype/toupper.c +++ b/functions/ctype/toupper.c @@ -10,9 +10,11 @@ #ifndef REGTEST +#include + int toupper( int c ) { - return _PDCLIB_locale_info.ctype[c].upper; + return _PDCLIB_lconv.ctype[c].upper; } #endif diff --git a/includes/locale.h b/includes/locale.h index fd014db..0277016 100644 --- a/includes/locale.h +++ b/includes/locale.h @@ -9,6 +9,16 @@ #ifndef _PDCLIB_LOCALE_H #define _PDCLIB_LOCALE_H _PDCLIB_LOCALE_H +#ifndef _PDCLIB_INT_H +#define _PDCLIB_INT_H _PDCLIB_INT_H +#include <_PDCLIB_int.h> +#endif + +#ifndef _PDCLIB_NULL_DEFINED +#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED +#define NULL _PDCLIB_NULL +#endif + /* The structure returned by localeconv(). The values for *_sep_by_space: @@ -27,6 +37,7 @@ */ struct lconv { + struct _PDCLIB_ctype_t * ctype; /* internal information */ char * decimal_point; /* decimal point character */ char * thousands_sep; /* character for seperating groups of digits */ char * grouping; /* string indicating the size of digit groups */ @@ -51,12 +62,10 @@ struct lconv char int_n_sep_by_space; /* Same as above, for international format */ char int_p_sign_posn; /* Same as above, for international format */ char int_n_sign_posn; /* Same as above, for international format */ -} +}; -#ifndef _PDCLIB_NULL_DEFINED -#define _PDCLIB_NULL_DEFINED _PDCLIB_NULL_DEFINED -#define NULL _PDCLIB_NULL -#endif +/* This is strictly internal, and visible here for technical reasons only. */ +extern struct lconv _PDCLIB_lconv; /* LC_ALL - entire locale diff --git a/internals/_PDCLIB_int.h b/internals/_PDCLIB_int.h index b5003af..2d99b91 100644 --- a/internals/_PDCLIB_int.h +++ b/internals/_PDCLIB_int.h @@ -450,10 +450,3 @@ struct _PDCLIB_ctype_t unsigned char collation; }; -struct _PDCLIB_locale_t -{ - struct _PDCLIB_ctype_t * ctype; -}; - -struct _PDCLIB_locale_t _PDCLIB_locale_info; - diff --git a/platform/example/functions/_PDCLIB/stdinit.c b/platform/example/functions/_PDCLIB/stdinit.c index a90d283..5550c4d 100644 --- a/platform/example/functions/_PDCLIB/stdinit.c +++ b/platform/example/functions/_PDCLIB/stdinit.c @@ -12,6 +12,8 @@ */ #include +#include +#include #ifndef REGTEST @@ -42,7 +44,7 @@ struct _PDCLIB_file_t * _PDCLIB_filelist = &_PDCLIB_sin; 1 kByte (+ 4 byte) of data. Each line: flags, lowercase, uppercase, collation. */ -static struct _PDCLIB_ctype_t ctype_info[] = { +static struct _PDCLIB_ctype_t _ctype[] = { { /* EOF */ 0, 0, 0, 0 }, { /* NUL */ _PDCLIB_CTYPE_CNTRL, 0x00, 0x00, 0x00 }, { /* SOH */ _PDCLIB_CTYPE_CNTRL, 0x01, 0x01, 0x01 }, @@ -302,7 +304,33 @@ static struct _PDCLIB_ctype_t ctype_info[] = { { 0x00, 0xFF, 0xFF, 0xFF } }; -struct _PDCLIB_locale_t _PDCLIB_locale_info = { ctype_info + 1 }; +struct lconv _PDCLIB_lconv = { + /* _PDCLIB_ctype */ _ctype + 1, + /* decimal_point */ (char *)".", + /* thousands_sep */ (char *)"", + /* grouping */ (char *)"", + /* mon_decimal_point */ (char *)"", + /* mon_thousands_sep */ (char *)"", + /* mon_grouping */ (char *)"", + /* positive_sign */ (char *)"", + /* negative_sign */ (char *)"", + /* currency_symbol */ (char *)"", + /* int_curr_symbol */ (char *)"", + /* frac_digits */ CHAR_MAX, + /* p_cs_precedes */ CHAR_MAX, + /* n_cs_precedes */ CHAR_MAX, + /* p_sep_by_space */ CHAR_MAX, + /* n_sep_by_space */ CHAR_MAX, + /* p_sign_posn */ CHAR_MAX, + /* n_sign_posn */ CHAR_MAX, + /* int_frac_digits */ CHAR_MAX, + /* int_p_cs_precedes */ CHAR_MAX, + /* int_n_cs_precedes */ CHAR_MAX, + /* int_p_sep_by_space */ CHAR_MAX, + /* int_n_sep_by_space */ CHAR_MAX, + /* int_p_sign_posn */ CHAR_MAX, + /* int_n_sign_posn */ CHAR_MAX, +}; #endif