Skip to content

Commit b8324e6

Browse files
committed
further fixes to ext/standard
1 parent 97e9d05 commit b8324e6

18 files changed

+108
-114
lines changed

ext/standard/array.c

+23-23
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ PHP_MSHUTDOWN_FUNCTION(array) /* {{{ */
141141
}
142142
/* }}} */
143143

144-
static void php_set_compare_func(int sort_type TSRMLS_DC) /* {{{ */
144+
static void php_set_compare_func(php_int_t sort_type TSRMLS_DC) /* {{{ */
145145
{
146146
switch (sort_type & ~PHP_SORT_FLAG_CASE) {
147147
case PHP_SORT_NUMERIC:
@@ -218,9 +218,9 @@ static int php_array_reverse_key_compare(const void *a, const void *b TSRMLS_DC)
218218
PHP_FUNCTION(krsort)
219219
{
220220
zval *array;
221-
long sort_type = PHP_SORT_REGULAR;
221+
php_int_t sort_type = PHP_SORT_REGULAR;
222222

223-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
223+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
224224
RETURN_FALSE;
225225
}
226226

@@ -238,9 +238,9 @@ PHP_FUNCTION(krsort)
238238
PHP_FUNCTION(ksort)
239239
{
240240
zval *array;
241-
long sort_type = PHP_SORT_REGULAR;
241+
php_int_t sort_type = PHP_SORT_REGULAR;
242242

243-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
243+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
244244
RETURN_FALSE;
245245
}
246246

@@ -253,7 +253,7 @@ PHP_FUNCTION(ksort)
253253
}
254254
/* }}} */
255255

256-
PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */
256+
PHPAPI php_int_t php_count_recursive(zval *array, php_int_t mode TSRMLS_DC) /* {{{ */
257257
{
258258
php_int_t cnt = 0;
259259
zval *element;
@@ -464,9 +464,9 @@ PHP_FUNCTION(natcasesort)
464464
PHP_FUNCTION(asort)
465465
{
466466
zval *array;
467-
long sort_type = PHP_SORT_REGULAR;
467+
php_int_t sort_type = PHP_SORT_REGULAR;
468468

469-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
469+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
470470
RETURN_FALSE;
471471
}
472472

@@ -484,9 +484,9 @@ PHP_FUNCTION(asort)
484484
PHP_FUNCTION(arsort)
485485
{
486486
zval *array;
487-
long sort_type = PHP_SORT_REGULAR;
487+
php_int_t sort_type = PHP_SORT_REGULAR;
488488

489-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
489+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
490490
RETURN_FALSE;
491491
}
492492

@@ -504,9 +504,9 @@ PHP_FUNCTION(arsort)
504504
PHP_FUNCTION(sort)
505505
{
506506
zval *array;
507-
long sort_type = PHP_SORT_REGULAR;
507+
php_int_t sort_type = PHP_SORT_REGULAR;
508508

509-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
509+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
510510
RETURN_FALSE;
511511
}
512512

@@ -524,9 +524,9 @@ PHP_FUNCTION(sort)
524524
PHP_FUNCTION(rsort)
525525
{
526526
zval *array;
527-
long sort_type = PHP_SORT_REGULAR;
527+
php_int_t sort_type = PHP_SORT_REGULAR;
528528

529-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|l", &array, &sort_type) == FAILURE) {
529+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|i", &array, &sort_type) == FAILURE) {
530530
RETURN_FALSE;
531531
}
532532

@@ -557,7 +557,7 @@ static int php_array_user_compare(const void *a, const void *b TSRMLS_DC) /* {{{
557557
BG(user_compare_fci).retval = &retval;
558558
BG(user_compare_fci).no_separation = 0;
559559
if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
560-
long ret = zval_get_int(&retval);
560+
php_int_t ret = zval_get_int(&retval);
561561
zval_ptr_dtor(&retval);
562562
zval_ptr_dtor(&args[1]);
563563
zval_ptr_dtor(&args[0]);
@@ -695,7 +695,7 @@ static int php_array_user_key_compare(const void *a, const void *b TSRMLS_DC) /*
695695
Bucket *s;
696696
zval args[2];
697697
zval retval;
698-
long result;
698+
php_int_t result;
699699

700700
ZVAL_NULL(&args[0]);
701701
ZVAL_NULL(&args[1]);
@@ -1357,15 +1357,15 @@ PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, int va
13571357
PHP_FUNCTION(extract)
13581358
{
13591359
zval *var_array, *prefix = NULL;
1360-
long extract_type = EXTR_OVERWRITE;
1360+
php_int_t extract_type = EXTR_OVERWRITE;
13611361
zval *entry;
13621362
zend_string *var_name;
13631363
php_uint_t num_key;
13641364
int var_exists, count = 0;
13651365
int extract_refs = 0;
13661366
zend_array *symbol_table;
13671367

1368-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|lz/", &var_array, &extract_type, &prefix) == FAILURE) {
1368+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/|iz/", &var_array, &extract_type, &prefix) == FAILURE) {
13691369
return;
13701370
}
13711371

@@ -2953,9 +2953,9 @@ PHP_FUNCTION(array_unique)
29532953
};
29542954
struct bucketindex *arTmp, *cmpdata, *lastkept;
29552955
unsigned int i;
2956-
long sort_type = PHP_SORT_STRING;
2956+
php_int_t sort_type = PHP_SORT_STRING;
29572957

2958-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) {
2958+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) {
29592959
return;
29602960
}
29612961

@@ -3061,7 +3061,7 @@ static int zval_user_compare(zval *a, zval *b TSRMLS_DC) /* {{{ */
30613061
BG(user_compare_fci).no_separation = 0;
30623062

30633063
if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
3064-
long ret = zval_get_int(&retval);
3064+
php_int_t ret = zval_get_int(&retval);
30653065
zval_ptr_dtor(&retval);
30663066
return ret < 0 ? -1 : ret > 0 ? 1 : 0;;
30673067
} else {
@@ -4324,13 +4324,13 @@ PHP_FUNCTION(array_filter)
43244324
zval args[2];
43254325
zval retval;
43264326
zend_bool have_callback = 0;
4327-
long use_type = 0;
4327+
php_int_t use_type = 0;
43284328
zend_string *string_key;
43294329
zend_fcall_info fci = empty_fcall_info;
43304330
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
43314331
php_uint_t num_key;
43324332

4333-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|fl", &array, &fci, &fci_cache, &use_type) == FAILURE) {
4333+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|fi", &array, &fci, &fci_cache, &use_type) == FAILURE) {
43344334
return;
43354335
}
43364336

ext/standard/math.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1422,16 +1422,16 @@ PHP_FUNCTION(fmod)
14221422
Returns the integer division of the numerator by the divisor */
14231423
PHP_FUNCTION(intdiv)
14241424
{
1425-
long numerator, divisor;
1425+
php_int_t numerator, divisor;
14261426

1427-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &numerator, &divisor) == FAILURE) {
1427+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ii", &numerator, &divisor) == FAILURE) {
14281428
return;
14291429
}
14301430

