sniper Wed Sep 11 10:40:52 2002 EDT Modified files: /php4/ext/standard string.c Log: ws fix
Index: php4/ext/standard/string.c diff -u php4/ext/standard/string.c:1.291 php4/ext/standard/string.c:1.292 --- php4/ext/standard/string.c:1.291 Wed Sep 11 10:24:27 2002 +++ php4/ext/standard/string.c Wed Sep 11 10:40:52 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.291 2002/09/11 14:24:27 sniper Exp $ */ +/* $Id: string.c,v 1.292 2002/09/11 14:40:52 sniper Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -180,8 +180,7 @@ char *result; size_t newlen; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &data) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &data) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(data); @@ -209,7 +208,7 @@ convert_to_string_ex(s2); RETURN_LONG(php_strspn(Z_STRVAL_PP(s1), Z_STRVAL_PP(s2), - Z_STRVAL_PP(s1) + Z_STRLEN_PP(s1), + Z_STRVAL_PP(s1) + Z_STRLEN_PP(s1), Z_STRVAL_PP(s2) + Z_STRLEN_PP(s2))); } /* }}} */ @@ -748,8 +747,7 @@ int limit = -1; int argc = ZEND_NUM_ARGS(); - if (argc < 2 || argc > 3 || - zend_get_parameters_ex(argc, &delim, &str, &zlimit) == FAILURE) { + if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &delim, &str, +&zlimit) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -1143,8 +1141,7 @@ zval **str; char *ret; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &str) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -1228,9 +1225,8 @@ /* }}} */ /* {{{ php_stristr - * case insensitve strstr */ -PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, - size_t s_len, size_t t_len) + case insensitve strstr */ +PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t +t_len) { php_strtolower(s, s_len); php_strtolower(t, t_len); @@ -1284,8 +1280,7 @@ char *haystack_orig; char needle_char[2]; - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &haystack, &needle) == FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack, &needle) == +FAILURE) { WRONG_PARAM_COUNT; } @@ -1304,21 +1299,17 @@ found = php_stristr(Z_STRVAL_PP(haystack), Z_STRVAL_PP(needle), Z_STRLEN_PP(haystack), Z_STRLEN_PP(needle)); - } - else { + } else { convert_to_long_ex(needle); needle_char[0] = (char) Z_LVAL_PP(needle); needle_char[1] = 0; - found = php_stristr(Z_STRVAL_PP(haystack), needle_char, - Z_STRLEN_PP(haystack), 1); + found = php_stristr(Z_STRVAL_PP(haystack), needle_char, +Z_STRLEN_PP(haystack), 1); } - + if (found) { found_offset = found - Z_STRVAL_PP(haystack); - RETVAL_STRINGL(haystack_orig + found_offset, - Z_STRLEN_PP(haystack) - found_offset, - 1); + RETVAL_STRINGL(haystack_orig + found_offset, Z_STRLEN_PP(haystack) - +found_offset, 1); } else { RETVAL_FALSE; } @@ -1348,17 +1339,15 @@ } found = php_memnstr(Z_STRVAL_PP(haystack), - Z_STRVAL_PP(needle), - Z_STRLEN_PP(needle), - Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); - } - else { + Z_STRVAL_PP(needle), + Z_STRLEN_PP(needle), + Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); + } else { convert_to_long_ex(needle); needle_char[0] = (char) Z_LVAL_PP(needle); needle_char[1] = 0; - found = php_memnstr(Z_STRVAL_PP(haystack), - needle_char, 1, + found = php_memnstr(Z_STRVAL_PP(haystack), needle_char, 1, Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); } @@ -1407,17 +1396,15 @@ } found = php_memnstr(Z_STRVAL_PP(haystack) + offset, - Z_STRVAL_PP(needle), - Z_STRLEN_PP(needle), - Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); - } - else { + Z_STRVAL_PP(needle), + Z_STRLEN_PP(needle), + Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); + } else { convert_to_long_ex(needle); needle_char[0] = (char) Z_LVAL_PP(needle); needle_char[1] = 0; - found = php_memnstr(Z_STRVAL_PP(haystack) + offset, - needle_char, 1, + found = php_memnstr(Z_STRVAL_PP(haystack) + offset, needle_char, 1, Z_STRVAL_PP(haystack) + Z_STRLEN_PP(haystack)); } @@ -1563,8 +1550,7 @@ RETURN_EMPTY_STRING(); } - result = php_chunk_split(Z_STRVAL_PP(p_str), Z_STRLEN_PP(p_str), - end, endlen, chunklen, &result_len); + result = php_chunk_split(Z_STRVAL_PP(p_str), Z_STRLEN_PP(p_str), end, endlen, +chunklen, &result_len); if (result) { RETURN_STRINGL(result, result_len, 0); } else { @@ -1582,8 +1568,7 @@ int f; int argc = ZEND_NUM_ARGS(); - if (argc < 2 || argc > 3 || - zend_get_parameters_ex(argc, &str, &from, &len) == FAILURE) { + if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &str, &from, &len) == +FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -1635,20 +1620,20 @@ Replaces part of a string with another string */ PHP_FUNCTION(substr_replace) { - zval **str; - zval **from; - zval **len; - zval **repl; - char *result; - int result_len; - int l; - int f; - int argc = ZEND_NUM_ARGS(); + zval **str; + zval **from; + zval **len; + zval **repl; + char *result; + int result_len; + int l; + int f; + int argc = ZEND_NUM_ARGS(); - if (argc < 3 || argc > 4 || - zend_get_parameters_ex(argc, &str, &repl, &from, &len) == FAILURE) { + if (argc < 3 || argc > 4 || zend_get_parameters_ex(argc, &str, &repl, &from, +&len) == FAILURE) { WRONG_PARAM_COUNT; } + convert_to_string_ex(str); convert_to_string_ex(repl); convert_to_long_ex(from); @@ -1685,7 +1670,7 @@ } } - if((f + l) > Z_STRLEN_PP(str)) { + if ((f + l) > Z_STRLEN_PP(str)) { l = Z_STRLEN_PP(str) - f; } @@ -1694,8 +1679,7 @@ memcpy(result, Z_STRVAL_PP(str), f); memcpy(&result[f], Z_STRVAL_PP(repl), Z_STRLEN_PP(repl)); - memcpy(&result[f + Z_STRLEN_PP(repl)], Z_STRVAL_PP(str) + f + l, - Z_STRLEN_PP(str) - f - l); + memcpy(&result[f + Z_STRLEN_PP(repl)], Z_STRVAL_PP(str) + f + l, +Z_STRLEN_PP(str) - f - l); RETURN_STRINGL(result, result_len, 0); } @@ -1711,8 +1695,7 @@ char *p, *q; char c; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &arg) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg); @@ -1793,8 +1776,7 @@ { zval **str; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &str) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -2045,8 +2027,7 @@ /* {{{ php_similar_char */ -static int php_similar_char(const char *txt1, int len1, - const char *txt2, int len2) +static int php_similar_char(const char *txt1, int len1, const char *txt2, int len2) { int sum; int pos1, pos2, max; @@ -2072,26 +2053,27 @@ int ac = ZEND_NUM_ARGS(); int sim; - if (ac < 2 || ac > 3 || - zend_get_parameters_ex(ac, &t1, &t2, &percent) == FAILURE) { + if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &t1, &t2, &percent) == +FAILURE) { WRONG_PARAM_COUNT; } + convert_to_string_ex(t1); convert_to_string_ex(t2); + if (ac > 2) { convert_to_double_ex(percent); } if (Z_STRLEN_PP(t1) + Z_STRLEN_PP(t2) == 0) { - if(ac > 2) { + if (ac > 2) { Z_DVAL_PP(percent) = 0; } RETURN_LONG(0); } - sim = php_similar_char(Z_STRVAL_PP(t1), Z_STRLEN_PP(t1), - Z_STRVAL_PP(t2), Z_STRLEN_PP(t2)); + sim = php_similar_char(Z_STRVAL_PP(t1), Z_STRLEN_PP(t1), Z_STRVAL_PP(t2), +Z_STRLEN_PP(t2)); + if (ac > 2) { Z_DVAL_PP(percent) = sim * 200.0 / (Z_STRLEN_PP(t1) + Z_STRLEN_PP(t2)); } @@ -2179,8 +2161,7 @@ { zval **str, **what; - if (ZEND_NUM_ARGS() != 2 || - zend_get_parameters_ex(2, &str, &what) == FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &str, &what) == FAILURE) +{ WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -2198,8 +2179,7 @@ Z_STRLEN_PP(str), &Z_STRLEN_P(return_value), 0, Z_STRVAL_PP(what), - Z_STRLEN_PP(what) TSRMLS_CC), - 0); + Z_STRLEN_PP(what) TSRMLS_CC), 0); } /* }}} */ @@ -2209,8 +2189,7 @@ { zval **str; - if (ZEND_NUM_ARGS() != 1 || - zend_get_parameters_ex(1, &str) == FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(str); @@ -2222,8 +2201,7 @@ RETURN_STRING(php_addslashes(Z_STRVAL_PP(str), Z_STRLEN_PP(str), &Z_STRLEN_P(return_value), 0 - TSRMLS_CC), - 0); + TSRMLS_CC), 0); } /* }}} */ @@ -3018,12 +2996,9 @@ int new_length, length; char *p, *end, *target; int repl_cnt = 0; - - int state = 0; - /* 0 - initial; 1 - \r found; 2 - \n found; */ - - int action; - /* actions: + int state = 0; /* 0 - initial; 1 - \r found; 2 - \n found; */ + int action; + /* actions: 0 - do nothing; 1 - replace \n; 2 - replace \r 3 - replace \n\r; 4 - replace \r\n; */ @@ -3300,7 +3275,7 @@ /* {{{ php_strip_tags - A simple little state-machine to strip out html and php tags + A simple little state-machine to strip out html and php tags State 0 is the output state, State 1 means we are inside a normal html tag and state 2 means we are inside a php tag. @@ -3852,8 +3827,8 @@ Implements an ANSI C compatible sscanf */ PHP_FUNCTION(sscanf) { - zval ***args; - int result; + zval ***args; + int result; int argc = ZEND_NUM_ARGS(); if (argc < 2) { @@ -3897,7 +3872,7 @@ *return_value = **arg; zval_copy_ctor(return_value); - php_strtr(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), rot13_from, rot13_to, 52); + php_strtr(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), rot13_from, +rot13_to, 52); } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php