From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH 2/2] libstdc++: Don't use std::tolower in <charconv> [PR103911]
Date: Sun, 1 May 2022 20:07:24 +0100 [thread overview]
Message-ID: <CACb0b4n_Mj2T3Z6Fpz+a2rF0j6ML4UNGLeNm9ds15nqZMxzrHQ@mail.gmail.com> (raw)
In-Reply-To: <20220501182109.3668200-2-ppalka@redhat.com>
On Sun, 1 May 2022 at 19:21, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> As in r12-6281-gc83ecfbe74a5cf for std::isdigit, <charconv> shouldn't
> use std::tolower either I think.
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk/11 and the
> 12 branch after it's thawed?
OK, thanks.
>
> PR libstdc++/103911
>
> libstdc++-v3/ChangeLog:
>
> * src/c++17/floating_from_chars.cc (find_end_of_float): Accept
> two possible delimeters for the exponent part in the form of a
> (possibly NULL) string of length two. Don't use std::tolower.
> (pattern): Adjust calls to find_end_of_float accordingly.
> ---
> libstdc++-v3/src/c++17/floating_from_chars.cc | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/libstdc++-v3/src/c++17/floating_from_chars.cc b/libstdc++-v3/src/c++17/floating_from_chars.cc
> index e7f3a58cf18..5d2a931d5dd 100644
> --- a/libstdc++-v3/src/c++17/floating_from_chars.cc
> +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc
> @@ -40,7 +40,6 @@
> #include <cmath>
> #include <cstdlib>
> #include <cstring>
> -#include <cctype>
> #include <locale.h>
> #include <bits/functexcept.h>
> #if _GLIBCXX_HAVE_XLOCALE_H
> @@ -142,10 +141,10 @@ namespace
>
> // Find initial portion of [first, last) containing a floating-point number.
> // The string `digits` is either `dec_digits` or `hex_digits`
> - // and `exp` is 'e' or 'p' or '\0'.
> + // and `exp` is "eE", "pP" or NULL.
> const char*
> find_end_of_float(const char* first, const char* last, const char* digits,
> - char exp)
> + const char *exp)
> {
> while (first < last && strchr(digits, *first) != nullptr)
> ++first;
> @@ -155,7 +154,7 @@ namespace
> while (first < last && strchr(digits, *first))
> ++first;
> }
> - if (first < last && exp != 0 && std::tolower((unsigned char)*first) == exp)
> + if (first < last && exp != nullptr && (*first == exp[0] || *first == exp[1]))
> {
> ++first;
> if (first < last && (*first == '-' || *first == '+'))
> @@ -237,7 +236,7 @@ namespace
>
> if ((last - first + 2) > buffer_resource::guaranteed_capacity())
> {
> - last = find_end_of_float(first + neg, last, digits, 'p');
> + last = find_end_of_float(first + neg, last, digits, "pP");
> #ifndef __cpp_exceptions
> if ((last - first + 2) > buffer_resource::guaranteed_capacity())
> {
> @@ -261,7 +260,7 @@ namespace
> if ((last - first) > buffer_resource::guaranteed_capacity())
> {
> last = find_end_of_float(first + neg, last, digits,
> - "e"[fmt == chars_format::fixed]);
> + fmt == chars_format::fixed ? nullptr : "eE");
> #ifndef __cpp_exceptions
> if ((last - first) > buffer_resource::guaranteed_capacity())
> {
> --
> 2.36.0.44.g0f828332d5
>
next prev parent reply other threads:[~2022-05-01 19:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-01 18:21 [PATCH 1/2] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441] Patrick Palka
2022-05-01 18:21 ` [PATCH 2/2] libstdc++: Don't use std::tolower in <charconv> [PR103911] Patrick Palka
2022-05-01 19:07 ` Jonathan Wakely [this message]
2022-05-01 19:09 ` [PATCH 1/2] libstdc++: case-sensitivity in hexfloat std::from_chars [PR105441] Jonathan Wakely
2022-05-02 5:05 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACb0b4n_Mj2T3Z6Fpz+a2rF0j6ML4UNGLeNm9ds15nqZMxzrHQ@mail.gmail.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).