further fixes to ext/standard and zend

This commit is contained in:
Anatol Belski 2014-08-16 17:31:40 +02:00
parent 54906c760f
commit 864172d9a4
12 changed files with 71 additions and 107 deletions

View File

@ -46,7 +46,7 @@
/* true multithread-shared globals */
ZEND_API zend_class_entry *zend_standard_class_def = NULL;
ZEND_API int (*zend_printf)(const char *format, ...);
ZEND_API zend_size_t (*zend_printf)(const char *format, ...);
ZEND_API zend_write_func_t zend_write;
ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
@ -54,7 +54,7 @@ ZEND_API void (*zend_block_interruptions)(void);
ZEND_API void (*zend_unblock_interruptions)(void);
ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
int (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap);
zend_size_t (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap);
zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
@ -204,7 +204,7 @@ static void print_flat_hash(HashTable *ht TSRMLS_DC) /* {{{ */
if (string_key) {
ZEND_WRITE(string_key->val, string_key->len);
} else {
zend_printf("%ld", num_key);
zend_printf(ZEND_UINT_FMT, num_key);
}
ZEND_PUTS("] => ");
zend_print_flat_zval_r(tmp TSRMLS_CC);

View File

@ -646,7 +646,7 @@ END_EXTERN_C()
#define ZEND_PUTC(c) zend_write(&(c), 1)
BEGIN_EXTERN_C()
extern ZEND_API int (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_size_t (*zend_printf)(const char *format, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2);
extern ZEND_API zend_write_func_t zend_write;
extern ZEND_API FILE *(*zend_fopen)(const char *filename, char **opened_path TSRMLS_DC);
extern ZEND_API void (*zend_block_interruptions)(void);
@ -655,7 +655,7 @@ extern ZEND_API void (*zend_ticks_function)(int ticks TSRMLS_DC);
extern ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 4, 0);
extern ZEND_API void (*zend_on_timeout)(int seconds TSRMLS_DC);
extern ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle TSRMLS_DC);
extern int (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap);
extern zend_int_t (*zend_vspprintf)(char **pbuf, zend_size_t max_len, const char *format, va_list ap);
extern zend_string *(*zend_vstrpprintf)(zend_size_t max_len, const char *format, va_list ap);
extern ZEND_API char *(*zend_getenv)(char *name, size_t name_len TSRMLS_DC);
extern ZEND_API char *(*zend_resolve_path)(const char *filename, int filename_len TSRMLS_DC);

View File

@ -2906,7 +2906,7 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
int name_len = name->len;
zend_string *lcname;
ALLOCA_FLAG(use_heap);
__debugbreak();
STR_ALLOCA_ALLOC(lcname, name_len, use_heap);
zend_str_tolower_copy(lcname->val, name->val, name_len + 1);

View File

@ -491,7 +491,7 @@ convert_to_hash:
ZVAL_COPY_VALUE(&p->val, pData);
HANDLE_UNBLOCK_INTERRUPTIONS();
if ((zend_int_t)h >= (zend_int_t)ht->nNextFreeElement) {
ht->nNextFreeElement = h < LONG_MAX ? h + 1 : LONG_MAX;
ht->nNextFreeElement = h < ZEND_INT_MAX ? h + 1 : ZEND_INT_MAX;
}
return &p->val;
}

View File

