%s -> %ls for wchar_t

I noticed my debug output for 24bit color mode was garbled due to
this being wrong. I spent a little time trying to get the compiler
to tell us about these, but -Wformat doesn't do anything for wchar
printf functions, and __attribute__((format(printf, n, m))) will
cause an error with wchar_t's, so I gave up and decided to manually
check out every '%s' in the entire project. I found (only) one
more.

debug(0, "%s", wchars) will report warnings for incorrect
specifiers but debug(0, L"%s", wchars) is unable. Thus there may
be reason to prefer not using L"..." as an argument if all else
is equal and it's not necessary.
This commit is contained in:
Aaron Gyes 2019-05-20 13:44:08 -07:00
parent 7ddae68645
commit 714b8420a9
2 changed files with 2 additions and 2 deletions

View file

@ -280,7 +280,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
streams.err.append_format(L"%ls: Condition '%ls' contained a syntax error", cmd,
condition);
for (size_t i = 0; i < errors.size(); i++) {
streams.err.append_format(L"\n%s: ", cmd);
streams.err.append_format(L"\n%ls: ", cmd);
streams.err.append(errors.at(i).describe(condition_string));
}
return STATUS_CMD_ERROR;

View file

@ -376,7 +376,7 @@ static void update_fish_color_support(const environment_t &vars) {
// Handle $fish_term24bit
if (auto fish_term24bit = vars.get(L"fish_term24bit")) {
support_term24bit = bool_from_string(fish_term24bit->as_string());
debug(2, L"'fish_term24bit' preference: 24-bit color %s",
debug(2, L"'fish_term24bit' preference: 24-bit color %ls",
support_term24bit ? L"enabled" : L"disabled");
} else {
// We don't attempt to infer term24 bit support yet.