diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-07 02:44:33 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-07 02:44:33 +0200 |
commit | 09dd6ec7326c91352dc32187dcc215f18c28d3f0 (patch) | |
tree | e4fc42f86d1aa0f4b260909714d5310c24690df5 | |
parent | 1614900522a5d603909a2679acbdd4744c235c1b (diff) | |
download | busybox-w32-09dd6ec7326c91352dc32187dcc215f18c28d3f0.tar.gz busybox-w32-09dd6ec7326c91352dc32187dcc215f18c28d3f0.tar.bz2 busybox-w32-09dd6ec7326c91352dc32187dcc215f18c28d3f0.zip |
ash: cosmetic fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 81 |
1 files changed, 21 insertions, 60 deletions
diff --git a/shell/ash.c b/shell/ash.c index dcac4fe04..6befe0fd3 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -5687,7 +5687,7 @@ removerecordregions(int endoff) | |||
5687 | return; | 5687 | return; |
5688 | 5688 | ||
5689 | if (ifsfirst.endoff > endoff) { | 5689 | if (ifsfirst.endoff > endoff) { |
5690 | while (ifsfirst.next != NULL) { | 5690 | while (ifsfirst.next) { |
5691 | struct ifsregion *ifsp; | 5691 | struct ifsregion *ifsp; |
5692 | INT_OFF; | 5692 | INT_OFF; |
5693 | ifsp = ifsfirst.next->next; | 5693 | ifsp = ifsfirst.next->next; |
@@ -5695,9 +5695,9 @@ removerecordregions(int endoff) | |||
5695 | ifsfirst.next = ifsp; | 5695 | ifsfirst.next = ifsp; |
5696 | INT_ON; | 5696 | INT_ON; |
5697 | } | 5697 | } |
5698 | if (ifsfirst.begoff > endoff) | 5698 | if (ifsfirst.begoff > endoff) { |
5699 | ifslastp = NULL; | 5699 | ifslastp = NULL; |
5700 | else { | 5700 | } else { |
5701 | ifslastp = &ifsfirst; | 5701 | ifslastp = &ifsfirst; |
5702 | ifsfirst.endoff = endoff; | 5702 | ifsfirst.endoff = endoff; |
5703 | } | 5703 | } |
@@ -5706,8 +5706,8 @@ removerecordregions(int endoff) | |||
5706 | 5706 | ||
5707 | ifslastp = &ifsfirst; | 5707 | ifslastp = &ifsfirst; |
5708 | while (ifslastp->next && ifslastp->next->begoff < endoff) | 5708 | while (ifslastp->next && ifslastp->next->begoff < endoff) |
5709 | ifslastp=ifslastp->next; | 5709 | ifslastp = ifslastp->next; |
5710 | while (ifslastp->next != NULL) { | 5710 | while (ifslastp->next) { |
5711 | struct ifsregion *ifsp; | 5711 | struct ifsregion *ifsp; |
5712 | INT_OFF; | 5712 | INT_OFF; |
5713 | ifsp = ifslastp->next->next; | 5713 | ifsp = ifslastp->next->next; |
@@ -5884,9 +5884,9 @@ expbackq(union node *cmd, int quoted, int quotes) | |||
5884 | 5884 | ||
5885 | if (quoted == 0) | 5885 | if (quoted == 0) |
5886 | recordregion(startloc, dest - (char *)stackblock(), 0); | 5886 | recordregion(startloc, dest - (char *)stackblock(), 0); |
5887 | TRACE(("evalbackq: size=%d: \"%.*s\"\n", | 5887 | TRACE(("evalbackq: size:%d:'%.*s'\n", |
5888 | (dest - (char *)stackblock()) - startloc, | 5888 | (int)((dest - (char *)stackblock()) - startloc), |
5889 | (dest - (char *)stackblock()) - startloc, | 5889 | (int)((dest - (char *)stackblock()) - startloc), |
5890 | stackblock() + startloc)); | 5890 | stackblock() + startloc)); |
5891 | } | 5891 | } |
5892 | 5892 | ||
@@ -6105,42 +6105,16 @@ argstr(char *p, int flags, struct strlist *var_str_list) | |||
6105 | } | 6105 | } |
6106 | 6106 | ||
6107 | static char * | 6107 | static char * |
6108 | scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM, char *str, int quotes, | 6108 | scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM, |
6109 | int zero) | 6109 | char *pattern, int quotes, int zero) |
6110 | { | 6110 | { |
6111 | // This commented out code was added by James Simmons <jsimmons@infradead.org> | 6111 | char *loc, *loc2; |
6112 | // as part of a larger change when he added support for ${var/a/b}. | ||
6113 | // However, it broke # and % operators: | ||
6114 | // | ||
6115 | //var=ababcdcd | ||
6116 | // ok bad | ||
6117 | //echo ${var#ab} abcdcd abcdcd | ||
6118 | //echo ${var##ab} abcdcd abcdcd | ||
6119 | //echo ${var#a*b} abcdcd ababcdcd (!) | ||
6120 | //echo ${var##a*b} cdcd cdcd | ||
6121 | //echo ${var#?} babcdcd ababcdcd (!) | ||
6122 | //echo ${var##?} babcdcd babcdcd | ||
6123 | //echo ${var#*} ababcdcd babcdcd (!) | ||
6124 | //echo ${var##*} | ||
6125 | //echo ${var%cd} ababcd ababcd | ||
6126 | //echo ${var%%cd} ababcd abab (!) | ||
6127 | //echo ${var%c*d} ababcd ababcd | ||
6128 | //echo ${var%%c*d} abab ababcdcd (!) | ||
6129 | //echo ${var%?} ababcdc ababcdc | ||
6130 | //echo ${var%%?} ababcdc ababcdcd (!) | ||
6131 | //echo ${var%*} ababcdcd ababcdcd | ||
6132 | //echo ${var%%*} | ||
6133 | // | ||
6134 | // Commenting it back out helped. Remove it completely if it really | ||
6135 | // is not needed. | ||
6136 | |||
6137 | char *loc, *loc2; //, *full; | ||
6138 | char c; | 6112 | char c; |
6139 | 6113 | ||
6140 | loc = startp; | 6114 | loc = startp; |
6141 | loc2 = rmesc; | 6115 | loc2 = rmesc; |
6142 | do { | 6116 | do { |
6143 | int match; // = strlen(str); | 6117 | int match; |
6144 | const char *s = loc2; | 6118 | const char *s = loc2; |
6145 | 6119 | ||
6146 | c = *loc2; | 6120 | c = *loc2; |
@@ -6148,35 +6122,22 @@ scanleft(char *startp, char *rmesc, char *rmescend UNUSED_PARAM, char *str, int | |||
6148 | *loc2 = '\0'; | 6122 | *loc2 = '\0'; |
6149 | s = rmesc; | 6123 | s = rmesc; |
6150 | } | 6124 | } |
6151 | match = pmatch(str, s); // this line was deleted | 6125 | match = pmatch(pattern, s); |
6152 | 6126 | ||
6153 | // // chop off end if its '*' | ||
6154 | // full = strrchr(str, '*'); | ||
6155 | // if (full && full != str) | ||
6156 | // match--; | ||
6157 | // | ||
6158 | // // If str starts with '*' replace with s. | ||
6159 | // if ((*str == '*') && strlen(s) >= match) { | ||
6160 | // full = xstrdup(s); | ||
6161 | // strncpy(full+strlen(s)-match+1, str+1, match-1); | ||
6162 | // } else | ||
6163 | // full = xstrndup(str, match); | ||
6164 | // match = strncmp(s, full, strlen(full)); | ||
6165 | // free(full); | ||
6166 | // | ||
6167 | *loc2 = c; | 6127 | *loc2 = c; |
6168 | if (match) // if (!match) | 6128 | if (match) |
6169 | return loc; | 6129 | return loc; |
6170 | if (quotes && (unsigned char)*loc == CTLESC) | 6130 | if (quotes && (unsigned char)*loc == CTLESC) |
6171 | loc++; | 6131 | loc++; |
6172 | loc++; | 6132 | loc++; |
6173 | loc2++; | 6133 | loc2++; |
6174 | } while (c); | 6134 | } while (c); |
6175 | return 0; | 6135 | return NULL; |
6176 | } | 6136 | } |
6177 | 6137 | ||
6178 | static char * | 6138 | static char * |
6179 | scanright(char *startp, char *rmesc, char *rmescend, char *pattern, int quotes, int match_at_start) | 6139 | scanright(char *startp, char *rmesc, char *rmescend, |
6140 | char *pattern, int quotes, int match_at_start) | ||
6180 | { | 6141 | { |
6181 | #if !ENABLE_ASH_OPTIMIZE_FOR_SIZE | 6142 | #if !ENABLE_ASH_OPTIMIZE_FOR_SIZE |
6182 | int try2optimize = match_at_start; | 6143 | int try2optimize = match_at_start; |
@@ -6242,7 +6203,7 @@ scanright(char *startp, char *rmesc, char *rmescend, char *pattern, int quotes, | |||
6242 | } | 6203 | } |
6243 | } | 6204 | } |
6244 | } | 6205 | } |
6245 | return 0; | 6206 | return NULL; |
6246 | } | 6207 | } |
6247 | 6208 | ||
6248 | static void varunset(const char *, const char *, const char *, int) NORETURN; | 6209 | static void varunset(const char *, const char *, const char *, int) NORETURN; |
@@ -6262,7 +6223,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) | |||
6262 | msg = umsg; | 6223 | msg = umsg; |
6263 | } | 6224 | } |
6264 | } | 6225 | } |
6265 | ash_msg_and_raise_error("%.*s: %s%s", end - var - 1, var, msg, tail); | 6226 | ash_msg_and_raise_error("%.*s: %s%s", (int)(end - var - 1), var, msg, tail); |
6266 | } | 6227 | } |
6267 | 6228 | ||
6268 | #if ENABLE_ASH_BASH_COMPAT | 6229 | #if ENABLE_ASH_BASH_COMPAT |