From 401e2626890ef3bc779b2074ba8c588c93f08055 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 27 Mar 2010 16:53:17 +0000 Subject: [PATCH] fix another expand-ugly SUSv4 bug --- check.t | 4 ++-- lex.c | 27 ++++++++++++++++++++++----- sh.h | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/check.t b/check.t index b974b1c..31200f9 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.369 2010/03/18 19:45:39 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.370 2010/03/27 16:53:15 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 R39 2010/03/14 + @(#)MIRBSD KSH R39 2010/03/27 description: Check version of shell. stdin: diff --git a/lex.c b/lex.c index f66c900..f6a4c45 100644 --- a/lex.c +++ b/lex.c @@ -22,7 +22,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.110 2010/02/25 20:18:16 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.111 2010/03/27 16:53:16 tg Exp $"); /* * states while lexing word @@ -324,6 +324,7 @@ yylex(int cf) getsc_qchar: if ((c = getsc())) { /* trailing \ is lost */ + store_qchar: *wp++ = QCHAR; *wp++ = c; } @@ -687,15 +688,31 @@ yylex(int cf) *wp++ = c; break; + case SQBRACE: + if (c == '\\') { + /* + * perform POSIX "quote removal" if the back- + * slash is "special", i.e. same cases as the + * {case '\\':} in Subst: plus closing brace; + * in mksh code "quote removal" on '\c' means + * write QCHAR+c, otherwise CHAR+\+CHAR+c are + * emitted (in heredocquote:) + */ + if ((c = getsc()) == '"' || c == '\\' || + c == '$' || c == '`' || c == /*{*/'}') + goto store_qchar; + goto heredocquote; + } + goto common_SQBRACE; + case SBRACE: if (c == '\'') goto open_ssquote; - /* FALLTHROUGH */ - case SQBRACE: - if (c == '"') - goto open_sdquote; else if (c == '\\') goto getsc_qchar; + common_SQBRACE: + if (c == '"') + goto open_sdquote; else if (c == '$') goto subst_dollar; else if (c == '`') diff --git a/sh.h b/sh.h index 8f10ac4..c4521e7 100644 --- a/sh.h +++ b/sh.h @@ -150,9 +150,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.385 2010/03/27 16:51:39 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.386 2010/03/27 16:53:17 tg Exp $"); #endif -#define MKSH_VERSION "R39 2010/03/14" +#define MKSH_VERSION "R39 2010/03/27" #ifndef MKSH_INCLUDES_ONLY