[pcre-dev] [Bug 682] New: Add REG_STARTEND support to PCRE

Page principale
Supprimer ce message
Auteur: Alan Lehotsky
Date:  
À: pcre-dev
Sujet: [pcre-dev] [Bug 682] New: Add REG_STARTEND support to PCRE
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=682
           Summary: Add REG_STARTEND support to PCRE
           Product: PCRE
           Version: N/A
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: wishlist
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: alehotsky@???
                CC: pcre-dev@???



BSD has the ability to do matching with a string that is not zero-terminated.

It does this by adding a flag REG_STARTEND and passing in values in the
match[0]
vector when calling the regexec() function.

It's a trivial addition to PCRE to support this. Here's a patch against the
7.5 sources. If the REG_STARTEND flag is set when calling pcre_exec(), the
string
start and end positions are selected from the pmatch[0].rm_so and .rm_eo
members
instead of assuming 0 and strlen(string).

ed pcreposix.h <<EOF
61a
#define REG_STARTEND 0x0080 /* pass string so,eo in via pmatch in # regexec()
*/
.
w
q
EOF

ed pcreposix.c <<EOF
299,300c

if ((eflags & REG_STARTEND) != 0) {
so = pmatch[0].rm_so;
eo = pmatch[0].rm_eo;
} else {
so = 0;
eo = strlen(string);
}

rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (eo-so),
so, options, ovector, nmatch * 3);
.
267a
int so,eo;
.
w
q
EOF


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email