even more test cases for comsub (2 breaking, but one of them fixed already)
This commit is contained in:
parent
97e1987dbf
commit
fb1392fb6b
18
check.t
18
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.419 2011/03/12 01:04:39 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.420 2011/03/12 20:20:14 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 $
|
||||
@ -6949,9 +6949,25 @@ description:
|
||||
stdin:
|
||||
echo $(case 1 in (1) echo yes;; (2) echo no;; esac)
|
||||
echo $(case 1 in 1) echo yes;; 2) echo no;; esac)
|
||||
echo $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))
|
||||
echo $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))
|
||||
TEST=1234; echo ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)}
|
||||
TEST=5678; echo ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)}
|
||||
(( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo $a.
|
||||
(( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo $a.
|
||||
a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo ${a[0]}.
|
||||
a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo ${a[0]}.
|
||||
expected-stdout:
|
||||
yes
|
||||
yes
|
||||
11
|
||||
21
|
||||
234
|
||||
678
|
||||
1.
|
||||
1.
|
||||
1.
|
||||
1.
|
||||
---
|
||||
name: comsub-2
|
||||
description:
|
||||
|
11
lex.c
11
lex.c
@ -1,4 +1,3 @@
|
||||
|
||||
/* $OpenBSD: lex.c,v 1.44 2008/07/03 17:52:08 otto Exp $ */
|
||||
|
||||
/*-
|
||||
@ -23,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.129 2011/03/07 20:32:49 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.130 2011/03/12 20:20:16 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@ -100,7 +99,7 @@ static int dopprompt(const char *, int, bool);
|
||||
|
||||
static int backslash_skip;
|
||||
static int ignore_backslash_newline;
|
||||
static int comsub_nesting_level;
|
||||
short comsub_nesting_level = 0;
|
||||
|
||||
/* optimised getsc_bn() */
|
||||
#define _getsc() (*source->str != '\0' && *source->str != '\\' \
|
||||
@ -360,9 +359,7 @@ yylex(int cf)
|
||||
} else {
|
||||
ungetsc(c);
|
||||
subst_command:
|
||||
++comsub_nesting_level;
|
||||
sp = yyrecursive();
|
||||
--comsub_nesting_level;
|
||||
c2 = strlen(sp) + 1;
|
||||
XcheckN(ws, wp, c2);
|
||||
*wp++ = COMSUB;
|
||||
@ -751,11 +748,13 @@ yylex(int cf)
|
||||
case SLETARRAY:
|
||||
if (c == '('/*)*/)
|
||||
++statep->nparen;
|
||||
else if (c == /*(*/')')
|
||||
else if (c == /*(*/')') {
|
||||
if (statep->nparen-- == 0) {
|
||||
c = 0;
|
||||
goto Done;
|
||||
}
|
||||
} else if (c == '$')
|
||||
goto subst_dollar;
|
||||
*wp++ = CHAR;
|
||||
*wp++ = c;
|
||||
break;
|
||||
|
7
syn.c
7
syn.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.54 2011/03/06 01:25:35 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.55 2011/03/12 20:20:17 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
@ -1093,6 +1093,10 @@ yyrecursive(void)
|
||||
char *cp;
|
||||
bool old_reject;
|
||||
int old_symbol;
|
||||
extern short comsub_nesting_level;
|
||||
|
||||
/* tell the lexer to accept a closing parenthesis as EOD */
|
||||
++comsub_nesting_level;
|
||||
|
||||
/* push reject state, parse recursively, pop reject state */
|
||||
old_reject = reject;
|
||||
@ -1107,5 +1111,6 @@ yyrecursive(void)
|
||||
cp = snptreef(NULL, 0, "%T", t->left);
|
||||
tfree(t, ATEMP);
|
||||
|
||||
--comsub_nesting_level;
|
||||
return (cp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user