aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-08-03 21:38:50 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-08-03 21:38:50 +0300
commitf591d307d9af95bfa0ccda4d5eb76a674447ba39 (patch)
tree65c8e2259634653566fc2c49ec996ff416330361 /profile.c
parent9907a598dca8f129422c42f8c4fa3b4e2c988221 (diff)
downloadegawk-f591d307d9af95bfa0ccda4d5eb76a674447ba39.tar.gz
egawk-f591d307d9af95bfa0ccda4d5eb76a674447ba39.tar.bz2
egawk-f591d307d9af95bfa0ccda4d5eb76a674447ba39.zip
Restore typed regexp code in a new branch.
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/profile.c b/profile.c
index 56df9e37..be8977e8 100644
--- a/profile.c
+++ b/profile.c
@@ -33,6 +33,7 @@ static char *pp_list(int nargs, const char *paren, const char *delim);
static char *pp_group3(const char *s1, const char *s2, const char *s3);
static char *pp_concat(int nargs);
static char *pp_string_or_strong_regex(const char *in_str, size_t len, int delim, bool strong_regex);
+static char *pp_strong_regex(const char *in_str, size_t len, int delim);
static bool is_binary(int type);
static bool is_scalar(int type);
static int prec_level(int type);
@@ -636,14 +637,17 @@ cleanup:
break;
case Op_push_re:
- if (pc->memory->type != Node_regex)
+ if (pc->memory->type != Node_regex && pc->memory->type != Node_typedregex)
break;
/* else
fall through */
case Op_match_rec:
{
NODE *re = pc->memory->re_exp;
- str = pp_string(re->stptr, re->stlen, '/');
+ if (pc->memory->type == Node_regex)
+ str = pp_string(re->stptr, re->stlen, '/');
+ else
+ str = pp_strong_regex(re->stptr, re->stlen, '/');
pp_push(pc->opcode, str, CAN_FREE);
}
break;
@@ -665,6 +669,11 @@ cleanup:
txt = t2->pp_str;
str = pp_group3(txt, op2str(pc->opcode), restr);
pp_free(t2);
+ } else if (m->type == Node_typedregex) {
+ NODE *re = m->re_exp;
+ restr = pp_strong_regex(re->stptr, re->stlen, '/');
+ str = pp_group3(txt, op2str(pc->opcode), restr);
+ efree(restr);
} else {
NODE *re = m->re_exp;
restr = pp_string(re->stptr, re->stlen, '/');
@@ -1405,6 +1414,13 @@ pp_string(const char *in_str, size_t len, int delim)
return pp_string_or_strong_regex(in_str, len, delim, false);
}
+/* pp_strong_regex --- pretty format a hard regex constant */
+
+static char *
+pp_strong_regex(const char *in_str, size_t len, int delim)
+{
+ return pp_string_or_strong_regex(in_str, len, delim, true);
+}
/* pp_string_or_strong_regex --- pretty format a string, regex, or hard regex constant */
@@ -1448,6 +1464,9 @@ pp_string_or_strong_regex(const char *in_str, size_t len, int delim, bool strong
obufout = obuf;
ofre = osiz - 1;
+ if (strong_regex)
+ *obufout++ = '@';
+
*obufout++ = delim;
for (; len > 0; len--, str++) {
chksize(2); /* make space for 2 chars */