X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <48E3E5DD.5010604@t-online.de> Date: Wed, 01 Oct 2008 23:04:29 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: mingw-runtime-3.15: regression in getopt() optind ? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ID: ZGPJwUZeght3bFnKNGuEiMcKl08dcaNKpnCXxmQZ7shMymwF8vc9VvE9A17RrnLQbq X-TOI-MSGID: 66a49bc2-b6f9-49d4-b14f-af91c4e661c4 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Chris Sutcliffe wrote: > I've made a new version of the mingw-runtime available for download. > For a list of changes see: > > http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/mingw/ChangeLog?rev=1.409&cvsroot=src > > New features in release 3.15 > ============================ > ... > * A replacement implementation for the getopt() family of functions, > adding support for the GNU getopt_long_only() function. ... > This new getopt() sets optind to the index of the current option instead of the next option. Testcase: #include #include int main(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "ab:c")) != -1) printf("opt=%c, optind=%d\n", opt, optind); printf("end optind=%d\n", optind); return 0; } Output for "./prog -a -b arg -c": - mingw-runtime-3.14, Cygwin, GNU getopt: opt=a, optind=2 opt=b, optind=4 opt=c, optind=5 end optind=5 - mingw-runtime-3.15: opt=a, optind=1 opt=b, optind=2 opt=c, optind=4 end optind=5 The new behavior violates this POSIX requirement: "The variable optind is the index of the next element of the argv[] vector to be processed." http://www.opengroup.org/onlinepubs/009695399/functions/getopt.html -- Christian Franke -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/