let SLETARRAY use SRETRACE, too

This commit is contained in:
tg 2011-03-13 15:57:23 +00:00
parent f16386954d
commit e66eaab861
2 changed files with 22 additions and 21 deletions

17
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.423 2011/03/13 01:20:14 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.424 2011/03/13 15:57:21 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 $
@ -6947,6 +6947,8 @@ stdin:
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))
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]}.
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.
@ -6956,22 +6958,13 @@ expected-stdout:
yes
11
21
1.
1.
234
678
1.
1.
---
name: comsub-1b
description:
COMSUB inside SLETARRAY and SASPAREN/EXPRSUB
expected-fail: yes
stdin:
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:
1.
1.
---
name: comsub-2
description:
RedHat BZ#496791 another case of missing recursion

26
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.137 2011/03/13 15:31:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.138 2011/03/13 15:57:23 tg Exp $");
/*
* states while lexing word
@ -214,17 +214,18 @@ yylex(int cf)
backslash_skip = 0;
ignore_backslash_newline = 0;
if (cf&ONEWORD)
if (cf & ONEWORD)
state = SWORD;
else if (cf&LETEXPR) {
else if (cf & LETEXPR) {
/* enclose arguments in (double) quotes */
*wp++ = OQUOTE;
state = SLETPAREN;
statep->nparen = 0;
#ifndef MKSH_SMALL
} else if (cf&LETARRAY) {
} else if (cf & LETARRAY) {
state = SLETARRAY;
statep->nparen = 0;
PUSH_SRETRACE();
#endif
} else {
/* normal lexing */
@ -789,13 +790,20 @@ yylex(int cf)
++statep->nparen;
else if (c == /*(*/')') {
if (statep->nparen-- == 0) {
c = 0;
POP_SRETRACE();
/* drop trailing paren */
c = strlen(dp = sp) - 1;
XcheckN(ws, wp, c * 2);
while (c--) {
*wp++ = CHAR;
*wp++ = *dp++;
}
afree(sp, ATEMP);
/* assert: c == 0 */
goto Done;
}
}
*wp++ = CHAR;
*wp++ = c;
break;
goto Sbase2;
#endif
/* <<< delimiter */
@ -1064,7 +1072,7 @@ yylex(int cf)
/* word is not unquoted */
*ident = '\0';
if (*ident != '\0' && (cf&(KEYWORD|ALIAS))) {
if (*ident != '\0' && (cf & (KEYWORD | ALIAS))) {
struct tbl *p;
uint32_t h = hash(ident);