]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
locale: Allow "" int_curr_Symbol (bug 22294)
authorCarlos O'Donell <carlos@systemhalted.org>
Fri, 13 Oct 2017 21:33:09 +0000 (14:33 -0700)
committerCarlos O'Donell <carlos@systemhalted.org>
Sat, 14 Oct 2017 05:30:19 +0000 (22:30 -0700)
The builtin POSIX locale has "" as the international currency symbol,
but a non-builtin locale may not have such a blank int_curr_symbol.

Therefore to support non-builtin locales with similar "" int_curr_symbol
we adjust the LC_MONETARY parser to allow the normal 4-character
int_curr_symbol *and* the empty "" no symbol. Anything else remains
invalid.

Tested by building all the locales.  Tested also with a custom C.UTF-8
locale with "" for int_curr_symbol.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog
locale/programs/ld-monetary.c

index fd3fe787dfca10ffd32326774fcc5e40670141dd..b31d3ec4b2658e83401733d2d3ed20de000faf9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-13  Carlos O'Donell  <carlos@redhat.com>
+
+       [BZ #22294]
+       * locale/programs/ld-monetary.c (monetary_finish): Allow ""
+       int_curr_symbol.
+
 2017-10-13  Carlos O'Donell  <carlos@redhat.com>
 
        [BZ #22292]
index 35d17490cbf09a0ebbb66419262a390db1b5adb9..9d94738041e32a388559db0998676b371a00908c 100644 (file)
@@ -216,14 +216,20 @@ No definition for %s category found"), "LC_MONETARY");
   /* The international currency symbol must come from ISO 4217.  */
   if (monetary->int_curr_symbol != NULL)
     {
-      if (strlen (monetary->int_curr_symbol) != 4)
+      /* POSIX says this should be a 3-character symbol from ISO 4217
+        along with a 4th character that is a divider, but the POSIX
+        locale is documented as having a special case of "", and we
+        support that also, so allow other locales to be created with
+        a blank int_curr_symbol.  */
+      int ics_len = strlen (monetary->int_curr_symbol);
+      if (ics_len != 4 && ics_len != 0)
        {
          if (! nothing)
            record_error (0, 0, _("\
 %s: value of field `int_curr_symbol' has wrong length"),
                          "LC_MONETARY");
        }
-      else
+      else if (ics_len == 4)
        { /* Check the first three characters against ISO 4217 */
          char symbol[4];
          strncpy (symbol, monetary->int_curr_symbol, 3);