mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 11:43:37 +08:00
Fix output with C locale
If given a prompt that includes a non-ascii char and a C locale, fish
currently fails to properly display it.
So you set `function fish_prompt; echo 😃; end` and it shows empty
space.
While the underlying cause is obviously using a C locale and non-C
characters to begin with, this is an unacceptable failure mode.
Apparently I misunderstood wcstombs, so I inadvertently broke this in
2b0b3d3
while trying to fix 5134949's crash.
Just return the offending bit to pre-5134949 levels, so instead of an
infinite recursion we just call a lame function a couple of times.
This commit is contained in:
parent
acad9b05e2
commit
1a063fe3c1
|
@ -402,6 +402,11 @@ int outputter_t::writech(wint_t ch) {
|
|||
void outputter_t::writestr(const wchar_t *str) {
|
||||
assert(str && "Empty input string");
|
||||
|
||||
if (MB_CUR_MAX == 1) {
|
||||
// Single-byte locale (C/POSIX/ISO-8859).
|
||||
while (*str) writech(*str++);
|
||||
return;
|
||||
}
|
||||
size_t len = wcstombs(nullptr, str, 0); // figure amount of space needed
|
||||
if (len == static_cast<size_t>(-1)) {
|
||||
debug(3, L"Tried to print invalid wide character string");
|
||||
|
|
Loading…
Reference in New Issue
Block a user