new (some possible) testcases from Austin ML, and one fix
This commit is contained in:
parent
803c51914b
commit
2dffc771ac
152
check.t
152
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 <<EOF
|
||||
here is the text
|
||||
EOF)
|
||||
echo = $text =
|
||||
expected-stdout:
|
||||
= here is the text =
|
||||
---
|
||||
name: heredoc-comsub-2
|
||||
description:
|
||||
Tests for here documents in COMSUB, taken from Austin ML
|
||||
stdin:
|
||||
unbalanced=$(cat <<EOF
|
||||
this paren ) is a problem
|
||||
EOF)
|
||||
echo = $unbalanced =
|
||||
expected-stdout:
|
||||
= this paren ) is a problem =
|
||||
---
|
||||
name: heredoc-comsub-3
|
||||
description:
|
||||
Tests for here documents in COMSUB, taken from Austin ML
|
||||
stdin:
|
||||
balanced=$(cat <<EOF
|
||||
these parens ( ) are not a problem
|
||||
EOF)
|
||||
echo = $balanced =
|
||||
expected-stdout:
|
||||
= these parens ( ) are not a problem =
|
||||
---
|
||||
name: heredoc-comsub-4
|
||||
description:
|
||||
Tests for here documents in COMSUB, taken from Austin ML
|
||||
stdin:
|
||||
balanced=$(cat <<EOF
|
||||
these parens \( ) are a problem
|
||||
EOF)
|
||||
echo = $balanced =
|
||||
expected-stdout:
|
||||
= these parens \( ) are a problem =
|
||||
---
|
||||
name: heredoc-subshell-1
|
||||
description:
|
||||
Tests for here documents in subshells, taken from Austin ML
|
||||
stdin:
|
||||
(cat <<EOF
|
||||
some text
|
||||
EOF)
|
||||
echo end
|
||||
expected-stdout:
|
||||
some text
|
||||
end
|
||||
---
|
||||
name: heredoc-subshell-2
|
||||
description:
|
||||
Tests for here documents in subshells, taken from Austin ML
|
||||
stdin:
|
||||
(cat <<EOF
|
||||
some text
|
||||
EOF
|
||||
)
|
||||
echo end
|
||||
expected-stdout:
|
||||
some text
|
||||
end
|
||||
---
|
||||
name: heredoc-subshell-3
|
||||
description:
|
||||
Tests for here documents in subshells, taken from Austin ML
|
||||
stdin:
|
||||
(cat <<EOF; )
|
||||
some text
|
||||
EOF
|
||||
echo end
|
||||
expected-stdout:
|
||||
some text
|
||||
end
|
||||
---
|
||||
name: heredoc-weird-1
|
||||
description:
|
||||
Tests for here documents, taken from Austin ML
|
||||
Documents current state in mksh, *NOT* necessarily correct!
|
||||
stdin:
|
||||
cat <<END
|
||||
hello
|
||||
END\
|
||||
END
|
||||
END
|
||||
echo end
|
||||
expected-stdout:
|
||||
hello
|
||||
ENDEND
|
||||
end
|
||||
---
|
||||
name: heredoc-weird-2
|
||||
description:
|
||||
Tests for here documents, taken from Austin ML
|
||||
stdin:
|
||||
cat <<' END '
|
||||
hello
|
||||
END
|
||||
echo end
|
||||
expected-stdout:
|
||||
hello
|
||||
end
|
||||
---
|
||||
name: heredoc-weird-3
|
||||
description:
|
||||
Tests for here documents, taken from Austin ML
|
||||
stdin:
|
||||
cat <<x*x & touch 'x*x'
|
||||
hello
|
||||
x*x
|
||||
echo end
|
||||
expected-stdout:
|
||||
hello
|
||||
end
|
||||
---
|
||||
name: heredoc-weird-4
|
||||
description:
|
||||
Tests for here documents, taken from Austin ML
|
||||
Documents current state in mksh, *NOT* necessarily correct!
|
||||
stdin:
|
||||
cat <<END
|
||||
hello\
|
||||
END
|
||||
END
|
||||
echo end
|
||||
expected-stdout:
|
||||
helloEND
|
||||
end
|
||||
---
|
||||
name: heredoc-weird-5
|
||||
description:
|
||||
Tests for here documents, taken from Austin ML
|
||||
Documents current state in mksh, *NOT* necessarily correct!
|
||||
stdin:
|
||||
cat <<END
|
||||
hello
|
||||
\END
|
||||
END
|
||||
echo end
|
||||
expected-stdout:
|
||||
hello
|
||||
\END
|
||||
end
|
||||
---
|
||||
name: heredoc-quoting-unsubst
|
||||
description:
|
||||
Check for correct handling of quoted characters in
|
||||
|
13
lex.c
13
lex.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.142 2011/03/13 16:35:54 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.143 2011/03/26 15:32:37 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@ -108,7 +108,7 @@ void yyskiputf8bom(void);
|
||||
static int backslash_skip;
|
||||
static int ignore_backslash_newline;
|
||||
static struct sretrace_info *retrace_info = NULL;
|
||||
short comsub_nesting_level = 0;
|
||||
short subshell_nesting_level = 0;
|
||||
|
||||
/* optimised getsc_bn() */
|
||||
#define _getsc() (*source->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:
|
||||
|
11
syn.c
11
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user