diff options
| author | Andrey Hristov <andrey@php.net> | 1999-05-29 19:38:50 +0000 |
|---|---|---|
| committer | Andrey Hristov <andrey@php.net> | 1999-05-29 19:38:50 +0000 |
| commit | 9c970e1910a9e7863eb92f0a8b2286a5aeb11b46 (patch) | |
| tree | 20cad25be706d053b60c02327a1eaadc8991d496 /ext/pcre/pcrelib | |
| parent | e058cccfc101b56ac49593106c775f12c3b4d726 (diff) | |
| download | php-git-9c970e1910a9e7863eb92f0a8b2286a5aeb11b46.tar.gz | |
Fixed PCRE so that global matching with patterns with \b works.
Diffstat (limited to 'ext/pcre/pcrelib')
| -rw-r--r-- | ext/pcre/pcrelib/internal.h | 1 | ||||
| -rw-r--r-- | ext/pcre/pcrelib/pcre.c | 20 | ||||
| -rw-r--r-- | ext/pcre/pcrelib/pcre.h | 2 |
3 files changed, 19 insertions, 4 deletions
diff --git a/ext/pcre/pcrelib/internal.h b/ext/pcre/pcrelib/internal.h index 2b28ac1a54..b6680a0d50 100644 --- a/ext/pcre/pcrelib/internal.h +++ b/ext/pcre/pcrelib/internal.h @@ -307,6 +307,7 @@ typedef struct match_data { const uschar *end_subject; /* End of the subject string */ const uschar *end_match_ptr; /* Subject position at end match */ int end_offset_top; /* Highwater mark at end of match */ + char regprev; /* Character previous to subject string (Andrey Zmievski) */ } match_data; /* Bit definitions for entries in the pcre_ctypes table. */ diff --git a/ext/pcre/pcrelib/pcre.c b/ext/pcre/pcrelib/pcre.c index caeeaa4971..51cb6b6c87 100644 --- a/ext/pcre/pcrelib/pcre.c +++ b/ext/pcre/pcrelib/pcre.c @@ -3321,8 +3321,12 @@ for (;;) case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: { - BOOL prev_is_word = (eptr != md->start_subject) && - ((md->ctypes[eptr[-1]] & ctype_word) != 0); + /* Modified the next line to check previous character + in case we're not at the beginning of the whole string + (Andrey Zmievski) */ + BOOL prev_is_word = (eptr != md->start_subject) ? + ((md->ctypes[eptr[-1]] & ctype_word) != 0) : + ((md->ctypes[md->regprev] & ctype_word) != 0); BOOL cur_is_word = (eptr < md->end_subject) && ((md->ctypes[*eptr] & ctype_word) != 0); if ((*ecode++ == OP_WORD_BOUNDARY)? @@ -4125,7 +4129,8 @@ Returns: > 0 => success; value is the number of elements filled in int pcre_exec(const pcre *external_re, const pcre_extra *external_extra, - const char *subject, int length, int options, int *offsets, int offsetcount, int minlen) + const char *subject, int length, const char *strbeg, int options, + int *offsets, int offsetcount, int minlen) { int resetcount, ocount; int first_char = -1; @@ -4160,6 +4165,15 @@ match_block.errorcode = PCRE_ERROR_NOMATCH; /* Default error */ match_block.lcc = re->tables + lcc_offset; match_block.ctypes = re->tables + ctypes_offset; +/* Setup previous character (Andrey Zmievski) */ +if (subject == strbeg) + match_block.regprev = '\n'; +else { + match_block.regprev = subject[-1]; + if (!(re->options & PCRE_MULTILINE) && match_block.regprev == '\n') + match_block.regprev = '\0'; +} + /* The ims options can vary during the matching as a result of the presence of (?ims) items in the pattern. They are kept in a local variable so that restoring at the exit of a group is easy. */ diff --git a/ext/pcre/pcrelib/pcre.h b/ext/pcre/pcrelib/pcre.h index 0efc0f6502..8fedb8189e 100644 --- a/ext/pcre/pcrelib/pcre.h +++ b/ext/pcre/pcrelib/pcre.h @@ -59,7 +59,7 @@ extern pcre *pcre_compile(const char *, int, const char **, int *, const unsigned char *); extern int pcre_copy_substring(const char *, int *, int, int, char *, int); extern int pcre_exec(const pcre *, const pcre_extra *, const char *, - int, int, int *, int, int); + int, const char *, int, int *, int, int); extern int pcre_get_substring(const char *, int *, int, int, const char **); extern int pcre_get_substring_list(const char *, int *, int, const char ***); extern int pcre_info(const pcre *, int *, int *); |
