From 80223417d7240162cc483ca6357b7ec0e01c4a4a Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 26 Jul 2011 16:57:28 +0000 Subject: [PATCH] =?UTF-8?q?followup=20fix=20for=201004D90467358D6B13C=20re?= =?UTF-8?q?garding=20escaped=20substitutions=20found=20in,=20out=20of=20al?= =?UTF-8?q?l=20things,=20Debian/m68k,=20by=20Wouter=20Verhelst=20(Yoe)=20f?= =?UTF-8?q?ix=20hacked=20at=20DebConf=2011,=20=D0=91=D0=B0=D1=9A=D0=B0=20?= =?UTF-8?q?=D0=9B=D1=83=D0=BA=D0=B0,=20=D0=A0=D0=B5=D0=BF=D1=83=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D0=BA=D0=B0=20=D0=A1=D1=80=D0=BF=D1=81=D0=BA=D0=B0?= =?UTF-8?q?,=20=D0=91=D0=BE=D1=81=D0=BD=D0=B0=20=D0=B8=20=D0=A5=D0=B5?= =?UTF-8?q?=D1=80=D1=86=D0=B5=D0=B3=D0=BE=D0=B2=D0=B8=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 13 +++++++------ lex.c | 34 ++++++++++++++++++++-------------- sh.h | 4 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/check.t b/check.t index 824a1d6..3068a95 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.478 2011/07/20 23:47:26 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.479 2011/07/26 16:57:25 tg Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ @@ -25,7 +25,7 @@ # http://www.research.att.com/~gsf/public/ifs.sh expected-stdout: - @(#)MIRBSD KSH R40 2011/07/20 + @(#)MIRBSD KSH R40 2011/07/26 description: Check version of shell. stdin: @@ -1603,16 +1603,17 @@ stdin: set +o sh x=foobar y=foobaz - echo "<${x%bar|baz},${y%bar|baz}>" + z=fooba\? + echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" echo "<${x%ba(r|z)},${y%ba(r|z)}>" set -o sh - echo "<${x%bar|baz},${y%bar|baz}>" + echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" z='foo(bar' echo "<${z%(*}>" expected-stdout: + - - + --- name: eglob-substrpl-1 diff --git a/lex.c b/lex.c index 0f924a0..4ade37e 100644 --- a/lex.c +++ b/lex.c @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.153 2011/06/04 16:11:18 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.154 2011/07/26 16:57:27 tg Exp $"); /* * states while lexing word @@ -40,9 +40,10 @@ __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.153 2011/06/04 16:11:18 tg Exp $"); #define SHEREDELIM 10 /* parsing <<,<<- delimiter */ #define SHEREDQUOTE 11 /* parsing " in <<,<<- delimiter */ #define SPATTERN 12 /* parsing *(...|...) pattern (*+?@!) */ -#define STBRACE 13 /* parsing ${...[#%]...} */ -#define SADELIM 14 /* like SBASE, looking for delimiter */ -#define SHERESTRING 15 /* parsing <<< string */ +#define SADELIM 13 /* like SBASE, looking for delimiter */ +#define SHERESTRING 14 /* parsing <<< string */ +#define STBRACEKORN 15 /* parsing ${...[#%]...} !FSH */ +#define STBRACEBOURNE 16 /* parsing ${...[#%]...} FSH */ #define SINVALID 255 /* invalid state */ struct sretrace_info { @@ -456,9 +457,12 @@ yylex(int cf) * If this is a trim operation, * treat (,|,) specially in STBRACE. */ - if (!Flag(FSH) && ctype(c, C_SUBOP2)) { + if (ctype(c, C_SUBOP2)) { ungetsc(c); - PUSH_STATE(STBRACE); + if (Flag(FSH)) + PUSH_STATE(STBRACEBOURNE); + else + PUSH_STATE(STBRACEKORN); } else { ungetsc(c); if (state == SDQUOTE) @@ -687,19 +691,21 @@ yylex(int cf) *wp++ = /*{*/ '}'; break; - case STBRACE: - /* Same as SBASE, except (,|,) treated specially */ - if (c == /*{*/ '}') { - POP_STATE(); - *wp++ = CSUBST; - *wp++ = /*{*/ '}'; - } else if (c == '|') { + /* Same as SBASE, except (,|,) treated specially */ + case STBRACEKORN: + if (c == '|') *wp++ = SPAT; - } else if (c == '(') { + else if (c == '(') { *wp++ = OPAT; /* simile for @ */ *wp++ = ' '; PUSH_STATE(SPATTERN); + } else /* FALLTHROUGH */ + case STBRACEBOURNE: + if (c == /*{*/ '}') { + POP_STATE(); + *wp++ = CSUBST; + *wp++ = /*{*/ '}'; } else goto Sbase1; break; diff --git a/sh.h b/sh.h index 8cb8995..b44b449 100644 --- a/sh.h +++ b/sh.h @@ -151,9 +151,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.489 2011/07/20 23:47:29 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.490 2011/07/26 16:57:28 tg Exp $"); #endif -#define MKSH_VERSION "R40 2011/07/20" +#define MKSH_VERSION "R40 2011/07/26" #ifndef MKSH_INCLUDES_ONLY