remove empty patches left over after [12348]
[openwrt/svn-archive/archive.git] / package / busybox / patches / 903-ash.patch
1 --- a/shell/ash.c
2 +++ b/shell/ash.c
3 @@ -1569,14 +1569,14 @@
4 static char *optptr; /* used by nextopt */
5
6 /*
7 - * XXX - should get rid of. have all builtins use getopt(3). the
8 - * library getopt must have the BSD extension static variable "optreset"
9 - * otherwise it can't be used within the shell safely.
10 + * XXX - should get rid of. Have all builtins use getopt(3).
11 + * The library getopt must have the BSD extension static variable
12 + * "optreset", otherwise it can't be used within the shell safely.
13 *
14 - * Standard option processing (a la getopt) for builtin routines. The
15 - * only argument that is passed to nextopt is the option string; the
16 - * other arguments are unnecessary. It return the character, or '\0' on
17 - * end of input.
18 + * Standard option processing (a la getopt) for builtin routines.
19 + * The only argument that is passed to nextopt is the option string;
20 + * the other arguments are unnecessary. It returns the character,
21 + * or '\0' on end of input.
22 */
23 static int
24 nextopt(const char *optstring)
25 @@ -1587,13 +1587,20 @@
26
27 p = optptr;
28 if (p == NULL || *p == '\0') {
29 + /* We ate entire "-param", take next one */
30 p = *argptr;
31 - if (p == NULL || *p != '-' || *++p == '\0')
32 + if (p == NULL)
33 + return '\0';
34 + if (*p != '-')
35 + return '\0';
36 + if (*++p == '\0') /* just "-" ? */
37 return '\0';
38 argptr++;
39 - if (LONE_DASH(p)) /* check for "--" */
40 + if (LONE_DASH(p)) /* "--" ? */
41 return '\0';
42 + /* p => next "-param" */
43 }
44 + /* p => some option char in the middle of a "-param" */
45 c = *p++;
46 for (q = optstring; *q != c;) {
47 if (*q == '\0')
48 @@ -1602,8 +1609,11 @@
49 q++;
50 }
51 if (*++q == ':') {
52 - if (*p == '\0' && (p = *argptr++) == NULL)
53 - ash_msg_and_raise_error("no arg for -%c option", c);
54 + if (*p == '\0') {
55 + p = *argptr++;
56 + if (p == NULL)
57 + ash_msg_and_raise_error("no arg for -%c option", c);
58 + }
59 optionarg = p;
60 p = NULL;
61 }
62 @@ -7428,8 +7438,10 @@
63 else if (c != 'p')
64 abort();
65 #endif
66 - if (verify)
67 + /* Mimic bash: just "command -v" doesn't complain, it's a nop */
68 + if (verify && (*argptr != NULL)) {
69 return describe_command(*argptr, verify - VERIFY_BRIEF);
70 + }
71
72 return 0;
73 }
74 @@ -7788,16 +7800,33 @@
75 static void
76 evaltree(union node *n, int flags)
77 {
78 +
79 + struct jmploc *volatile savehandler = exception_handler;
80 + struct jmploc jmploc;
81 int checkexit = 0;
82 void (*evalfn)(union node *, int);
83 - unsigned isor;
84 int status;
85 +
86 if (n == NULL) {
87 TRACE(("evaltree(NULL) called\n"));
88 - goto out;
89 + goto out1;
90 }
91 TRACE(("pid %d, evaltree(%p: %d, %d) called\n",
92 getpid(), n, n->type, flags));
93 +
94 + exception_handler = &jmploc;
95 + {
96 + int err = setjmp(jmploc.loc);
97 + if (err) {
98 + /* if it was a signal, check for trap handlers */
99 + if (exception == EXSIG)
100 + goto out;
101 + /* continue on the way out */
102 + exception_handler = savehandler;
103 + longjmp(exception_handler->loc, err);
104 + }
105 + }
106 +
107 switch (n->type) {
108 default:
109 #if DEBUG
110 @@ -7843,19 +7872,20 @@
111 goto calleval;
112 case NAND:
113 case NOR:
114 - case NSEMI:
115 + case NSEMI: {
116 +
117 #if NAND + 1 != NOR
118 #error NAND + 1 != NOR
119 #endif
120 #if NOR + 1 != NSEMI
121 #error NOR + 1 != NSEMI
122 #endif
123 - isor = n->type - NAND;
124 + unsigned is_or = n->type - NAND;
125 evaltree(
126 n->nbinary.ch1,
127 - (flags | ((isor >> 1) - 1)) & EV_TESTED
128 + (flags | ((is_or >> 1) - 1)) & EV_TESTED
129 );
130 - if (!exitstatus == isor)
131 + if (!exitstatus == is_or)
132 break;
133 if (!evalskip) {
134 n = n->nbinary.ch2;
135 @@ -7866,6 +7896,7 @@
136 break;
137 }
138 break;
139 + }
140 case NIF:
141 evaltree(n->nif.test, EV_TESTED);
142 if (evalskip)
143 @@ -7886,8 +7917,11 @@
144 exitstatus = status;
145 break;
146 }
147 +
148 out:
149 - if ((checkexit & exitstatus))
150 + exception_handler = savehandler;
151 + out1:
152 + if (checkexit & exitstatus)
153 evalskip |= SKIPEVAL;
154 else if (pendingsig && dotrap())
155 goto exexit;