php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8041 yp_first and yp_next Return Different Array Formats
Submitted: 2000-11-29 21:05 UTC Modified: 2007-04-04 19:05 UTC
From: jalessio at stoic dot net Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.3pl1 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jalessio at stoic dot net
New email:
PHP Version: OS:

 

 [2000-11-29 21:05 UTC] jalessio at stoic dot net
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);
  }




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-18 17:22 UTC] ohrn@php.net
Fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC