From 2dffc771ac81892ac906c2c18cd50cb16efbaf4d Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 26 Mar 2011 15:32:37 +0000 Subject: [PATCH] new (some possible) testcases from Austin ML, and one fix --- check.t | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- lex.c | 13 +++-- syn.c | 11 ++-- 3 files changed, 166 insertions(+), 10 deletions(-) diff --git a/check.t b/check.t index afc6e1f..ed9e354 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.432 2011/03/23 18:47:04 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.433 2011/03/26 15:32:35 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 $ @@ -2080,6 +2080,156 @@ expected-stdout: } vf={=f $x @= } | --- +name: heredoc-comsub-1 +description: + Tests for here documents in COMSUB, taken from Austin ML +stdin: + text=$(cat <str != '\0' && *source->str != '\\' && \ @@ -1198,10 +1198,13 @@ readhere(struct ioword *iop) /* end of here document marker, what to do? */ switch (c) { case /*(*/ ')': - if (!comsub_nesting_level) - /* not allowed outside $(...) => mismatch */ + if (!subshell_nesting_level) + /*- + * not allowed outside $(...) or (...) + * => mismatch + */ break; - /* Allow $(...) to close here */ + /* allow $(...) or (...) to close here */ ungetsc(/*(*/ ')'); /* FALLTHROUGH */ case 0: diff --git a/syn.c b/syn.c index d099b86..3809529 100644 --- a/syn.c +++ b/syn.c @@ -22,7 +22,9 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.58 2011/03/21 21:57:35 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.59 2011/03/26 15:32:37 tg Exp $"); + +extern short subshell_nesting_level; struct nesting_state { int start_token; /* token than began nesting (eg, FOR) */ @@ -356,7 +358,9 @@ get_command(int cf) case '(': Subshell: + ++subshell_nesting_level; t = nested(TPAREN, '(', ')'); + --subshell_nesting_level; break; case '{': /*}*/ @@ -1098,10 +1102,9 @@ yyrecursive(void) bool old_reject; int old_symbol; struct ioword **old_herep; - extern short comsub_nesting_level; /* tell the lexer to accept a closing parenthesis as EOD */ - ++comsub_nesting_level; + ++subshell_nesting_level; /* push reject state, parse recursively, pop reject state */ old_reject = reject; @@ -1118,6 +1121,6 @@ yyrecursive(void) cp = snptreef(NULL, 0, "%T", t->left); tfree(t, ATEMP); - --comsub_nesting_level; + --subshell_nesting_level; return (cp); }