aboutsummaryrefslogtreecommitdiff
path: root/locale
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2013-11-11 18:09:18 +0100
committerAndreas Schwab <schwab@suse.de>2013-11-18 12:50:09 +0100
commita7931fcfba2a5007021f8d10fffa5f51651ad7b3 (patch)
tree95ee74831a1fcc8cad2b92cb26af5396837bf45e /locale
parent728dab0e13529ba8778e6ef07e2cc80eddf028b5 (diff)
downloadglibc-a7931fcfba2a5007021f8d10fffa5f51651ad7b3.zip
glibc-a7931fcfba2a5007021f8d10fffa5f51651ad7b3.tar.gz
glibc-a7931fcfba2a5007021f8d10fffa5f51651ad7b3.tar.bz2
Properly handle unavailable elements in LC_MONETARY category
Diffstat (limited to 'locale')
-rw-r--r--locale/C-monetary.c4
-rw-r--r--locale/localeconv.c44
-rw-r--r--locale/programs/ld-monetary.c3
-rw-r--r--locale/programs/ld-numeric.c3
-rw-r--r--locale/programs/locale.c2
5 files changed, 28 insertions, 28 deletions
diff --git a/locale/C-monetary.c b/locale/C-monetary.c
index b4ffb16..3246ff5 100644
--- a/locale/C-monetary.c
+++ b/locale/C-monetary.c
@@ -21,11 +21,7 @@
/* This table's entries are taken from POSIX.2 Table 2-9
``LC_MONETARY Category Definition in the POSIX Locale'',
with additions from ISO 14652, section 4.4. */
-#ifdef __CHAR_UNSIGNED__
static const char not_available[] = "\377";
-#else
-static const char not_available[] = "\177";
-#endif
const struct __locale_data _nl_C_LC_MONETARY attribute_hidden =
{
diff --git a/locale/localeconv.c b/locale/localeconv.c
index 71ba4c6..98e82a5 100644
--- a/locale/localeconv.c
+++ b/locale/localeconv.c
@@ -28,7 +28,7 @@ __localeconv (void)
result.decimal_point = (char *) _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
result.thousands_sep = (char *) _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP);
result.grouping = (char *) _NL_CURRENT (LC_NUMERIC, GROUPING);
- if (*result.grouping == CHAR_MAX || *result.grouping == (char) -1)
+ if (*result.grouping == '\177' || *result.grouping == '\377')
result.grouping = (char *) "";
result.int_curr_symbol = (char *) _NL_CURRENT (LC_MONETARY, INT_CURR_SYMBOL);
@@ -38,31 +38,29 @@ __localeconv (void)
result.mon_thousands_sep = (char *) _NL_CURRENT (LC_MONETARY,
MON_THOUSANDS_SEP);
result.mon_grouping = (char *) _NL_CURRENT (LC_MONETARY, MON_GROUPING);
- if (*result.mon_grouping == CHAR_MAX || *result.mon_grouping == (char) -1)
+ if (*result.mon_grouping == '\177' || *result.mon_grouping == '\377')
result.mon_grouping = (char *) "";
result.positive_sign = (char *) _NL_CURRENT (LC_MONETARY, POSITIVE_SIGN);
result.negative_sign = (char *) _NL_CURRENT (LC_MONETARY, NEGATIVE_SIGN);
- result.int_frac_digits = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_FRAC_DIGITS);
- result.frac_digits = *(char *) _NL_CURRENT (LC_MONETARY, FRAC_DIGITS);
- result.p_cs_precedes = *(char *) _NL_CURRENT (LC_MONETARY, P_CS_PRECEDES);
- result.p_sep_by_space = *(char *) _NL_CURRENT (LC_MONETARY, P_SEP_BY_SPACE);
- result.n_cs_precedes = *(char *) _NL_CURRENT (LC_MONETARY, N_CS_PRECEDES);
- result.n_sep_by_space = *(char *) _NL_CURRENT (LC_MONETARY, N_SEP_BY_SPACE);
- result.p_sign_posn = *(char *) _NL_CURRENT (LC_MONETARY, P_SIGN_POSN);
- result.n_sign_posn = *(char *) _NL_CURRENT (LC_MONETARY, N_SIGN_POSN);
- result.int_p_cs_precedes = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_P_CS_PRECEDES);
- result.int_p_sep_by_space = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_P_SEP_BY_SPACE);
- result.int_n_cs_precedes = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_N_CS_PRECEDES);
- result.int_n_sep_by_space = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_N_SEP_BY_SPACE);
- result.int_p_sign_posn = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_P_SIGN_POSN);
- result.int_n_sign_posn = *(char *) _NL_CURRENT (LC_MONETARY,
- INT_N_SIGN_POSN);
+
+#define INT_ELEM(member, element) \
+ result.member = *(char *) _NL_CURRENT (LC_MONETARY, element); \
+ if (result.member == '\377') result.member = CHAR_MAX
+
+ INT_ELEM (int_frac_digits, INT_FRAC_DIGITS);
+ INT_ELEM (frac_digits, FRAC_DIGITS);
+ INT_ELEM (p_cs_precedes, P_CS_PRECEDES);
+ INT_ELEM (p_sep_by_space, P_SEP_BY_SPACE);
+ INT_ELEM (n_cs_precedes, N_CS_PRECEDES);
+ INT_ELEM (n_sep_by_space, N_SEP_BY_SPACE);
+ INT_ELEM (p_sign_posn, P_SIGN_POSN);
+ INT_ELEM (n_sign_posn, N_SIGN_POSN);
+ INT_ELEM (int_p_cs_precedes, INT_P_CS_PRECEDES);
+ INT_ELEM (int_p_sep_by_space, INT_P_SEP_BY_SPACE);
+ INT_ELEM (int_n_cs_precedes, INT_N_CS_PRECEDES);
+ INT_ELEM (int_n_sep_by_space, INT_N_SEP_BY_SPACE);
+ INT_ELEM (int_p_sign_posn, INT_P_SIGN_POSN);
+ INT_ELEM (int_n_sign_posn, INT_N_SIGN_POSN);
return &result;
}
diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c
index ec86223..c88275f 100644
--- a/locale/programs/ld-monetary.c
+++ b/locale/programs/ld-monetary.c
@@ -677,6 +677,9 @@ monetary_read (struct linereader *ldfile, struct localedef_t *result,
if (!ignore_content)
{
+ /* A single -1 means no grouping. */
+ if (act == 1 && grouping[0] == '\177')
+ act--;
grouping[act++] = '\0';
monetary->mon_grouping = xrealloc (grouping, act);
diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c
index 093a049..f759947 100644
--- a/locale/programs/ld-numeric.c
+++ b/locale/programs/ld-numeric.c
@@ -305,6 +305,9 @@ numeric_read (struct linereader *ldfile, struct localedef_t *result,
if (now->tok != tok_eol)
goto err_label;
+ /* A single -1 means no grouping. */
+ if (act == 1 && grouping[0] == '\177')
+ act--;
grouping[act++] = '\0';
numeric->grouping = xrealloc (grouping, act);
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 14d34e6..c0bdb6c 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -895,7 +895,7 @@ show_info (const char *name)
printf ("%s=", item->name);
if (val != NULL)
- printf ("%d", *val == '\177' ? -1 : *val);
+ printf ("%d", *val == '\377' ? -1 : *val);
putchar ('\n');
}
break;