14311431
if (divisor == 0) {
14321432
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Division by zero");
14331433
RETURN_BOOL(0);
1434-
} else if (divisor == -1 && numerator == LONG_MIN) {
1434+
} else if (divisor == -1 && numerator == PHP_INT_MIN) {
14351435
/* Prevent overflow error/crash
14361436
We don't return a float here as that violates function contract */
14371437
RETURN_INT(0);

ext/standard/md5.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,19 @@ PHPAPI void make_digest_ex(char *md5str, const unsigned char *digest, int len) /
4646
Calculate the md5 hash of a string */
4747
PHP_NAMED_FUNCTION(php_if_md5)
4848
{
49-
char *arg;
50-
int arg_len;
49+
zend_string *arg;
5150
zend_bool raw_output = 0;
5251
char md5str[33];
5352
PHP_MD5_CTX context;
5453
unsigned char digest[16];
5554

56-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &arg, &arg_len, &raw_output) == FAILURE) {
55+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|b", &arg, &raw_output) == FAILURE) {
5756
return;
5857
}
5958

6059
md5str[0] = '\0';
6160
PHP_MD5Init(&context);
62-
PHP_MD5Update(&context, arg, arg_len);
61+
PHP_MD5Update(&context, arg->val, arg->len);
6362
PHP_MD5Final(digest, &context);
6463
if (raw_output) {
6564
RETURN_STRINGL(digest, 16);
@@ -82,7 +81,7 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
8281
unsigned char buf[1024];
8382
unsigned char digest[16];
8483
PHP_MD5_CTX context;
85-
int n;
84+
php_size_t n;
8685
php_stream *stream;
8786

8887
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) {

ext/standard/metaphone.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@
2525
#include "php.h"
2626
#include "php_metaphone.h"
2727

28-
static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional);
28+
static int metaphone(unsigned char *word, php_size_t word_len, php_int_t max_phonemes, zend_string **phoned_word, int traditional);
2929

3030
/* {{{ proto string metaphone(string text[, int phones])
3131
Break english phrases down into their phonemes */
3232
PHP_FUNCTION(metaphone)
3333
{
34-
char *str;
34+
zend_string *str;
3535
zend_string *result = NULL;
36-
int str_len;
37-
long phones = 0;
36+
php_int_t phones = 0;
3837

39-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &str_len,
40-
&phones) == FAILURE) {
38+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|i", &str, &phones) == FAILURE) {
4139
return;
4240
}
4341

