On Tue, Jan 30, 2018 at 07:48:17AM +0100, Otto Moerbeek wrote:
> On Mon, Jan 29, 2018 at 11:23:18PM -0600, Edgar Pettijohn wrote:
>
> > I'm trying to use patterns.c for some pattern matching. The manual mentions
> > captures using "()" around what you want to capture. I don't see how to get
> > at the data though. Here is a sample program.
> >
> > #include <stdio.h>
> > #include "patterns.h"
> >
> > int
> > main(int argc, char *argv[])
> > {
> > const char *errstr = NULL;
> > const char *string = "the quick the brown the fox";
> > const char *pattern = "the";
> > int ret;
> > struct str_match match;
> >
> > ret = str_match(string, pattern, &match, &errstr);
> >
> > if (errstr != NULL)
> > printf("%s\n", errstr);
> > else
> > printf("number of matches %d\n", match.sm_nmatch);
> >
> > return 0;
> > }
> >
> > It prints 2 which I was expecting 3. I've tried multiple other patterns and
> > it seems the answer is always 2. Which leads me to believe I'm doing
> > something wrong. Any assistance appreciated.
> >
> >
> > Thanks,
> >
> >
> > Edgar
>
> Hmm, str_match() isn't a function in any OpenBSD API. So I have no
> idea what function you are talking about.
>
> -Otto
>
It is in httpd patterns.c, which is based on the LUA pattern matching code.
--
Kind regards,
Hiltjo