aboutsummaryrefslogtreecommitdiff
path: root/editors/awk.c
diff options
context:
space:
mode:
Diffstat (limited to 'editors/awk.c')
-rw-r--r--editors/awk.c103
1 files changed, 53 insertions, 50 deletions
diff --git a/editors/awk.c b/editors/awk.c
index b5bab16af..9d306bf5f 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -392,23 +392,10 @@ static const char vValues[] =
392static const unsigned PRIMES[] = { 251, 1021, 4093, 16381, 65521 }; 392static const unsigned PRIMES[] = { 251, 1021, 4093, 16381, 65521 };
393enum { NPRIMES = sizeof(PRIMES) / sizeof(PRIMES[0]) }; 393enum { NPRIMES = sizeof(PRIMES) / sizeof(PRIMES[0]) };
394 394
395/* globals */
396 395
396/* Globals. Split in two parts so that first one is addressed
397 * with (mostly short) negative offsets */
397struct globals { 398struct globals {
398 /* former 'struct t' */
399 uint32_t t_info; /* often used */
400 uint32_t t_tclass;
401 char *t_string;
402 double t_double;
403 int t_lineno;
404 int t_rollback;
405
406 /* the rest */
407 smallint icase;
408 smallint exiting;
409 smallint nextrec;
410 smallint nextfile;
411 smallint is_f0_split;
412 chain beginseq, mainseq, endseq, *seq; 399 chain beginseq, mainseq, endseq, *seq;
413 node *break_ptr, *continue_ptr; 400 node *break_ptr, *continue_ptr;
414 rstream *iF; 401 rstream *iF;
@@ -421,17 +408,31 @@ struct globals {
421 nvblock *g_cb; 408 nvblock *g_cb;
422 char *g_pos; 409 char *g_pos;
423 char *g_buf; 410 char *g_buf;
411 smallint icase;
412 smallint exiting;
413 smallint nextrec;
414 smallint nextfile;
415 smallint is_f0_split;
416};
417struct globals2 {
418 uint32_t t_info; /* often used */
419 uint32_t t_tclass;
420 char *t_string;
421 int t_lineno;
422 int t_rollback;
423
424 var *intvar[NUM_INTERNAL_VARS]; /* often used */
424 425
425 /* former statics from various functions */ 426 /* former statics from various functions */
426 char *split_f0__fstrings; 427 char *split_f0__fstrings;
427 428
428 rstream next_input_file__rsm;
429 smallint next_input_file__files_happen;
430
431 smallint next_token__concat_inserted;
432 uint32_t next_token__save_tclass; 429 uint32_t next_token__save_tclass;
433 uint32_t next_token__save_info; 430 uint32_t next_token__save_info;
434 uint32_t next_token__ltclass; 431 uint32_t next_token__ltclass;
432 smallint next_token__concat_inserted;
433
434 smallint next_input_file__files_happen;
435 rstream next_input_file__rsm;
435 436
436 var *evaluate__fnargs; 437 var *evaluate__fnargs;
437 unsigned evaluate__seed; 438 unsigned evaluate__seed;
@@ -441,50 +442,52 @@ struct globals {
441 442
442 tsplitter exec_builtin__tspl; 443 tsplitter exec_builtin__tspl;
443 444
444 /* biggest members go last */ 445 /* biggest and least used members go last */
445 var *intvar[NUM_INTERNAL_VARS]; 446 double t_double;
446 tsplitter fsplitter, rsplitter; 447 tsplitter fsplitter, rsplitter;
447}; 448};
448#define G (*ptr_to_globals) 449#define G1 (ptr_to_globals[-1])
449/* for debug */ 450#define G (*(struct globals2 *const)ptr_to_globals)
450/* char Gsize[sizeof(G)]; ~0x240 */ 451/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */
452/* char G1size[sizeof(G1)]; - 0x6c */
453/* char Gsize[sizeof(G)]; - 0x1cc */
451/* Trying to keep most of members accessible with short offsets: */ 454/* Trying to keep most of members accessible with short offsets: */
452/* char Gofs_seed[offsetof(struct globals, evaluate__seed)]; ~0xc0 */ 455/* char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; - 0x90 */
456#define beginseq (G1.beginseq )
457#define mainseq (G1.mainseq )
458#define endseq (G1.endseq )
459#define seq (G1.seq )
460#define break_ptr (G1.break_ptr )
461#define continue_ptr (G1.continue_ptr)
462#define iF (G1.iF )
463#define vhash (G1.vhash )
464#define ahash (G1.ahash )
465#define fdhash (G1.fdhash )
466#define fnhash (G1.fnhash )
467#define g_progname (G1.g_progname )
468#define g_lineno (G1.g_lineno )
469#define nfields (G1.nfields )
470#define maxfields (G1.maxfields )
471#define Fields (G1.Fields )
472#define g_cb (G1.g_cb )
473#define g_pos (G1.g_pos )
474#define g_buf (G1.g_buf )
475#define icase (G1.icase )
476#define exiting (G1.exiting )
477#define nextrec (G1.nextrec )
478#define nextfile (G1.nextfile )
479#define is_f0_split (G1.is_f0_split )
453#define t_info (G.t_info ) 480#define t_info (G.t_info )
454#define t_tclass (G.t_tclass ) 481#define t_tclass (G.t_tclass )
455#define t_string (G.t_string ) 482#define t_string (G.t_string )
456#define t_double (G.t_double ) 483#define t_double (G.t_double )
457#define t_lineno (G.t_lineno ) 484#define t_lineno (G.t_lineno )
458#define t_rollback (G.t_rollback ) 485#define t_rollback (G.t_rollback )
459#define icase (G.icase )
460#define exiting (G.exiting )
461#define nextrec (G.nextrec )
462#define nextfile (G.nextfile )
463#define is_f0_split (G.is_f0_split )
464#define beginseq (G.beginseq )
465#define mainseq (G.mainseq )
466#define endseq (G.endseq )
467#define seq (G.seq )
468#define break_ptr (G.break_ptr )
469#define continue_ptr (G.continue_ptr)
470#define iF (G.iF )
471#define vhash (G.vhash )
472#define ahash (G.ahash )
473#define fdhash (G.fdhash )
474#define fnhash (G.fnhash )
475#define g_progname (G.g_progname )
476#define g_lineno (G.g_lineno )
477#define nfields (G.nfields )
478#define maxfields (G.maxfields )
479#define Fields (G.Fields )
480#define g_cb (G.g_cb )
481#define g_pos (G.g_pos )
482#define g_buf (G.g_buf )
483#define intvar (G.intvar ) 486#define intvar (G.intvar )
484#define fsplitter (G.fsplitter ) 487#define fsplitter (G.fsplitter )
485#define rsplitter (G.rsplitter ) 488#define rsplitter (G.rsplitter )
486#define INIT_G() do { \ 489#define INIT_G() do { \
487 PTR_TO_GLOBALS = xzalloc(sizeof(G)); \ 490 PTR_TO_GLOBALS = xzalloc(sizeof(G1) + sizeof(G)) + sizeof(G1); \
488 G.next_token__ltclass = TC_OPTERM; \ 491 G.next_token__ltclass = TC_OPTERM; \
489 G.evaluate__seed = 1; \ 492 G.evaluate__seed = 1; \
490} while (0) 493} while (0)