mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 17:24:50 +01: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>
|
||||
|
||||
* 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
|
||||
if (isset(MULTIBYTE)) {
|
||||
chars = mbrlen(ptr, lleft, &mbs);
|
||||
if (chars < 0) {
|
||||
/*
|
||||
* Invalid/incomplete character at this
|
||||
* point. Assume all the rest are a
|
||||
* single byte. That's about the best we
|
||||
* can do.
|
||||
*/
|
||||
lchars += lleft;
|
||||
lbytes = (ptr - b) + lleft;
|
||||
break;
|
||||
} else if (chars == 0) {
|
||||
/* NUL, handle as real character */
|
||||
/*
|
||||
* chars <= 0 means one of
|
||||
*
|
||||
* 0: NUL, handle as real character
|
||||
*
|
||||
* -1: MB_INVALID: Assume this is
|
||||
* a single character as we do
|
||||
* elsewhere in the code.
|
||||
*
|
||||
* -2: MB_INCOMPLETE: We're not waiting
|
||||
* for input on this occasion, so
|
||||
* just treat this as invalid.
|
||||
*/
|
||||
if (chars <= 0)
|
||||
chars = 1;
|
||||
}
|
||||
}
|
||||
else /* use the non-multibyte code below */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue