/* $Id$ */
-/* Get PCRE library from ftp://ftp.cus.cam.ac.uk/pub/software/programs/pcre/ */
-
#include "php.h"
#if HAVE_PCRE
do {
/* Execute the regular expression. */
count = pcre_exec(re, extra, &subject->value.str.val[subject_offset],
- subject->value.str.len-subject_offset,
+ subject->value.str.len-subject_offset, subject->value.str.val,
(subject_offset ? exoptions|PCRE_NOTBOL : exoptions),
offsets, size_offsets, 0);
while (count >= 0) {
/* Execute the regular expression. */
count = pcre_exec(re, extra, piece,
- subject_end-piece,
+ subject_end-piece, subject,
(piece==subject ? exoptions : exoptions|PCRE_NOTBOL),
offsets, size_offsets, (piece == match));
/* Get next piece if no limit or limit not yet reached and something matched*/
while ((limit_val == -1 || limit_val > 0) && count >= 0) {
count = pcre_exec(re, extra, &subject->value.str.val[last_offset],
- subject->value.str.len-last_offset,
+ subject->value.str.len-last_offset, subject->value.str.val,
(last_offset ? exoptions|PCRE_NOTBOL : exoptions),
offsets, size_offsets, 0);
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. */
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)?
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;
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. */
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 *);