MINOR: regex: Create JIT compatible function that return match strings

This patchs rename the "regex_exec" to "regex_exec2". It add a new
"regex_exec", "regex_exec_match" and "regex_exec_match2" function. This
function can match regex and return array containing matching parts.
Otherwise, this function use the compiled method (JIT or PCRE or POSIX).

JIT require a subject with length. PCREPOSIX and native POSIX regex
require a null terminted subject. The regex_exec* function are splited
in two version. The first version take a null terminated string, but it
execute strlen() on the subject if it is compiled with JIT. The second
version (terminated by "2") take the subject and the length. This
version adds a null character in the subject if it is compiled with
PCREPOSIX or native POSIX functions.

The documentation of posix regex and pcreposix says that the function
returns 0 if the string matche otherwise it returns REG_NOMATCH. The
REG_NOMATCH macro take the value 1 with posix regex and the value 17
with the pcreposix. The documentaion of the native pcre API (used with
JIT) returns a negative number if no match, otherwise, it returns 0 or a
positive number.

This patch fix also the return codes of the regex_exec* functions. Now,
these function returns true if the string match, otherwise it returns
false.
diff --git a/include/common/regex.h b/include/common/regex.h
index 2e26b67..cec68c8 100644
--- a/include/common/regex.h
+++ b/include/common/regex.h
@@ -84,23 +84,50 @@
 const char *chain_regex(struct hdr_exp **head, const regex_t *preg,
 			int action, const char *replace, void *cond);
 
+/* If the function doesn't match, it returns false, else it returns true.
+ */
+static inline int regex_exec(const struct my_regex *preg, char *subject) {
+#ifdef USE_PCRE_JIT
+	if (pcre_exec(preg->reg, preg->extra, subject, strlen(subject), 0, 0, NULL, 0) < 0)
+		return 0;
+	return 1;
+#else
+	int match;
+	match = regexec(&preg->regex, subject, 0, NULL, 0);
+	if (match == REG_NOMATCH)
+		return 0;
+	return 1;
+#endif
+}
+
 /* Note that <subject> MUST be at least <length+1> characters long and must
  * be writable because the function will temporarily force a zero past the
  * last character.
+ *
+ * If the function doesn't match, it returns false, else it returns true.
  */
-static inline int regex_exec(const struct my_regex *preg, char *subject, int length) {
+static inline int regex_exec2(const struct my_regex *preg, char *subject, int length) {
 #ifdef USE_PCRE_JIT
-	return pcre_exec(preg->reg, preg->extra, subject, length, 0, 0, NULL, 0);
+	if (pcre_exec(preg->reg, preg->extra, subject, length, 0, 0, NULL, 0) < 0)
+		return 0;
+	return 1;
 #else
 	int match;
 	char old_char = subject[length];
 	subject[length] = 0;
 	match = regexec(&preg->regex, subject, 0, NULL, 0);
 	subject[length] = old_char;
-	return match;
+	if (match == REG_NOMATCH)
+		return 0;
+	return 1;
 #endif
 }
 
+int regex_exec_match(const struct my_regex *preg, const char *subject,
+                     size_t nmatch, regmatch_t pmatch[]);
+int regex_exec_match2(const struct my_regex *preg, char *subject, int length,
+                      size_t nmatch, regmatch_t pmatch[]);
+
 static inline void regex_free(struct my_regex *preg) {
 #ifdef USE_PCRE_JIT
 	pcre_free_study(preg->extra);