[PHP4BETA] CVS update: php4/ext/pcre
| From: | andrey | Date: | Sat, 29 May 1999 20:45:01 +0000 |
| Subject: | [PHP4BETA] CVS update: php4/ext/pcre | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-1199@lists.php.net to get a copy of this message | ||
Date: Saturday May 29, 1999 @ 16:45
Author: andrey
Update of /repository/php4/ext/pcre
In directory php:/tmp/cvs-serv11010/ext/pcre
Modified Files:
pcre.c
Log Message:
Updated preg_split().
Index: php4/ext/pcre/pcre.c
diff -u php4/ext/pcre/pcre.c:1.11 php4/ext/pcre/pcre.c:1.12
--- php4/ext/pcre/pcre.c:1.11 Sat May 29 16:04:05 1999
+++ php4/ext/pcre/pcre.c Sat May 29 16:45:00 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pcre.c,v 1.11 1999/05/29 20:04:05 andrey Exp $ */
+/* $Id: pcre.c,v 1.12 1999/05/29 20:45:00 andrey Exp $ */
#include "php.h"
@@ -762,7 +762,9 @@
int argc; /* Argument count */
int limit_val; /* Integer value of limit */
int count = 0; /* Count of matched subpatterns */
- int last_offset; /* Holds the offset of the last match */
+ char *match, /* The current match */
+ *piece, /* The current piece of subject */
+ *subject_end; /* Points to the end of subject string */
/* Get function parameters and do error checking */
argc = ARG_COUNT(ht);
@@ -794,14 +796,16 @@
offsets = (int *)emalloc(size_offsets * sizeof(int));
/* Start at the beginning of the string */
- last_offset = 0;
+ piece = subject->value.str.val;
+ subject_end = piece + subject->value.str.len;
+ match = NULL;
/* 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.val,
- (last_offset ? exoptions|PCRE_NOTBOL : exoptions),
- offsets, size_offsets, 0);
+ count = pcre_exec(re, extra, piece,
+ subject_end-piece, subject->value.str.val,
+ (piece==subject->value.str.val ? exoptions : exoptions|PCRE_NOTBOL),
+ offsets, size_offsets, (piece==match));
/* Check for too many substrings condition. */
if (count == 0) {
@@ -811,13 +815,15 @@
/* If something matched */
if (count > 0) {
+ match = piece + offsets[0];
+
/* Add the piece to the return value */
add_next_index_stringl(return_value,
- &subject->value.str.val[last_offset],
+ piece,
offsets[0], 1);
/* Advance to next position */
- last_offset += offsets[1];
+ piece += offsets[1];
/* One less left to do */
if (limit_val != -1)
@@ -826,10 +832,10 @@
else { /* if no match */
/* Add the last piece to the return value, if there
were matches before */
- if (last_offset > 0)
+ if (piece > subject->value.str.val)
add_next_index_stringl(return_value,
- &subject->value.str.val[last_offset],
- subject->value.str.len - last_offset, 1);
+ piece,
+ subject_end-piece, 1);
}
}
--
PHP 4 Beta