mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-20 22:18:02 +02:00
58586: print "%s" with invalid multibyte character
Treat each byte that is invalid or part of an incopmlete set as a single byte.
This commit is contained in:
parent
9bd477dce9
commit
6763f45e77
2 changed files with 20 additions and 13 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2023-03-22 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 51586: Src/builtin.c: When printf "%s" encounters a byte
|
||||||
|
that's not part of a vaild multibyte character it should handle
|
||||||
|
it a single byte at a time.
|
||||||
|
|
||||||
2023-03-16 Oliver Kiddle <opk@zsh.org>
|
2023-03-16 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
* 51583: Completion/Unix/Command/_git: update completion of
|
* 51583: Completion/Unix/Command/_git: update completion of
|
||||||
|
|
|
@ -5329,20 +5329,21 @@ bin_print(char *name, char **args, Options ops, int func)
|
||||||
#ifdef MULTIBYTE_SUPPORT
|
#ifdef MULTIBYTE_SUPPORT
|
||||||
if (isset(MULTIBYTE)) {
|
if (isset(MULTIBYTE)) {
|
||||||
chars = mbrlen(ptr, lleft, &mbs);
|
chars = mbrlen(ptr, lleft, &mbs);
|
||||||
if (chars < 0) {
|
/*
|
||||||
/*
|
* chars <= 0 means one of
|
||||||
* Invalid/incomplete character at this
|
*
|
||||||
* point. Assume all the rest are a
|
* 0: NUL, handle as real character
|
||||||
* single byte. That's about the best we
|
*
|
||||||
* can do.
|
* -1: MB_INVALID: Assume this is
|
||||||
*/
|
* a single character as we do
|
||||||
lchars += lleft;
|
* elsewhere in the code.
|
||||||
lbytes = (ptr - b) + lleft;
|
*
|
||||||
break;
|
* -2: MB_INCOMPLETE: We're not waiting
|
||||||
} else if (chars == 0) {
|
* for input on this occasion, so
|
||||||
/* NUL, handle as real character */
|
* just treat this as invalid.
|
||||||
|
*/
|
||||||
|
if (chars <= 0)
|
||||||
chars = 1;
|
chars = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else /* use the non-multibyte code below */
|
else /* use the non-multibyte code below */
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue