Skip to content

locale.c: Reverse order of conditionals #23575

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

Merged
merged 1 commit into from
Aug 16, 2025
Merged
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: 4 additions & 4 deletions locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -8629,7 +8629,10 @@ S_strftime8(pTHX_ const char * fmt,

case UTF8NESS_YES: /* Known to be UTF-8; must be UTF-8 locale if can't
downgrade. */
if (! is_locale_utf8(locale)) {
if (is_locale_utf8(locale)) {
locale_utf8ness = LOCALE_IS_UTF8;
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe drop the curlys for less whitespace/more code on 1 screen for the if()?

Its upto you, I dont have much of an opinion either way.

LOCALE_IS_UTF8 is a const from an enum according to grep, not a STMT_START { thing or a complicated long expression so I dont see a real or paranoia precedence/syntax error hazard here for inserting {} for a 1 liner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have been burned too many times by adding, say, a debugging statement that broke things because I forgot to add braces at the same time.

locale_utf8ness = LOCALE_NOT_UTF8;

Size_t fmt_len = strlen(fmt);
Expand All @@ -8639,9 +8642,6 @@ S_strftime8(pTHX_ const char * fmt,
return false;
}
}
else {
locale_utf8ness = LOCALE_IS_UTF8;
}

break;

Expand Down
Loading