public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-9979] libstdc++: Don't use std::tolower in <charconv> [PR103911] Date: Wed, 11 May 2022 15:15:47 +0000 (GMT) [thread overview] Message-ID: <20220511151547.4F286395BC3B@sourceware.org> (raw) https://gcc.gnu.org/g:39099827b0f731b5f2da696f6f580156c8a7819c commit r11-9979-g39099827b0f731b5f2da696f6f580156c8a7819c Author: Patrick Palka <ppalka@redhat.com> Date: Mon May 2 07:01:33 2022 -0400 libstdc++: Don't use std::tolower in <charconv> [PR103911] As with std::isdigit in r12-6281-gc83ecfbe74a5cf, we shouldn't be using std::tolower in <charconv> either. PR libstdc++/103911 libstdc++-v3/ChangeLog: * src/c++17/floating_from_chars.cc (find_end_of_float): Accept two 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. (cherry picked from commit 86d821ddf5615e693ead667b2580898f46de8eb9) Diff: --- 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 f815e4981dd..ca1ad84e2ca 100644 --- a/libstdc++-v3/src/c++17/floating_from_chars.cc +++ b/libstdc++-v3/src/c++17/floating_from_chars.cc @@ -37,7 +37,6 @@ #include <cmath> #include <cstdlib> #include <cstring> -#include <cctype> #include <locale.h> #include <bits/functexcept.h> #if _GLIBCXX_HAVE_XLOCALE_H @@ -115,10 +114,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; @@ -128,7 +127,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 == '+')) @@ -210,7 +209,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()) { @@ -234,7 +233,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()) {
reply other threads:[~2022-05-11 15:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220511151547.4F286395BC3B@sourceware.org \ --to=ppalka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /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: linkBe 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).