summaryrefslogtreecommitdiff
path: root/editors/awk.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-29 01:03:42 +0200
committerDenys Vlasenko2021-06-29 01:03:42 +0200
commitaf0172369eb024fff3c8c2cd2c8765a7fde5a9f5 (patch)
tree68683a72ec134249d5cc608ebcce995f26763f6c /editors/awk.c
parent5dbbd0a6f52befe6bc57baf97d39168e595197f1 (diff)
downloadbusybox-af0172369eb024fff3c8c2cd2c8765a7fde5a9f5.zip
busybox-af0172369eb024fff3c8c2cd2c8765a7fde5a9f5.tar.gz
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>
Diffstat (limited to 'editors/awk.c')
-rw-r--r--editors/awk.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 86076d7..9826a57 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1093,8 +1093,9 @@ static void nvfree(var *v)
/* ------- awk program text parsing ------- */
-/* Parse next token pointed by global pos, place results into global ttt.
- * If token isn't expected, give away. Return token class
+/* Parse next token pointed by global pos, place results into global t_XYZ variables.
+ * If token isn't expected, print error message and die.
+ * Return token class (also store it in t_tclass).
*/
static uint32_t next_token(uint32_t expected)
{
@@ -1248,33 +1249,35 @@ static uint32_t next_token(uint32_t expected)
goto readnext;
/* insert concatenation operator when needed */
- debug_printf_parse("%s: %x %x %x concat_inserted?\n", __func__,
- (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP));
+ debug_printf_parse("%s: concat_inserted if all nonzero: %x %x %x %x\n", __func__,
+ (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP),
+ !(ltclass == TC_LENGTH && tc == TC_SEQSTART));
if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP)
&& !(ltclass == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */
) {
concat_inserted = TRUE;
save_tclass = tc;
save_info = t_info;
- tc = TC_BINOP;
+ tc = TC_BINOPX;
t_info = OC_CONCAT | SS | P(35);
}
- debug_printf_parse("%s: t_tclass=tc=%x\n", __func__, t_tclass);
t_tclass = tc;
+ debug_printf_parse("%s: t_tclass=tc=%x\n", __func__, tc);
}
- ltclass = t_tclass;
-
/* Are we ready for this? */
- if (!(ltclass & expected)) {
+ if (!(t_tclass & expected)) {
syntax_error((ltclass & (TC_NEWLINE | TC_EOF)) ?
EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN);
}
- debug_printf_parse("%s: returning, t_double:%f ltclass:", __func__, t_double);
- debug_parse_print_tc(ltclass);
+ debug_printf_parse("%s: returning, t_double:%f t_tclass:", __func__, t_double);
+ debug_parse_print_tc(t_tclass);
debug_printf_parse("\n");
- return ltclass;
+
+ ltclass = t_tclass;
+
+ return t_tclass;
#undef concat_inserted
#undef save_tclass
#undef save_info
@@ -1700,8 +1703,9 @@ static void parse_program(char *p)
/* Arg followed either by end of arg list or 1 comma */
if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM)
break;
- if (t_tclass != TC_COMMA)
- syntax_error(EMSG_UNEXP_TOKEN);
+//Impossible: next_token() above would error out and die
+// if (t_tclass != TC_COMMA)
+// syntax_error(EMSG_UNEXP_TOKEN);
}
seq = &f->body;
chain_group();