mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
48202 + 48366: Fix handling of NUL bytes in zexpandtabs multibyte version
This commit is contained in:
parent
3afdfef31c
commit
ea3351c496
3 changed files with 15 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
|||
2021-04-01 Mikael Magnusson <mikachu@gmail.com>
|
||||
|
||||
* 48202 (+ 48366 test fix from Jun): Src/utils.c,
|
||||
Test/B03print.ztst: Fix handling of NUL bytes in zexpandtabs
|
||||
multibyte version
|
||||
|
||||
2021-03-31 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* github #74: Caleb Maclennan: Completion/Unix/Command/_vcsh:
|
||||
|
|
|
@ -5912,8 +5912,11 @@ zexpandtabs(const char *s, int len, int width, int startpos, FILE *fout,
|
|||
memset(&mbs, 0, sizeof(mbs));
|
||||
s++;
|
||||
len--;
|
||||
} else if (ret == MB_INCOMPLETE) {
|
||||
} else if (ret == MB_INCOMPLETE ||
|
||||
/* incomplete at end --- assume likewise, best we've got */
|
||||
ret == 0) {
|
||||
/* NUL character returns 0, which would loop infinitely, so advance
|
||||
* one byte in this case too */
|
||||
s++;
|
||||
len--;
|
||||
} else {
|
||||
|
|
|
@ -304,15 +304,16 @@
|
|||
foo=$'one\ttwo\tthree\tfour\n'
|
||||
foo+=$'\tone\ttwo\tthree\tfour\n'
|
||||
foo+=$'\t\tone\t\ttwo\t\tthree\t\tfour'
|
||||
print -x4 $foo
|
||||
print -X4 $foo
|
||||
foo+='\0' # regression test for multibyte tab expand
|
||||
print -x4 $foo | tr '\0' Z # avoid raw nul byte in expected output below
|
||||
print -X4 $foo | tr '\0' Z
|
||||
0:Tab expansion by print
|
||||
>one two three four
|
||||
> one two three four
|
||||
> one two three four
|
||||
> one two three fourZ
|
||||
>one two three four
|
||||
> one two three four
|
||||
> one two three four
|
||||
> one two three fourZ
|
||||
|
||||
unset foo
|
||||
print -v foo once more
|
||||
|
|
Loading…
Reference in a new issue