Prefix the names of members of _RuneLocale and its sub-structures

with ``__'' to avoid polluting the namespace. This doesn't change the
documented rune interface at all, but breaks applications that accessed
_RuneLocale directly.
This commit is contained in:
Tim J. Robbins 2004-06-23 07:01:44 +00:00
parent 587a4462c9
commit ddc1eded85
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=130961
11 changed files with 158 additions and 153 deletions

View file

@ -190,7 +190,7 @@ static __inline int
__maskrune(__ct_rune_t _c, unsigned long _f) __maskrune(__ct_rune_t _c, unsigned long _f)
{ {
return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) :
_CurrentRuneLocale->runetype[_c]) & _f; _CurrentRuneLocale->__runetype[_c]) & _f;
} }
static __inline int static __inline int
@ -203,21 +203,21 @@ static __inline int
__isctype(__ct_rune_t _c, unsigned long _f) __isctype(__ct_rune_t _c, unsigned long _f)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
!!(_DefaultRuneLocale.runetype[_c] & _f); !!(_DefaultRuneLocale.__runetype[_c] & _f);
} }
static __inline __ct_rune_t static __inline __ct_rune_t
__toupper(__ct_rune_t _c) __toupper(__ct_rune_t _c)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
_CurrentRuneLocale->mapupper[_c]; _CurrentRuneLocale->__mapupper[_c];
} }
static __inline __ct_rune_t static __inline __ct_rune_t
__tolower(__ct_rune_t _c) __tolower(__ct_rune_t _c)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
_CurrentRuneLocale->maplower[_c]; _CurrentRuneLocale->__maplower[_c];
} }
#else /* not using inlines */ #else /* not using inlines */

View file

@ -190,7 +190,7 @@ static __inline int
__maskrune(__ct_rune_t _c, unsigned long _f) __maskrune(__ct_rune_t _c, unsigned long _f)
{ {
return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) :
_CurrentRuneLocale->runetype[_c]) & _f; _CurrentRuneLocale->__runetype[_c]) & _f;
} }
static __inline int static __inline int
@ -203,21 +203,21 @@ static __inline int
__isctype(__ct_rune_t _c, unsigned long _f) __isctype(__ct_rune_t _c, unsigned long _f)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? 0 : return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
!!(_DefaultRuneLocale.runetype[_c] & _f); !!(_DefaultRuneLocale.__runetype[_c] & _f);
} }
static __inline __ct_rune_t static __inline __ct_rune_t
__toupper(__ct_rune_t _c) __toupper(__ct_rune_t _c)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
_CurrentRuneLocale->mapupper[_c]; _CurrentRuneLocale->__mapupper[_c];
} }
static __inline __ct_rune_t static __inline __ct_rune_t
__tolower(__ct_rune_t _c) __tolower(__ct_rune_t _c)
{ {
return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
_CurrentRuneLocale->maplower[_c]; _CurrentRuneLocale->__maplower[_c];
} }
#else /* not using inlines */ #else /* not using inlines */

View file

@ -48,13 +48,11 @@
typedef __rune_t rune_t; typedef __rune_t rune_t;
#endif #endif
#define _INVALID_RUNE _CurrentRuneLocale->invalid_rune #define _INVALID_RUNE _CurrentRuneLocale->__invalid_rune
#define __sgetrune _CurrentRuneLocale->sgetrune #define sgetrune(s, n, r) (_CurrentRuneLocale->__sgetrune)((s), (n), (r))
#define __sputrune _CurrentRuneLocale->sputrune #define sputrune(c, s, n, r) (_CurrentRuneLocale->__sputrune)((c), (s), \
(n), (r))
#define sgetrune(s, n, r) (*__sgetrune)((s), (n), (r))
#define sputrune(c, s, n, r) (*__sputrune)((c), (s), (n), (r))
__BEGIN_DECLS __BEGIN_DECLS
char *mbrune(const char *, rune_t); char *mbrune(const char *, rune_t);

View file

@ -50,40 +50,40 @@
* The lower 8 bits of runetype[] contain the digit value of the rune. * The lower 8 bits of runetype[] contain the digit value of the rune.
*/ */
typedef struct { typedef struct {
__rune_t min; /* First rune of the range */ __rune_t __min; /* First rune of the range */
__rune_t max; /* Last rune (inclusive) of the range */ __rune_t __max; /* Last rune (inclusive) of the range */
__rune_t map; /* What first maps to in maps */ __rune_t __map; /* What first maps to in maps */
unsigned long *types; /* Array of types in range */ unsigned long *__types; /* Array of types in range */
} _RuneEntry; } _RuneEntry;
typedef struct { typedef struct {
int nranges; /* Number of ranges stored */ int __nranges; /* Number of ranges stored */
_RuneEntry *ranges; /* Pointer to the ranges */ _RuneEntry *__ranges; /* Pointer to the ranges */
} _RuneRange; } _RuneRange;
typedef struct { typedef struct {
char magic[8]; /* Magic saying what version we are */ char __magic[8]; /* Magic saying what version we are */
char encoding[32]; /* ASCII name of this encoding */ char __encoding[32]; /* ASCII name of this encoding */
__rune_t (*sgetrune)(const char *, __size_t, char const **); __rune_t (*__sgetrune)(const char *, __size_t, char const **);
int (*sputrune)(__rune_t, char *, __size_t, char **); int (*__sputrune)(__rune_t, char *, __size_t, char **);
__rune_t invalid_rune; __rune_t __invalid_rune;
unsigned long runetype[_CACHED_RUNES]; unsigned long __runetype[_CACHED_RUNES];
__rune_t maplower[_CACHED_RUNES]; __rune_t __maplower[_CACHED_RUNES];
__rune_t mapupper[_CACHED_RUNES]; __rune_t __mapupper[_CACHED_RUNES];
/* /*
* The following are to deal with Runes larger than _CACHED_RUNES - 1. * The following are to deal with Runes larger than _CACHED_RUNES - 1.
* Their data is actually contiguous with this structure so as to make * Their data is actually contiguous with this structure so as to make
* it easier to read/write from/to disk. * it easier to read/write from/to disk.
*/ */
_RuneRange runetype_ext; _RuneRange __runetype_ext;
_RuneRange maplower_ext; _RuneRange __maplower_ext;
_RuneRange mapupper_ext; _RuneRange __mapupper_ext;
void *variable; /* Data which depends on the encoding */ void *__variable; /* Data which depends on the encoding */
int variable_len; /* how long that data is */ int __variable_len; /* how long that data is */
} _RuneLocale; } _RuneLocale;
#define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ #define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */

View file

@ -74,10 +74,10 @@ _EUC_init(_RuneLocale *rl)
int x, new__mb_cur_max; int x, new__mb_cur_max;
char *v, *e; char *v, *e;
if (rl->variable == NULL) if (rl->__variable == NULL)
return (EFTYPE); return (EFTYPE);
v = (char *)rl->variable; v = (char *)rl->__variable;
while (*v == ' ' || *v == '\t') while (*v == ' ' || *v == '\t')
++v; ++v;
@ -109,8 +109,8 @@ _EUC_init(_RuneLocale *rl)
free(ei); free(ei);
return (EFTYPE); return (EFTYPE);
} }
rl->variable = ei; rl->__variable = ei;
rl->variable_len = sizeof(_EucInfo); rl->__variable_len = sizeof(_EucInfo);
_CurrentRuneLocale = rl; _CurrentRuneLocale = rl;
__mb_cur_max = new__mb_cur_max; __mb_cur_max = new__mb_cur_max;
__mbrtowc = _EUC_mbrtowc; __mbrtowc = _EUC_mbrtowc;
@ -126,7 +126,7 @@ _EUC_mbsinit(const mbstate_t *ps)
return (ps == NULL || ((const _EucState *)ps)->want == 0); return (ps == NULL || ((const _EucState *)ps)->want == 0);
} }
#define CEI ((_EucInfo *)(_CurrentRuneLocale->variable)) #define CEI ((_EucInfo *)(_CurrentRuneLocale->__variable))
#define _SS2 0x008e #define _SS2 0x008e
#define _SS3 0x008f #define _SS3 0x008f

