aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-11-15 21:03:57 +0200
committerArnold D. Robbins <arnold@skeeve.com>2016-11-15 21:03:57 +0200
commitb37675aa79213f2665abb2bbb4db90560642bdee (patch)
tree74a00854546a7a174b0722277def07fbfbc0e4cd /builtin.c
parent84a7c376d6322a6e2429af79358091d10d94c004 (diff)
downloadegawk-b37675aa79213f2665abb2bbb4db90560642bdee.tar.gz
egawk-b37675aa79213f2665abb2bbb4db90560642bdee.tar.bz2
egawk-b37675aa79213f2665abb2bbb4db90560642bdee.zip
First steps reworking code away from node type.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/builtin.c b/builtin.c
index a7fe6312..001dd6e2 100644
--- a/builtin.c
+++ b/builtin.c
@@ -536,7 +536,7 @@ do_length(int nargs)
return make_number(size);
}
- assert(tmp->type == Node_val || tmp->type == Node_typedregex);
+ assert(tmp->type == Node_val);
if (do_lint && (fixtype(tmp)->flags & STRING) == 0)
lintwarn(_("length: received non-string argument"));
@@ -2195,11 +2195,9 @@ do_print(int nargs, int redirtype)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp));
}
- if (tmp->type == Node_typedregex)
- args_array[i] = force_string(tmp);
- else if ( (tmp->flags & STRCUR) == 0
- || ( tmp->stfmt != STFMT_UNUSED
- && tmp->stfmt != OFMTidx))
+ if ( (tmp->flags & STRCUR) == 0
+ || ( tmp->stfmt != STFMT_UNUSED
+ && tmp->stfmt != OFMTidx))
args_array[i] = format_val(OFMT, OFMTidx, tmp);
}
@@ -3203,7 +3201,7 @@ call_sub(const char *name, int nargs)
* push replace
* push $0
*/
- if (regex->type != Node_typedregex)
+ if ((regex->flags & REGEX) == 0)
regex = make_regnode(Node_regex, regex);
PUSH(regex);
PUSH(replace);
@@ -3228,7 +3226,7 @@ call_sub(const char *name, int nargs)
* nargs++
* }
*/
- if (regex->type != Node_typedregex)
+ if ((regex->flags & REGEX) == 0)
regex = make_regnode(Node_regex, regex);
PUSH(regex);
PUSH(replace);
@@ -3266,7 +3264,7 @@ call_match(int nargs)
/* Don't need to pop the string just to push it back ... */
- if (regex->type != Node_typedregex)
+ if ((regex->flags & REGEX) == 0)
regex = make_regnode(Node_regex, regex);
PUSH(regex);
@@ -3295,7 +3293,7 @@ call_split_func(const char *name, int nargs)
if (nargs >= 3) {
regex = POP_STRING();
- if (regex->type != Node_typedregex)
+ if ((regex->flags & REGEX) == 0)
regex = make_regnode(Node_regex, regex);
} else {
if (name[0] == 's') {
@@ -3955,12 +3953,9 @@ do_typeof(int nargs)
res = "array";
deref = false;
break;
- case Node_typedregex:
- res = "regexp";
- break;
case Node_val:
case Node_var:
- switch (arg->flags & (STRING|NUMBER|MAYBE_NUM)) {
+ switch (arg->flags & (STRING|NUMBER|MAYBE_NUM|REGEX)) {
case STRING:
res = "string";
break;
@@ -3970,6 +3965,9 @@ do_typeof(int nargs)
case STRING|MAYBE_NUM:
res = "strnum";
break;
+ case REGEX:
+ res = "regexp";
+ break;
case NUMBER|STRING:
if (arg == Nnull_string) {
res = "unassigned";