aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2026-02-02 15:08:20 +0000
committerRon Yorston <rmy@pobox.com>2026-02-02 15:08:20 +0000
commit74ee6e70c9a4f7822e7461069579c4e6ef0a2f04 (patch)
tree1db535ead8de13300dcceadf07278dec22fb2d02 /editors
parente27f759c63b338e6e6cf6dc8d9d0711e9c05d6a5 (diff)
parenta2f8c89aecf473f905da6eba53d02fb23eca93cd (diff)
downloadbusybox-w32-74ee6e70c9a4f7822e7461069579c4e6ef0a2f04.tar.gz
busybox-w32-74ee6e70c9a4f7822e7461069579c4e6ef0a2f04.tar.bz2
busybox-w32-74ee6e70c9a4f7822e7461069579c4e6ef0a2f04.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c72
1 files changed, 33 insertions, 39 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 1feb49da1..b3ec99d3f 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -583,14 +583,10 @@ static const char vValues[] ALIGN1 =
583static const uint16_t PRIMES[] ALIGN2 = { 251, 1021, 4093, 16381, 65521 }; 583static const uint16_t PRIMES[] ALIGN2 = { 251, 1021, 4093, 16381, 65521 };
584 584
585 585
586/* Globals. Split in two parts so that first one is addressed
587 * with (mostly short) negative offsets.
588 * NB: it's unsafe to put members of type "double"
589 * into globals2 (gcc may fail to align them).
590 */
591struct globals { 586struct globals {
592 double t_double;
593 chain beginseq, mainseq, endseq; 587 chain beginseq, mainseq, endseq;
588
589 double t_double;
594 chain *seq; 590 chain *seq;
595 node *break_ptr, *continue_ptr; 591 node *break_ptr, *continue_ptr;
596 xhash *ahash; /* argument names, used only while parsing function bodies */ 592 xhash *ahash; /* argument names, used only while parsing function bodies */
@@ -618,9 +614,8 @@ struct globals {
618 smallint next_token__concat_inserted; 614 smallint next_token__concat_inserted;
619 uint32_t next_token__save_tclass; 615 uint32_t next_token__save_tclass;
620 uint32_t next_token__save_info; 616 uint32_t next_token__save_info;
621}; 617
622struct globals2 { 618 uint32_t t_info;
623 uint32_t t_info; /* often used */
624 uint32_t t_tclass; 619 uint32_t t_tclass;
625 char *t_string; 620 char *t_string;
626 int t_lineno; 621 int t_lineno;
@@ -654,41 +649,40 @@ struct globals2 {
654 649
655 char g_buf[MAXVARFMT + 1]; 650 char g_buf[MAXVARFMT + 1];
656}; 651};
657#define G1 (ptr_to_globals[-1]) 652#define G (*OFFSET_PTR_TO_GLOBALS)
658#define G (*(struct globals2 *)ptr_to_globals)
659/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */ 653/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */
660//char G1size[sizeof(G1)]; // 0x70 654//char G1size[sizeof(G1)]; // 0x70
661//char Gsize[sizeof(G)]; // 0x2f8 655//char Gsize[sizeof(G)]; // 0x2f8
662/* Trying to keep most of members accessible with short offsets: */ 656/* Trying to keep most of members accessible with short offsets: */
663//char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; // 0x7c 657//char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; // 0x7c
664#define t_double (G1.t_double ) 658#define t_double (G.t_double )
665#define beginseq (G1.beginseq ) 659#define beginseq (G.beginseq )
666#define mainseq (G1.mainseq ) 660#define mainseq (G.mainseq )
667#define endseq (G1.endseq ) 661#define endseq (G.endseq )
668#define seq (G1.seq ) 662#define seq (G.seq )
669#define break_ptr (G1.break_ptr ) 663#define break_ptr (G.break_ptr )
670#define continue_ptr (G1.continue_ptr) 664#define continue_ptr (G.continue_ptr)
671#define ahash (G1.ahash ) 665#define ahash (G.ahash )
672#define fnhash (G1.fnhash ) 666#define fnhash (G.fnhash )
673#define vhash (G1.vhash ) 667#define vhash (G.vhash )
674#define fdhash ahash 668#define fdhash ahash
675//^^^^^^^^^^^^^^^^^^ ahash is cleared after every function parsing, 669//^^^^^^^^^^^^^^^^^^ ahash is cleared after every function parsing,
676// and ends up empty after parsing phase. Thus, we can simply reuse it 670// and ends up empty after parsing phase. Thus, we can simply reuse it
677// for fdhash in execution stage. 671// for fdhash in execution stage.
678#define g_progname (G1.g_progname ) 672#define g_progname (G.g_progname )
679#define g_lineno (G1.g_lineno ) 673#define g_lineno (G.g_lineno )
680#define num_fields (G1.num_fields ) 674#define num_fields (G.num_fields )
681#define num_alloc_fields (G1.num_alloc_fields) 675#define num_alloc_fields (G.num_alloc_fields)
682#define Fields (G1.Fields ) 676#define Fields (G.Fields )
683#define g_pos (G1.g_pos ) 677#define g_pos (G.g_pos )
684#define g_saved_ch (G1.g_saved_ch ) 678#define g_saved_ch (G.g_saved_ch )
685#define got_program (G1.got_program ) 679#define got_program (G.got_program )
686#define icase (G1.icase ) 680#define icase (G.icase )
687#define exiting (G1.exiting ) 681#define exiting (G.exiting )
688#define nextrec (G1.nextrec ) 682#define nextrec (G.nextrec )
689#define nextfile (G1.nextfile ) 683#define nextfile (G.nextfile )
690#define is_f0_split (G1.is_f0_split ) 684#define is_f0_split (G.is_f0_split )
691#define t_rollback (G1.t_rollback ) 685#define t_rollback (G.t_rollback )
692#define t_info (G.t_info ) 686#define t_info (G.t_info )
693#define t_tclass (G.t_tclass ) 687#define t_tclass (G.t_tclass )
694#define t_string (G.t_string ) 688#define t_string (G.t_string )
@@ -699,7 +693,7 @@ struct globals2 {
699#define rsplitter (G.rsplitter ) 693#define rsplitter (G.rsplitter )
700#define g_buf (G.g_buf ) 694#define g_buf (G.g_buf )
701#define INIT_G() do { \ 695#define INIT_G() do { \
702 SET_PTR_TO_GLOBALS((char*)xzalloc(sizeof(G1)+sizeof(G)) + sizeof(G1)); \ 696 SET_OFFSET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
703 t_tclass = TC_NEWLINE; \ 697 t_tclass = TC_NEWLINE; \
704 G.evaluate__seed = 1; \ 698 G.evaluate__seed = 1; \
705} while (0) 699} while (0)
@@ -1168,9 +1162,9 @@ static int istrue(var *v)
1168 */ 1162 */
1169static uint32_t next_token(uint32_t expected) 1163static uint32_t next_token(uint32_t expected)
1170{ 1164{
1171#define concat_inserted (G1.next_token__concat_inserted) 1165#define concat_inserted (G.next_token__concat_inserted)
1172#define save_tclass (G1.next_token__save_tclass) 1166#define save_tclass (G.next_token__save_tclass)
1173#define save_info (G1.next_token__save_info) 1167#define save_info (G.next_token__save_info)
1174 1168
1175 char *p; 1169 char *p;
1176 const char *tl; 1170 const char *tl;