mirror of git://sourceware.org/git/glibc.git
Minor cleanup in ld-ctype.c
This commit is contained in:
parent
c079afb772
commit
d7e49b19d3
|
@ -1,5 +1,12 @@
|
||||||
2014-09-12 Roland McGrath <roland@hack.frob.com>
|
2014-09-12 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
|
* locale/programs/ld-ctype.c (set_one_default): New function, broken
|
||||||
|
out of ...
|
||||||
|
(set_class_defaults): ... local function set_default here.
|
||||||
|
Define set_default as a macro locally to pass constant parameters.
|
||||||
|
(allocate_arrays, set_class_defaults): Use C99 for scope for each CNT,
|
||||||
|
rather than a shared local.
|
||||||
|
|
||||||
* stdlib/rpmatch.c (try): New function, broken out of ...
|
* stdlib/rpmatch.c (try): New function, broken out of ...
|
||||||
(rpmatch): ... local function here. Also, prototypify definition.
|
(rpmatch): ... local function here. Also, prototypify definition.
|
||||||
|
|
||||||
|
|
|
@ -2928,21 +2928,11 @@ previous definition was here")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Subroutine of set_class_defaults, below. */
|
||||||
static void
|
static void
|
||||||
set_class_defaults (struct locale_ctype_t *ctype,
|
set_one_default (struct locale_ctype_t *ctype,
|
||||||
const struct charmap_t *charmap,
|
const struct charmap_t *charmap,
|
||||||
struct repertoire_t *repertoire)
|
int bitpos, int from, int to)
|
||||||
{
|
|
||||||
size_t cnt;
|
|
||||||
|
|
||||||
/* These function defines the default values for the classes and conversions
|
|
||||||
according to POSIX.2 2.5.2.1.
|
|
||||||
It may seem that the order of these if-blocks is arbitrary but it is NOT.
|
|
||||||
Don't move them unless you know what you do! */
|
|
||||||
|
|
||||||
auto void set_default (int bitpos, int from, int to);
|
|
||||||
|
|
||||||
void set_default (int bitpos, int from, int to)
|
|
||||||
{
|
{
|
||||||
char tmp[2];
|
char tmp[2];
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -2983,6 +2973,19 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
|
const struct charmap_t *charmap,
|
||||||
|
struct repertoire_t *repertoire)
|
||||||
|
{
|
||||||
|
#define set_default(bitpos, from, to) \
|
||||||
|
set_one_default (ctype, charmap, bitpos, from, to)
|
||||||
|
|
||||||
|
/* These function defines the default values for the classes and conversions
|
||||||
|
according to POSIX.2 2.5.2.1.
|
||||||
|
It may seem that the order of these if-blocks is arbitrary but it is NOT.
|
||||||
|
Don't move them unless you know what you do! */
|
||||||
|
|
||||||
/* Set default values if keyword was not present. */
|
/* Set default values if keyword was not present. */
|
||||||
if ((ctype->class_done & BITw (tok_upper)) == 0)
|
if ((ctype->class_done & BITw (tok_upper)) == 0)
|
||||||
/* "If this keyword [lower] is not specified, the lowercase letters
|
/* "If this keyword [lower] is not specified, the lowercase letters
|
||||||
|
@ -3003,11 +3006,11 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
unsigned long int mask = BIT (tok_upper) | BIT (tok_lower);
|
unsigned long int mask = BIT (tok_upper) | BIT (tok_lower);
|
||||||
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower);
|
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower);
|
||||||
|
|
||||||
for (cnt = 0; cnt < 256; ++cnt)
|
for (size_t cnt = 0; cnt < 256; ++cnt)
|
||||||
if ((ctype->class256_collection[cnt] & mask) != 0)
|
if ((ctype->class256_collection[cnt] & mask) != 0)
|
||||||
ctype->class256_collection[cnt] |= BIT (tok_alpha);
|
ctype->class256_collection[cnt] |= BIT (tok_alpha);
|
||||||
|
|
||||||
for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
for (size_t cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
||||||
if ((ctype->class_collection[cnt] & maskw) != 0)
|
if ((ctype->class_collection[cnt] & maskw) != 0)
|
||||||
ctype->class_collection[cnt] |= BITw (tok_alpha);
|
ctype->class_collection[cnt] |= BITw (tok_alpha);
|
||||||
}
|
}
|
||||||
|
@ -3025,11 +3028,11 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
unsigned long int mask = BIT (tok_alpha) | BIT (tok_digit);
|
unsigned long int mask = BIT (tok_alpha) | BIT (tok_digit);
|
||||||
unsigned long int maskw = BITw (tok_alpha) | BITw (tok_digit);
|
unsigned long int maskw = BITw (tok_alpha) | BITw (tok_digit);
|
||||||
|
|
||||||
for (cnt = 0; cnt < 256; ++cnt)
|
for (size_t cnt = 0; cnt < 256; ++cnt)
|
||||||
if ((ctype->class256_collection[cnt] & mask) != 0)
|
if ((ctype->class256_collection[cnt] & mask) != 0)
|
||||||
ctype->class256_collection[cnt] |= BIT (tok_alnum);
|
ctype->class256_collection[cnt] |= BIT (tok_alnum);
|
||||||
|
|
||||||
for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
for (size_t cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
||||||
if ((ctype->class_collection[cnt] & maskw) != 0)
|
if ((ctype->class_collection[cnt] & maskw) != 0)
|
||||||
ctype->class_collection[cnt] |= BITw (tok_alnum);
|
ctype->class_collection[cnt] |= BITw (tok_alnum);
|
||||||
}
|
}
|
||||||
|
@ -3240,13 +3243,12 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower) |
|
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower) |
|
||||||
BITw (tok_alpha) | BITw (tok_digit) | BITw (tok_xdigit) |
|
BITw (tok_alpha) | BITw (tok_digit) | BITw (tok_xdigit) |
|
||||||
BITw (tok_punct);
|
BITw (tok_punct);
|
||||||
size_t cnt;
|
|
||||||
|
|
||||||
for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
for (size_t cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
||||||
if ((ctype->class_collection[cnt] & maskw) != 0)
|
if ((ctype->class_collection[cnt] & maskw) != 0)
|
||||||
ctype->class_collection[cnt] |= BITw (tok_graph);
|
ctype->class_collection[cnt] |= BITw (tok_graph);
|
||||||
|
|
||||||
for (cnt = 0; cnt < 256; ++cnt)
|
for (size_t cnt = 0; cnt < 256; ++cnt)
|
||||||
if ((ctype->class256_collection[cnt] & mask) != 0)
|
if ((ctype->class256_collection[cnt] & mask) != 0)
|
||||||
ctype->class256_collection[cnt] |= BIT (tok_graph);
|
ctype->class256_collection[cnt] |= BIT (tok_graph);
|
||||||
}
|
}
|
||||||
|
@ -3262,14 +3264,13 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower) |
|
unsigned long int maskw = BITw (tok_upper) | BITw (tok_lower) |
|
||||||
BITw (tok_alpha) | BITw (tok_digit) | BITw (tok_xdigit) |
|
BITw (tok_alpha) | BITw (tok_digit) | BITw (tok_xdigit) |
|
||||||
BITw (tok_punct);
|
BITw (tok_punct);
|
||||||
size_t cnt;
|
|
||||||
struct charseq *seq;
|
struct charseq *seq;
|
||||||
|
|
||||||
for (cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
for (size_t cnt = 0; cnt < ctype->class_collection_act; ++cnt)
|
||||||
if ((ctype->class_collection[cnt] & maskw) != 0)
|
if ((ctype->class_collection[cnt] & maskw) != 0)
|
||||||
ctype->class_collection[cnt] |= BITw (tok_print);
|
ctype->class_collection[cnt] |= BITw (tok_print);
|
||||||
|
|
||||||
for (cnt = 0; cnt < 256; ++cnt)
|
for (size_t cnt = 0; cnt < 256; ++cnt)
|
||||||
if ((ctype->class256_collection[cnt] & mask) != 0)
|
if ((ctype->class256_collection[cnt] & mask) != 0)
|
||||||
ctype->class256_collection[cnt] |= BIT (tok_print);
|
ctype->class256_collection[cnt] |= BIT (tok_print);
|
||||||
|
|
||||||
|
@ -3376,13 +3377,13 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
/* "If this keyword [tolower] is not specified, the mapping shall be
|
/* "If this keyword [tolower] is not specified, the mapping shall be
|
||||||
the reverse mapping of the one specified to `toupper'." [P1003.2] */
|
the reverse mapping of the one specified to `toupper'." [P1003.2] */
|
||||||
{
|
{
|
||||||
for (cnt = 0; cnt < ctype->map_collection_act[0]; ++cnt)
|
for (size_t cnt = 0; cnt < ctype->map_collection_act[0]; ++cnt)
|
||||||
if (ctype->map_collection[0][cnt] != 0)
|
if (ctype->map_collection[0][cnt] != 0)
|
||||||
ELEM (ctype, map_collection, [1],
|
ELEM (ctype, map_collection, [1],
|
||||||
ctype->map_collection[0][cnt])
|
ctype->map_collection[0][cnt])
|
||||||
= ctype->charnames[cnt];
|
= ctype->charnames[cnt];
|
||||||
|
|
||||||
for (cnt = 0; cnt < 256; ++cnt)
|
for (size_t cnt = 0; cnt < 256; ++cnt)
|
||||||
if (ctype->map256_collection[0][cnt] != 0)
|
if (ctype->map256_collection[0][cnt] != 0)
|
||||||
ctype->map256_collection[1][ctype->map256_collection[0][cnt]] = cnt;
|
ctype->map256_collection[1][ctype->map256_collection[0][cnt]] = cnt;
|
||||||
}
|
}
|
||||||
|
@ -3394,7 +3395,7 @@ set_class_defaults (struct locale_ctype_t *ctype,
|
||||||
%s: field `%s' does not contain exactly ten entries"),
|
%s: field `%s' does not contain exactly ten entries"),
|
||||||
"LC_CTYPE", "outdigit"));
|
"LC_CTYPE", "outdigit"));
|
||||||
|
|
||||||
for (cnt = ctype->outdigits_act; cnt < 10; ++cnt)
|
for (size_t cnt = ctype->outdigits_act; cnt < 10; ++cnt)
|
||||||
{
|
{
|
||||||
ctype->mboutdigits[cnt] = charmap_find_symbol (charmap,
|
ctype->mboutdigits[cnt] = charmap_find_symbol (charmap,
|
||||||
(char *) digits + cnt,
|
(char *) digits + cnt,
|
||||||
|
@ -3429,6 +3430,8 @@ no output digits defined and none of the standard names in the charmap")));
|
||||||
|
|
||||||
ctype->outdigits_act = 10;
|
ctype->outdigits_act = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef set_default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3878,10 +3881,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
|
||||||
|
|
||||||
/* Now add the explicitly specified widths. */
|
/* Now add the explicitly specified widths. */
|
||||||
if (charmap->width_rules != NULL)
|
if (charmap->width_rules != NULL)
|
||||||
{
|
for (size_t cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
|
||||||
size_t cnt;
|
|
||||||
|
|
||||||
for (cnt = 0; cnt < charmap->nwidth_rules; ++cnt)
|
|
||||||
{
|
{
|
||||||
unsigned char bytes[charmap->mb_cur_max];
|
unsigned char bytes[charmap->mb_cur_max];
|
||||||
int nbytes = charmap->width_rules[cnt].from->nbytes;
|
int nbytes = charmap->width_rules[cnt].from->nbytes;
|
||||||
|
@ -3947,7 +3947,6 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the width of L'\0' to 0. */
|
/* Set the width of L'\0' to 0. */
|
||||||
wcwidth_table_add (t, 0, 0);
|
wcwidth_table_add (t, 0, 0);
|
||||||
|
@ -3976,7 +3975,6 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
|
||||||
/* First count how many entries we have. This is the upper limit
|
/* First count how many entries we have. This is the upper limit
|
||||||
since some entries from the included files might be overwritten. */
|
since some entries from the included files might be overwritten. */
|
||||||
size_t number = 0;
|
size_t number = 0;
|
||||||
size_t cnt;
|
|
||||||
struct translit_t *runp = ctype->translit;
|
struct translit_t *runp = ctype->translit;
|
||||||
struct translit_t **sorted;
|
struct translit_t **sorted;
|
||||||
size_t from_len, to_len;
|
size_t from_len, to_len;
|
||||||
|
@ -4036,7 +4034,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
|
||||||
- to-string array.
|
- to-string array.
|
||||||
*/
|
*/
|
||||||
from_len = to_len = 0;
|
from_len = to_len = 0;
|
||||||
for (cnt = 0; cnt < number; ++cnt)
|
for (size_t cnt = 0; cnt < number; ++cnt)
|
||||||
{
|
{
|
||||||
struct translit_to_t *srunp;
|
struct translit_to_t *srunp;
|
||||||
from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1;
|
from_len += wcslen ((const wchar_t *) sorted[cnt]->from) + 1;
|
||||||
|
@ -4059,7 +4057,7 @@ allocate_arrays (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
|
||||||
|
|
||||||
from_len = 0;
|
from_len = 0;
|
||||||
to_len = 0;
|
to_len = 0;
|
||||||
for (cnt = 0; cnt < number; ++cnt)
|
for (size_t cnt = 0; cnt < number; ++cnt)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
struct translit_to_t *srunp;
|
struct translit_to_t *srunp;
|
||||||
|
|
Loading…
Reference in New Issue