diff options
Diffstat (limited to 'awk.h')
-rw-r--r-- | awk.h | 84 |
1 files changed, 40 insertions, 44 deletions
@@ -49,9 +49,7 @@ #include <stdio.h> #include <assert.h> -#ifdef HAVE_LIMITS_H #include <limits.h> -#endif /* HAVE_LIMITS_H */ #include <ctype.h> #include <setjmp.h> @@ -71,11 +69,8 @@ #endif #endif -#if defined(HAVE_STDARG_H) #include <stdarg.h> -#else -#error "gawk no longer supports <varargs.h>. Please update your compiler and runtime" -#endif +#include <stdbool.h> #include <signal.h> #include <time.h> #include <errno.h> @@ -87,11 +82,6 @@ extern int errno; #include <stdlib.h> #endif /* not STDC_HEADERS */ -#ifdef HAVE_STDBOOL_H -#include <stdbool.h> -#else -#include "missing_d/gawkbool.h" -#endif /* We can handle multibyte strings. */ #include <wchar.h> @@ -306,6 +296,12 @@ typedef union bucket_item { } hi; } BUCKET; +enum commenttype { + EOL_COMMENT = 1, + BLOCK_COMMENT, + FOR_COMMENT // special case +}; + /* string hash table */ #define ahnext hs.next #define ahname hs.name /* a string index node */ @@ -324,6 +320,19 @@ struct exp_instruction; typedef int (*Func_print)(FILE *, const char *, ...); typedef struct exp_node **(*afunc_t)(struct exp_node *, struct exp_node *); +typedef struct { + const char *name; + afunc_t init; + afunc_t type_of; /* avoid reserved word typeof */ + afunc_t lookup; + afunc_t exists; + afunc_t clear; + afunc_t remove; + afunc_t list; + afunc_t copy; + afunc_t dump; + afunc_t store; +} array_funcs_t; /* * NOTE - this struct is a rather kludgey -- it is packed to minimize @@ -336,7 +345,7 @@ typedef struct exp_node { struct exp_node *lptr; struct exp_instruction *li; long ll; - afunc_t *lp; + const array_funcs_t *lp; } l; union { struct exp_node *rptr; @@ -350,6 +359,7 @@ typedef struct exp_node { struct exp_node *extra; void (*aptr)(void); long xl; + void *cmnt; // used by pretty printer } x; char *name; size_t reserved; @@ -378,6 +388,7 @@ typedef struct exp_node { wchar_t *wsp; size_t wslen; struct exp_node *typre; + enum commenttype comtype; } val; } sub; NODETYPE type; @@ -542,29 +553,16 @@ typedef struct exp_node { #define xarray sub.nodep.rn #define parent_array sub.nodep.x.extra -#define ainit array_funcs[0] -#define ainit_ind 0 -#define atypeof array_funcs[1] -#define atypeof_ind 1 -#define alength array_funcs[2] -#define alength_ind 2 -#define alookup array_funcs[3] -#define alookup_ind 3 -#define aexists array_funcs[4] -#define aexists_ind 4 -#define aclear array_funcs[5] -#define aclear_ind 5 -#define aremove array_funcs[6] -#define aremove_ind 6 -#define alist array_funcs[7] -#define alist_ind 7 -#define acopy array_funcs[8] -#define acopy_ind 8 -#define adump array_funcs[9] -#define adump_ind 9 -#define astore array_funcs[10] -#define astore_ind 10 -#define NUM_AFUNCS 11 /* # of entries in array_funcs */ +#define ainit array_funcs->init +#define atypeof array_funcs->type_of +#define alookup array_funcs->lookup +#define aexists array_funcs->exists +#define aclear array_funcs->clear +#define aremove array_funcs->remove +#define alist array_funcs->list +#define acopy array_funcs->copy +#define adump array_funcs->dump +#define astore array_funcs->store /* Node_array_ref: */ #define orig_array lnode @@ -575,9 +573,7 @@ typedef struct exp_node { #define alevel sub.nodep.x.xl /* Op_comment */ -#define comment_type sub.val.idx -#define EOL_COMMENT 1 -#define FULL_COMMENT 2 +#define comment_type sub.val.comtype /* --------------------------------lint warning types----------------------------*/ typedef enum lintvals { @@ -774,6 +770,7 @@ typedef struct exp_instruction { awk_ext_func_t *exf; } x; + struct exp_instruction *comment; short source_line; short pool_size; // memory management in symbol.c OPCODE opcode; @@ -1019,6 +1016,7 @@ typedef struct srcfile { char *lexeme; char *lexptr_begin; int lasttok; + INSTRUCTION *comment; /* comment on @load line */ } SRCFILE; // structure for INSTRUCTION pool, needed mainly for debugger @@ -1119,9 +1117,9 @@ extern NODE *(*format_val)(const char *, int, NODE *); extern int (*cmp_numbers)(const NODE *, const NODE *); /* built-in array types */ -extern afunc_t str_array_func[]; -extern afunc_t cint_array_func[]; -extern afunc_t int_array_func[]; +extern const array_funcs_t str_array_func; +extern const array_funcs_t cint_array_func; +extern const array_funcs_t int_array_func; /* special node used to indicate success in array routines (not NULL) */ extern NODE *success_node; @@ -1345,7 +1343,7 @@ DEREF(NODE *r) extern jmp_buf fatal_tag; extern int fatal_tag_valid; -#define assoc_length(a) ((*((a)->alength(a, NULL)))->table_size) +#define assoc_length(a) ((a)->table_size) #define assoc_empty(a) (assoc_length(a) == 0) #define assoc_lookup(a, s) ((a)->alookup(a, s)) @@ -1377,8 +1375,6 @@ extern NODE *force_array(NODE *symbol, bool canfatal); extern const char *make_aname(const NODE *symbol); extern const char *array_vname(const NODE *symbol); extern void array_init(void); -extern int register_array_func(afunc_t *afunc); -extern NODE **null_length(NODE *symbol, NODE *subs); extern NODE **null_afunc(NODE *symbol, NODE *subs); extern void set_SUBSEP(void); extern NODE *concat_exp(int nargs, bool do_subsep); |