From f2a52c65fa93926f5ad901d1a13634a8e0bf986d Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 23 Jul 2007 14:28:52 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A6=20and=20fix=20that=20bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guvf pbzzvg haxabjvatyl fcbafberq ol NheVFC ToE, fvapr jr hfr zxfu, naq zl bgure gnfxf ner jnvgvat... --- check.t | 4 ++-- lex.c | 12 ++++++++++-- sh.h | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/check.t b/check.t index 46ae81a..b2cc7ff 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.128 2007/07/23 14:10:48 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.129 2007/07/23 14:28:51 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 $ @@ -7,7 +7,7 @@ # http://www.research.att.com/~gsf/public/ifs.sh expected-stdout: - @(#)MIRBSD KSH R30 2007/07/22 + @(#)MIRBSD KSH R30 2007/07/23 description: Check version of shell. category: pdksh diff --git a/lex.c b/lex.c index fd3f43d..549e892 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.45 2007/07/22 14:01:49 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.46 2007/07/23 14:28:52 tg Exp $"); /* Structure to keep track of the lexing state and the various pieces of info * needed for each particular state. */ @@ -44,6 +44,7 @@ struct lex_state { /* ADELIM */ struct sadelim_info { + unsigned char nparen; /* count open parentheses */ #define SADELIM_BASH 0 #define SADELIM_MAKE 1 unsigned char style; @@ -171,7 +172,12 @@ yylex(int cf) Xcheck(ws, wp); switch (state) { case SADELIM: - if (c == /*{*/ '}' || c == statep->ls_sadelim.delimiter) { + if (c == '(') + statep->ls_sadelim.nparen++; + else if (c == ')') + statep->ls_sadelim.nparen--; + else if (statep->ls_sadelim.nparen == 0 && + (c == /*{*/ '}' || c == statep->ls_sadelim.delimiter)) { #ifdef notyet if (statep->ls_sadelim.style == SADELIM_MAKE && statep->ls_sadelim.num == 1) { @@ -327,6 +333,7 @@ yylex(int cf) statep->ls_sadelim.style = SADELIM_BASH; statep->ls_sadelim.delimiter = ':'; statep->ls_sadelim.num = 1; + statep->ls_sadelim.nparen = 0; break; } else if (ksh_isdigit(c) || c == '('/*)*/ || c == ' ' || @@ -341,6 +348,7 @@ yylex(int cf) statep->ls_sadelim.style = SADELIM_BASH; statep->ls_sadelim.delimiter = ':'; statep->ls_sadelim.num = 2; + statep->ls_sadelim.nparen = 0; break; } } diff --git a/sh.h b/sh.h index 6fa72ad..0362b84 100644 --- a/sh.h +++ b/sh.h @@ -8,8 +8,8 @@ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ -#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.161 2007/07/22 14:01:50 tg Exp $" -#define MKSH_VERSION "R30 2007/07/22" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.162 2007/07/23 14:28:52 tg Exp $" +#define MKSH_VERSION "R30 2007/07/23" #if HAVE_SYS_PARAM_H #include