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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 21:01:34 2025 UTC