locale: Allow "" int_curr_Symbol.

Message ID ecf86593-0f60-3cbe-9d52-1c1de261e935@redhat.com
State Committed
Headers

Commit Message

Carlos O'Donell Oct. 13, 2017, 8:33 p.m. UTC
  Again, working on new C.UTF-8 with a "" int_curr_symbol, which
I assume you tried given the comments in your Fedora C.UTF-8.
This time however I tracked down the required changes to allow
a blank int_curr_symbol.

--- commit msg:
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>
---

2017-10-13  Carlos O'Donell  <carlos@redhat.com>

	* locale/programs/ld-monetary.c (monetary_finish): Allow ""
	int_curr_symbol.

---
  

Comments

Florian Weimer Oct. 13, 2017, 8:41 p.m. UTC | #1
* Carlos O'Donell:

> 2017-10-13  Carlos O'Donell  <carlos@redhat.com>
>
> 	* locale/programs/ld-monetary.c (monetary_finish): Allow ""
> 	int_curr_symbol.

Looks okay.
  
Carlos O'Donell Oct. 13, 2017, 9:39 p.m. UTC | #2
On 10/13/2017 01:41 PM, Florian Weimer wrote:
> * Carlos O'Donell:
> 
>> 2017-10-13  Carlos O'Donell  <carlos@redhat.com>
>>
>> 	* locale/programs/ld-monetary.c (monetary_finish): Allow ""
>> 	int_curr_symbol.
> 
> Looks okay.
> 

Thanks. Pushed. I added bugs for both this fix and the next
because they are a change in user observable behaviour.
  

Patch

diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c
index a0befe5..547861e 100644
--- a/locale/programs/ld-monetary.c
+++ b/locale/programs/ld-monetary.c
@@ -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);