aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 01:09:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 01:09:08 +0200
commit832cb4fcb98d2845bd3f9d244593fc1b5f362ca0 (patch)
tree4da2c3925b4c4eaa03c8319c9274fd39543fde29
parentaf0172369eb024fff3c8c2cd2c8765a7fde5a9f5 (diff)
downloadbusybox-w32-832cb4fcb98d2845bd3f9d244593fc1b5f362ca0.tar.gz
busybox-w32-832cb4fcb98d2845bd3f9d244593fc1b5f362ca0.tar.bz2
busybox-w32-832cb4fcb98d2845bd3f9d244593fc1b5f362ca0.zip
awk: make ltclass ("last token class") local to next_token()
function old new delta next_token 784 790 +6 next_input_file 219 216 -3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 6/-3) Total: 3 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 9826a57c6..418bda160 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -556,7 +556,6 @@ struct globals2 {
556 556
557 uint32_t next_token__save_tclass; 557 uint32_t next_token__save_tclass;
558 uint32_t next_token__save_info; 558 uint32_t next_token__save_info;
559 uint32_t next_token__ltclass;
560 smallint next_token__concat_inserted; 559 smallint next_token__concat_inserted;
561 560
562 smallint next_input_file__files_happen; 561 smallint next_input_file__files_happen;
@@ -615,7 +614,7 @@ struct globals2 {
615#define rsplitter (G.rsplitter ) 614#define rsplitter (G.rsplitter )
616#define INIT_G() do { \ 615#define INIT_G() do { \
617 SET_PTR_TO_GLOBALS((char*)xzalloc(sizeof(G1)+sizeof(G)) + sizeof(G1)); \ 616 SET_PTR_TO_GLOBALS((char*)xzalloc(sizeof(G1)+sizeof(G)) + sizeof(G1)); \
618 G.next_token__ltclass = TC_OPTERM; \ 617 t_tclass = TC_OPTERM; \
619 G.evaluate__seed = 1; \ 618 G.evaluate__seed = 1; \
620} while (0) 619} while (0)
621 620
@@ -1102,13 +1101,13 @@ static uint32_t next_token(uint32_t expected)
1102#define concat_inserted (G.next_token__concat_inserted) 1101#define concat_inserted (G.next_token__concat_inserted)
1103#define save_tclass (G.next_token__save_tclass) 1102#define save_tclass (G.next_token__save_tclass)
1104#define save_info (G.next_token__save_info) 1103#define save_info (G.next_token__save_info)
1105/* Initialized to TC_OPTERM: */
1106#define ltclass (G.next_token__ltclass)
1107 1104
1108 char *p, *s; 1105 char *p, *s;
1109 const char *tl; 1106 const char *tl;
1110 uint32_t tc;
1111 const uint32_t *ti; 1107 const uint32_t *ti;
1108 uint32_t tc, last_token_class;
1109
1110 last_token_class = t_tclass; /* t_tclass is initialized to TC_OPTERM */
1112 1111
1113 debug_printf_parse("%s() expected(%x):", __func__, expected); 1112 debug_printf_parse("%s() expected(%x):", __func__, expected);
1114 debug_parse_print_tc(expected); 1113 debug_parse_print_tc(expected);
@@ -1245,15 +1244,15 @@ static uint32_t next_token(uint32_t expected)
1245 g_pos = p; 1244 g_pos = p;
1246 1245
1247 /* skipping newlines in some cases */ 1246 /* skipping newlines in some cases */
1248 if ((ltclass & TC_NOTERM) && (tc & TC_NEWLINE)) 1247 if ((last_token_class & TC_NOTERM) && (tc & TC_NEWLINE))
1249 goto readnext; 1248 goto readnext;
1250 1249
1251 /* insert concatenation operator when needed */ 1250 /* insert concatenation operator when needed */
1252 debug_printf_parse("%s: concat_inserted if all nonzero: %x %x %x %x\n", __func__, 1251 debug_printf_parse("%s: concat_inserted if all nonzero: %x %x %x %x\n", __func__,
1253 (ltclass & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP), 1252 (last_token_class & TC_CONCAT1), (tc & TC_CONCAT2), (expected & TC_BINOP),
1254 !(ltclass == TC_LENGTH && tc == TC_SEQSTART)); 1253 !(last_token_class == TC_LENGTH && tc == TC_SEQSTART));
1255 if ((ltclass & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP) 1254 if ((last_token_class & TC_CONCAT1) && (tc & TC_CONCAT2) && (expected & TC_BINOP)
1256 && !(ltclass == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */ 1255 && !(last_token_class == TC_LENGTH && tc == TC_SEQSTART) /* but not for "length(..." */
1257 ) { 1256 ) {
1258 concat_inserted = TRUE; 1257 concat_inserted = TRUE;
1259 save_tclass = tc; 1258 save_tclass = tc;
@@ -1267,7 +1266,7 @@ static uint32_t next_token(uint32_t expected)
1267 } 1266 }
1268 /* Are we ready for this? */ 1267 /* Are we ready for this? */
1269 if (!(t_tclass & expected)) { 1268 if (!(t_tclass & expected)) {
1270 syntax_error((ltclass & (TC_NEWLINE | TC_EOF)) ? 1269 syntax_error((last_token_class & (TC_NEWLINE | TC_EOF)) ?
1271 EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN); 1270 EMSG_UNEXP_EOS : EMSG_UNEXP_TOKEN);
1272 } 1271 }
1273 1272
@@ -1275,13 +1274,10 @@ static uint32_t next_token(uint32_t expected)
1275 debug_parse_print_tc(t_tclass); 1274 debug_parse_print_tc(t_tclass);
1276 debug_printf_parse("\n"); 1275 debug_printf_parse("\n");
1277 1276
1278 ltclass = t_tclass;
1279
1280 return t_tclass; 1277 return t_tclass;
1281#undef concat_inserted 1278#undef concat_inserted
1282#undef save_tclass 1279#undef save_tclass
1283#undef save_info 1280#undef save_info
1284#undef ltclass
1285} 1281}
1286 1282
1287static void rollback_token(void) 1283static void rollback_token(void)