summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2008-07-28 15:15:59 +0000
committerDenis Vlasenko2008-07-28 15:15:59 +0000
commit12acec5ad40cba57e621829f7339eeb16d981f9f (patch)
tree0c0f282cc8b7d73b39150073d8fb8056c76900a7
parent5e052cab1753f64ddeaaa1f30242eba12f78737b (diff)
downloadbusybox-12acec5ad40cba57e621829f7339eeb16d981f9f.zip
busybox-12acec5ad40cba57e621829f7339eeb16d981f9f.tar.gz
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.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 56374fa..98a69c1 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2027,9 +2027,10 @@ static int run_list(struct pipe *pi)
smalluint rcode = 0; /* probably for gcc only */
#if ENABLE_HUSH_IF
smalluint cond_code = 0;
- smalluint last_cond_code = 0; /* need double-buffer to handle "elif" */
+///experimentally off: last_cond_code seems to be bogus
+ ///smalluint last_cond_code = 0; /* need double-buffer to handle "elif" */
#else
- enum { cond_code = 0, last_cond_code = 0 };
+ enum { cond_code = 0, /* ///last_cond_code = 0 */ };
#endif
/*reserved_style*/ smallint rword IF_HAS_NO_KEYWORDS(= RES_NONE);
/*reserved_style*/ smallint skip_more_for_this_rword = RES_XXXX;
@@ -2062,8 +2063,8 @@ static int run_list(struct pipe *pi)
#endif
/* Past this point, all code paths should jump to ret: label
- * in order to return, no direct "return" statements.
- * This helps to ensure that no memory is leaked */
+ * in order to return, no direct "return" statements please.
+ * This helps to ensure that no memory is leaked. */
#if ENABLE_HUSH_JOB
/* Example of nested list: "while true; do { sleep 1 | exit 2; } done".
@@ -2124,7 +2125,8 @@ static int run_list(struct pipe *pi)
}
#endif
if (rword == skip_more_for_this_rword && flag_skip) {
- /* it is "<false> && CMD ... */
+ /* it is "<false> && CMD" or "<true> || CMD"
+ * and we should not execute CMD */
if (pi->followup == PIPE_SEQ)
flag_skip = 0;
continue;
@@ -2132,13 +2134,13 @@ static int run_list(struct pipe *pi)
flag_skip = 1;
skip_more_for_this_rword = RES_XXXX;
#if ENABLE_HUSH_IF
- if (rword == RES_THEN || rword == RES_ELSE)
- cond_code = last_cond_code;
+/// if (rword == RES_THEN) // || rword == RES_ELSE)
+/// cond_code = last_cond_code;
if (rword == RES_THEN && cond_code)
continue; /* "if <false> THEN cmd": skip cmd */
if (rword == RES_ELSE && !cond_code)
- continue; /* "if <true> then ... ELSE cmd": skip cmd */
-// TODO: break;?
+ //continue; /* "if <true> then ... ELSE cmd": skip cmd */
+ break; //TEST
if (rword == RES_ELIF && !cond_code)
break; /* "if <true> then ... ELIF cmd": skip cmd and all following ones */
#endif
@@ -2173,7 +2175,7 @@ static int run_list(struct pipe *pi)
}
free(pi->progs->argv[0]);
if (!*for_lcur) {
- /* for loop is over, clean up */
+ /* "for" loop is over, clean up */
free(for_list);
for_list = NULL;
for_lcur = NULL;
@@ -2197,7 +2199,7 @@ static int run_list(struct pipe *pi)
} else {
loop_top = NULL;
}
-//TODO: continue;? DONE has no cmd anyway
+ continue; //TEST /* "done" has no cmd anyway */
}
#endif
#if ENABLE_HUSH_CASE
@@ -2213,17 +2215,17 @@ static int run_list(struct pipe *pi)
/* all prev words didn't match, does this one match? */
pattern = expand_strvec_to_string(pi->progs->argv);
/* TODO: which FNM_xxx flags to use? */
- last_cond_code = (fnmatch(pattern, case_word, /*flags:*/ 0) != 0);
- //bb_error_msg("fnmatch('%s','%s'):%d", pattern, case_word, last_cond_code);
+ /* ///last_ */ cond_code = (fnmatch(pattern, case_word, /*flags:*/ 0) != 0);
+ //bb_error_msg("fnmatch('%s','%s'):%d", pattern, case_word, cond_code);
free(pattern);
- if (last_cond_code == 0) { /* match! we will execute this branch */
+ if (/* ///last_ */ cond_code == 0) { /* match! we will execute this branch */
free(case_word); /* make future "word)" stop */
case_word = NULL;
}
continue;
}
if (rword == RES_CASEI) { /* inside of a case branch */
- if (last_cond_code != 0)
+ if (/* ///last_ */ cond_code != 0)
continue; /* not matched yet, skip this pipe */
}
#endif
@@ -2269,7 +2271,7 @@ static int run_list(struct pipe *pi)
/* Analyze how result affects subsequent commands */
#if ENABLE_HUSH_IF
if (rword == RES_IF || rword == RES_ELIF)
- last_cond_code = rcode;
+ /* ///last_cond_code = */ cond_code = rcode;
#endif
#if ENABLE_HUSH_LOOPS
if (rword == RES_WHILE) {