mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Improve fix for parentheses in param expansions (re: 5ed9ffd6
)
The fix was incomplete: expansions using '?' (${var?w(ord}, ${var:?wo)rd}) still did not tolerate parentheses in the word as regular characters. It was also possible to simplify the fix by making use of the ST_BRACE (sh_lexstate7[]) state table. See data/lexstates.c and include/lexstates.h. src/cmd/ksh93/sh/lex.c: sh_lex(): case S_MOD1: - The previous fix tested for modifier operator characters : - + = as part of the S_MOD2 case, though they are defined as S_MOD1 in the ST_BRACE state table. It only worked because of the fallthrough. And it turns out the S_MOD1 case already had a similar fix, though incomplete. The new fix effectively cancelled the old one out as any S_MOD1 character eventually led to 'continue'. So it can be simplified by removing most of that code, without causing any change in behaviour. Only the mode change to the ST_QUOTE state table followed by 'continue' is necessary. This also fixes it for the '?' operator as that is also defined as S_MOD1 in the ST_BRACE state table. src/cmd/ksh93/sh/macro.c: - When skipping a ${...} expansion using sh_lexskip(), use the ST_QUOTE state table if the character c is an S_MOD1 modifier operator character. This makes it consistent with the S_MOD1 handling in sh_lex(). src/cmd/ksh93/tests/variables.sh: - Update regression tests to include ? and :? operators.
This commit is contained in:
parent
ab5dedded7
commit
9f2066f146
3 changed files with 15 additions and 24 deletions
|
@ -1628,8 +1628,7 @@ retry1:
|
|||
}
|
||||
else
|
||||
{
|
||||
int state = (!newops && mp->quote || c=='-' || c=='+' || c=='=') ? ST_QUOTE : ST_NESTED;
|
||||
sh_lexskip(lp, RBRACE, 0, state);
|
||||
sh_lexskip(lp, RBRACE, 0, sh_lexstates[ST_BRACE][c]==S_MOD1 ? ST_QUOTE : ST_NESTED);
|
||||
stkseek(stkp,offset);
|
||||
}
|
||||
argp=stkptr(stkp,offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue