Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uncaught exception on machines with no locales set #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion loguru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,13 @@ namespace loguru
for (int arg_it = 1; arg_it < argc; ++arg_it) {
auto cmd = argv[arg_it];
auto arg_len = strlen(verbosity_flag);
if (strncmp(cmd, verbosity_flag, arg_len) == 0 && !std::isalpha(cmd[arg_len], std::locale(""))) {
bool is_alpha;
try {
is_alpha = std::isalpha(cmd[arg_len], std::locale(""));
Copy link
Collaborator

@bylowerik bylowerik Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we calling locale with ""? Would it make sense to just call std::isalpha?

} catch (...) {
is_alpha = std::isalpha(cmd[arg_len]);
}
if (strncmp(cmd, verbosity_flag, arg_len) == 0 && !is_alpha) {
out_argc -= 1;
auto value_str = cmd + arg_len;
if (value_str[0] == '\0') {
Expand Down