From 4b9e804b825cb163e41c8bcee92428887c257c31 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Mon, 14 Jun 2021 17:31:00 +0530 Subject: [PATCH] refactor: use locale functions in command_line_args.cc (#29550) This change refactors the code to use isalpha() and isspace() so that the code is more readable. Signed-off-by: Darshan Sen --- shell/app/command_line_args.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/app/command_line_args.cc b/shell/app/command_line_args.cc index 3dbc56c1e63..e9d052a8fa4 100644 --- a/shell/app/command_line_args.cc +++ b/shell/app/command_line_args.cc @@ -3,13 +3,14 @@ // found in the LICENSE file. #include "shell/app/command_line_args.h" +#include namespace { bool IsUrlArg(const base::CommandLine::CharType* arg) { // the first character must be a letter for this to be a URL auto c = *arg; - if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) { + if (std::isalpha(c, std::locale::classic())) { for (auto* p = arg + 1; *p; ++p) { c = *p; @@ -23,7 +24,7 @@ bool IsUrlArg(const base::CommandLine::CharType* arg) { } // white-space before a colon means it's not a URL - if (c == ' ' || (0x9 <= c && c <= 0xD)) + if (std::isspace(c, std::locale::classic())) break; } }