Skip to content

Commit 3db6b51

Browse files
committed
Get basic language tests to all pass (minus xfails)
1 parent 91abad1 commit 3db6b51

14 files changed

+231
-228
lines changed

Zend/zend_API.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,13 @@ END_EXTERN_C()
574574
#define ZVAL_STRING(z, s, duplicate) do { \
575575
const char *__s=(s); \
576576
zval *__z = (z); \
577-
Z_STRSIZE_P(__z) = strlen(__s); \
577+
Z_STRSIZE_P(__z) = (zend_str_size) strlen(__s); \
578578
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, Z_STRSIZE_P(__z)):(char*)__s);\
579579
Z_TYPE_P(__z) = IS_STRING; \
580580
} while (0)
581581

582582
#define ZVAL_STRINGL(z, s, l, duplicate) do { \
583-
const char *__s=(s); zend_str_size __l=l; \
583+
const char *__s=(s); zend_str_size __l= (zend_str_size) (l); \
584584
zval *__z = (z); \
585585
Z_STRSIZE_P(__z) = __l; \
586586
Z_STRVAL_P(__z) = (duplicate?estrndup(__s, __l):(char*)__s);\

Zend/zend_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ typedef unsigned short zend_ushort;
3333
#define zend_str_size_int int
3434
#define zend_str_size_uint unsigned int
3535
#define zend_str_size_size_t size_t
36+
#define zend_str_size_long long
3637
typedef int zend_str_size;
3738
#else
3839
#define zend_str_size_int zend_str_size
3940
#define zend_str_size_uint zend_str_size
4041
#define zend_str_size_size_t zend_str_size
42+
#define zend_str_size_long zend_str_size
4143
typedef size_t zend_str_size;
4244
#endif
4345

ext/pcre/php_pcre.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ static char **make_subpats_table(int num_subpats, pcre_cache_entry *pce TSRMLS_D
226226

227227
/* {{{ pcre_get_compiled_regex_cache
228228
*/
229-
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, zend_str_size_int regex_len TSRMLS_DC)
229+
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC)
230230
{
231231
pcre *re = NULL;
232232
pcre_extra *extra;
233233
int coptions = 0;
234234
int soptions = 0;
235235
const char *error;
236-
zend_str_size erroffset;
236+
int erroffset;
237237
char delimiter;
238238
char start_delimiter;
239239
char end_delimiter;
@@ -399,7 +399,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, zend_str_siz
399399
re = pcre_compile(pattern,
400400
coptions,
401401
&error,
402-
&erroffset,
402+
(int *) &erroffset,
403403
tables);
404404

405405
if (re == NULL) {
@@ -508,7 +508,7 @@ PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *pr
508508
/* }}} */
509509

510510
/* {{{ add_offset_pair */
511-
static inline void add_offset_pair(zval *result, char *str, zend_str_size_int len, zend_str_size_int offset, char *name)
511+
static inline void add_offset_pair(zval *result, char *str, zend_str_size_int len, long offset, char *name)
512512
{
513513
zval *match_pair;
514514

@@ -546,17 +546,17 @@ static void php_do_pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* {{{ *
546546
}
547547

548548
/* Compile regex or get it from cache. */
549-
if ((pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC)) == NULL) {
549+
if ((pce = pcre_get_compiled_regex_cache(regex, (int) regex_len TSRMLS_CC)) == NULL) {
550550
RETURN_FALSE;
551551
}
552552

553-
php_pcre_match_impl(pce, subject, subject_len, return_value, subpats,
553+
php_pcre_match_impl(pce, subject, (int) subject_len, return_value, subpats,
554554
global, ZEND_NUM_ARGS() >= 4, flags, start_offset TSRMLS_CC);
555555
}
556556
/* }}} */
557557

558558
/* {{{ php_pcre_match_impl() */
559-
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *return_value,
559+
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
560560
zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC)
561561
{
562562
zval *result_set, /* Holds a set of subpatterns after
@@ -855,12 +855,12 @@ static int preg_get_backref(char **str, int *backref)
855855

856856
/* {{{ preg_do_repl_func
857857
*/
858-
static int preg_do_repl_func(zval *function, char *subject, zend_str_size_int *offsets, char **subpat_names, int count, char **result TSRMLS_DC)
858+
static int preg_do_repl_func(zval *function, char *subject, int *offsets, char **subpat_names, int count, char **result TSRMLS_DC)
859859
{
860860
zval *retval_ptr; /* Function return value */
861861
zval **args[1]; /* Argument to pass to function */
862862
zval *subpats; /* Captured subpatterns */
863-
zend_str_size result_len; /* Return value length */
863+
int result_len; /* Return value length */
864864
int i;
865865

866866
MAKE_STD_ZVAL(subpats);
@@ -894,8 +894,8 @@ static int preg_do_repl_func(zval *function, char *subject, zend_str_size_int *o
894894

895895
/* {{{ preg_do_eval
896896
*/
897-
static int preg_do_eval(char *eval_str, zend_str_size_int eval_str_len, char *subject,
898-
zend_str_size_int *offsets, int count, char **result TSRMLS_DC)
897+
static int preg_do_eval(char *eval_str, int eval_str_len, char *subject,
898+
int *offsets, int count, char **result TSRMLS_DC)
899899
{
900900
zval retval; /* Return value from evaluation */
901901
char *eval_str_end, /* End of eval string */
@@ -904,10 +904,10 @@ static int preg_do_eval(char *eval_str, zend_str_size_int eval_str_len, char *su
904904
*walk, /* Used to walk the code string */
905905
*segment, /* Start of segment to append while walking */
906906
walk_last; /* Last walked character */
907-
zend_str_size match_len; /* Length of the match */
908-
zend_str_size esc_match_len; /* Length of the quote-escaped match */
909-
zend_str_size result_len; /* Length of the result of the evaluation */
910-
zend_str_size backref; /* Current backref */
907+
zend_str_size match_len; /* Length of the match */
908+
zend_str_size esc_match_len; /* Length of the quote-escaped match */
909+
zend_str_size result_len; /* Length of the result of the evaluation */
910+
int backref; /* Current backref */
911911
char *compiled_string_description;
912912
smart_str code = {0};
913913

@@ -982,10 +982,10 @@ static int preg_do_eval(char *eval_str, zend_str_size_int eval_str_len, char *su
982982

983983
/* {{{ php_pcre_replace
984984
*/
985-
PHPAPI char *php_pcre_replace(char *regex, zend_str_size_int regex_len,
986-
char *subject, zend_str_size_int subject_len,
985+
PHPAPI char *php_pcre_replace(char *regex, int regex_len,
986+
char *subject, int subject_len,
987987
zval *replace_val, int is_callable_replace,
988-
zend_str_size_int *result_len, int limit, int *replace_count TSRMLS_DC)
988+
int *result_len, int limit, int *replace_count TSRMLS_DC)
989989
{
990990
pcre_cache_entry *pce; /* Compiled regular expression */
991991

@@ -1000,27 +1000,27 @@ PHPAPI char *php_pcre_replace(char *regex, zend_str_size_int regex_len,
10001000
/* }}} */
10011001

10021002
/* {{{ php_pcre_replace_impl() */
1003-
PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *replace_val,
1004-
int is_callable_replace, zend_str_size_int *result_len, int limit, int *replace_count TSRMLS_DC)
1003+
PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *replace_val,
1004+
int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC)
10051005
{
10061006
pcre_extra *extra = pce->extra;/* Holds results of studying */
10071007
pcre_extra extra_data; /* Used locally for exec options */
10081008
int exoptions = 0; /* Execution options */
10091009
int count = 0; /* Count of matched subpatterns */
1010-
int *offsets; /* Array of subpattern offsets */
1010+
int *offsets; /* Array of subpattern offsets */
10111011
char **subpat_names; /* Array for named subpatterns */
10121012
int num_subpats; /* Number of captured subpatterns */
10131013
int size_offsets; /* Size of the offsets array */
1014-
zend_str_size new_len; /* Length of needed storage */
1015-
zend_str_size alloc_len; /* Actual allocated length */
1016-
zend_str_size eval_result_len=0; /* Length of the eval'ed or
1014+
int new_len; /* Length of needed storage */
1015+
int alloc_len; /* Actual allocated length */
1016+
int eval_result_len=0; /* Length of the eval'ed or
10171017
function-returned string */
1018-
zend_str_size match_len; /* Length of the current match */
1019-
zend_str_size backref; /* Backreference number */
1018+
int match_len; /* Length of the current match */
1019+
int backref; /* Backreference number */
10201020
int eval; /* If the replacement string should be eval'ed */
1021-
zend_str_size start_offset; /* Where the new search starts */
1021+
int start_offset; /* Where the new search starts */
10221022
int g_notempty=0; /* If the match should not be empty */
1023-
zend_str_size replace_len=0; /* Length of replacement string */
1023+
int replace_len=0; /* Length of replacement string */
10241024
char *result, /* Result of replacement */
10251025
*replace=NULL, /* Replacement string */
10261026
*new_buf, /* Temporary buffer for re-allocation */
@@ -1243,15 +1243,15 @@ PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, zend_st
12431243

12441244
/* {{{ php_replace_in_subject
12451245
*/
1246-
static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject, zend_str_size_int *result_len, int limit, int is_callable_replace, int *replace_count TSRMLS_DC)
1246+
static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject, int *result_len, int limit, int is_callable_replace, int *replace_count TSRMLS_DC)
12471247
{
12481248
zval **regex_entry,
12491249
**replace_entry = NULL,
12501250
*replace_value,
12511251
empty_replace;
12521252
char *subject_value,
12531253
*result;
1254-
zend_str_size subject_len;
1254+
int subject_len;
12551255

12561256
/* Make sure we're dealing with strings. */
12571257
convert_to_string_ex(subject);
@@ -1339,7 +1339,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
13391339
**subject_entry,
13401340
**zcount = NULL;
13411341
char *result;
1342-
zend_str_size result_len;
1342+
int result_len;
13431343
int limit_val = -1;
13441344
long limit = -1;
13451345
char *string_key;
@@ -1397,11 +1397,11 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
13971397
switch(zend_hash_get_current_key(Z_ARRVAL_PP(subject), &string_key, &num_key, 0))
13981398
{
13991399
case HASH_KEY_IS_STRING:
1400-
add_assoc_stringl(return_value, string_key, result, result_len, 0);
1400+
add_assoc_stringl(return_value, string_key, result, (zend_str_size) result_len, 0);
14011401
break;
14021402

14031403
case HASH_KEY_IS_LONG:
1404-
add_index_stringl(return_value, num_key, result, result_len, 0);
1404+
add_index_stringl(return_value, num_key, result, (zend_str_size) result_len, 0);
14051405
break;
14061406
}
14071407
} else {
@@ -1415,7 +1415,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
14151415
old_replace_count = replace_count;
14161416
if ((result = php_replace_in_subject(*regex, *replace, subject, &result_len, limit_val, is_callable_replace, &replace_count TSRMLS_CC)) != NULL) {
14171417
if (!is_filter || replace_count > old_replace_count) {
1418-
RETVAL_STRINGL(result, result_len, 0);
1418+
RETVAL_STRINGL(result, (zend_str_size) result_len, 0);
14191419
} else {
14201420
efree(result);
14211421
}
@@ -1472,17 +1472,17 @@ static PHP_FUNCTION(preg_split)
14721472
}
14731473

14741474
/* Compile regex or get it from cache. */
1475-
if ((pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC)) == NULL) {
1475+
if ((pce = pcre_get_compiled_regex_cache(regex, (int) regex_len TSRMLS_CC)) == NULL) {
14761476
RETURN_FALSE;
14771477
}
14781478

1479-
php_pcre_split_impl(pce, subject, subject_len, return_value, limit_val, flags TSRMLS_CC);
1479+
php_pcre_split_impl(pce, subject, (int) subject_len, return_value, limit_val, flags TSRMLS_CC);
14801480
}
14811481
/* }}} */
14821482

14831483
/* {{{ php_pcre_split
14841484
*/
1485-
PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *return_value,
1485+
PHPAPI void php_pcre_split_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
14861486
long limit_val, long flags TSRMLS_DC)
14871487
{
14881488
pcre_extra *extra = NULL; /* Holds results of studying */
@@ -1753,7 +1753,7 @@ static PHP_FUNCTION(preg_grep)
17531753
}
17541754

17551755
/* Compile regex or get it from cache. */
1756-
if ((pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC)) == NULL) {
1756+
if ((pce = pcre_get_compiled_regex_cache(regex, (int) regex_len TSRMLS_CC)) == NULL) {
17571757
RETURN_FALSE;
17581758
}
17591759

ext/pcre/php_pcre.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <locale.h>
3434
#endif
3535

36-
PHPAPI char *php_pcre_replace(char *regex, zend_str_size_int regex_len, char *subject, zend_str_size_int subject_len, zval *replace_val, int is_callable_replace, zend_str_size_int *result_len, int limit, int *replace_count TSRMLS_DC);
36+
PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC);
3737
PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *options TSRMLS_DC);
3838
PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *coptions TSRMLS_DC);
3939

@@ -52,15 +52,15 @@ typedef struct {
5252
int refcount;
5353
} pcre_cache_entry;
5454

55-
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, zend_str_size_int regex_len TSRMLS_DC);
55+
PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC);
5656

57-
PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *return_value,
57+
PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
5858
zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC);
5959

60-
PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *return_value,
61-
int is_callable_replace, zend_str_size_int *result_len, int limit, int *replace_count TSRMLS_DC);
60+
PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
61+
int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC);
6262

63-
PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, zend_str_size_int subject_len, zval *return_value,
63+
PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
6464
long limit_val, long flags TSRMLS_DC);
6565

6666
PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value,

0 commit comments

Comments
 (0)