View file

@ -92,86 +92,89 @@ _Read_RuneMagi(fp)
rl = (_RuneLocale *)data; rl = (_RuneLocale *)data;
lastp = data + sb.st_size; lastp = data + sb.st_size;
rl->variable = rl + 1; rl->__variable = rl + 1;
if (memcmp(rl->magic, _RUNE_MAGIC_1, sizeof(rl->magic))) { if (memcmp(rl->__magic, _RUNE_MAGIC_1, sizeof(rl->__magic))) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
} }
rl->invalid_rune = ntohl(rl->invalid_rune); rl->__invalid_rune = ntohl(rl->__invalid_rune);
rl->variable_len = ntohl(rl->variable_len); rl->__variable_len = ntohl(rl->__variable_len);
rl->runetype_ext.nranges = ntohl(rl->runetype_ext.nranges); rl->__runetype_ext.__nranges = ntohl(rl->__runetype_ext.__nranges);
rl->maplower_ext.nranges = ntohl(rl->maplower_ext.nranges); rl->__maplower_ext.__nranges = ntohl(rl->__maplower_ext.__nranges);
rl->mapupper_ext.nranges = ntohl(rl->mapupper_ext.nranges); rl->__mapupper_ext.__nranges = ntohl(rl->__mapupper_ext.__nranges);
for (x = 0; x < _CACHED_RUNES; ++x) { for (x = 0; x < _CACHED_RUNES; ++x) {
rl->runetype[x] = ntohl(rl->runetype[x]); rl->__runetype[x] = ntohl(rl->__runetype[x]);
rl->maplower[x] = ntohl(rl->maplower[x]); rl->__maplower[x] = ntohl(rl->__maplower[x]);
rl->mapupper[x] = ntohl(rl->mapupper[x]); rl->__mapupper[x] = ntohl(rl->__mapupper[x]);
} }
rl->runetype_ext.ranges = (_RuneEntry *)rl->variable; rl->__runetype_ext.__ranges = (_RuneEntry *)rl->__variable;
rl->variable = rl->runetype_ext.ranges + rl->runetype_ext.nranges; rl->__variable = rl->__runetype_ext.__ranges +
if (rl->variable > lastp) { rl->__runetype_ext.__nranges;
if (rl->__variable > lastp) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
} }
rl->maplower_ext.ranges = (_RuneEntry *)rl->variable; rl->__maplower_ext.__ranges = (_RuneEntry *)rl->__variable;
rl->variable = rl->maplower_ext.ranges + rl->maplower_ext.nranges; rl->__variable = rl->__maplower_ext.__ranges +
if (rl->variable > lastp) { rl->__maplower_ext.__nranges;
if (rl->__variable > lastp) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
} }
rl->mapupper_ext.ranges = (_RuneEntry *)rl->variable; rl->__mapupper_ext.__ranges = (_RuneEntry *)rl->__variable;
rl->variable = rl->mapupper_ext.ranges + rl->mapupper_ext.nranges; rl->__variable = rl->__mapupper_ext.__ranges +
if (rl->variable > lastp) { rl->__mapupper_ext.__nranges;
if (rl->__variable > lastp) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
} }
for (x = 0; x < rl->runetype_ext.nranges; ++x) { for (x = 0; x < rl->__runetype_ext.__nranges; ++x) {
rr = rl->runetype_ext.ranges; rr = rl->__runetype_ext.__ranges;
rr[x].min = ntohl(rr[x].min); rr[x].__min = ntohl(rr[x].__min);
rr[x].max = ntohl(rr[x].max); rr[x].__max = ntohl(rr[x].__max);
if ((rr[x].map = ntohl(rr[x].map)) == 0) { if ((rr[x].__map = ntohl(rr[x].__map)) == 0) {
int len = rr[x].max - rr[x].min + 1; int len = rr[x].__max - rr[x].__min + 1;
rr[x].types = rl->variable; rr[x].__types = rl->__variable;
rl->variable = rr[x].types + len; rl->__variable = rr[x].__types + len;
if (rl->variable > lastp) { if (rl->__variable > lastp) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
} }
while (len-- > 0) while (len-- > 0)
rr[x].types[len] = ntohl(rr[x].types[len]); rr[x].__types[len] = ntohl(rr[x].__types[len]);
} else } else
rr[x].types = 0; rr[x].__types = 0;
} }
for (x = 0; x < rl->maplower_ext.nranges; ++x) { for (x = 0; x < rl->__maplower_ext.__nranges; ++x) {
rr = rl->maplower_ext.ranges; rr = rl->__maplower_ext.__ranges;
rr[x].min = ntohl(rr[x].min); rr[x].__min = ntohl(rr[x].__min);
rr[x].max = ntohl(rr[x].max); rr[x].__max = ntohl(rr[x].__max);
rr[x].map = ntohl(rr[x].map); rr[x].__map = ntohl(rr[x].__map);
} }
for (x = 0; x < rl->mapupper_ext.nranges; ++x) { for (x = 0; x < rl->__mapupper_ext.__nranges; ++x) {
rr = rl->mapupper_ext.ranges; rr = rl->__mapupper_ext.__ranges;
rr[x].min = ntohl(rr[x].min); rr[x].__min = ntohl(rr[x].__min);
rr[x].max = ntohl(rr[x].max); rr[x].__max = ntohl(rr[x].__max);
rr[x].map = ntohl(rr[x].map); rr[x].__map = ntohl(rr[x].__map);
} }
if (((char *)rl->variable) + rl->variable_len > (char *)lastp) { if (((char *)rl->__variable) + rl->__variable_len > (char *)lastp) {
free(data); free(data);
errno = EFTYPE; errno = EFTYPE;
return (NULL); return (NULL);
@ -180,17 +183,17 @@ _Read_RuneMagi(fp)
/* /*
* Go out and zero pointers that should be zero. * Go out and zero pointers that should be zero.
*/ */
if (!rl->variable_len) if (!rl->__variable_len)
rl->variable = 0; rl->__variable = 0;
if (!rl->runetype_ext.nranges) if (!rl->__runetype_ext.__nranges)
rl->runetype_ext.ranges = 0; rl->__runetype_ext.__ranges = 0;
if (!rl->maplower_ext.nranges) if (!rl->__maplower_ext.__nranges)
rl->maplower_ext.ranges = 0; rl->__maplower_ext.__ranges = 0;
if (!rl->mapupper_ext.nranges) if (!rl->__mapupper_ext.__nranges)
rl->mapupper_ext.ranges = 0; rl->__mapupper_ext.__ranges = 0;
return (rl); return (rl);
} }

View file

@ -45,22 +45,22 @@ ___runetype(c)
__ct_rune_t c; __ct_rune_t c;
{ {
size_t lim; size_t lim;
_RuneRange *rr = &_CurrentRuneLocale->runetype_ext; _RuneRange *rr = &_CurrentRuneLocale->__runetype_ext;
_RuneEntry *base, *re; _RuneEntry *base, *re;
if (c < 0 || c == EOF) if (c < 0 || c == EOF)
return(0L); return(0L);
/* Binary search -- see bsearch.c for explanation. */ /* Binary search -- see bsearch.c for explanation. */
base = rr->ranges; base = rr->__ranges;
for (lim = rr->nranges; lim != 0; lim >>= 1) { for (lim = rr->__nranges; lim != 0; lim >>= 1) {
re = base + (lim >> 1); re = base + (lim >> 1);
if (re->min <= c && c <= re->max) { if (re->__min <= c && c <= re->__max) {
if (re->types) if (re->__types)
return(re->types[c - re->min]); return(re->__types[c - re->__min]);
else else
return(re->map); return(re->__map);
} else if (c > re->max) { } else if (c > re->__max) {
base = re + 1; base = re + 1;
lim--; lim--;
} }

View file

@ -159,33 +159,33 @@ __setrunelocale(const char *encoding)
__mbsrtowcs = __mbsrtowcs_std; __mbsrtowcs = __mbsrtowcs_std;
__wcrtomb = NULL; __wcrtomb = NULL;
__wcsrtombs = __wcsrtombs_std; __wcsrtombs = __wcsrtombs_std;
rl->sputrune = __emulated_sputrune; rl->__sputrune = __emulated_sputrune;
rl->sgetrune = __emulated_sgetrune; rl->__sgetrune = __emulated_sgetrune;
if (strcmp(rl->encoding, "NONE") == 0) if (strcmp(rl->__encoding, "NONE") == 0)
ret = _none_init(rl); ret = _none_init(rl);
else if (strcmp(rl->encoding, "UTF2") == 0) else if (strcmp(rl->__encoding, "UTF2") == 0)
ret = _UTF2_init(rl); ret = _UTF2_init(rl);
else if (strcmp(rl->encoding, "UTF-8") == 0) else if (strcmp(rl->__encoding, "UTF-8") == 0)
ret = _UTF8_init(rl); ret = _UTF8_init(rl);
else if (strcmp(rl->encoding, "EUC") == 0) else if (strcmp(rl->__encoding, "EUC") == 0)
ret = _EUC_init(rl); ret = _EUC_init(rl);
else if (strcmp(rl->encoding, "GB18030") == 0) else if (strcmp(rl->__encoding, "GB18030") == 0)
ret = _GB18030_init(rl); ret = _GB18030_init(rl);
else if (strcmp(rl->encoding, "GB2312") == 0) else if (strcmp(rl->__encoding, "GB2312") == 0)
ret = _GB2312_init(rl); ret = _GB2312_init(rl);
else if (strcmp(rl->encoding, "GBK") == 0) else if (strcmp(rl->__encoding, "GBK") == 0)
ret = _GBK_init(rl); ret = _GBK_init(rl);
else if (strcmp(rl->encoding, "BIG5") == 0) else if (strcmp(rl->__encoding, "BIG5") == 0)
ret = _BIG5_init(rl); ret = _BIG5_init(rl);
else if (strcmp(rl->encoding, "MSKanji") == 0) else if (strcmp(rl->__encoding, "MSKanji") == 0)
ret = _MSKanji_init(rl); ret = _MSKanji_init(rl);
else else
ret = EFTYPE; ret = EFTYPE;
if (ret == 0) { if (ret == 0) {
if (CachedRuneLocale != NULL) { if (CachedRuneLocale != NULL) {
/* See euc.c */ /* See euc.c */
if (strcmp(CachedRuneLocale->encoding, "EUC") == 0) if (strcmp(CachedRuneLocale->__encoding, "EUC") == 0)
free(CachedRuneLocale->variable); free(CachedRuneLocale->__variable);
free(CachedRuneLocale); free(CachedRuneLocale);
} }
CachedRuneLocale = _CurrentRuneLocale; CachedRuneLocale = _CurrentRuneLocale;

View file

@ -45,19 +45,19 @@ ___tolower(c)
__ct_rune_t c; __ct_rune_t c;
{ {
size_t lim; size_t lim;
_RuneRange *rr = &_CurrentRuneLocale->maplower_ext; _RuneRange *rr = &_CurrentRuneLocale->__maplower_ext;
_RuneEntry *base, *re; _RuneEntry *base, *re;
if (c < 0 || c == EOF) if (c < 0 || c == EOF)
return(c); return(c);
/* Binary search -- see bsearch.c for explanation. */ /* Binary search -- see bsearch.c for explanation. */
base = rr->ranges; base = rr->__ranges;
for (lim = rr->nranges; lim != 0; lim >>= 1) { for (lim = rr->__nranges; lim != 0; lim >>= 1) {
re = base + (lim >> 1); re = base + (lim >> 1);
if (re->min <= c && c <= re->max) if (re->__min <= c && c <= re->__max)
return (re->map + c - re->min); return (re->__map + c - re->__min);
else if (c > re->max) { else if (c > re->__max) {
base = re + 1; base = re + 1;
lim--; lim--;
} }

View file

@ -45,19 +45,19 @@ ___toupper(c)
__ct_rune_t c; __ct_rune_t c;
{ {
size_t lim; size_t lim;
_RuneRange *rr = &_CurrentRuneLocale->mapupper_ext; _RuneRange *rr = &_CurrentRuneLocale->__mapupper_ext;
_RuneEntry *base, *re; _RuneEntry *base, *re;
if (c < 0 || c == EOF) if (c < 0 || c == EOF)
return(c); return(c);
/* Binary search -- see bsearch.c for explanation. */ /* Binary search -- see bsearch.c for explanation. */
base = rr->ranges; base = rr->__ranges;
for (lim = rr->nranges; lim != 0; lim >>= 1) { for (lim = rr->__nranges; lim != 0; lim >>= 1) {
re = base + (lim >> 1); re = base + (lim >> 1);
if (re->min <= c && c <= re->max) if (re->__min <= c && c <= re->__max)
return (re->map + c - re->min); return (re->__map + c - re->__min);
else if (c > re->max) { else if (c > re->__max) {
base = re + 1; base = re + 1;
lim--; lim--;
} }

View file

@ -127,15 +127,16 @@ entry : ENCODING STRING
strcmp($2, "BIG5") && strcmp($2, "BIG5") &&
strcmp($2, "MSKanji")) strcmp($2, "MSKanji"))
warnx("ENCODING %s is not supported by libc", $2); warnx("ENCODING %s is not supported by libc", $2);
strncpy(new_locale.encoding, $2, sizeof(new_locale.encoding)); } strncpy(new_locale.__encoding, $2,
sizeof(new_locale.__encoding)); }
| VARIABLE | VARIABLE
{ new_locale.variable_len = strlen($1) + 1; { new_locale.__variable_len = strlen($1) + 1;
new_locale.variable = xmalloc(new_locale.variable_len); new_locale.__variable = xmalloc(new_locale.__variable_len);
strcpy((char *)new_locale.variable, $1); strcpy((char *)new_locale.__variable, $1);
} }
| INVALID RUNE | INVALID RUNE
{ warnx("the INVALID keyword is deprecated"); { warnx("the INVALID keyword is deprecated");
new_locale.invalid_rune = $2; new_locale.__invalid_rune = $2;
} }
| LIST list | LIST list
{ set_map(&types, $2, $1); } { set_map(&types, $2, $1); }
@ -259,8 +260,8 @@ main(int ac, char *av[])
mapupper.map[x] = x; mapupper.map[x] = x;
maplower.map[x] = x; maplower.map[x] = x;
} }
new_locale.invalid_rune = _INVALID_RUNE; new_locale.__invalid_rune = _INVALID_RUNE;
memcpy(new_locale.magic, _RUNE_MAGIC_1, sizeof(new_locale.magic)); memcpy(new_locale.__magic, _RUNE_MAGIC_1, sizeof(new_locale.__magic));
yyparse(); yyparse();
@ -598,7 +599,7 @@ dump_tables()
else if (curr_d - first_d < 9) else if (curr_d - first_d < 9)
errx(1, "error: DIGIT range is too small in the single byte area"); errx(1, "error: DIGIT range is too small in the single byte area");
new_locale.invalid_rune = htonl(new_locale.invalid_rune); new_locale.__invalid_rune = htonl(new_locale.__invalid_rune);
/* /*
* Fill in our tables. Do this in network order so that * Fill in our tables. Do this in network order so that
@ -607,9 +608,9 @@ dump_tables()
* word size. Sigh. We tried.) * word size. Sigh. We tried.)
*/ */
for (x = 0; x < _CACHED_RUNES; ++x) { for (x = 0; x < _CACHED_RUNES; ++x) {
new_locale.runetype[x] = htonl(types.map[x]); new_locale.__runetype[x] = htonl(types.map[x]);
new_locale.maplower[x] = htonl(maplower.map[x]); new_locale.__maplower[x] = htonl(maplower.map[x]);
new_locale.mapupper[x] = htonl(mapupper.map[x]); new_locale.__mapupper[x] = htonl(mapupper.map[x]);
} }
/* /*
@ -618,28 +619,31 @@ dump_tables()
list = types.root; list = types.root;
while (list) { while (list) {
new_locale.runetype_ext.nranges++; new_locale.__runetype_ext.__nranges++;
list = list->next; list = list->next;
} }
new_locale.runetype_ext.nranges = htonl(new_locale.runetype_ext.nranges); new_locale.__runetype_ext.__nranges =
htonl(new_locale.__runetype_ext.__nranges);
list = maplower.root; list = maplower.root;
while (list) { while (list) {
new_locale.maplower_ext.nranges++; new_locale.__maplower_ext.__nranges++;
list = list->next; list = list->next;
} }
new_locale.maplower_ext.nranges = htonl(new_locale.maplower_ext.nranges); new_locale.__maplower_ext.__nranges =
htonl(new_locale.__maplower_ext.__nranges);
list = mapupper.root; list = mapupper.root;
while (list) { while (list) {
new_locale.mapupper_ext.nranges++; new_locale.__mapupper_ext.__nranges++;
list = list->next; list = list->next;
} }
new_locale.mapupper_ext.nranges = htonl(new_locale.mapupper_ext.nranges); new_locale.__mapupper_ext.__nranges =
htonl(new_locale.__mapupper_ext.__nranges);
new_locale.variable_len = htonl(new_locale.variable_len); new_locale.__variable_len = htonl(new_locale.__variable_len);
/* /*
* Okay, we are now ready to write the new locale file. * Okay, we are now ready to write the new locale file.
@ -660,9 +664,9 @@ dump_tables()
while (list) { while (list) {
_RuneEntry re; _RuneEntry re;
re.min = htonl(list->min); re.__min = htonl(list->min);
re.max = htonl(list->max); re.__max = htonl(list->max);
re.map = htonl(list->map); re.__map = htonl(list->map);
if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) { if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
perror(locale_file); perror(locale_file);
@ -679,9 +683,9 @@ dump_tables()
while (list) { while (list) {
_RuneEntry re; _RuneEntry re;
re.min = htonl(list->min); re.__min = htonl(list->min);
re.max = htonl(list->max); re.__max = htonl(list->max);
re.map = htonl(list->map); re.__map = htonl(list->map);
if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) { if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
perror(locale_file); perror(locale_file);
@ -698,9 +702,9 @@ dump_tables()
while (list) { while (list) {
_RuneEntry re; _RuneEntry re;
re.min = htonl(list->min); re.__min = htonl(list->min);
re.max = htonl(list->max); re.__max = htonl(list->max);
re.map = htonl(list->map); re.__map = htonl(list->map);
if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) { if (fwrite((char *)&re, sizeof(re), 1, fp) != 1) {
perror(locale_file); perror(locale_file);
@ -731,8 +735,8 @@ dump_tables()
/* /*
* PART 5: And finally the variable data * PART 5: And finally the variable data
*/ */
if (fwrite((char *)new_locale.variable, if (fwrite((char *)new_locale.__variable,
ntohl(new_locale.variable_len), 1, fp) != 1) { ntohl(new_locale.__variable_len), 1, fp) != 1) {
perror(locale_file); perror(locale_file);
exit(1); exit(1);
} }
@ -745,10 +749,10 @@ dump_tables()
if (!debug) if (!debug)
return; return;
if (new_locale.encoding[0]) if (new_locale.__encoding[0])
fprintf(stderr, "ENCODING %s\n", new_locale.encoding); fprintf(stderr, "ENCODING %s\n", new_locale.__encoding);
if (new_locale.variable) if (new_locale.__variable)
fprintf(stderr, "VARIABLE %s\n", (char *)new_locale.variable); fprintf(stderr, "VARIABLE %s\n", (char *)new_locale.__variable);
fprintf(stderr, "\nMAPLOWER:\n\n"); fprintf(stderr, "\nMAPLOWER:\n\n");