Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Several PCRE module oddities



On Jul 23, 10:18pm, Jun T. wrote:
} Subject: Re: [PATCH] Several PCRE module oddities
}
} 
} On 2014/07/21, at 01:55, Bart Schaefer wrote:
} > I was thinking more of using offset_start < 0 as a flag for whether the
} > -n option appears at all, since the return value of getposint() can be
} > independently examined.
} 
} With this patch, if the -n option is not given, then offset_start remains
} as -1 and pcre_exec() (line 314)

Well, drat.  I was sure I'd run "make check".  How did I miss that?

} Maybe offset_start can be initialized to 0 as in the original code?

Yes, thinko on my part.  I started with the idea that -n 0 was a case
that needed to be differentiated, but in the end that doesn't seem to
be the case.

Thanks for catching.


diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 0e43ab7..040a33f 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -274,7 +274,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func))
     int return_value = 1;
     /* The subject length and offset start are both int values in pcre_exec */
     int subject_len;
-    int offset_start = -1;
+    int offset_start = 0;
     int want_offset_pair = 0;
 
     if (pcre_pattern == NULL) {



Messages sorted by: Reverse Date, Date, Thread, Author