php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36723 getopt test fails
Submitted: 2006-03-13 18:43 UTC Modified: 2006-03-13 19:02 UTC
From: gml4410 at ggr dot co dot uk Assigned:
Status: Not a bug Package: *Compile Issues
PHP Version: 4.4.2 OS: Solaris8
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: gml4410 at ggr dot co dot uk
New email:
PHP Version: OS:

 

 [2006-03-13 18:43 UTC] gml4410 at ggr dot co dot uk
Description:
------------
Bug #36091 actualy fixes this, but you might like an explanation of why settign optind to 1 and not 0 works.
Bascially, it *documented* that it needs to be set to 1!

Bug #35564 added a fix for recurring getopt()s of:

+       /* Force reinitialization of getopt() (via optind reset) on
every call. */
+       optind = 0;
+

   However, the Open group standrad for getopt() (see http://www.opengroup.org/onlinepubs/009695399/functions/getopt.html) states:

>> The variable optind is the index of the next element
>> of the argv[] vector to be processed. It shall be 
>> initialized to 1 by the system, 

   Whereas Linux (well, GNU glibc) is happy with a 0 setting to restart things other OSes (eg: Solaris) are not.

   This line must be chanegd to "optind = 1;" to work across all systems (tested on linux and Solaris).

Reproduce code:
---------------
   Just build php and run "make test".  The test report wil include this line in the FAILED TEST SUMMARY.

getopt [ext/standard/tests/general_functions/getopt.phpt]



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-13 19:02 UTC] tony2001@php.net
No need for an exaplanation in the bug system, if the bug has been already fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 07:01:29 2024 UTC