1
$MirOS: contrib/hosted/tg/deb/mksh/debian/diffs/backport-function-parens.diff,v 1.1 2009/09/26 21:06:54 tg Exp $
3
Backport support for the "function stop () {" bashism
5
--- check.t~ Sat Sep 26 21:02:49 2009
6
+++ check.t Sat Sep 26 21:03:12 2009
7
@@ -5102,6 +5102,33 @@ expected-stdout:
11
+name: bash-function-parens
13
+ ensure the keyword function is ignored when preceding
14
+ POSIX style function declarations (bashism)
17
+ echo '#!'"$__progname"
19
+ echo ' echo "bar='\''$0'\'\"
23
+ mk 'function foo' >f-korn
25
+ mk 'function foo ()' >f-bash
26
+ mk 'function stop ()' stop >f-stop
28
+ echo "korn: $(./f-korn)"
29
+ echo "dash: $(./f-dash)"
30
+ echo "bash: $(./f-bash)"
31
+ echo "stop: $(./f-stop)"
34
+ dash: bar='./f-dash'
35
+ bash: bar='./f-bash'
36
+ stop: bar='./f-stop'
38
name: integer-base-one-1
40
check if the use of fake integer base 1 works
41
--- mksh.1~ Sat Sep 26 21:02:49 2009
42
+++ mksh.1 Sat Sep 26 21:03:12 2009
43
@@ -741,6 +741,15 @@ below).
44
Whitespace (space or tab) after
46
will be ignored most of the time.
47
+.It Xo function Ar name Ns ()
56
.It Xo Ic time Op Fl p
59
--- syn.c~ Sat Sep 26 21:02:49 2009
60
+++ syn.c Sat Sep 26 21:03:12 2009
61
@@ -41,7 +41,7 @@ static struct op *thenpart(void);
62
static struct op *elsepart(void);
63
static struct op *caselist(void);
64
static struct op *casepart(int);
65
-static struct op *function_body(char *, int);
66
+static struct op *function_body(char *, bool);
67
static char **wordlist(void);
68
static struct op *block(int, struct op *, struct op *, char **);
69
static struct op *newtp(int);
70
@@ -595,7 +595,7 @@ casepart(int endtok)
73
function_body(char *name,
74
- int ksh_func) /* function foo { ... } vs foo() { .. } */
75
+ bool ksh_func) /* function foo { ... } vs foo() { .. } */
79
@@ -612,11 +612,6 @@ function_body(char *name,
80
if (ctype(*p, C_QUOTE) || *p == '=')
81
yyerror("%s: invalid function name\n", sname);
85
- t->u.ksh_func = ksh_func;
86
- t->lineno = source->line;
88
/* Note that POSIX allows only compound statements after foo(), sh and
89
* AT&T ksh allow any command, go with the later since it shouldn't
90
* break anything. However, for function foo, AT&T ksh only accepts
91
@@ -623,9 +618,25 @@ function_body(char *name,
95
+ if (tpeek(CONTIN|KEYWORD|ALIAS) == '(' /* ) */) {
98
+ /* function foo () { */
101
+ /* degrade to POSIX function */
103
+ if ((tp = ktsearch(&aliases, sname, hash(sname))))
106
musthave('{', CONTIN|KEYWORD|ALIAS); /* } */
112
+ t->u.ksh_func = ksh_func;
113
+ t->lineno = source->line;
115
old_func_parse = e->flags & EF_FUNC_PARSE;
116
e->flags |= EF_FUNC_PARSE;