@ -2319,16 +2319,10 @@ ZEND_API int zend_binary_strcmp(const char *s1, zend_size_t len1, const char *s2
}
retval = memcmp(s1, s2, MIN(len1, len2));
if (!retval) {
if (len1 > len2) {
retval = 1;
} else if (len1 < len2) {
retval = -1;
} else {
retval = 0;
}
return (int)(len1 - len2);
} else {
return retval;
}
return retval;
}
/* }}} */
@ -2341,16 +2335,10 @@ ZEND_API int zend_binary_strncmp(const char *s1, zend_size_t len1, const char *s
}
retval = memcmp(s1, s2, MIN(length, MIN(len1, len2)));
if (!retval) {
if (MIN(length, len1) > MIN(length, len2)) {
retval = 1;
} else if (MIN(length, len1) < MIN(length, len2)) {
retval = -1;
} else {
retval = 0;
}
return (int)(MIN(length, len1) - MIN(length, len2));
} else {
return retval;
}
return retval;
}
/* }}} */
@ -2372,13 +2360,7 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, zend_size_t len1, const char
}
}
if (len1 > len2) {
return 1;
} else if (len1 < len2) {
return -1;
} else {
return 0;
}
return (int)(len1 - len2);
}
/* }}} */
@ -2399,13 +2381,7 @@ ZEND_API int zend_binary_strncasecmp(const char *s1, zend_size_t len1, const cha
}
}
if (MIN(length, len1) > MIN(length, len2)) {
return 1;
} else if (MIN(length, len1) < MIN(length, len2)) {
return -1;
} else {
return 0;
}
return (int)(MIN(length, len1) - MIN(length, len2));
}
/* }}} */
@ -2427,13 +2403,7 @@ ZEND_API int zend_binary_strcasecmp_l(const char *s1, zend_size_t len1, const ch
}
}
if (len1 > len2) {
return 1;
} else if (len1 < len2) {
return -1;
} else {
return 0;
}
return (int)(len1 - len2);
}
/* }}} */
@ -2454,13 +2424,7 @@ ZEND_API int zend_binary_strncasecmp_l(const char *s1, zend_size_t len1, const c
}
}
if (MIN(length, len1) > MIN(length, len2)) {
return 1;
} else if (MIN(length, len1) < MIN(length, len2)) {
return -1;
} else {
return 0;
}
return (int)(MIN(length, len1) - MIN(length, len2));
}
/* }}} */

View File

