From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 183503858D35 for ; Fri, 25 Feb 2022 15:27:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 183503858D35 Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-u3LiG1ZGMa6dPCfKiBW8xQ-1; Fri, 25 Feb 2022 10:27:32 -0500 X-MC-Unique: u3LiG1ZGMa6dPCfKiBW8xQ-1 Received: by mail-il1-f198.google.com with SMTP id d16-20020a923650000000b002c2984ac062so3007386ilf.2 for ; Fri, 25 Feb 2022 07:27:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=FWc47fm6PK1A+fjPAmDk+4WXKKoDVf5WUQevGFkXKj8=; b=pjU6TI0nz7/+BN1u81QaNFLuELnumC/EQnTo0T4cEAiwvXpDWWhcoRBOhN/7u9RmqA cq7BopmZ9326XIs3NueEaa1vFTo98YUZR4olSC19tpxEPxJO+c2n8d7XT2RSW44Hc9Xf iw3yYWp9q4q3p20cfD9sDGEzmpYtwJS0ffzcNIpcP61bpVdp7rh0U0nWBYU9a9crCHu+ bXA0lKHhETFc1bZOTgniuwaxn0IuJJaJ/yTLfPLL0+XKbsDeM6jzlr+v4gGKmmPvK1lU fd1k2D/OqGMrYtVpK8sYtlZSLOifz4Q0i3Kus22YWcpzM8So8QMbkeUZ+NTKJf48/6hv NP7Q== X-Gm-Message-State: AOAM533XymWtunDYF1CZubFsZn4ktgAkQKTELd7nhlAGt0fljFztUzV3 TGgImp4YRXXwSOKoUHPXFJnKj4VnYpRB1RrriCdokqoMuTWmKqoWuNeJRRxGf36JhM4OddbripE cp3qh7BOlv9Nb1cWfFQZe X-Received: by 2002:a02:a698:0:b0:315:b27:4c04 with SMTP id j24-20020a02a698000000b003150b274c04mr6130805jam.265.1645802851747; Fri, 25 Feb 2022 07:27:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3Mjz1RoGYhdzt7biTOLx2c3CztzgVSR+oXSXuAwYPiLOveWQelq8h6r9t6rgoe/38eLL78g== X-Received: by 2002:a02:a698:0:b0:315:b27:4c04 with SMTP id j24-20020a02a698000000b003150b274c04mr6130793jam.265.1645802851483; Fri, 25 Feb 2022 07:27:31 -0800 (PST) Received: from [192.168.0.241] (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id m2-20020a924a02000000b002c259d04d0fsm1760950ilf.26.2022.02.25.07.27.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Feb 2022 07:27:31 -0800 (PST) Message-ID: <7afe7c6e-d348-5c0c-3f98-a9beaaffc580@redhat.com> Date: Fri, 25 Feb 2022 10:27:30 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v2 1/2] localedef: Update LC_MONETARY handling (Bug 28845) To: DJ Delorie Cc: libc-alpha@sourceware.org References: From: Carlos O'Donell Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Feb 2022 15:27:35 -0000 On 2/25/22 00:54, DJ Delorie wrote: > > Two comment changes but otherwise OK. > > Reviewed-by: DJ Delorie Thanks. I pushed a v3 with these fixes. > "Carlos O'Donell" writes: >> diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c > >> + mon_grouping "\177" i.e. terminating -1 > > \177 is char *max*, not -1. \377 is -1. > >> + mon_grouping "\177" i.e. terminating -1 > > Likewise. > >> + /* The purpose of TEST_ELEM is to define a default value for the fields >> + in the category if the field was not defined in the cateory. If the >> + category was present but we didn't see a definition for the field then >> + we also issue a warning, otherwise the only warning you get is the one >> + earlier when a default category is created (completely missing category). >> + This missing field warning is glibc-specific since no standard requires >> + this warning, but we consider it valuable to print a warning for all >> + missing fields in the category. */ > > Ok. > >> #define TEST_ELEM(cat, initval) \ >> if (monetary->cat == NULL) \ >> { \ >> if (! nothing) \ >> - record_error (0, 0, _("%s: field `%s' not defined"), \ >> - "LC_MONETARY", #cat); \ >> + record_warning (_("%s: field `%s' not defined"), \ >> + "LC_MONETARY", #cat); \ > > Ok. > >> + /* Keyword: int_curr_symbol. */ >> TEST_ELEM (int_curr_symbol, ""); >> - TEST_ELEM (currency_symbol, ""); >> - TEST_ELEM (mon_thousands_sep, ""); >> - TEST_ELEM (positive_sign, ""); >> - TEST_ELEM (negative_sign, ""); > > Ok. > >> @@ -247,41 +331,63 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), >> } >> } >> >> - /* The decimal point must not be empty. This is not said explicitly >> - in POSIX but ANSI C (ISO/IEC 9899) says in 4.4.2.1 it has to be >> - != "". */ >> + /* Keyword: currency_symbol */ >> + TEST_ELEM (currency_symbol, ""); >> + >> + /* Keyword: mon_decimal_point */ >> + /* ISO C17 7.11.2.1.3 explicitly allows mon_decimal_point to be the >> + empty string e.g. "". This indicates the value is not available in the >> + current locale or is of zero length. However, if the value was never >> + defined then we issue a warning and use a glibc-specific default. ISO >> + 30112 in the i18n FDCC-Set uses ",", and POSIX Issue 7 in the >> + POSIX locale uses "". It is specific to glibc that the default is >> + "."; we retain this existing behaviour for backwards compatibility. */ > > Ok. > >> if (monetary->mon_decimal_point == NULL) >> { >> if (! nothing) >> - record_error (0, 0, _("%s: field `%s' not defined"), >> - "LC_MONETARY", "mon_decimal_point"); >> + record_warning (_("%s: field `%s' not defined, using defaults"), >> + "LC_MONETARY", "mon_decimal_point"); > > Ok. > >> - else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing) >> - record_error (0, 0, _("\ >> -%s: value for field `%s' must not be an empty string"), >> - "LC_MONETARY", "mon_decimal_point"); > > Ok. > >> + >> + /* Keyword: mon_thousands_sep */ >> + if (monetary->mon_thousands_sep == NULL) >> { >> + if (! nothing) >> + record_warning (_("%s: field `%s' not defined, using defaults"), >> + "LC_MONETARY", "mon_thousands_sep"); >> + monetary->mon_thousands_sep = ""; >> + monetary->mon_thousands_sep_wc = L'\0'; >> } > > Ok. > >> + /* Keyword: mon_grouping */ >> if (monetary->mon_grouping_len == 0) >> { >> if (! nothing) >> - record_error (0, 0, _("%s: field `%s' not defined"), >> - "LC_MONETARY", "mon_grouping"); >> - >> + record_warning (_("%s: field `%s' not defined"), >> + "LC_MONETARY", "mon_grouping"); > > Ok. > >> + /* Missing entries are given 1 element in their bytearray with >> + a value of CHAR_MAX which indicates that "No further grouping >> + is to be performed" (functionally equivalent to ISO C's "C" >> + locale default of ""). */ >> monetary->mon_grouping = (char *) "\177"; >> monetary->mon_grouping_len = 1; > > Ok. > >> + /* Keyword: positive_sign */ >> + TEST_ELEM (positive_sign, ""); >> + >> + /* Keyword: negative_sign */ >> + TEST_ELEM (negative_sign, ""); >> + > > Ok. > >> #undef TEST_ELEM >> #define TEST_ELEM(cat, min, max, initval) \ >> if (monetary->cat == -2) \ >> { \ >> if (! nothing) \ >> - record_error (0, 0, _("%s: field `%s' not defined"), \ >> - "LC_MONETARY", #cat); \ >> + record_warning (_("%s: field `%s' not defined"), \ >> + "LC_MONETARY", #cat); \ > > Ok. > >> @@ -300,16 +406,11 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), >> TEST_ELEM (p_sign_posn, -1, 4, -1); >> TEST_ELEM (n_sign_posn, -1, 4, -1); >> >> - /* The non-POSIX.2 extensions are optional. */ >> - if (monetary->duo_int_curr_symbol == NULL) >> - monetary->duo_int_curr_symbol = monetary->int_curr_symbol; >> - if (monetary->duo_currency_symbol == NULL) >> - monetary->duo_currency_symbol = monetary->currency_symbol; >> - >> - if (monetary->duo_int_frac_digits == -2) >> - monetary->duo_int_frac_digits = monetary->int_frac_digits; >> - if (monetary->duo_frac_digits == -2) >> - monetary->duo_frac_digits = monetary->frac_digits; > > Ok. > >> + /* Keyword: crncystr */ >> + monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) >> + + 2); >> + monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; >> + strcpy (&monetary->crncystr[1], monetary->currency_symbol); > > Ok. > >> @@ -327,6 +428,17 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), >> TEST_ELEM (int_p_sign_posn, p_sign_posn, -1, 4); >> TEST_ELEM (int_n_sign_posn, n_sign_posn, -1, 4); >> >> + /* The non-POSIX.2 extensions are optional. */ >> + if (monetary->duo_int_curr_symbol == NULL) >> + monetary->duo_int_curr_symbol = monetary->int_curr_symbol; >> + if (monetary->duo_currency_symbol == NULL) >> + monetary->duo_currency_symbol = monetary->currency_symbol; >> + >> + if (monetary->duo_int_frac_digits == -2) >> + monetary->duo_int_frac_digits = monetary->int_frac_digits; >> + if (monetary->duo_frac_digits == -2) >> + monetary->duo_frac_digits = monetary->frac_digits; >> + > > Ok. > >> + /* Keyword: conversion_rate */ > > Ok. >> >> - /* Create the crncystr entry. */ >> - monetary->crncystr = (char *) xmalloc (strlen (monetary->currency_symbol) >> - + 2); >> - monetary->crncystr[0] = monetary->p_cs_precedes ? '-' : '+'; >> - strcpy (&monetary->crncystr[1], monetary->currency_symbol); >> + /* A value for monetary-decimal-point-wc was set when >> + monetary_decimal_point was set, likewise for monetary-thousands-sep-wc. */ >> } > > Ok. > -- Cheers, Carlos.