~ubuntu-branches/ubuntu/lucid/mksh/lucid

« back to all changes in this revision

Viewing changes to debian/diffs/backport-function-parens.diff

  • Committer: Bazaar Package Importer
  • Author(s): Thorsten Glaser
  • Date: 2010-02-28 17:32:01 UTC
  • mfrom: (1.1.15 upstream) (2.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100228173201-wkqhm2ppvcj4opi0
Tags: 39.3-1ubuntu1
* Merge from Debian unstable. (Closes LP: #529559)
  New upstream version. (Closes LP: #355883)
  This integrates a workaround for a gcc bug. (cf. LP: #375604)
  Remaining Ubuntu changes:
  - debian/control, debian/rules: Exclude dietlibc on powerpc/ppc64
    and sparc (cf. LP: #381332)
  - debian/README.Debian, debian/mksh.postinst: Hardcode installing
    mksh as /bin/sh to false (cf. LP: #348872) but retain debconf
    infrastructure so that, if set to true in old installations, it
    will correctly be removed on upgrade

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
$MirOS: contrib/hosted/tg/deb/mksh/debian/diffs/backport-function-parens.diff,v 1.1 2009/09/26 21:06:54 tg Exp $
2
 
 
3
 
        Backport support for the "function stop () {" bashism
4
 
 
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:
8
 
        bar
9
 
        rab
10
 
 ---
11
 
+name: bash-function-parens
12
 
+description:
13
 
+       ensure the keyword function is ignored when preceding
14
 
+       POSIX style function declarations (bashism)
15
 
+stdin:
16
 
+       mk() {
17
 
+               echo '#!'"$__progname"
18
 
+               echo "$1 {"
19
 
+               echo '  echo "bar='\''$0'\'\"
20
 
+               echo '}'
21
 
+               echo ${2:-foo}
22
 
+       }
23
 
+       mk 'function foo' >f-korn
24
 
+       mk 'foo ()' >f-dash
25
 
+       mk 'function foo ()' >f-bash
26
 
+       mk 'function stop ()' stop >f-stop
27
 
+       chmod +x f-*
28
 
+       echo "korn: $(./f-korn)"
29
 
+       echo "dash: $(./f-dash)"
30
 
+       echo "bash: $(./f-bash)"
31
 
+       echo "stop: $(./f-stop)"
32
 
+expected-stdout:
33
 
+       korn: bar='foo'
34
 
+       dash: bar='./f-dash'
35
 
+       bash: bar='./f-bash'
36
 
+       stop: bar='./f-stop'
37
 
+---
38
 
 name: integer-base-one-1
39
 
 description:
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
45
 
 .Ar name
46
 
 will be ignored most of the time.
47
 
+.It Xo function Ar name Ns ()
48
 
+.No { Ar list ; No }
49
 
+.Xc
50
 
+The same as
51
 
+.Ar name Ns ()
52
 
+.Pq Nm bash Ns ism .
53
 
+The
54
 
+.Ic function
55
 
+keyword is ignored.
56
 
 .It Xo Ic time Op Fl p
57
 
 .Op Ar pipeline
58
 
 .Xc
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)
71
 
 
72
 
 static struct op *
73
 
 function_body(char *name,
74
 
-    int ksh_func)              /* function foo { ... } vs foo() { .. } */
75
 
+    bool ksh_func)             /* function foo { ... } vs foo() { .. } */
76
 
 {
77
 
        char *sname, *p;
78
 
        struct op *t;
79
 
@@ -612,11 +612,6 @@ function_body(char *name,
80
 
                if (ctype(*p, C_QUOTE) || *p == '=')
81
 
                        yyerror("%s: invalid function name\n", sname);
82
 
 
83
 
-       t = newtp(TFUNCT);
84
 
-       t->str = sname;
85
 
-       t->u.ksh_func = ksh_func;
86
 
-       t->lineno = source->line;
87
 
-
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,
92
 
         * an open-brace.
93
 
         */
94
 
        if (ksh_func) {
95
 
+               if (tpeek(CONTIN|KEYWORD|ALIAS) == '(' /* ) */) {
96
 
+                       struct tbl *tp;
97
 
+
98
 
+                       /* function foo () { */
99
 
+                       ACCEPT;
100
 
+                       musthave(')', 0);
101
 
+                       /* degrade to POSIX function */
102
 
+                       ksh_func = false;
103
 
+                       if ((tp = ktsearch(&aliases, sname, hash(sname))))
104
 
+                               ktdelete(tp);
105
 
+               }
106
 
                musthave('{', CONTIN|KEYWORD|ALIAS); /* } */
107
 
                REJECT;
108
 
        }
109
 
+
110
 
+       t = newtp(TFUNCT);
111
 
+       t->str = sname;
112
 
+       t->u.ksh_func = ksh_func;
113
 
+       t->lineno = source->line;
114
 
 
115
 
        old_func_parse = e->flags & EF_FUNC_PARSE;
116
 
        e->flags |= EF_FUNC_PARSE;