44-
if (metaphone((unsigned char *)str, str_len, phones, &result, 1) == 0) {
42+
if (metaphone((unsigned char *)str->val, str->len, phones, &result, 1) == 0) {
4543
RETVAL_STR(result);
4644
} else {
4745
if (result) {
@@ -167,11 +165,11 @@ static char Lookahead(char *word, int how_far)
167165

168166
/* {{{ metaphone
169167
*/
170-
static int metaphone(unsigned char *word, int word_len, long max_phonemes, zend_string **phoned_word, int traditional)
168+
static int metaphone(unsigned char *word, php_size_t word_len, php_int_t max_phonemes, zend_string **phoned_word, int traditional)
171169
{
172170
int w_idx = 0; /* point in the phonization we're at. */
173171
int p_idx = 0; /* end of the phoned phrase */
174-
int max_buffer_len = 0; /* maximum length of the destination buffer */
172+
php_size_t max_buffer_len = 0; /* maximum length of the destination buffer */
175173

176174
/*-- Parameter checks --*/
177175
/* Negative phoneme length is meaningless */

ext/standard/microtime.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ PHP_FUNCTION(gettimeofday)
111111
PHP_FUNCTION(getrusage)
112112
{
113113
struct rusage usg;
114-
long pwho = 0;
114+
php_int_t pwho = 0;
115115
int who = RUSAGE_SELF;
116116

117-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &pwho) == FAILURE) {
117+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &pwho) == FAILURE) {
118118
return;
119119
}
120120

ext/standard/pageinfo.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ PHPAPI void php_statpage(TSRMLS_D)
7979

8080
/* {{{ php_getuid
8181
*/
82-
long php_getuid(TSRMLS_D)
82+
php_int_t php_getuid(TSRMLS_D)
8383
{
8484
php_statpage(TSRMLS_C);
8585
return (BG(page_uid));
8686
}
8787
/* }}} */
8888

89-
long php_getgid(TSRMLS_D)
89+
php_int_t php_getgid(TSRMLS_D)
9090
{
9191
php_statpage(TSRMLS_C);
9292
return (BG(page_gid));
@@ -96,7 +96,7 @@ long php_getgid(TSRMLS_D)
9696
Get PHP script owner's UID */
9797
PHP_FUNCTION(getmyuid)
9898
{
99-
long uid;
99+
php_int_t uid;
100100

101101
if (zend_parse_parameters_none() == FAILURE) {
102102
return;
@@ -115,7 +115,7 @@ PHP_FUNCTION(getmyuid)
115115
Get PHP script owner's GID */
116116
PHP_FUNCTION(getmygid)
117117
{
118-
long gid;
118+
php_int_t gid;
119119

120120
if (zend_parse_parameters_none() == FAILURE) {
121121
return;
@@ -134,7 +134,7 @@ PHP_FUNCTION(getmygid)
134134
Get current process ID */
135135
PHP_FUNCTION(getmypid)
136136
{
137-
int pid;
137+
php_int_t pid;
138138

139139
if (zend_parse_parameters_none() == FAILURE) {
140140
return;
@@ -144,7 +144,7 @@ PHP_FUNCTION(getmypid)
144144
if (pid < 0) {
145145
RETURN_FALSE;
146146
} else {
147-
RETURN_INT((long) pid);
147+
RETURN_INT(pid);
148148
}
149149
}
150150
/* }}} */
@@ -166,7 +166,7 @@ PHP_FUNCTION(getmyinode)
166166
}
167167
/* }}} */
168168

169-
PHPAPI long php_getlastmod(TSRMLS_D)
169+
PHPAPI time_t php_getlastmod(TSRMLS_D)
170170
{
171171
php_statpage(TSRMLS_C);
172172
return BG(page_mtime);
@@ -176,7 +176,7 @@ PHPAPI long php_getlastmod(TSRMLS_D)
176176
Get time of last page modification */
177177
PHP_FUNCTION(getlastmod)
178178
{
179-
long lm;
179+
php_int_t lm;
180180

181181
if (zend_parse_parameters_none() == FAILURE) {
182182
return;

ext/standard/pageinfo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ PHP_FUNCTION(getmyinode);
2828
PHP_FUNCTION(getlastmod);
2929

3030
PHPAPI void php_statpage(TSRMLS_D);
31-
PHPAPI long php_getlastmod(TSRMLS_D);
32-
extern long php_getuid(TSRMLS_D);
33-
extern long php_getgid(TSRMLS_D);
31+
PHPAPI time_t php_getlastmod(TSRMLS_D);
32+
extern php_int_t php_getuid(TSRMLS_D);
33+
extern php_int_t php_getgid(TSRMLS_D);
3434

3535
#endif

ext/standard/php_array.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ PHPAPI HashTable* php_splice(HashTable *, int, int, zval *, int, HashTable *);
107107
PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC);
108108
PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC);
109109
PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);
110-
PHPAPI int php_count_recursive(zval *array, long mode TSRMLS_DC);
110+
PHPAPI php_int_t php_count_recursive(zval *array, php_int_t mode TSRMLS_DC);
111111

112112
#define PHP_SORT_REGULAR 0
113113
#define PHP_SORT_NUMERIC 1

0 commit comments

Comments
 (0)