summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/module.c15
-rw-r--r--Test/V07pcre.ztst9
3 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9cf17923e..026fe3796 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-11  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* Phil: 41527 (tweak to use heap memory): Src/module.c,
+	Test/V07pcre.ztst: fix [[ ... ]]] conditions passed to modules.
+
 2017-08-09  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: README: 5.4,1 typo fixed.
diff --git a/Src/module.c b/Src/module.c
index 21d68b1ac..4ae78310f 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -649,11 +649,21 @@ getconddef(int inf, const char *name, int autol)
 {
     Conddef p;
     int f = 1;
+    char *lookup, *s;
+
+    /* detokenize the Dash to the form encoded in lookup tables */
+    lookup = dupstring(name);
+    if (!lookup)
+	return NULL;
+    for (s = lookup; *s != '\0'; s++) {
+	if (*s == Dash)
+	    *s = '-';
+    }
 
     do {
 	for (p = condtab; p; p = p->next) {
 	    if ((!!inf == !!(p->flags & CONDF_INFIX)) &&
-		!strcmp(name, p->name))
+		!strcmp(lookup, p->name))
 		break;
 	}
 	if (autol && p && p->module) {
@@ -664,7 +674,7 @@ getconddef(int inf, const char *name, int autol)
 	    if (f) {
 		(void)ensurefeature(p->module,
 				    (p->flags & CONDF_INFIX) ? "C:" : "c:",
-				    (p->flags & CONDF_AUTOALL) ? NULL : name);
+				    (p->flags & CONDF_AUTOALL) ? NULL : lookup);
 		f = 0;
 		p = NULL;
 	    } else {
@@ -674,6 +684,7 @@ getconddef(int inf, const char *name, int autol)
 	} else
 	    break;
     } while (!p);
+
     return p;
 }
 
diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst
index 7426e7bf8..ab41d33dc 100644
--- a/Test/V07pcre.ztst
+++ b/Test/V07pcre.ztst
@@ -137,6 +137,15 @@
 0:ensure ASCII NUL passes in and out of matched plaintext
 >6; 3; 3
 
+# Ensure the long-form infix operator works
+  [[ foo -pcre-match ^f..$ ]]
+  print $?
+  [[ foo -pcre-match ^g..$ ]]
+  print $?
+0:infix -pcre-match works
+>0
+>1
+
 # Subshell because crash on failure
   ( setopt re_match_pcre
     [[ test.txt =~ '^(.*_)?(test)' ]]