PHP 4.0 Bug #8041: yp_first and yp_next Return Different Array Formats

From: Date: Thu, 30 Nov 2000 02:05:55 +0000
Subject: PHP 4.0 Bug #8041: yp_first and yp_next Return Different Array Formats
Groups: php.dev 
Request: Send a blank email to php-dev+get-39664@lists.php.net to get a copy of this message
From: jalessio@stoic.net Operating system: N/A PHP version: 4.0.3pl1 PHP Bug Type: YP/NIS related Bug description: yp_first and yp_next Return Different Array Formats The output of the yp_first function and the yp_next function return different types of arrays. These two functions are fetching the same information yet returning them in an inconsistent format. yp_first returns an array as such when output with print_r: Array ( [key] => d264 [value] => hal:/export/& ) and yp_next returns an array like this: Array ( [d273] => squash:/export/& ) The result of yp_next if much more intuitive and useful. In any case, a consistent result from these two functions would be nicer. Below is the context diff for the fix on "ext/yp/yp.c": NOTE: This also incorporates the fix for BUG #6559 *** yp.c Wed Nov 29 18:01:34 2000 --- yp.c.fixed Wed Nov 29 18:01:08 2000 *************** *** 150,158 **** if(yp_first((*domain)->value.str.val,(*map)->value.str.val,&outkey,&outkeylen,&outval,&outvallen)) { RETURN_FALSE; } array_init(return_value); ! add_assoc_string(return_value,"key",outkey,1); ! add_assoc_string(return_value,"value",outval,1); } /* }}} */ --- 150,159 ---- if(yp_first((*domain)->value.str.val,(*map)->value.str.val,&outkey,&outkeylen,&outval,&outvallen)) { RETURN_FALSE; } + outval[outvallen] = 0; + outkey[outkeylen] = 0; array_init(return_value); ! add_assoc_string(return_value,outkey,outval,1); } /* }}} */ *************** *** 175,180 **** --- 176,183 ---- RETURN_FALSE; } + outval[outvallen] = 0; + outkey[outkeylen] = 0; array_init(return_value); add_assoc_string(return_value,outkey,outval,1); } -- Edit Bug report at: http://bugs.php.net/?id=8041&edit=1

« previous php.dev (#39664) next »