From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 62E2E385781D; Fri, 6 May 2022 13:13:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62E2E385781D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-8349] libstdc++: Don't use std::tolower in [PR103911] X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 39c56695c70a2052fc6bdcfca606dfff9c2fa975 X-Git-Newrev: eed2cd48cd5e8d94ceb15c5fd86cdd27926b54b5 Message-Id: <20220506131353.62E2E385781D@sourceware.org> Date: Fri, 6 May 2022 13:13:53 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 13:13:53 -0000 https://gcc.gnu.org/g:eed2cd48cd5e8d94ceb15c5fd86cdd27926b54b5 commit r12-8349-geed2cd48cd5e8d94ceb15c5fd86cdd27926b54b5 Author: Patrick Palka Date: Mon May 2 07:01:33 2022 -0400 libstdc++: Don't use std::tolower in [PR103911] As with std::isdigit in r12-6281-gc83ecfbe74a5cf, we shouldn't be using std::tolower in 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 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 #include #include -#include #include #include #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()) {