[master] 32f1b62ce vre: New VRE_capture() function
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Aug 30 12:25:08 UTC 2021
commit 32f1b62ce0d3d572f0ce8bfa7c7b3f7c11d6b7a2
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Tue Aug 3 12:13:34 2021 +0200
vre: New VRE_capture() function
It's a thin wrapper on top of vre_capture() that returns the number of
groups captured during a match.
Now that txt appears in vre.h we need vdef.h anywhere the former is
included. There was one generated file where that wasn't the case.
Closes #3655
diff --git a/include/vre.h b/include/vre.h
index c206078da..2a9450ad5 100644
--- a/include/vre.h
+++ b/include/vre.h
@@ -60,6 +60,8 @@ vre_t *VRE_export(const vre_t *, size_t *);
int VRE_error(struct vsb *, int err);
int VRE_match(const vre_t *code, const char *subject, size_t length,
int options, const volatile struct vre_limits *lim);
+int VRE_capture(vre_t *code, const char *subject, size_t length, int options,
+ txt *groups, size_t count, const volatile struct vre_limits *lim);
int VRE_sub(const vre_t *code, const char *subject, const char *replacement,
struct vsb *vsb, const volatile struct vre_limits *lim, int all);
void VRE_free(vre_t **);
diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c
index 83077656c..959201fa8 100644
--- a/lib/libvarnish/vre.c
+++ b/lib/libvarnish/vre.c
@@ -243,6 +243,29 @@ VRE_match(const vre_t *code, const char *subject, size_t length,
NULL, NULL, NULL));
}
+int
+VRE_capture(vre_t *code, const char *subject, size_t length, int options,
+ txt *groups, size_t count, const volatile struct vre_limits *lim)
+{
+ int i;
+
+ CHECK_OBJ_NOTNULL(code, VRE_MAGIC);
+ AN(subject);
+ AZ(options & (~VRE_MASK_MATCH));
+ AN(groups);
+ AN(count);
+
+ if (length == 0)
+ length = PCRE2_ZERO_TERMINATED;
+ vre_limit(code, lim);
+ i = vre_capture(code, subject, length, 0, options,
+ groups, &count, NULL);
+
+ if (i <= 0)
+ return (i);
+ return (count);
+}
+
int
VRE_sub(const vre_t *code, const char *subject, const char *replacement,
struct vsb *vsb, const volatile struct vre_limits *lim, int all)
diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py
index 3924e4a13..10bef4257 100755
--- a/lib/libvarnishapi/generate.py
+++ b/lib/libvarnishapi/generate.py
@@ -192,6 +192,7 @@ fo.write("""
#include <ctype.h>
#include <stdio.h>
+#include "vdef.h"
#include "vqueue.h"
#include "vre.h"
More information about the varnish-commit
mailing list