MFH: sync

This commit is contained in:
Jani Taskinen 2009-05-10 23:08:52 +00:00
parent 1338aa26be
commit f3bd837434

View file

@ -36,7 +36,7 @@
#if ZEND_USE_TOLOWER_L
#include <locale.h>
static _locale_t current_locale = NULL;
/* this is true global! may lead to strange effects on ZTS, but so is setlocale() */
/* this is true global! may lead to strange effects on ZTS, but so may setlocale() */
#define zend_tolower(c) _tolower_l(c, current_locale)
#else
#define zend_tolower(c) tolower(c)
@ -44,7 +44,7 @@ static _locale_t current_locale = NULL;
#define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2))
ZEND_API int zend_atoi(const char *str, int str_len)
ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */
{
int retval;
@ -70,8 +70,9 @@ ZEND_API int zend_atoi(const char *str, int str_len)
}
return retval;
}
/* }}} */
ZEND_API long zend_atol(const char *str, int str_len)
ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */
{
long retval;
@ -97,9 +98,9 @@ ZEND_API long zend_atol(const char *str, int str_len)
}
return retval;
}
/* }}} */
ZEND_API double zend_string_to_double(const char *number, zend_uint length)
ZEND_API double zend_string_to_double(const char *number, zend_uint length) /* {{{ */
{
double divisor = 10.0;
double result = 0.0;
@ -143,9 +144,9 @@ ZEND_API double zend_string_to_double(const char *number, zend_uint length)
}
return result;
}
/* }}} */
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
{
switch (Z_TYPE_P(op)) {
case IS_STRING:
@ -174,7 +175,9 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
break;
}
}
/* }}} */
/* {{{ zendi_convert_scalar_to_number */
#define zendi_convert_scalar_to_number(op, holder, result) \
if (op==result) { \
if (Z_TYPE_P(op) != IS_LONG) { \
@ -210,7 +213,9 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
} \
}
/* }}} */
/* {{{ zendi_convert_to_long */
#define zendi_convert_to_long(op, holder, result) \
if (op == result) { \
convert_to_long(op); \
@ -246,7 +251,9 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
(op) = &(holder); \
}
/* }}} */
/* {{{ zendi_convert_to_boolean */
#define zendi_convert_to_boolean(op, holder, result) \
if (op==result) { \
convert_to_boolean(op); \
@ -286,7 +293,9 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
(op) = &(holder); \
}
/* }}} */
/* {{{ convert_object_to_type */
#define convert_object_to_type(op, ctype, conv_func) \
if (Z_OBJ_HT_P(op)->cast_object) { \
zval dst; \
@ -312,14 +321,17 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
} \
}
ZEND_API void convert_to_long(zval *op)
/* }}} */
ZEND_API void convert_to_long(zval *op) /* {{{ */
{
if (Z_TYPE_P(op) != IS_LONG) {
convert_to_long_base(op, 10);
}
}
/* }}} */
ZEND_API void convert_to_long_base(zval *op, int base)
ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */
{
char *strval;
long tmp;
@ -375,9 +387,9 @@ ZEND_API void convert_to_long_base(zval *op, int base)
Z_TYPE_P(op) = IS_LONG;
}
/* }}} */
ZEND_API void convert_to_double(zval *op)
ZEND_API void convert_to_double(zval *op) /* {{{ */
{
char *strval;
double tmp;
@ -433,9 +445,9 @@ ZEND_API void convert_to_double(zval *op)
}
Z_TYPE_P(op) = IS_DOUBLE;
}
/* }}} */
ZEND_API void convert_to_null(zval *op)
ZEND_API void convert_to_null(zval *op) /* {{{ */
{
if (Z_TYPE_P(op) == IS_OBJECT) {
if (Z_OBJ_HT_P(op)->cast_object) {
@ -456,9 +468,9 @@ ZEND_API void convert_to_null(zval *op)
zval_dtor(op);
Z_TYPE_P(op) = IS_NULL;
}
/* }}} */
ZEND_API void convert_to_boolean(zval *op)
ZEND_API void convert_to_boolean(zval *op) /* {{{ */
{
char *strval;
int tmp;
@ -519,8 +531,9 @@ ZEND_API void convert_to_boolean(zval *op)
}
Z_TYPE_P(op) = IS_BOOL;
}
/* }}} */
ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC)
ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */
{
long lval;
double dval;
@ -589,9 +602,9 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC)
}
Z_TYPE_P(op) = IS_STRING;
}
/* }}} */
static void convert_scalar_to_array(zval *op, int type)
static void convert_scalar_to_array(zval *op, int type) /* {{{ */
{
zval *entry;
@ -617,9 +630,9 @@ static void convert_scalar_to_array(zval *op, int type)
break;
}
}
/* }}} */
ZEND_API void convert_to_array(zval *op)
ZEND_API void convert_to_array(zval *op) /* {{{ */
{
TSRMLS_FETCH();
@ -664,9 +677,9 @@ ZEND_API void convert_to_array(zval *op)
break;
}
}
/* }}} */
ZEND_API void convert_to_object(zval *op)
ZEND_API void convert_to_object(zval *op) /* {{{ */
{
switch (Z_TYPE_P(op)) {
case IS_ARRAY:
@ -693,8 +706,9 @@ ZEND_API void convert_to_object(zval *op)
break;
}
}
/* }}} */
ZEND_API void multi_convert_to_long_ex(int argc, ...)
ZEND_API void multi_convert_to_long_ex(int argc, ...) /* {{{ */
{
zval **arg;
va_list ap;
@ -708,8 +722,9 @@ ZEND_API void multi_convert_to_long_ex(int argc, ...)
va_end(ap);
}
/* }}} */
ZEND_API void multi_convert_to_double_ex(int argc, ...)
ZEND_API void multi_convert_to_double_ex(int argc, ...) /* {{{ */
{
zval **arg;
va_list ap;
@ -723,8 +738,9 @@ ZEND_API void multi_convert_to_double_ex(int argc, ...)
va_end(ap);
}
/* }}} */
ZEND_API void multi_convert_to_string_ex(int argc, ...)
ZEND_API void multi_convert_to_string_ex(int argc, ...) /* {{{ */
{
zval **arg;
va_list ap;
@ -738,8 +754,9 @@ ZEND_API void multi_convert_to_string_ex(int argc, ...)
va_end(ap);
}
/* }}} */
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int converted = 0;
@ -799,9 +816,9 @@ ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
}
}
/* }}} */
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int converted = 0;
@ -846,9 +863,9 @@ ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
}
}
/* }}} */
ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int converted = 0;
@ -887,8 +904,9 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
}
}
/* }}} */
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int converted = 0;
@ -951,9 +969,9 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
}
}
/* }}} */
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -975,10 +993,9 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) % Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -987,9 +1004,9 @@ ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_BOOL(result, Z_LVAL_P(op1) ^ Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC)
ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
{
zval op1_copy;
@ -998,9 +1015,9 @@ ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC)
ZVAL_BOOL(result, !Z_LVAL_P(op1));
return SUCCESS;
}
/* }}} */
ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC)
ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */
{
zval op1_copy = *op1;
@ -1026,9 +1043,9 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC)
zend_error(E_ERROR, "Unsupported operand types");
return FAILURE; /* unknown datatype */
}
/* }}} */
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1064,9 +1081,9 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) | Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1104,9 +1121,9 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) & Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1143,9 +1160,9 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) ^ Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1154,9 +1171,9 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) << Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1165,11 +1182,10 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_LONG(result, Z_LVAL_P(op1) >> Z_LVAL_P(op2));
return SUCCESS;
}
/* }}} */
/* must support result==op1 */
ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2)
ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */
{
Z_STRLEN_P(result) = Z_STRLEN_P(op1) + 1;
Z_STRVAL_P(result) = (char *) erealloc(Z_STRVAL_P(op1), Z_STRLEN_P(result)+1);
@ -1178,10 +1194,10 @@ ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2)
Z_TYPE_P(result) = IS_STRING;
return SUCCESS;
}
/* }}} */
/* must support result==op1 */
ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2)
ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2) /* {{{ */
{
int length = Z_STRLEN_P(op1) + Z_STRLEN_P(op2);
@ -1192,9 +1208,9 @@ ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2
Z_TYPE_P(result) = IS_STRING;
return SUCCESS;
}
/* }}} */
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0;
@ -1242,9 +1258,9 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
return SUCCESS;
}
/* }}} */
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0;
@ -1275,7 +1291,7 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
}
#if HAVE_STRCOLL
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
int use_copy1 = 0, use_copy2 = 0;
@ -1306,7 +1322,7 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T
}
#endif
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
zval op1_copy, op2_copy;
@ -1323,9 +1339,9 @@ ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_
return SUCCESS;
}
/* }}} */
static inline void zend_free_obj_get_result(zval *op TSRMLS_DC)
static inline void zend_free_obj_get_result(zval *op TSRMLS_DC) /* {{{ */
{
if (Z_REFCOUNT_P(op) == 0) {
GC_REMOVE_ZVAL_FROM_BUFFER(op);
@ -1335,8 +1351,9 @@ static inline void zend_free_obj_get_result(zval *op TSRMLS_DC)
zval_ptr_dtor(&op);
}
}
/* }}} */
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
int ret;
int converted = 0;
@ -1497,9 +1514,9 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
}
}
/* }}} */
static int hash_zval_identical_function(const zval **z1, const zval **z2)
static int hash_zval_identical_function(const zval **z1, const zval **z2) /* {{{ */
{
zval result;
TSRMLS_FETCH();
@ -1512,11 +1529,11 @@ static int hash_zval_identical_function(const zval **z1, const zval **z2)
if (is_identical_function(&result, (zval *) *z1, (zval *) *z2 TSRMLS_CC)==FAILURE) {
return 1;
}
return !result.value.lval;
return !Z_LVAL(result);
}
/* }}} */
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
Z_TYPE_P(result) = IS_BOOL;
if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
@ -1555,9 +1572,9 @@ ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
}
return SUCCESS;
}
/* }}} */
ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
if (is_identical_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
return FAILURE;
@ -1565,9 +1582,9 @@ ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS
Z_LVAL_P(result) = !Z_LVAL_P(result);
return SUCCESS;
}
/* }}} */
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
return FAILURE;
@ -1575,9 +1592,9 @@ ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_BOOL(result, (Z_LVAL_P(result) == 0));
return SUCCESS;
}
/* }}} */
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
return FAILURE;
@ -1585,9 +1602,9 @@ ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_BOOL(result, (Z_LVAL_P(result) != 0));
return SUCCESS;
}
/* }}} */
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
return FAILURE;
@ -1595,9 +1612,9 @@ ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZVAL_BOOL(result, (Z_LVAL_P(result) < 0));
return SUCCESS;
}
/* }}} */
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
{
if (compare_function(result, op1, op2 TSRMLS_CC) == FAILURE) {
return FAILURE;
@ -1605,9 +1622,9 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR
ZVAL_BOOL(result, (Z_LVAL_P(result) <= 0));
return SUCCESS;
}
/* }}} */
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC)
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC) /* {{{ */
{
zend_uint i;
@ -1627,18 +1644,19 @@ ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, c
return 0;
}
/* }}} */
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC)
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC) /* {{{ */
{
return instanceof_function_ex(instance_ce, ce, 0 TSRMLS_CC);
}
/* }}} */
#define LOWER_CASE 1
#define UPPER_CASE 2
#define NUMERIC 3
static void increment_string(zval *str)
static void increment_string(zval *str) /* {{{ */
{
int carry=0;
int pos=Z_STRLEN_P(str)-1;
@ -1713,9 +1731,9 @@ static void increment_string(zval *str)
Z_STRVAL_P(str) = t;
}
}
/* }}} */
ZEND_API int increment_function(zval *op1)
ZEND_API int increment_function(zval *op1) /* {{{ */
{
switch (Z_TYPE_P(op1)) {
case IS_LONG:
@ -1764,9 +1782,9 @@ ZEND_API int increment_function(zval *op1)
}
return SUCCESS;
}
/* }}} */
ZEND_API int decrement_function(zval *op1)
ZEND_API int decrement_function(zval *op1) /* {{{ */
{
long lval;
double dval;
@ -1811,22 +1829,22 @@ ZEND_API int decrement_function(zval *op1)
return SUCCESS;
}
/* }}} */
ZEND_API int zval_is_true(zval *op)
ZEND_API int zval_is_true(zval *op) /* {{{ */
{
convert_to_boolean(op);
return (Z_LVAL_P(op) ? 1 : 0);
}
/* }}} */
#ifdef ZEND_USE_TOLOWER_L
ZEND_API void zend_update_current_locale(void)
ZEND_API void zend_update_current_locale(void) /* {{{ */
{
current_locale = _get_current_locale();
}
#endif
ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length)
ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length) /* {{{ */
{
register unsigned char *str = (unsigned char*)source;
register unsigned char *result = (unsigned char*)dest;
@ -1839,13 +1857,15 @@ ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned in
return dest;
}
/* }}} */
ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length)
ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length) /* {{{ */
{
return zend_str_tolower_copy((char *)emalloc(length+1), source, length);
}
/* }}} */
ZEND_API void zend_str_tolower(char *str, unsigned int length)
ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */
{
register unsigned char *p = (unsigned char*)str;
register unsigned char *end = p + length;
@ -1855,8 +1875,9 @@ ZEND_API void zend_str_tolower(char *str, unsigned int length)
p++;
}
}
/* }}} */
ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2)
ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
{
int retval;
@ -1867,8 +1888,9 @@ ZEND_API int zend_binary_strcmp(const char *s1, uint len1, const char *s2, uint
return retval;
}
}
/* }}} */
ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length)
ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
{
int retval;
@ -1879,9 +1901,9 @@ ZEND_API int zend_binary_strncmp(const char *s1, uint len1, const char *s2, uint
return retval;
}
}
/* }}} */
ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2)
ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, uint len2) /* {{{ */
{
int len;
int c1, c2;
@ -1898,9 +1920,9 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u
return len1 - len2;
}
/* }}} */
ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length)
ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2, uint len2, uint length) /* {{{ */
{
int len;
int c1, c2;
@ -1917,32 +1939,34 @@ ZEND_API int zend_binary_strncasecmp(const char *s1, uint len1, const char *s2,
return MIN(length, len1) - MIN(length, len2);
}
/* }}} */
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2)
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2) /* {{{ */
{
return zend_binary_strcmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2));
}
ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3)
/* }}} */
ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3) /* {{{ */
{
return zend_binary_strncmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3));
}
/* }}} */
ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2)
ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2) /* {{{ */
{
return zend_binary_strcasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2));
}
/* }}} */
ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3)
ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3) /* {{{ */
{
return zend_binary_strncasecmp(Z_STRVAL_P(s1), Z_STRLEN_P(s1), Z_STRVAL_P(s2), Z_STRLEN_P(s2), Z_LVAL_P(s3));
}
/* }}} */
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2)
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */
{
int ret1, ret2;
long lval1, lval2;
@ -1972,38 +1996,38 @@ string_cmp:
}
return;
}
/* }}} */
static int hash_zval_compare_function(const zval **z1, const zval **z2 TSRMLS_DC)
static int hash_zval_compare_function(const zval **z1, const zval **z2 TSRMLS_DC) /* {{{ */
{
zval result;
if (compare_function(&result, (zval *) *z1, (zval *) *z2 TSRMLS_CC)==FAILURE) {
return 1;
}
return result.value.lval;
return Z_LVAL(result);
}
/* }}} */
ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_DC)
ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */
{
return zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC);
}
/* }}} */
ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC)
ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */
{
ZVAL_LONG(result, zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC));
}
/* }}} */
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC)
ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC) /* {{{ */
{
zend_compare_symbol_tables(result, Z_ARRVAL_P(a1), Z_ARRVAL_P(a2) TSRMLS_CC);
}
/* }}} */
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC)
ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
Z_TYPE_P(result) = IS_LONG;
@ -2018,13 +2042,15 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC)
Z_LVAL_P(result) = Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC);
}
}
/* }}} */
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC)
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) /* {{{ */
{
TSRMLS_FETCH();
Z_STRLEN_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%.*G", (int) EG(precision), (double)Z_DVAL_P(op));
}
/* }}} */
/*
* Local variables: