44
44
45
45
#define PCRE_CACHE_SIZE 4096
46
46
47
+ /* not fully functional workaround for libpcre < 8.0, see bug #70232 */
48
+ #ifndef PCRE_NOTEMPTY_ATSTART
49
+ # define PCRE_NOTEMPTY_ATSTART PCRE_NOTEMPTY
50
+ #endif
51
+
47
52
enum {
48
53
PHP_PCRE_NO_ERROR = 0 ,
49
54
PHP_PCRE_INTERNAL_ERROR ,
@@ -876,7 +881,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
876
881
pcre_free ((void * ) stringlist );
877
882
}
878
883
} else if (count == PCRE_ERROR_NOMATCH ) {
879
- /* If we previously set PCRE_NOTEMPTY after a null match,
884
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
880
885
this is not necessarily the end. We need to advance
881
886
the start offset, and continue. Fudge the offset values
882
887
to achieve this, unless we're already at the end of the string. */
@@ -893,10 +898,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
893
898
}
894
899
895
900
/* If we have matched an empty string, mimic what Perl's /g options does.
896
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
901
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
897
902
the match again at the same point. If this fails (picked up above) we
898
903
advance to the next character. */
899
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
904
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
900
905
901
906
/* Advance to the position right after the last full match */
902
907
start_offset = offsets [1 ];
@@ -1271,7 +1276,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
1271
1276
limit -- ;
1272
1277
}
1273
1278
} else if (count == PCRE_ERROR_NOMATCH || UNEXPECTED (limit == 0 )) {
1274
- /* If we previously set PCRE_NOTEMPTY after a null match,
1279
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
1275
1280
this is not necessarily the end. We need to advance
1276
1281
the start offset, and continue. Fudge the offset values
1277
1282
to achieve this, unless we're already at the end of the string. */
@@ -1313,10 +1318,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
1313
1318
}
1314
1319
1315
1320
/* If we have matched an empty string, mimic what Perl's /g options does.
1316
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
1321
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
1317
1322
the match again at the same point. If this fails (picked up above) we
1318
1323
advance to the next character. */
1319
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
1324
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
1320
1325
1321
1326
/* Advance to the next piece. */
1322
1327
start_offset = offsets [1 ];
@@ -1815,7 +1820,7 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
1815
1820
}
1816
1821
}
1817
1822
} else if (count == PCRE_ERROR_NOMATCH ) {
1818
- /* If we previously set PCRE_NOTEMPTY after a null match,
1823
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
1819
1824
this is not necessarily the end. We need to advance
1820
1825
the start offset, and continue. Fudge the offset values
1821
1826
to achieve this, unless we're already at the end of the string. */
@@ -1849,10 +1854,10 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
1849
1854
}
1850
1855
1851
1856
/* If we have matched an empty string, mimic what Perl's /g options does.
1852
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
1857
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
1853
1858
the match again at the same point. If this fails (picked up above) we
1854
1859
advance to the next character. */
1855
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
1860
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
1856
1861
1857
1862
/* Advance to the position right after the last full match */
1858
1863
start_offset = offsets [1 ];
0 commit comments