Commit 32f1b62c authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

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
parent 357242a1
......@@ -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 **);
......
......@@ -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)
......
......@@ -192,6 +192,7 @@ fo.write("""
#include <ctype.h>
#include <stdio.h>
#include "vdef.h"
#include "vqueue.h"
#include "vre.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment