summaryrefslogtreecommitdiff
path: root/awkgram.y
diff options
context:
space:
mode:
Diffstat (limited to 'awkgram.y')
-rw-r--r--awkgram.y27
1 files changed, 20 insertions, 7 deletions
diff --git a/awkgram.y b/awkgram.y
index 067a933f..d723f510 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -73,7 +73,6 @@ static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op)
static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op);
static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op);
static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype);
-static NODE *make_regnode(int type, NODE *exp);
static int count_expressions(INSTRUCTION **list, bool isarg);
static INSTRUCTION *optimize_assignment(INSTRUCTION *exp);
static void add_lint(INSTRUCTION *list, LINTTYPE linttype);
@@ -1950,7 +1949,6 @@ static const struct token tokentab[] = {
{"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext, 0},
{"default", Op_K_default, LEX_DEFAULT, GAWKX, 0, 0},
{"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0, 0},
-{"div", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_div, MPF(div)},
{"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0, 0},
{"else", Op_K_else, LEX_ELSE, 0, 0, 0},
{"eval", Op_symbol, LEX_EVAL, 0, 0, 0},
@@ -1971,6 +1969,7 @@ static const struct token tokentab[] = {
{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0},
{"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0},
{"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)},
+{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0},
{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0},
{"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0},
@@ -4144,9 +4143,9 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg; /* argument may be array */
- } else if (r->builtin == do_div
+ } else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR
- || r->builtin == MPF(div)
+ || r->builtin == MPF(intdiv)
#endif
) {
arg = subn->nexti->lasti->nexti->lasti->nexti; /* 3rd arg list */
@@ -4712,7 +4711,7 @@ variable(int location, char *name, NODETYPE type)
/* make_regnode --- make a regular expression node */
-static NODE *
+NODE *
make_regnode(int type, NODE *exp)
{
NODE *n;
@@ -5868,13 +5867,26 @@ lookup_builtin(const char *name)
{
int mid = check_special(name);
- if (mid == -1 || tokentab[mid].class != LEX_BUILTIN)
+ if (mid == -1)
return NULL;
+
+ switch (tokentab[mid].class) {
+ case LEX_BUILTIN:
+ case LEX_LENGTH:
+ break;
+ default:
+ return NULL;
+ }
+
#ifdef HAVE_MPFR
if (do_mpfr)
return tokentab[mid].ptr2;
#endif
+ /* And another special case... */
+ if (tokentab[mid].value == Op_sub_builtin)
+ return (builtin_func_t) do_sub;
+
return tokentab[mid].ptr;
}
@@ -5887,7 +5899,8 @@ install_builtins(void)
j = sizeof(tokentab) / sizeof(tokentab[0]);
for (i = 0; i < j; i++) {
- if ( tokentab[i].class == LEX_BUILTIN
+ if ( (tokentab[i].class == LEX_BUILTIN
+ || tokentab[i].class == LEX_LENGTH)
&& (tokentab[i].flags & DEBUG_USE) == 0) {
(void) install_symbol(tokentab[i].operator, Node_builtin_func);
}