43
43
44
44
#define PCRE_CACHE_SIZE 4096
45
45
46
+ /* not fully functional workaround for libpcre < 8.0, see bug #70232 */
47
+ #ifndef PCRE_NOTEMPTY_ATSTART
48
+ # define PCRE_NOTEMPTY_ATSTART PCRE_NOTEMPTY
49
+ #endif
50
+
46
51
enum {
47
52
PHP_PCRE_NO_ERROR = 0 ,
48
53
PHP_PCRE_INTERNAL_ERROR ,
@@ -794,7 +799,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
794
799
pcre_free ((void * ) stringlist );
795
800
}
796
801
} else if (count == PCRE_ERROR_NOMATCH ) {
797
- /* If we previously set PCRE_NOTEMPTY after a null match,
802
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
798
803
this is not necessarily the end. We need to advance
799
804
the start offset, and continue. Fudge the offset values
800
805
to achieve this, unless we're already at the end of the string. */
@@ -811,10 +816,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
811
816
}
812
817
813
818
/* If we have matched an empty string, mimic what Perl's /g options does.
814
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
819
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
815
820
the match again at the same point. If this fails (picked up above) we
816
821
advance to the next character. */
817
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
822
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
818
823
819
824
/* Advance to the position right after the last full match */
820
825
start_offset = offsets [1 ];
@@ -1256,7 +1261,7 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub
1256
1261
limit -- ;
1257
1262
1258
1263
} else if (count == PCRE_ERROR_NOMATCH || limit == 0 ) {
1259
- /* If we previously set PCRE_NOTEMPTY after a null match,
1264
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
1260
1265
this is not necessarily the end. We need to advance
1261
1266
the start offset, and continue. Fudge the offset values
1262
1267
to achieve this, unless we're already at the end of the string. */
@@ -1290,10 +1295,10 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int sub
1290
1295
}
1291
1296
1292
1297
/* If we have matched an empty string, mimic what Perl's /g options does.
1293
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
1298
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
1294
1299
the match again at the same point. If this fails (picked up above) we
1295
1300
advance to the next character. */
1296
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
1301
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
1297
1302
1298
1303
/* Advance to the next piece. */
1299
1304
start_offset = offsets [1 ];
@@ -1659,7 +1664,7 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
1659
1664
}
1660
1665
}
1661
1666
} else if (count == PCRE_ERROR_NOMATCH ) {
1662
- /* If we previously set PCRE_NOTEMPTY after a null match,
1667
+ /* If we previously set PCRE_NOTEMPTY_ATSTART after a null match,
1663
1668
this is not necessarily the end. We need to advance
1664
1669
the start offset, and continue. Fudge the offset values
1665
1670
to achieve this, unless we're already at the end of the string. */
@@ -1691,10 +1696,10 @@ PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subjec
1691
1696
}
1692
1697
1693
1698
/* If we have matched an empty string, mimic what Perl's /g options does.
1694
- This turns out to be rather cunning. First we set PCRE_NOTEMPTY and try
1699
+ This turns out to be rather cunning. First we set PCRE_NOTEMPTY_ATSTART and try
1695
1700
the match again at the same point. If this fails (picked up above) we
1696
1701
advance to the next character. */
1697
- g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY | PCRE_ANCHORED : 0 ;
1702
+ g_notempty = (offsets [1 ] == offsets [0 ])? PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED : 0 ;
1698
1703
1699
1704
/* Advance to the position right after the last full match */
1700
1705
start_offset = offsets [1 ];
0 commit comments