@ -174,7 +174,7 @@ typedef unsigned long int uint32_t;
#endif
#define Long int32_t
#define zend_uint_t uint32_t
#define ULong uint32_t
#ifdef __cplusplus
#include "malloc.h"
@ -272,7 +272,7 @@ BEGIN_EXTERN_C()
typedef union {
double d;
zend_uint_t ul[2];
ULong ul[2];
} _double;
#define value(x) ((x).d)
#ifdef IEEE_LITTLE_ENDIAN
@ -418,7 +418,7 @@ extern double rnd_prod(double, double), rnd_quot(double, double);
struct Bigint {
struct Bigint *next;
int k, maxwds, sign, wds;
zend_uint_t x[1];
ULong x[1];
};
typedef struct Bigint Bigint;
@ -519,9 +519,9 @@ static void Bfree(Bigint *v)
static char * rv_alloc(int i) {
int j, k, *r;
j = sizeof(zend_uint_t);
j = sizeof(ULong);
for(k = 0;
sizeof(Bigint) - sizeof(zend_uint_t) - sizeof(int) + j <= i;
sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
j <<= 1) {
k++;
}
@ -548,9 +548,9 @@ static char * nrv_alloc(char *s, char **rve, int n)
static Bigint * multadd(Bigint *b, int m, int a) /* multiply by m and add a */
{
int i, wds;
zend_uint_t *x, y;
ULong *x, y;
#ifdef Pack_32
zend_uint_t xi, z;
ULong xi, z;
#endif
Bigint *b1;
@ -584,7 +584,7 @@ static Bigint * multadd(Bigint *b, int m, int a) /* multiply by m and add a */
return b;
}
static int hi0bits(zend_uint_t x)
static int hi0bits(ULong x)
{
int k = 0;
@ -613,10 +613,10 @@ static int hi0bits(zend_uint_t x)
return k;
}
static int lo0bits(zend_uint_t *y)
static int lo0bits(ULong *y)
{
int k;
zend_uint_t x = *y;
ULong x = *y;
if (x & 7) {
if (x & 1) {
@ -671,10 +671,10 @@ static Bigint * mult(Bigint *a, Bigint *b)
{
Bigint *c;
int k, wa, wb, wc;
zend_uint_t carry, y, z;
zend_uint_t *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
ULong carry, y, z;
ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
#ifdef Pack_32
zend_uint_t z2;
ULong z2;
#endif
if (a->wds < b->wds) {
@ -751,7 +751,7 @@ static Bigint * mult(Bigint *a, Bigint *b)
return c;
}
static Bigint * s2b (CONST char *s, int nd0, int nd, zend_uint_t y9)
static Bigint * s2b (CONST char *s, int nd0, int nd, ULong y9)
{
Bigint *b;
int i, k;
@ -830,7 +830,7 @@ static Bigint *lshift(Bigint *b, int k)
{
int i, k1, n, n1;
Bigint *b1;
zend_uint_t *x, *x1, *xe, z;
ULong *x, *x1, *xe, z;
#ifdef Pack_32
n = k >> 5;
@ -886,7 +886,7 @@ static Bigint *lshift(Bigint *b, int k)
static int cmp(Bigint *a, Bigint *b)
{
zend_uint_t *xa, *xa0, *xb, *xb0;
ULong *xa, *xa0, *xb, *xb0;
int i, j;
i = a->wds;
@ -918,7 +918,7 @@ static Bigint * diff(Bigint *a, Bigint *b)
Bigint *c;
int i, wa, wb;
Long borrow, y; /* We need signed shifts here. */
zend_uint_t *xa, *xae, *xb, *xbe, *xc;
ULong *xa, *xae, *xb, *xbe, *xc;
#ifdef Pack_32
Long z;
#endif
@ -1030,11 +1030,11 @@ b2d
(Bigint *a, int *e)
#endif
{
zend_uint_t *xa, *xa0, w, y, z;
ULong *xa, *xa0, w, y, z;
int k;
volatile _double d;
#ifdef VAX
zend_uint_t d0, d1;
ULong d0, d1;
#else
#define d0 word0(d)
#define d1 word1(d)
@ -1097,10 +1097,10 @@ static Bigint * d2b(double _d, int *e, int *bits)
{
Bigint *b;
int de, i, k;
zend_uint_t *x, y, z;
ULong *x, y, z;
volatile _double d;
#ifdef VAX
zend_uint_t d0, d1;
ULong d0, d1;
#endif
value(d) = _d;
@ -1283,11 +1283,11 @@ static int quorem(Bigint *b, Bigint *S)
{
int n;
Long borrow, y;
zend_uint_t carry, q, ys;
zend_uint_t *bx, *bxe, *sx, *sxe;
ULong carry, q, ys;
ULong *bx, *bxe, *sx, *sxe;
#ifdef Pack_32
Long z;
zend_uint_t si, zs;
ULong si, zs;
#endif
n = S->wds;
@ -1481,7 +1481,7 @@ ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sig
Long L;
#ifndef Sudden_Underflow
int denorm;
zend_uint_t x;
ULong x;
#endif
Bigint *b, *b1, *delta, *mlo, *mhi, *S, *tmp;
double ds;
@ -2044,7 +2044,7 @@ ZEND_API double zend_strtod (CONST char *s00, CONST char **se)
volatile double aadj, aadj1, adj;
volatile _double rv, rv0;
Long L;
zend_uint_t y, z;
ULong y, z;
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta, *tmp;
double result;

View File

@ -5091,7 +5091,7 @@ ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY)
SAVE_OPLINE();
if (!EG(error_reporting) && Z_IVAL_P(EX_VAR(opline->op1.var)) != 0) {
EG(error_reporting) = Z_IVAL_P(EX_VAR(opline->op1.var));
_zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res);
_zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), zend_uint_t, res);
if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) {
if (EXPECTED(EG(error_reporting_ini_entry)->modified &&
EG(error_reporting_ini_entry)->value != EG(error_reporting_ini_entry)->orig_value)) {

View File

@ -8797,7 +8797,7 @@ static int ZEND_FASTCALL ZEND_END_SILENCE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_
SAVE_OPLINE();
if (!EG(error_reporting) && Z_IVAL_P(EX_VAR(opline->op1.var)) != 0) {
EG(error_reporting) = Z_IVAL_P(EX_VAR(opline->op1.var));
_zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), unsigned long, res);
_zend_print_signed_to_buf(buf + sizeof(buf) - 1, EG(error_reporting), zend_uint_t, res);
if (EXPECTED(EG(error_reporting_ini_entry) != NULL)) {
if (EXPECTED(EG(error_reporting_ini_entry)->modified &&
EG(error_reporting_ini_entry)->value != EG(error_reporting_ini_entry)->orig_value)) {

View File

@ -395,7 +395,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_merge_recursive, 0, 0, 2)
ZEND_ARG_INFO(0, arr1) /* ARRAY_INFO(0, arg, 0) */
ZEND_ARG_VARIADIC_INFO(0, arrays)
@ -4428,7 +4428,7 @@ PHP_FUNCTION(usleep)
Delay for a number of seconds and nano seconds */
PHP_FUNCTION(time_nanosleep)
{
php_int_t tv_sec, tv_nsec;
long tv_sec, tv_nsec;
struct timespec php_req, php_rem;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &tv_sec, &tv_nsec) == FAILURE) {

View File

@ -42,19 +42,19 @@
#endif
#define RAND_RANGE(__n, __min, __max, __tmax) \
(__n) = (__min) + (long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
(__n) = (__min) + (php_int_t) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0)))
/* MT Rand */
#define PHP_MT_RAND_MAX ((long) (0x7FFFFFFF)) /* (1<<31) - 1 */
#define PHP_MT_RAND_MAX ((php_int_t) (0x7FFFFFFF)) /* (1<<31) - 1 */
#ifdef PHP_WIN32
#define GENERATE_SEED() (((long) (time(0) * GetCurrentProcessId())) ^ ((long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#define GENERATE_SEED() (((php_int_t) (time(0) * GetCurrentProcessId())) ^ ((php_int_t) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#else
#define GENERATE_SEED() (((long) (time(0) * getpid())) ^ ((long) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#define GENERATE_SEED() (((php_int_t) (time(0) * getpid())) ^ ((php_int_t) (1000000.0 * php_combined_lcg(TSRMLS_C))))
#endif
PHPAPI void php_srand(long seed TSRMLS_DC);
PHPAPI long php_rand(TSRMLS_D);
PHPAPI void php_srand(php_int_t seed TSRMLS_DC);
PHPAPI php_int_t php_rand(TSRMLS_D);
PHPAPI void php_mt_srand(php_uint32 seed TSRMLS_DC);
PHPAPI php_uint32 php_mt_rand(TSRMLS_D);

View File

@ -38,7 +38,7 @@
/* {{{ php_srand
*/
PHPAPI void php_srand(long seed TSRMLS_DC)
PHPAPI void php_srand(php_int_t seed TSRMLS_DC)
{
#ifdef ZTS
BG(rand_seed) = (unsigned int) seed;
@ -59,9 +59,9 @@ PHPAPI void php_srand(long seed TSRMLS_DC)
/* {{{ php_rand
*/
PHPAPI long php_rand(TSRMLS_D)
PHPAPI php_int_t php_rand(TSRMLS_D)
{
long ret;
php_int_t ret;
if (!BG(rand_is_seeded)) {
php_srand(GENERATE_SEED() TSRMLS_CC);
@ -229,9 +229,9 @@ PHPAPI php_uint32 php_mt_rand(TSRMLS_D)
Seeds random number generator */
PHP_FUNCTION(srand)
{
long seed = 0;
php_int_t seed = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &seed) == FAILURE)
return;
if (ZEND_NUM_ARGS() == 0)
@ -245,9 +245,9 @@ PHP_FUNCTION(srand)
Seeds Mersenne Twister random number generator */
PHP_FUNCTION(mt_srand)
{
long seed = 0;
php_int_t seed = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &seed) == FAILURE)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &seed) == FAILURE)
return;
if (ZEND_NUM_ARGS() == 0)
@ -288,12 +288,12 @@ PHP_FUNCTION(mt_srand)
Returns a random number */
PHP_FUNCTION(rand)
{
long min;
long max;
long number;
php_int_t min;
php_int_t max;
php_int_t number;
int argc = ZEND_NUM_ARGS();
if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE)
if (argc != 0 && zend_parse_parameters(argc TSRMLS_CC, "ii", &min, &max) == FAILURE)
return;
number = php_rand(TSRMLS_C);
@ -309,16 +309,16 @@ PHP_FUNCTION(rand)
Returns a random number from Mersenne Twister */
PHP_FUNCTION(mt_rand)
{
long min;
long max;
long number;
php_int_t min;
php_int_t max;
php_int_t number;
int argc = ZEND_NUM_ARGS();
if (argc != 0) {
if (zend_parse_parameters(argc TSRMLS_CC, "ll", &min, &max) == FAILURE) {
if (zend_parse_parameters(argc TSRMLS_CC, "ii", &min, &max) == FAILURE) {
return;
} else if (max < min) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(%ld) is smaller than min(%ld)", max, min);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "max(" ZEND_INT_FMT ") is smaller than min(" ZEND_INT_FMT ")", max, min);
RETURN_FALSE;
}
}
@ -335,7 +335,7 @@ PHP_FUNCTION(mt_rand)
* Update:
* I talked with Cokus via email and it won't ruin the algorithm
*/
number = (long) (php_mt_rand(TSRMLS_C) >> 1);
number = (php_int_t) (php_mt_rand(TSRMLS_C) >> 1);
if (argc == 2) {
RAND_RANGE(number, min, max, PHP_MT_RAND_MAX);
}

View File

@ -4730,7 +4730,7 @@ PHP_FUNCTION(str_repeat)
zend_string *result; /* Resulting string */
size_t result_len; /* Length of the resulting string */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl", &input_str, &mult) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si", &input_str, &mult) == FAILURE) {
return;
}