#36723 [Opn->Bgs]: getopt test fails
ID: 36723
Updated by: tony2001@php.net
Reported By: gml4410 at ggr dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: *Compile Issues
Operating System: Solaris8
PHP Version: 4.4.2
New Comment:
No need for an exaplanation in the bug system, if the bug has been
already fixed in CVS.
Previous Comments:
------------------------------------------------------------------------
[2006-03-13 18:43:19] 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]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36723&edit=1
Thread (2 messages)