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 358CE383E6B6 for ; Mon, 23 May 2022 07:20:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 358CE383E6B6 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-140-zy-pc9RNPXSfsObp4VfTqQ-1; Mon, 23 May 2022 03:20:37 -0400 X-MC-Unique: zy-pc9RNPXSfsObp4VfTqQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C279C801210; Mon, 23 May 2022 07:20:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E93752026D6A; Mon, 23 May 2022 07:20:35 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 15/26] locale: Add more cached data to LC_CTYPE References: <5ea6ef24-5d02-ceeb-6908-746138652006@linaro.org> Date: Mon, 23 May 2022 09:20:33 +0200 In-Reply-To: <5ea6ef24-5d02-ceeb-6908-746138652006@linaro.org> (Adhemerval Zanella's message of "Fri, 20 May 2022 15:29:28 -0300") Message-ID: <8735h0zpdq.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.2 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.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: Mon, 23 May 2022 07:20:40 -0000 * Adhemerval Zanella: > On 17/03/2022 16:30, Florian Weimer via Libc-alpha wrote: >> This data will be used in number formatting. > > Looks ok, some minor comments below. > > Reviewed-by: Adhemerval Zanella >> diff --git a/locale/loadlocale.c b/locale/loadlocale.c >> index 9069bafcd8..ce78dfd071 100644 >> --- a/locale/loadlocale.c >> +++ b/locale/loadlocale.c >> @@ -31,7 +31,6 @@ >> #include >> #include "localeinfo.h" >> >> - > > Spurious line removal. Fixed. >> static const size_t _nl_category_num_items[] = >> { >> #define DEFINE_CATEGORY(category, category_name, items, a) \ >> @@ -62,6 +61,61 @@ static const enum value_type *const _nl_value_types[] = >> #undef DEFINE_CATEGORY >> }; >> >> +/* Fill in LOCDATA->private for the LC_CTYPE category. */ >> +static void >> +_nl_intern_locale_data_fill_cache_ctype (struct __locale_data *locdata) >> +{ >> + struct lc_ctype_data *data = locdata->private; >> + >> + /* Default to no translation. Assumes zero initialization of *data. */ >> + memset (data->outdigit_bytes, 1, 10); > > Use sizeof data->outdigit_bytes here. Also fixed. >> +/* Ancillary data for LC_CTYPE. Co-allocated after struct >> + __locale_data by _nl_intern_locale_data. */ >> +struct lc_ctype_data >> +{ >> + /* See get_gconv_fcts and __wcsmbs_load_conv. */ >> + const struct gconv_fcts *fcts; >> + >> + /* If false, outdigit just maps to the ASCII digits. */ >> + bool outdigit_translation_needed; >> + >> + /* Cached multi-byte string lengths. This could be added to the >> + locale data itself if the format is changed (which impacts >> + existing statically linked binaries). */ >> + >> + /* For the outdigit decimal digits (copied from LC_CTYPE). */ >> + unsigned char outdigit_bytes[10]; >> + >> + /* If all outdigit_bytes elements are equal, this is that value, >> + otherwise it is 0. */ >> + unsigned char outdigit_bytes_all_equal; > > Why not _Bool? And use outdigit_bytes[0] instead of this field? The use looks like this: if (ctype->outdigit_bytes_all_equal > 0) return (last - first) * ctype->outdigit_bytes_all_equal; I thought this was simple enough. Thanks, Florian