diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-29 10:16:05 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-29 10:16:05 +0000 |
commit | dadfb4975b23b284fa02d15a5cfd21593b2993fc (patch) | |
tree | 993a6e7a9efd1d2a06408d9cd069cb4eeb09e883 | |
parent | e1ee48e0fdfe18aadb410b62f21516bf4b8ea581 (diff) | |
download | busybox-dadfb4975b23b284fa02d15a5cfd21593b2993fc.tar.gz |
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.c | 2 | ||||
-rw-r--r-- | modutils/rmmod.c | 2 | ||||
-rw-r--r-- | networking/interface.c | 2 | ||||
-rw-r--r-- | networking/traceroute.c | 4 | ||||
-rw-r--r-- | procps/nmeter.c | 2 | ||||
-rw-r--r-- | shell/hush.c | 17 | ||||
-rw-r--r-- | shell/hush_test/hush-misc/builtin1.right | 2 | ||||
-rwxr-xr-x | shell/hush_test/hush-misc/builtin1.tests | 6 |
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, return TRUE; } -static int inline include_conf_recursive(struct include_conf_t *conf, const char *filename) +static int include_conf_recursive(struct include_conf_t *conf, const char *filename) { return recursive_action(filename, ACTION_RECURSE, 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); #endif #if ENABLE_FEATURE_2_6_MODULES -static inline void filename2modname(char *modname, const char *afterslash) +static void filename2modname(char *modname, const char *afterslash) { unsigned int i; 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) } } -static inline int procnetdev_version(char *buf) +static int procnetdev_version(char *buf) { if (strstr(buf, "compressed")) 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) * If the nflag has been supplied, give * numeric value, otherwise try for symbolic name. */ -static inline void +static void print_inetname(struct sockaddr_in *from) { const char *ina; @@ -836,7 +836,7 @@ print_inetname(struct sockaddr_in *from) } } -static inline void +static void print(unsigned char *buf, int cc, struct sockaddr_in *from) { 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) return pf->file; } -static inline ullong read_after_slash(const char *p) +static ullong read_after_slash(const char *p) { p = strchr(p, '/'); 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 { struct pipe *toplevel_list; smallint ctrl_z_flag; #endif +#if ENABLE_HUSH_LOOPS smallint flag_break_continue; +#endif smallint fake_mode; /* these three support $?, $#, and $1 */ smalluint last_return_code; char **global_argv; int global_argc; +#if ENABLE_HUSH_LOOPS unsigned depth_break_continue; +#endif pid_t last_bg_pid; const char *ifs; const char *cwd; @@ -722,8 +726,10 @@ static int builtin_shift(char **argv); static int builtin_source(char **argv); static int builtin_umask(char **argv); static int builtin_unset(char **argv); +#if ENABLE_HUSH_LOOPS static int builtin_break(char **argv); static int builtin_continue(char **argv); +#endif //static int builtin_not_written(char **argv); /* Table of built-in functions. They can be forked or not, depending on @@ -753,9 +759,13 @@ static const struct built_in_command bltins[] = { #if ENABLE_HUSH_JOB BLTIN("bg" , builtin_fg_bg, "Resume a job in the background"), #endif +#if ENABLE_HUSH_LOOPS BLTIN("break" , builtin_break, "Exit from a loop"), +#endif BLTIN("cd" , builtin_cd, "Change directory"), +#if ENABLE_HUSH_LOOPS BLTIN("continue", builtin_continue, "Start new loop iteration"), +#endif BLTIN("echo" , builtin_echo, "Write to stdout"), BLTIN("eval" , builtin_eval, "Construct and run shell command"), BLTIN("exec" , builtin_exec, "Execute command, don't return to shell"), @@ -2246,13 +2256,15 @@ static int run_list(struct pipe *pi) debug_printf_exec(": run_pipe with %d members\n", pi->num_progs); { int r; +#if ENABLE_HUSH_LOOPS flag_break_continue = 0; +#endif rcode = r = run_pipe(pi); /* NB: rcode is a smallint */ if (r != -1) { /* we only ran a builtin: rcode is already known * and we don't need to wait for anything. */ +#if ENABLE_HUSH_LOOPS /* was it "break" or "continue"? */ - if (flag_break_continue) { smallint fbc = flag_break_continue; /* we might fall into outer *loop*, @@ -2271,6 +2283,7 @@ static int run_list(struct pipe *pi) bb_error_msg("break/continue: only meaningful in a loop"); /* bash compat: exit code is still 0 */ } +#endif } else if (pi->followup == PIPE_BG) { /* what does bash do with attempts to background builtins? */ /* even bash 3.2 doesn't do that well with nested bg: @@ -4534,6 +4547,7 @@ static int builtin_unset(char **argv) return EXIT_SUCCESS; } +#if ENABLE_HUSH_LOOPS static int builtin_break(char **argv) { flag_break_continue++; /* BC_BREAK = 1 */ @@ -4554,3 +4568,4 @@ static int builtin_continue(char **argv) flag_break_continue++; /* BC_CONTINUE = 2 = 1+1 */ return builtin_break(argv); } +#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 @@ +VARIABLE=export +OK: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 @@ +# builtins, unlike keywords like "while", can be constructed +# with substitutions +VARIABLE=export +$VARIABLE VARIABLE +env | grep ^VARIABLE +echo OK:$? |