diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-28 15:15:59 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-28 15:15:59 +0000 |
commit | 12acec5ad40cba57e621829f7339eeb16d981f9f (patch) | |
tree | 0c0f282cc8b7d73b39150073d8fb8056c76900a7 | |
parent | 5e052cab1753f64ddeaaa1f30242eba12f78737b (diff) | |
download | busybox-w32-12acec5ad40cba57e621829f7339eeb16d981f9f.tar.gz busybox-w32-12acec5ad40cba57e621829f7339eeb16d981f9f.tar.bz2 busybox-w32-12acec5ad40cba57e621829f7339eeb16d981f9f.zip |
hush: in run_list(), last_cond_code seems to be superfluous. comment it out
function old new delta
run_list 2055 2039 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-16) Total: -16 bytes
-rw-r--r-- | shell/hush.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/shell/hush.c b/shell/hush.c index 56374fa2a..98a69c1b1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2027,9 +2027,10 @@ static int run_list(struct pipe *pi) | |||
2027 | smalluint rcode = 0; /* probably for gcc only */ | 2027 | smalluint rcode = 0; /* probably for gcc only */ |
2028 | #if ENABLE_HUSH_IF | 2028 | #if ENABLE_HUSH_IF |
2029 | smalluint cond_code = 0; | 2029 | smalluint cond_code = 0; |
2030 | smalluint last_cond_code = 0; /* need double-buffer to handle "elif" */ | 2030 | ///experimentally off: last_cond_code seems to be bogus |
2031 | ///smalluint last_cond_code = 0; /* need double-buffer to handle "elif" */ | ||
2031 | #else | 2032 | #else |
2032 | enum { cond_code = 0, last_cond_code = 0 }; | 2033 | enum { cond_code = 0, /* ///last_cond_code = 0 */ }; |
2033 | #endif | 2034 | #endif |
2034 | /*reserved_style*/ smallint rword IF_HAS_NO_KEYWORDS(= RES_NONE); | 2035 | /*reserved_style*/ smallint rword IF_HAS_NO_KEYWORDS(= RES_NONE); |
2035 | /*reserved_style*/ smallint skip_more_for_this_rword = RES_XXXX; | 2036 | /*reserved_style*/ smallint skip_more_for_this_rword = RES_XXXX; |
@@ -2062,8 +2063,8 @@ static int run_list(struct pipe *pi) | |||
2062 | #endif | 2063 | #endif |
2063 | 2064 | ||
2064 | /* Past this point, all code paths should jump to ret: label | 2065 | /* Past this point, all code paths should jump to ret: label |
2065 | * in order to return, no direct "return" statements. | 2066 | * in order to return, no direct "return" statements please. |
2066 | * This helps to ensure that no memory is leaked */ | 2067 | * This helps to ensure that no memory is leaked. */ |
2067 | 2068 | ||
2068 | #if ENABLE_HUSH_JOB | 2069 | #if ENABLE_HUSH_JOB |
2069 | /* Example of nested list: "while true; do { sleep 1 | exit 2; } done". | 2070 | /* Example of nested list: "while true; do { sleep 1 | exit 2; } done". |
@@ -2124,7 +2125,8 @@ static int run_list(struct pipe *pi) | |||
2124 | } | 2125 | } |
2125 | #endif | 2126 | #endif |
2126 | if (rword == skip_more_for_this_rword && flag_skip) { | 2127 | if (rword == skip_more_for_this_rword && flag_skip) { |
2127 | /* it is "<false> && CMD ... */ | 2128 | /* it is "<false> && CMD" or "<true> || CMD" |
2129 | * and we should not execute CMD */ | ||
2128 | if (pi->followup == PIPE_SEQ) | 2130 | if (pi->followup == PIPE_SEQ) |
2129 | flag_skip = 0; | 2131 | flag_skip = 0; |
2130 | continue; | 2132 | continue; |
@@ -2132,13 +2134,13 @@ static int run_list(struct pipe *pi) | |||
2132 | flag_skip = 1; | 2134 | flag_skip = 1; |
2133 | skip_more_for_this_rword = RES_XXXX; | 2135 | skip_more_for_this_rword = RES_XXXX; |
2134 | #if ENABLE_HUSH_IF | 2136 | #if ENABLE_HUSH_IF |
2135 | if (rword == RES_THEN || rword == RES_ELSE) | 2137 | /// if (rword == RES_THEN) // || rword == RES_ELSE) |
2136 | cond_code = last_cond_code; | 2138 | /// cond_code = last_cond_code; |
2137 | if (rword == RES_THEN && cond_code) | 2139 | if (rword == RES_THEN && cond_code) |
2138 | continue; /* "if <false> THEN cmd": skip cmd */ | 2140 | continue; /* "if <false> THEN cmd": skip cmd */ |
2139 | if (rword == RES_ELSE && !cond_code) | 2141 | if (rword == RES_ELSE && !cond_code) |
2140 | continue; /* "if <true> then ... ELSE cmd": skip cmd */ | 2142 | //continue; /* "if <true> then ... ELSE cmd": skip cmd */ |
2141 | // TODO: break;? | 2143 | break; //TEST |
2142 | if (rword == RES_ELIF && !cond_code) | 2144 | if (rword == RES_ELIF && !cond_code) |
2143 | break; /* "if <true> then ... ELIF cmd": skip cmd and all following ones */ | 2145 | break; /* "if <true> then ... ELIF cmd": skip cmd and all following ones */ |
2144 | #endif | 2146 | #endif |
@@ -2173,7 +2175,7 @@ static int run_list(struct pipe *pi) | |||
2173 | } | 2175 | } |
2174 | free(pi->progs->argv[0]); | 2176 | free(pi->progs->argv[0]); |
2175 | if (!*for_lcur) { | 2177 | if (!*for_lcur) { |
2176 | /* for loop is over, clean up */ | 2178 | /* "for" loop is over, clean up */ |
2177 | free(for_list); | 2179 | free(for_list); |
2178 | for_list = NULL; | 2180 | for_list = NULL; |
2179 | for_lcur = NULL; | 2181 | for_lcur = NULL; |
@@ -2197,7 +2199,7 @@ static int run_list(struct pipe *pi) | |||
2197 | } else { | 2199 | } else { |
2198 | loop_top = NULL; | 2200 | loop_top = NULL; |
2199 | } | 2201 | } |
2200 | //TODO: continue;? DONE has no cmd anyway | 2202 | continue; //TEST /* "done" has no cmd anyway */ |
2201 | } | 2203 | } |
2202 | #endif | 2204 | #endif |
2203 | #if ENABLE_HUSH_CASE | 2205 | #if ENABLE_HUSH_CASE |
@@ -2213,17 +2215,17 @@ static int run_list(struct pipe *pi) | |||
2213 | /* all prev words didn't match, does this one match? */ | 2215 | /* all prev words didn't match, does this one match? */ |
2214 | pattern = expand_strvec_to_string(pi->progs->argv); | 2216 | pattern = expand_strvec_to_string(pi->progs->argv); |
2215 | /* TODO: which FNM_xxx flags to use? */ | 2217 | /* TODO: which FNM_xxx flags to use? */ |
2216 | last_cond_code = (fnmatch(pattern, case_word, /*flags:*/ 0) != 0); | 2218 | /* ///last_ */ cond_code = (fnmatch(pattern, case_word, /*flags:*/ 0) != 0); |
2217 | //bb_error_msg("fnmatch('%s','%s'):%d", pattern, case_word, last_cond_code); | 2219 | //bb_error_msg("fnmatch('%s','%s'):%d", pattern, case_word, cond_code); |
2218 | free(pattern); | 2220 | free(pattern); |
2219 | if (last_cond_code == 0) { /* match! we will execute this branch */ | 2221 | if (/* ///last_ */ cond_code == 0) { /* match! we will execute this branch */ |
2220 | free(case_word); /* make future "word)" stop */ | 2222 | free(case_word); /* make future "word)" stop */ |
2221 | case_word = NULL; | 2223 | case_word = NULL; |
2222 | } | 2224 | } |
2223 | continue; | 2225 | continue; |
2224 | } | 2226 | } |
2225 | if (rword == RES_CASEI) { /* inside of a case branch */ | 2227 | if (rword == RES_CASEI) { /* inside of a case branch */ |
2226 | if (last_cond_code != 0) | 2228 | if (/* ///last_ */ cond_code != 0) |
2227 | continue; /* not matched yet, skip this pipe */ | 2229 | continue; /* not matched yet, skip this pipe */ |
2228 | } | 2230 | } |
2229 | #endif | 2231 | #endif |
@@ -2269,7 +2271,7 @@ static int run_list(struct pipe *pi) | |||
2269 | /* Analyze how result affects subsequent commands */ | 2271 | /* Analyze how result affects subsequent commands */ |
2270 | #if ENABLE_HUSH_IF | 2272 | #if ENABLE_HUSH_IF |
2271 | if (rword == RES_IF || rword == RES_ELIF) | 2273 | if (rword == RES_IF || rword == RES_ELIF) |
2272 | last_cond_code = rcode; | 2274 | /* ///last_cond_code = */ cond_code = rcode; |
2273 | #endif | 2275 | #endif |
2274 | #if ENABLE_HUSH_LOOPS | 2276 | #if ENABLE_HUSH_LOOPS |
2275 | if (rword == RES_WHILE) { | 2277 | if (rword == RES_WHILE) { |