1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-21 07:26:05 +02:00

51207: fix for read -d when the delimiter is a byte >= 0x80

This commit is contained in:
Jun-ichi Takimoto 2022-12-13 20:12:06 +09:00 committed by Oliver Kiddle
parent a73c705b0c
commit 2701ab161d
3 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2022-12-16 Oliver Kiddle <opk@zsh.org>
* Jun T.: 51207: Src/builtin.c, Test/B04read.ztst:
fix for read -d when the delimiter is a byte >= 0x80
* 51212: Etc/zsh-development-guide, Src/Modules/curses.c,
Src/Modules/stat.c, Src/Modules/zftp.c, Src/Modules/zpty.c,
Src/Modules/zutil.c, Src/Zle/compcore.c, Src/Zle/complete.c,

View File

@ -6286,7 +6286,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
char *laststart;
size_t ret;
#else
char delim = '\n';
int delim = '\n';
#endif
if (OPT_HASARG(ops,c='k')) {
@ -6413,10 +6413,11 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
if (wi != WEOF)
delim = (wchar_t)wi;
else
delim = (wchar_t)((delimstr[0] == Meta) ?
delim = (wchar_t) (unsigned char) ((delimstr[0] == Meta) ?
delimstr[1] ^ 32 : delimstr[0]);
#else
delim = (delimstr[0] == Meta) ? delimstr[1] ^ 32 : delimstr[0];
delim = (unsigned char) ((delimstr[0] == Meta) ?
delimstr[1] ^ 32 : delimstr[0]);
#endif
if (SHTTY != -1) {
struct ttyinfo ti;

View File

@ -82,6 +82,12 @@
>Testing the
>null hypothesis
print -n $'first line\x80second line\x80' |
while read -d $'\x80' line; do print $line; done
0:read with a delimiter >= 0x80
>first line
>second line
# Note that trailing NULLs are not stripped even if they are in
# $IFS; only whitespace characters contained in $IFS are stripped.
print -n $'Aaargh, I hate nulls.\0\0\0' | read line