diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-10 08:18:21 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-09-10 08:18:21 +0300 |
commit | 6de0102373304c0fdf70a7ddeb17dd1caa3a9b23 (patch) | |
tree | 7a8f3f18180e0b84893a4cccd883c80ffb7d9bc0 /awkgram.c | |
parent | d7c8dfd41bd5671ddfa6c81b2ef1779cab06e56b (diff) | |
parent | ca9f23d6c33c4b5cb3786d480948a42988ca99ac (diff) | |
download | egawk-6de0102373304c0fdf70a7ddeb17dd1caa3a9b23.tar.gz egawk-6de0102373304c0fdf70a7ddeb17dd1caa3a9b23.tar.bz2 egawk-6de0102373304c0fdf70a7ddeb17dd1caa3a9b23.zip |
Merge branch 'master' into comment
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -4409,6 +4409,7 @@ struct token { # define GAWKX 0x0400 /* gawk extension */ # define BREAK 0x0800 /* break allowed inside */ # define CONTINUE 0x1000 /* continue allowed inside */ +# define DEBUG_USE 0x2000 /* for use by developers */ NODE *(*ptr)(int); /* function that implements this keyword */ NODE *(*ptr2)(int); /* alternate arbitrary-precision function */ @@ -4447,7 +4448,7 @@ static const struct token tokentab[] = { {"END", Op_rule, LEX_END, 0, 0, 0}, {"ENDFILE", Op_rule, LEX_ENDFILE, GAWKX, 0, 0}, #ifdef ARRAYDEBUG -{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_adump, 0}, +{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|DEBUG_USE, do_adump, 0}, #endif {"and", Op_builtin, LEX_BUILTIN, GAWKX, do_and, MPF(and)}, {"asort", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asort, 0}, @@ -4507,7 +4508,7 @@ static const struct token tokentab[] = { {"sqrt", Op_builtin, LEX_BUILTIN, A(1), do_sqrt, MPF(sqrt)}, {"srand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand, MPF(srand)}, #if defined(GAWKDEBUG) || defined(ARRAYDEBUG) /* || ... */ -{"stopme", Op_builtin, LEX_BUILTIN, GAWKX|A(0), stopme, 0}, +{"stopme", Op_builtin, LEX_BUILTIN, GAWKX|A(0)|DEBUG_USE, stopme, 0}, #endif {"strftime", Op_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2)|A(3), do_strftime, 0}, {"strtonum", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum, MPF(strtonum)}, @@ -8423,3 +8424,35 @@ one_line_close(int fd) } +/* lookup_builtin --- find a builtin function or return NULL */ + +builtin_func_t +lookup_builtin(const char *name) +{ + int mid = check_special(name); + + if (mid == -1 || tokentab[mid].class != LEX_BUILTIN) + return NULL; +#ifdef HAVE_MPFR + if (do_mpfr) + return tokentab[mid].ptr2; +#endif + + return tokentab[mid].ptr; +} + +/* install_builtins --- add built-in functions to FUNCTAB */ + +void +install_builtins(void) +{ + int i, j; + + j = sizeof(tokentab) / sizeof(tokentab[0]); + for (i = 0; i < j; i++) { + if ( tokentab[i].class == LEX_BUILTIN + && (tokentab[i].flags & DEBUG_USE) == 0) { + (void) install_symbol(tokentab[i].operator, Node_builtin_func); + } + } +} |