Skip to content

Commit e59223c

Browse files
committed
read: fix stripping of final IFS delimiters with SHOPT_MUlTIBYTE=0
The previous commit has a regression test failure when SHOPT_MULTIBYTE is turned off in SHOPT.sh: builtins.sh[1775]: FAIL: issue 926 r7 (expected $'end: <one\ntwo\nthXree\nX>', got $'end: <one\ntwo\nthXree\n>') read.c lines 543-568 contains a perforamnce optimisation that is only used when SHOPT_MULTIBYTE is turned off at compile time. This code had a bug where *all* final $IFS delimiters were stripped from a field though only whitespace delimiters should be stripped. This commit fixes that bug by adding an isspace(3) check for that. Resolves: #926 (again)
1 parent ad27275 commit e59223c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/cmd/ksh93/bltins/read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ int sh_readline(char **names, volatile int fd, int flags, ssize_t size, Sflong_t
553553
cpmax--;
554554
if(cpmax>cp)
555555
{
556-
while((c=sh.ifstable[*--cpmax])==S_DELIM || c==S_SPACE);
556+
while((c=sh.ifstable[*--cpmax])==S_DELIM && isspace(*cpmax) || c==S_SPACE);
557557
cpmax[1] = 0;
558558
}
559559
else

0 commit comments

Comments
 (0)