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/pcre.c | |
| 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/pcre.c')
| -rw-r--r-- | ext/pcre/pcrelib/pcre.c | 20 | 
1 files changed, 17 insertions, 3 deletions
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. */  | 
