aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
Diffstat (limited to 'awkgram.c')
-rw-r--r--awkgram.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/awkgram.c b/awkgram.c
index f5fa6b2f..9c19767b 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -97,7 +97,7 @@ static int include_source(INSTRUCTION *file);
static int load_library(INSTRUCTION *file);
static void next_sourcefile(void);
static char *tokexpand(void);
-static NODE *make_profile_number(double d, const char *str, size_t len);
+static NODE *set_profile_text(NODE *n, const char *str, size_t len);
#define instruction(t) bcalloc(t, 1, 0)
@@ -3810,7 +3810,7 @@ regular_print:
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
(yyvsp[-1])->opcode = Op_push_i;
- (yyvsp[-1])->memory = make_profile_number(0.0, "0", 1);
+ (yyvsp[-1])->memory = set_profile_text(make_number(0.0), "0", 1);
(yyval) = list_append(list_append(list_create((yyvsp[-1])),
instruction(Op_field_spec)), (yyvsp[0]));
} else {
@@ -6440,12 +6440,7 @@ retry:
errno = 0;
IEEE_FMT(r->mpg_numbr, tval);
}
- yylval->memory = r;
- if (do_pretty_print) {
- yylval->memory->stptr = estrdup(tokstart, strlen(tokstart)-1);
- yylval->memory->stlen = strlen(tokstart)-1;
- yylval->memory->flags |= NUMCONSTSTR;
- }
+ yylval->memory = set_profile_text(r, tokstart, strlen(tokstart)-1);
return lasttok = YNUMBER;
}
#endif
@@ -6453,7 +6448,7 @@ retry:
d = nondec2awknum(tokstart, strlen(tokstart)-1, NULL);
else
d = atof(tokstart);
- yylval->memory = make_profile_number(d, tokstart, strlen(tokstart) - 1);
+ yylval->memory = set_profile_text(make_number(d), tokstart, strlen(tokstart) - 1);
if (d <= INT32_MAX && d >= INT32_MIN && d == (int32_t) d)
yylval->memory->flags |= NUMINT;
return lasttok = YNUMBER;
@@ -6763,7 +6758,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
INSTRUCTION *expr;
expr = list_create(instruction(Op_push_i));
- expr->nexti->memory = make_profile_number(0.0, "0", 1);
+ expr->nexti->memory = set_profile_text(make_number(0.0), "0", 1);
(void) mk_expression_list(subn,
list_append(expr, instruction(Op_field_spec)));
}
@@ -6811,7 +6806,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
r->sub_flags |= GENSUB;
if (nexp == 3) {
ip = instruction(Op_push_i);
- ip->memory = make_profile_number(0.0, "0", 1);
+ ip->memory = set_profile_text(make_number(0.0), "0", 1);
(void) mk_expression_list(subn,
list_append(list_create(ip), instruction(Op_field_spec)));
}
@@ -6840,7 +6835,7 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
list = list_create(r);
(void) list_prepend(list, instruction(Op_field_spec));
(void) list_prepend(list, instruction(Op_push_i));
- list->nexti->memory = make_profile_number(0.0, "0", 1);
+ list->nexti->memory = set_profile_text(make_number(0.0), "0", 1);
return list;
} else {
arg = subn->nexti;
@@ -7647,7 +7642,7 @@ mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op)
}
op->opcode = Op_push_i;
- // We don't need to call make_profile_number() here since
+ // We don't need to call set_profile_text() here since
// optimizing is disabled when doing pretty printing.
op->memory = make_number(res);
unref(n1);
@@ -8711,12 +8706,11 @@ is_identchar(int c)
return (is_alnum(c) || c == '_');
}
-/* make_profile_number --- make a number that can be printed when profiling */
+/* set_profile_text --- make a number that can be printed when profiling */
static NODE *
-make_profile_number(double d, const char *str, size_t len)
+set_profile_text(NODE *n, const char *str, size_t len)
{
- NODE *n = make_number(d);
if (do_pretty_print) {
// extra byte in case need to add minus sign in negate_num
n->stptr = estrdup(str, len + 1);