aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-29 10:16:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-29 10:16:05 +0000
commitdadfb4975b23b284fa02d15a5cfd21593b2993fc (patch)
tree993a6e7a9efd1d2a06408d9cd069cb4eeb09e883
parente1ee48e0fdfe18aadb410b62f21516bf4b8ea581 (diff)
downloadbusybox-w32-dadfb4975b23b284fa02d15a5cfd21593b2993fc.tar.gz
busybox-w32-dadfb4975b23b284fa02d15a5cfd21593b2993fc.tar.bz2
busybox-w32-dadfb4975b23b284fa02d15a5cfd21593b2993fc.zip
hush: add #defines to switch off break/continue if loops are not supported
*: remove a few inline keywords no code changes
-rw-r--r--modutils/modprobe.c2
-rw-r--r--modutils/rmmod.c2
-rw-r--r--networking/interface.c2
-rw-r--r--networking/traceroute.c4
-rw-r--r--procps/nmeter.c2
-rw-r--r--shell/hush.c17
-rw-r--r--shell/hush_test/hush-misc/builtin1.right2
-rwxr-xr-xshell/hush_test/hush-misc/builtin1.tests6
8 files changed, 30 insertions, 7 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 0c59e8ab3..3a2d893ee 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -263,7 +263,7 @@ static int FAST_FUNC include_conf_dir_act(const char *filename UNUSED_PARAM,
263 return TRUE; 263 return TRUE;
264} 264}
265 265
266static int inline include_conf_recursive(struct include_conf_t *conf, const char *filename) 266static int include_conf_recursive(struct include_conf_t *conf, const char *filename)
267{ 267{
268 return recursive_action(filename, ACTION_RECURSE, 268 return recursive_action(filename, ACTION_RECURSE,
269 include_conf_file_act, 269 include_conf_file_act,
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index a96a27457..5129b3495 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -17,7 +17,7 @@ extern int delete_module(const char *module, unsigned int flags);
17#endif 17#endif
18 18
19#if ENABLE_FEATURE_2_6_MODULES 19#if ENABLE_FEATURE_2_6_MODULES
20static inline void filename2modname(char *modname, const char *afterslash) 20static void filename2modname(char *modname, const char *afterslash)
21{ 21{
22 unsigned int i; 22 unsigned int i;
23 int kr_chk = 1; 23 int kr_chk = 1;
diff --git a/networking/interface.c b/networking/interface.c
index 065b4baeb..7861b9fd9 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -498,7 +498,7 @@ static void get_dev_fields(char *bp, struct interface *ife, int procnetdev_vsn)
498 } 498 }
499} 499}
500 500
501static inline int procnetdev_version(char *buf) 501static int procnetdev_version(char *buf)
502{ 502{
503 if (strstr(buf, "compressed")) 503 if (strstr(buf, "compressed"))
504 return 2; 504 return 2;
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 4e6ca2d9b..29cebfa61 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -819,7 +819,7 @@ packet_ok(unsigned char *buf, int cc, struct sockaddr_in *from, int seq)
819 * If the nflag has been supplied, give 819 * If the nflag has been supplied, give
820 * numeric value, otherwise try for symbolic name. 820 * numeric value, otherwise try for symbolic name.
821 */ 821 */
822static inline void 822static void
823print_inetname(struct sockaddr_in *from) 823print_inetname(struct sockaddr_in *from)
824{ 824{
825 const char *ina; 825 const char *ina;
@@ -836,7 +836,7 @@ print_inetname(struct sockaddr_in *from)
836 } 836 }
837} 837}
838 838
839static inline void 839static void
840print(unsigned char *buf, int cc, struct sockaddr_in *from) 840print(unsigned char *buf, int cc, struct sockaddr_in *from)
841{ 841{
842 struct ip *ip; 842 struct ip *ip;
diff --git a/procps/nmeter.c b/procps/nmeter.c
index be039320b..48a5b4e26 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -152,7 +152,7 @@ static const char* get_file(proc_file *pf)
152 return pf->file; 152 return pf->file;
153} 153}
154 154
155static inline ullong read_after_slash(const char *p) 155static ullong read_after_slash(const char *p)
156{ 156{
157 p = strchr(p, '/'); 157 p = strchr(p, '/');
158 if (!p) return 0; 158 if (!p) return 0;
diff --git a/shell/hush.c b/shell/hush.c
index 5b2f188cd..5af939d06 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -434,13 +434,17 @@ struct globals {
434 struct pipe *toplevel_list; 434 struct pipe *toplevel_list;
435 smallint ctrl_z_flag; 435 smallint ctrl_z_flag;
436#endif 436#endif
437#if ENABLE_HUSH_LOOPS
437 smallint flag_break_continue; 438 smallint flag_break_continue;
439#endif
438 smallint fake_mode; 440 smallint fake_mode;
439 /* these three support $?, $#, and $1 */ 441 /* these three support $?, $#, and $1 */
440 smalluint last_return_code; 442 smalluint last_return_code;
441 char **global_argv; 443 char **global_argv;
442 int global_argc; 444 int global_argc;
445#if ENABLE_HUSH_LOOPS
443 unsigned depth_break_continue; 446 unsigned depth_break_continue;
447#endif
444 pid_t last_bg_pid; 448 pid_t last_bg_pid;
445 const char *ifs; 449 const char *ifs;
446 const char *cwd; 450 const char *cwd;
@@ -722,8 +726,10 @@ static int builtin_shift(char **argv);
722static int builtin_source(char **argv); 726static int builtin_source(char **argv);
723static int builtin_umask(char **argv); 727static int builtin_umask(char **argv);
724static int builtin_unset(char **argv); 728static int builtin_unset(char **argv);
729#if ENABLE_HUSH_LOOPS
725static int builtin_break(char **argv); 730static int builtin_break(char **argv);
726static int builtin_continue(char **argv); 731static int builtin_continue(char **argv);
732#endif
727//static int builtin_not_written(char **argv); 733//static int builtin_not_written(char **argv);
728 734
729/* Table of built-in functions. They can be forked or not, depending on 735/* Table of built-in functions. They can be forked or not, depending on
@@ -753,9 +759,13 @@ static const struct built_in_command bltins[] = {
753#if ENABLE_HUSH_JOB 759#if ENABLE_HUSH_JOB
754 BLTIN("bg" , builtin_fg_bg, "Resume a job in the background"), 760 BLTIN("bg" , builtin_fg_bg, "Resume a job in the background"),
755#endif 761#endif
762#if ENABLE_HUSH_LOOPS
756 BLTIN("break" , builtin_break, "Exit from a loop"), 763 BLTIN("break" , builtin_break, "Exit from a loop"),
764#endif
757 BLTIN("cd" , builtin_cd, "Change directory"), 765 BLTIN("cd" , builtin_cd, "Change directory"),
766#if ENABLE_HUSH_LOOPS
758 BLTIN("continue", builtin_continue, "Start new loop iteration"), 767 BLTIN("continue", builtin_continue, "Start new loop iteration"),
768#endif
759 BLTIN("echo" , builtin_echo, "Write to stdout"), 769 BLTIN("echo" , builtin_echo, "Write to stdout"),
760 BLTIN("eval" , builtin_eval, "Construct and run shell command"), 770 BLTIN("eval" , builtin_eval, "Construct and run shell command"),
761 BLTIN("exec" , builtin_exec, "Execute command, don't return to shell"), 771 BLTIN("exec" , builtin_exec, "Execute command, don't return to shell"),
@@ -2246,13 +2256,15 @@ static int run_list(struct pipe *pi)
2246 debug_printf_exec(": run_pipe with %d members\n", pi->num_progs); 2256 debug_printf_exec(": run_pipe with %d members\n", pi->num_progs);
2247 { 2257 {
2248 int r; 2258 int r;
2259#if ENABLE_HUSH_LOOPS
2249 flag_break_continue = 0; 2260 flag_break_continue = 0;
2261#endif
2250 rcode = r = run_pipe(pi); /* NB: rcode is a smallint */ 2262 rcode = r = run_pipe(pi); /* NB: rcode is a smallint */
2251 if (r != -1) { 2263 if (r != -1) {
2252 /* we only ran a builtin: rcode is already known 2264 /* we only ran a builtin: rcode is already known
2253 * and we don't need to wait for anything. */ 2265 * and we don't need to wait for anything. */
2266#if ENABLE_HUSH_LOOPS
2254 /* was it "break" or "continue"? */ 2267 /* was it "break" or "continue"? */
2255
2256 if (flag_break_continue) { 2268 if (flag_break_continue) {
2257 smallint fbc = flag_break_continue; 2269 smallint fbc = flag_break_continue;
2258 /* we might fall into outer *loop*, 2270 /* we might fall into outer *loop*,
@@ -2271,6 +2283,7 @@ static int run_list(struct pipe *pi)
2271 bb_error_msg("break/continue: only meaningful in a loop"); 2283 bb_error_msg("break/continue: only meaningful in a loop");
2272 /* bash compat: exit code is still 0 */ 2284 /* bash compat: exit code is still 0 */
2273 } 2285 }
2286#endif
2274 } else if (pi->followup == PIPE_BG) { 2287 } else if (pi->followup == PIPE_BG) {
2275 /* what does bash do with attempts to background builtins? */ 2288 /* what does bash do with attempts to background builtins? */
2276 /* even bash 3.2 doesn't do that well with nested bg: 2289 /* even bash 3.2 doesn't do that well with nested bg:
@@ -4534,6 +4547,7 @@ static int builtin_unset(char **argv)
4534 return EXIT_SUCCESS; 4547 return EXIT_SUCCESS;
4535} 4548}
4536 4549
4550#if ENABLE_HUSH_LOOPS
4537static int builtin_break(char **argv) 4551static int builtin_break(char **argv)
4538{ 4552{
4539 flag_break_continue++; /* BC_BREAK = 1 */ 4553 flag_break_continue++; /* BC_BREAK = 1 */
@@ -4554,3 +4568,4 @@ static int builtin_continue(char **argv)
4554 flag_break_continue++; /* BC_CONTINUE = 2 = 1+1 */ 4568 flag_break_continue++; /* BC_CONTINUE = 2 = 1+1 */
4555 return builtin_break(argv); 4569 return builtin_break(argv);
4556} 4570}
4571#endif
diff --git a/shell/hush_test/hush-misc/builtin1.right b/shell/hush_test/hush-misc/builtin1.right
new file mode 100644
index 000000000..2e55ecb09
--- /dev/null
+++ b/shell/hush_test/hush-misc/builtin1.right
@@ -0,0 +1,2 @@
1VARIABLE=export
2OK:0
diff --git a/shell/hush_test/hush-misc/builtin1.tests b/shell/hush_test/hush-misc/builtin1.tests
new file mode 100755
index 000000000..1a2941faa
--- /dev/null
+++ b/shell/hush_test/hush-misc/builtin1.tests
@@ -0,0 +1,6 @@
1# builtins, unlike keywords like "while", can be constructed
2# with substitutions
3VARIABLE=export
4$VARIABLE VARIABLE
5env | grep ^VARIABLE
6echo OK:$?