[pcre-dev] [Bug 2756] New: Documented DFA example does not w…

Top Page

Reply to this message
Author: admin
Date:  
To: pcre-dev
Subject: [pcre-dev] [Bug 2756] New: Documented DFA example does not work as expected
https://bugs.exim.org/show_bug.cgi?id=2756

            Bug ID: 2756
           Summary: Documented DFA example does not work as expected
           Product: PCRE
           Version: 10.36 (PCRE2)
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: Philip.Hazel@???
          Reporter: stevenjshuck@???
                CC: pcre-dev@???


The DFA example in the docs demonstrating finding every match does not work as
expected. (I think it's a code bug rather than a docs bug, so I chose
component as "Code".)



#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#include <stdio.h>
#include <string.h>

static const char *pattern = "<.*>";
static const char *subject =
    "This is <something> <something else> <something further> no more";


#define WSCOUNT 128

int main()
{
    int errorcode;
    size_t erroroffset;


    pcre2_code *code = pcre2_compile(
        pattern,
        strlen(pattern),
        0,
        &errorcode,
        &erroroffset,
        NULL
    );


    pcre2_match_data *matchdata  = pcre2_match_data_create_from_pattern(
        code,
        NULL
    );


    int ws[WSCOUNT];


    const int result = pcre2_dfa_match(
        code,
        subject,
        strlen(subject),
        0,
        0,
        matchdata,
        NULL,
        ws,
        WSCOUNT
    );


    printf("%d\n", result);


    return 0;
}



It prints 0 but should print 3.

--
You are receiving this mail because:
You are on the CC list for the bug.