From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id A98053857374 for ; Fri, 20 May 2022 13:22:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A98053857374 Received: by mail-ot1-x334.google.com with SMTP id r12-20020a056830448c00b0060aec7b7a54so1703299otv.5 for ; Fri, 20 May 2022 06:22:41 -0700 (PDT) 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:references:from:in-reply-to :content-transfer-encoding; bh=c8A7ROFtYWLHbU/3PrHvl/Ud4DHBe3K3WMScMw+hKh8=; b=GPEwT97AkpIoKgmKDAxSzsTRVrXCqX1zens9CO4cuDbScgIOzJJq2W5qYDasL4iqPb La6xqClJftfkwYMptYhj06z/ajPeyE+267FIv0TFYgcyuVTRBeZGcQjZNZXlrs+yrrrt eB5b+d/g+M2h9IQHUPuR60Re5SvmwHcc8RUaDibsOzPpBMCF9elzQr5fWJ/UN90kJBCT bZnohWJh1+FHsIBnKUZnehSZP6AQkF9kVOvebSbo0BzmUqWqFnoL4I8ZUIjb48sSAZ/J hcsK9Lyt/C9sObxqjHth+9zbcl5e0WI8rfMLIUbizKtJoNlZvsFsWL5AeNKU6OCZ35hS 8zSQ== X-Gm-Message-State: AOAM532/KWIvKlp7XBaNPR+JOGf6UoSoLtzBgVUohJ8vlqQ973Vhee1j JbINyhVIaSEJNdSfiAVtUaXhG1D7FRgnhA== X-Google-Smtp-Source: ABdhPJww5c8uJk8o3Q4DPtGeP/ZfNSPuCJEUkbffPT1uW4a6cq0AtujQf+Pl2/pdbcxeVmzLN5ZQDQ== X-Received: by 2002:a05:6830:3108:b0:606:581b:b7bb with SMTP id b8-20020a056830310800b00606581bb7bbmr3891132ots.270.1653052960794; Fri, 20 May 2022 06:22:40 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:cdd6:1223:d9e4:2076:bfdf? ([2804:431:c7cb:cdd6:1223:d9e4:2076:bfdf]) by smtp.gmail.com with ESMTPSA id w8-20020a9d70c8000000b0060603221255sm865437otj.37.2022.05.20.06.22.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 May 2022 06:22:40 -0700 (PDT) Message-ID: <46cd3655-331d-efb1-89c9-db9fd9a66827@linaro.org> Date: Fri, 20 May 2022 10:22:38 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH 04/26] stdio-common: Add tst-printf-width-i18n to cover numeric field width Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org References: From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, 20 May 2022 13:22:43 -0000 On 17/03/2022 16:28, Florian Weimer via Libc-alpha wrote: > Related to bug 28943 and bug 28944. LGTM with the fix to enabled the test. Reviewed-by: Adhemerval Zanella > --- > stdio-common/Makefile | 1 + > stdio-common/tst-printf-width-i18n.c | 95 ++++++++++++++++++++++++++++ > 2 files changed, 96 insertions(+) > create mode 100644 stdio-common/tst-printf-width-i18n.c > > diff --git a/stdio-common/Makefile b/stdio-common/Makefile > index 435cd8904f..f0e65f0dcd 100644 > --- a/stdio-common/Makefile > +++ b/stdio-common/Makefile > @@ -250,6 +250,7 @@ LOCALES := \ > de_DE.ISO-8859-1 \ > de_DE.UTF-8 \ > en_US.ISO-8859-1 \ > + hi_IN.UTF-8 \ > ja_JP.EUC-JP \ > ps_AF.UTF-8 \ > # LOCALES The tests is not enabled since there is no entry in tests. > diff --git a/stdio-common/tst-printf-width-i18n.c b/stdio-common/tst-printf-width-i18n.c > new file mode 100644 > index 0000000000..2355f30d67 > --- /dev/null > +++ b/stdio-common/tst-printf-width-i18n.c > @@ -0,0 +1,95 @@ > +/* Test for width of non-ASCII digit sequences. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +/* Behavior is currently inconsistent between %d and %f (bug 28943, > + bug 28944). This test intends to capture the status quo. */ > + > +#include > +#include > +#include > +#include > + > +static int > +do_test (void) > +{ > + char buf[40]; > + > + xsetlocale (LC_ALL, "hi_IN.UTF-8"); > + > + /* Ungrouped, not translated. */ > + TEST_COMPARE (sprintf (buf, "%7d", 12345), 7); > + TEST_COMPARE_STRING (buf, " 12345"); > + TEST_COMPARE (sprintf (buf, "%10.2f", 12345.67), 10); > + TEST_COMPARE_STRING (buf, " 12345.67"); > + TEST_COMPARE (strfmon (buf, sizeof (buf), "%^13i", 12345.67), 13); > + TEST_COMPARE_STRING (buf, " INR12345.67"); > + > + /* Grouped. */ > + TEST_COMPARE (sprintf (buf, "%'8d", 12345), 8); > + TEST_COMPARE_STRING (buf, " 12,345"); > + TEST_COMPARE (sprintf (buf, "%'11.2f", 12345.67), 11); > + TEST_COMPARE_STRING (buf, " 12,345.67"); > + TEST_COMPARE (strfmon (buf, sizeof (buf), "%13i", 12345.67), 13); > + TEST_COMPARE_STRING (buf, " INR12,345.67"); > + > + /* Translated. */ > + TEST_COMPARE (sprintf (buf, "%I16d", 12345), 16); > + TEST_COMPARE_STRING (buf, " १२३४५"); > + TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 26); > + TEST_COMPARE_STRING (buf, " १२३४५.६७"); > + > + /* Translated and grouped. */ > + TEST_COMPARE (sprintf (buf, "%'I17d", 12345), 17); > + TEST_COMPARE_STRING (buf, " १२,३४५"); > + TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 26); > + TEST_COMPARE_STRING (buf, " १२,३४५.६७"); > + > + xsetlocale (LC_ALL, "ps_AF.UTF-8"); > + > + /* Ungrouped, not translated. */ > + TEST_COMPARE (sprintf (buf, "%7d", 12345), 7); > + TEST_COMPARE_STRING (buf, " 12345"); > + TEST_COMPARE (sprintf (buf, "%10.2f", 12345.67), 11); > + TEST_COMPARE_STRING (buf, " 12345٫67"); > + TEST_COMPARE (strfmon (buf, sizeof (buf), "%^13i", 12345.67), 13); > + TEST_COMPARE_STRING (buf, " 12346 AFN"); > + > + /* Grouped. */ > + TEST_COMPARE (sprintf (buf, "%'8d", 12345), 8); > + TEST_COMPARE_STRING (buf, " 12٬345"); > + TEST_COMPARE (sprintf (buf, "%'11.2f", 12345.67), 13); > + TEST_COMPARE_STRING (buf, " 12٬345٫67"); /* Counts characters. */ > + TEST_COMPARE (strfmon (buf, sizeof (buf), "%13i", 12345.67), 13); > + TEST_COMPARE_STRING (buf, " 12٬346 AFN"); /* Counts bytes. */ > + > + /* Translated. */ > + TEST_COMPARE (sprintf (buf, "%I11d", 12345), 11); > + TEST_COMPARE_STRING (buf, " ١٢٣۴٥"); > + TEST_COMPARE (sprintf (buf, "%I12.2f", 12345.67), 20); > + TEST_COMPARE_STRING (buf, " ١٢٣۴٥٫٦٧"); > + > + /* Translated and grouped. */ > + TEST_COMPARE (sprintf (buf, "%'I13d", 12345), 13); > + TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥"); > + TEST_COMPARE (sprintf (buf, "%'I12.2f", 12345.67), 21); > + TEST_COMPARE_STRING (buf, " ١٢٬٣۴٥٫٦٧"); > + > + return 0; > +} > + > +#include Ok.