From patchwork Mon Jan 31 05:34:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 50582 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2DF49385841A for ; Mon, 31 Jan 2022 05:35:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DF49385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643607355; bh=pInOY6FYaKc7EU6qS+/ah0MbW+N22fIsj0OPYPt2TJc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Xu/uOc6W8HbS4A/2btcfV7oXCdHTnHoBZvhSIKcImWj3NFV8QL/EJm4SbAJYABbsw Z7vhP2wbMd5hc98AyrDh07GNtNuH28WEM06L8xYMeEok+UvDfDAafI5tFxFnleExF7 2rZgt51wrEIAs6A9mONsh/DgMl6trTj337RhhKu4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 14E5B3858D28 for ; Mon, 31 Jan 2022 05:34:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14E5B3858D28 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-7kqG73x9NDamPQ7WBQ9-jw-1; Mon, 31 Jan 2022 00:34:52 -0500 X-MC-Unique: 7kqG73x9NDamPQ7WBQ9-jw-1 Received: by mail-qk1-f197.google.com with SMTP id j66-20020a375545000000b004e0e071f37eso6316945qkb.23 for ; Sun, 30 Jan 2022 21:34:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pInOY6FYaKc7EU6qS+/ah0MbW+N22fIsj0OPYPt2TJc=; b=qeo/FevmYwdauqcb54DXsL+Nk3PqvDPHsXFRZkwpOP/XnzeuJNt6GYYnUSug8Or41x ro76yLQmQYiOTOD5Xii4JahnMfc2ugncKChffv28jNt8PwlbMt1VsPEdDKUSlfi/tav6 KmzlRBLbTHNLynADyOBNXYB162dVqVufXuxjzJuvuVIHvBLS+ID7wOF9TKDvQDn7GLuM 5zmmKT2B+v/D4rrusp3yFxdKdMMdU2q5+/Yk63BcFFZcizUGWmgBSNK51glTAyFHiZUm +9fmSMGpE69rhFlFWMkGr+leE8yID0iRcpNZAqgHBR346lfZeAlQJB2JJuvfhE9bRpBJ o+pA== X-Gm-Message-State: AOAM533KGkrwQVmShz0SA5aLQUV+8gHWkm6ltsJRYV9L2NV30ZfvJYK+ HfIdB2MvY+f0XxNpGmHOWoH1CUKGoXqzqlHpqZtuoHmulPa2jmfEsA/q6bE6M58dqXUrX9rOWw+ 7WowUf0rim3TqWJSCBaqMuqlwFSP0Eb8w8edHk6bpU1fbRz2fKcM5Ckv3usSRFkTGhOx0pg== X-Received: by 2002:a05:6214:21e8:: with SMTP id p8mr16407211qvj.116.1643607291953; Sun, 30 Jan 2022 21:34:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwII0dPfrVz3GHqwMla+OG9IEG9+J2m0YI0+EwzvUT3IwKEXHWqqay1IYI9/MzcFnyERUNbcA== X-Received: by 2002:a05:6214:21e8:: with SMTP id p8mr16407198qvj.116.1643607291679; Sun, 30 Jan 2022 21:34:51 -0800 (PST) Received: from athas.redhat.com (135-23-175-80.cpe.pppoe.ca. [135.23.175.80]) by smtp.gmail.com with ESMTPSA id 18sm7261884qka.126.2022.01.30.21.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 21:34:51 -0800 (PST) To: libc-alpha@sourceware.org, fweimer@redhat.com, michael.hudson@canonical.com Subject: [PATCH 1/2] localedef: Fix handling of empty mon_decimal_point Date: Mon, 31 Jan 2022 00:34:41 -0500 Message-Id: <20220131053442.3995804-2-carlos@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220131053442.3995804-1-carlos@redhat.com> References: <20220131053442.3995804-1-carlos@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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-Patchwork-Original-From: Carlos O'Donell via Libc-alpha From: Carlos O'Donell Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The handling of mon_decimal_point is incorrect when it comes to handling the empty "" value. The existing parser in monetary_read() will correctly handle setting the non-wide-character value and the wide-character value e.g. STR_ELEM_WC(mon_decimal_point) if they are set in the locale definition. However, in monetary_finish() we have conflicting TEST_ELEM() which sets a default value (if the locale definition doesn't include one), and subsequent code which looks for mon_decimal_point to be NULL to issue a specific error message and set the defaults. The latter is unused because TEST_ELEM() always sets a default. The simplest solution is to remove the TEST_ELEM() check, and allow the existing check to look to see if mon_decimal_point is NULL and set an appropriate default. The final fix is to move the setting of mon_decimal_point_wc so it occurs only when mon_decimal_point is being set to a default, keeping both values consistent. There is no way to tell the difference between mon_decimal_point_wc having been set to the empty string and not having been defined at all, for that distinction we must use mon_decimal_point being NULL or "", and so we must logically set the default together with mon_decimal_point. Lastly, there are more fixes similar to this that could be made to ld-monetary.c, but we avoid that in order to fix just the code required for mon_decimal_point, which impacts the ability for C.UTF-8 to set mon_decimal_point to "", since without this fix we end up with an inconsistent setting of mon_decimal_point set to "", but mon_decimal_point_wc set to "." which is incorrect. Tested on x86_64 and i686 without regression. Reviewed-by: Florian Weimer --- locale/programs/ld-monetary.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c index 277b9ff042..3b0412b405 100644 --- a/locale/programs/ld-monetary.c +++ b/locale/programs/ld-monetary.c @@ -207,7 +207,6 @@ No definition for %s category found"), "LC_MONETARY"); TEST_ELEM (int_curr_symbol, ""); TEST_ELEM (currency_symbol, ""); - TEST_ELEM (mon_decimal_point, "."); TEST_ELEM (mon_thousands_sep, ""); TEST_ELEM (positive_sign, ""); TEST_ELEM (negative_sign, ""); @@ -257,6 +256,7 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), record_error (0, 0, _("%s: field `%s' not defined"), "LC_MONETARY", "mon_decimal_point"); monetary->mon_decimal_point = "."; + monetary->mon_decimal_point_wc = L'.'; } else if (monetary->mon_decimal_point[0] == '\0' && ! be_quiet && ! nothing) { @@ -264,8 +264,6 @@ not correspond to a valid name in ISO 4217 [--no-warnings=intcurrsym]"), %s: value for field `%s' must not be an empty string"), "LC_MONETARY", "mon_decimal_point"); } - if (monetary->mon_decimal_point_wc == L'\0') - monetary->mon_decimal_point_wc = L'.'; if (monetary->mon_grouping_len == 0) {