]> granicus.if.org Git - php/commitdiff
Update tests to accomodate new parameter parsing API and make long2ip() use
authorIlia Alshanetsky <iliaa@php.net>
Wed, 29 Apr 2009 22:06:28 +0000 (22:06 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 29 Apr 2009 22:06:28 +0000 (22:06 +0000)
it as well

ext/standard/basic_functions.c
ext/standard/tests/network/ip2long_error.phpt
ext/standard/tests/network/ip2long_variation1.phpt
ext/standard/tests/network/ip_x86_64.phpt
ext/standard/tests/network/long2ip_error.phpt
ext/standard/tests/network/long2ip_variation1.phpt

index 2e7ffd9aa91778b954d43268932018d934e16895..4061df9defaf3536135a4a32497bc020a71c6821 100644 (file)
@@ -4372,16 +4372,17 @@ PHP_FUNCTION(ip2long)
    Converts an (IPv4) Internet network address into a string in Internet standard dotted format */
 PHP_FUNCTION(long2ip)
 {
-       zval **num;
+       /* "It's a long but it's not, PHP ints are signed */
+       char *ip;
+       int ip_len;
        unsigned long n;
        struct in_addr myaddr;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) == FAILURE) {
+               return;
        }
-       convert_to_string_ex(num);
-       
-       n = strtoul(Z_STRVAL_PP(num), NULL, 0);
+
+       n = strtoul(ip, NULL, 0);
 
        myaddr.s_addr = htonl(n);
        RETURN_STRING(inet_ntoa(myaddr), 1);
index 219363e6aab3049b75e3296d7450ab65856311ff..65e73155956f580a53e837dc86815fa4efa994e8 100644 (file)
@@ -27,11 +27,11 @@ var_dump( ip2long($ip_address, $extra_arg) );
 
 -- Testing ip2long() function with Zero arguments --
 
-Warning: Wrong parameter count for ip2long() in %s on line %d
+Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing ip2long() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for ip2long() in %s on line %d
+Warning: ip2long() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 ===DONE===
index 2592d5fced2812546aa3ffdf26e64af21691fe1d..ac3c9c81e19ec127d70812bedff99940c10aa038 100644 (file)
@@ -141,20 +141,20 @@ bool(false)
 bool(false)
 
 --empty array--
-Error: 8 - Array to string conversion, %s(%d)
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --int indexed array--
-Error: 8 - Array to string conversion, %s(%d)
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --associative array--
-Error: 8 - Array to string conversion, %s(%d)
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --nested arrays--
-Error: 8 - Array to string conversion, %s(%d)
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --uppercase NULL--
 bool(false)
@@ -184,9 +184,8 @@ bool(false)
 bool(false)
 
 --instance of classWithoutToString--
-Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
-Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, object given, %s(%d)
+NULL
 
 --undefined var--
 bool(false)
@@ -195,5 +194,6 @@ bool(false)
 bool(false)
 
 --resource--
-bool(false)
+Error: 2 - ip2long() expects parameter 1 to be string, resource given, %s(%d)
+NULL
 ===DONE===
\ No newline at end of file
index bc3e72c2a2cf0b84220fd36e333ecf4cff2ee4ab..1fcb8b2043cf61f661ca8f13112cfaf4a37a9638 100644 (file)
@@ -48,20 +48,20 @@ string(7) "0.0.0.0"
 int(1118019956)
 string(14) "66.163.161.116"
 
-Warning: Wrong parameter count for ip2long() in %s on line %d
+Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 bool(false)
 bool(false)
 int(1869573999)
 
-Notice: Array to string conversion in %s on line %d
-bool(false)
+Warning: ip2long() expects parameter 1 to be string, array given in %s on line %d
+NULL
 
-Warning: Wrong parameter count for long2ip() in %s on line %d
+Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 string(13) "255.254.82.80"
 string(7) "0.0.0.0"
 
-Notice: Array to string conversion in %s on line %d
-string(7) "0.0.0.0"
+Warning: long2ip() expects parameter 1 to be string, array given in %s on line %d
+NULL
 Done
index 61fb34a806ca2bc13678d3c856ab1bfe5cbb0ad0..d56397cdd5e23432430a82e7f6841c8498bbab9d 100644 (file)
@@ -27,11 +27,11 @@ var_dump( long2ip($proper_address, $extra_arg) );
 
 -- Testing long2ip() function with Zero arguments --
 
-Warning: Wrong parameter count for long2ip() in %s on line %d
+Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
 -- Testing long2ip() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for long2ip() in %s on line %d
+Warning: long2ip() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 ===DONE===
\ No newline at end of file
index a4a867277ea0b0b4674c96f294a9218c61e0b522..2dc6fb123b31feaa9b7457aaf82475357ab5aa95 100644 (file)
@@ -126,20 +126,20 @@ string(15) "255.255.255.246"
 string(7) "0.0.0.0"
 
 --empty array--
-Error: 8 - Array to string conversion, %s(%d)
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --int indexed array--
-Error: 8 - Array to string conversion, %s(%d)
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --associative array--
-Error: 8 - Array to string conversion, %s(%d)
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --nested arrays--
-Error: 8 - Array to string conversion, %s(%d)
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d)
+NULL
 
 --uppercase NULL--
 string(7) "0.0.0.0"
@@ -181,9 +181,8 @@ string(7) "0.0.0.0"
 string(7) "0.0.0.0"
 
 --instance of classWithoutToString--
-Error: 4096 - Object of class classWithoutToString could not be converted to string, %s(%d)
-Error: 8 - Object of class classWithoutToString to string conversion, %s(%d)
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, object given, %s(%d)
+NULL
 
 --undefined var--
 string(7) "0.0.0.0"
@@ -192,5 +191,6 @@ string(7) "0.0.0.0"
 string(7) "0.0.0.0"
 
 --resource--
-string(7) "0.0.0.0"
+Error: 2 - long2ip() expects parameter 1 to be string, resource given, %s(%d)
+NULL
 ===DONE===