[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-1397-gecf875a |
Date: |
Tue, 05 May 2015 07:39:24 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/regex-type has been updated
via ecf875a23050b7e3b64805674e9ce3cac4199cb8 (commit)
from 8f79856a02dd3e3ba8fc00a6e3086a367ca0cdf4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=ecf875a23050b7e3b64805674e9ce3cac4199cb8
commit ecf875a23050b7e3b64805674e9ce3cac4199cb8
Author: Arnold D. Robbins <address@hidden>
Date: Tue May 5 10:39:03 2015 +0300
Make profiling work for hard regexes.
diff --git a/ChangeLog b/ChangeLog
index ad0d35d..3ea9c17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-05-05 Arnold D. Robbins <address@hidden>
+
+ Make profiling for hard regexes work.
+
+ * profile.c (pp_string_or_hard_regex): Renamed from pp_string.
+ Add bool param for hard regex and add @ if so.
+ (pp_string): New function, calls pp_string_or_hard_regex.
+ (pp_hard_regex): New function, calls pp_string_or_hard_regex.
+ (pprint): Adjust to print a hard regex correctly.
+
2015-05-01 Arnold D. Robbins <address@hidden>
* awkgram.y: Make sure values are not null in param list.
diff --git a/profile.c b/profile.c
index dcc2946..a5c24b7 100644
--- a/profile.c
+++ b/profile.c
@@ -32,6 +32,8 @@ static void parenthesize(int type, NODE *left, NODE *right);
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_hard_regex(const char *in_str, size_t len, int
delim, bool hard_regex);
+static char *pp_hard_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);
@@ -624,14 +626,17 @@ cleanup:
break;
case Op_push_re:
- if (pc->memory->type != Node_regex)
+ if (pc->memory->type != Node_regex && pc->memory->type
!= Node_hardregex)
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_hard_regex(re->stptr, re->stlen, '/');
pp_push(pc->opcode, str, CAN_FREE);
}
break;
@@ -653,6 +658,11 @@ cleanup:
txt = t2->pp_str;
str = pp_group3(txt, op2str(pc->opcode), restr);
pp_free(t2);
+ } else if (m->type == Node_hardregex) {
+ NODE *re = m->re_exp;
+ restr = pp_hard_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, '/');
@@ -1323,11 +1333,27 @@ parenthesize(int type, NODE *left, NODE *right)
pp_parenthesize(right);
}
-/* pp_string --- pretty format a string or regex constant */
+/* pp_string --- pretty format a string or regular regex constant */
char *
pp_string(const char *in_str, size_t len, int delim)
{
+ return pp_string_or_hard_regex(in_str, len, delim, false);
+}
+
+/* pp_hard_regex --- pretty format a hard regex constant */
+
+static char *
+pp_hard_regex(const char *in_str, size_t len, int delim)
+{
+ return pp_string_or_hard_regex(in_str, len, delim, true);
+}
+
+/* pp_string_or_hard_regex --- pretty format a string, regex, or hard regex
constant */
+
+char *
+pp_string_or_hard_regex(const char *in_str, size_t len, int delim, bool
hard_regex)
+{
static char str_escapes[] = "\a\b\f\n\r\t\v\\";
static char str_printables[] = "abfnrtv\\";
static char re_escapes[] = "\a\b\f\n\r\t\v";
@@ -1359,11 +1385,15 @@ pp_string(const char *in_str, size_t len, int delim)
osiz *= 2; \
} ofre -= (l)
- osiz = len + 3 + 1; /* initial size; 3 for delim + terminating null
*/
+ /* initial size; 3 for delim + terminating null, 1 for @ */
+ osiz = len + 3 + 1 + (hard_regex == true);
emalloc(obuf, char *, osiz, "pp_string");
obufout = obuf;
ofre = osiz - 1;
+ if (hard_regex)
+ *obufout++ = '@';
+
*obufout++ = delim;
for (; len > 0; len--, str++) {
chksize(2); /* make space for 2 chars */
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 ++++++++++
profile.c | 38 ++++++++++++++++++++++++++++++++++----
2 files changed, 44 insertions(+), 4 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/regex-type, updated. gawk-4.1.0-1397-gecf875a,
Arnold Robbins <=