diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-29 01:03:42 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-29 01:03:42 +0200 |
commit | af0172369eb024fff3c8c2cd2c8765a7fde5a9f5 (patch) | |
tree | 68683a72ec134249d5cc608ebcce995f26763f6c | |
parent | 5dbbd0a6f52befe6bc57baf97d39168e595197f1 (diff) | |
download | busybox-w32-af0172369eb024fff3c8c2cd2c8765a7fde5a9f5.tar.gz busybox-w32-af0172369eb024fff3c8c2cd2c8765a7fde5a9f5.tar.bz2 busybox-w32-af0172369eb024fff3c8c2cd2c8765a7fde5a9f5.zip |
awk: remove redundant check
function old new delta
next_token 785 784 -1
parse_program 337 328 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-10) Total: -10 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/editors/awk.c b/editors/awk.c index 86076d7b6..9826a57c6 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -1093,8 +1093,9 @@ static void nvfree(var *v) | |||
1093 | 1093 | ||
1094 | /* ------- awk program text parsing ------- */ | 1094 | /* ------- awk program text parsing ------- */ |
1095 | 1095 | ||
1096 | /* Parse next token pointed by global pos, place results into global ttt. | 1096 | /* Parse next token pointed by global pos, place results into global t_XYZ variables. |
1097 | * If token isn't expected, give away. Return token class | 1097 | * If token isn't expected, print error message and die. |
1098 | * Return token class (also store it in t_tclass). | ||
1098 | */ | 1099 | */ |
1099 | static uint32_t next_token(uint32_t expected) | 1100 | static uint32_t next_token(uint32_t expected) |
1100 | { | 1101 | { |
@@ -1248,33 +1249,35 @@ static uint32_t next_token(uint32_t expected) | |||
1248 | goto readnext; | 1249 | goto readnext; |
1249 | 1250 | ||
1250 | /* insert concatenation operator when needed */ | 1251 | /* insert concatenation operator when needed */ |
1251 | debug_printf_parse("%s: %x %x %x concat_inserted?\n", __func__, | 1252 | debug_printf_parse("%s: concat_inserted if all nonzero: %x %x %x %x\n", __func__, |
1252 | (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP)); | 1253 | (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP), |
1254 | !(ltclass == TC_LENGTH && tc == TC_SEQSTART)); | ||
1253 | if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP) | 1255 | if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP) |
1254 | && !(ltclass == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */ | 1256 | && !(ltclass == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */ |
1255 | ) { | 1257 | ) { |
1256 | concat_inserted = TRUE; | 1258 | concat_inserted = TRUE; |
1257 | save_tclass = tc; | 1259 | save_tclass = tc; |
1258 | save_info = t_info; | 1260 | save_info = t_info; |
1259 | tc = TC_BINOP; | 1261 | tc = TC_BINOPX; |
1260 | t_info = OC_CONCAT | SS | P(35); | 1262 | t_info = OC_CONCAT | SS | P(35); |
1261 | } | 1263 | } |
1262 | 1264 | ||
1263 | debug_printf_parse("%s: t_tclass=tc=%x\n", __func__, t_tclass); | ||
1264 | t_tclass = tc; | 1265 | t_tclass = tc; |
1266 | debug_printf_parse("%s: t_tclass=tc=%x\n", __func__, tc); | ||
1265 | } | 1267 | } |
1266 | ltclass = t_tclass; | ||
1267 | |||
1268 | /* Are we ready for this? */ | 1268 | /* Are we ready for this? */ |
1269 | if (!(ltclass & expected)) { | 1269 | if (!(t_tclass & expected)) { |
1270 | syntax_error((ltclass & (TC_NEWLINE | TC_EOF)) ? | 1270 | syntax_error((ltclass & (TC_NEWLINE | TC_EOF)) ? |
1271 | EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN); | 1271 | EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN); |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | debug_printf_parse("%s: returning, t_double:%f ltclass:", __func__, t_double); | 1274 | debug_printf_parse("%s: returning, t_double:%f t_tclass:", __func__, t_double); |
1275 | debug_parse_print_tc(ltclass); | 1275 | debug_parse_print_tc(t_tclass); |
1276 | debug_printf_parse("\n"); | 1276 | debug_printf_parse("\n"); |
1277 | return ltclass; | 1277 | |
1278 | ltclass = t_tclass; | ||
1279 | |||
1280 | return t_tclass; | ||
1278 | #undef concat_inserted | 1281 | #undef concat_inserted |
1279 | #undef save_tclass | 1282 | #undef save_tclass |
1280 | #undef save_info | 1283 | #undef save_info |
@@ -1700,8 +1703,9 @@ static void parse_program(char *p) | |||
1700 | /* Arg followed either by end of arg list or 1 comma */ | 1703 | /* Arg followed either by end of arg list or 1 comma */ |
1701 | if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM) | 1704 | if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM) |
1702 | break; | 1705 | break; |
1703 | if (t_tclass != TC_COMMA) | 1706 | //Impossible: next_token() above would error out and die |
1704 | syntax_error(EMSG_UNEXP_TOKEN); | 1707 | // if (t_tclass != TC_COMMA) |
1708 | // syntax_error(EMSG_UNEXP_TOKEN); | ||
1705 | } | 1709 | } |
1706 | seq = &f->body; | 1710 | seq = &f->body; |
1707 | chain_group(); | 1711 | chain_group(); |