• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

POSIX.1 National Language Support API for MinGW


Commit MetaInfo

Revision4169903111ce12e8fc3edd929d1b6d50bb7848d4 (tree)
Zeit2008-01-12 08:38:46
AutorKeith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Make replacement getopt' function module more GNU compatible.

Ändern Zusammenfassung

Diff

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
1+2008-01-11 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ Make replacement `getopt' function module more GNU compatible.
4+
5+ * repl/getopt.c (optind): Initialise to one; POSIX requires this.
6+ (getopt_parse): Handle changed initial value for `optind'; allow
7+ caller to reset the parser, by setting `optind = 0'.
8+
19 2008-01-10 Keith Marshall <keithmarshall@users.sourceforge.net>
210
311 * gencat.c: Delay writing the catalogue header until *after* the
--- a/repl/getopt.c
+++ b/repl/getopt.c
@@ -9,7 +9,7 @@
99 * This file is part of the MinGW32 package set.
1010 *
1111 * Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
12- * Last modification: 27-Dec-2007
12+ * Last modification: 11-Jan-2008
1313 *
1414 * THIS SOFTWARE IS NOT COPYRIGHTED
1515 *
@@ -49,7 +49,7 @@ extern char __declspec(dllimport) *__progname;
4949
5050 /* Initialise the public variables. */
5151
52-int optind = 0; /* index for first non-option arg */
52+int optind = 1; /* index for first non-option arg */
5353 int opterr = 1; /* enable built-in error messages */
5454
5555 char *optarg = NULL; /* pointer to current option argument */
@@ -306,6 +306,19 @@ int getopt_parse( int mode, getopt_std_args, ... )
306306 static const CHAR *nextchar = NULL;
307307 static int optmark = 0;
308308
309+ if( (argind == 0) || (optind == 0) )
310+ {
311+ /* POSIX wants `optind' to have an initial value of one, but we want
312+ * it to be initialised to zero, when we are called for the first time,
313+ * (as indicated by `argind' having a value of zero). We also want to
314+ * allow the caller to reset the `getopt' parser, causing it to scan
315+ * the arguments again, (or to scan a new set of arguments); this
316+ * may be achieved by the caller resetting `optind' to zero.
317+ */
318+ optmark = optind = argind = 0;
319+ nextchar = NULL;
320+ }
321+
309322 if( nextchar && *nextchar )
310323 {
311324 /* we are parsing a standard, or short format, option argument ...
@@ -633,4 +646,4 @@ __weak_alias( getopt_long, _getopt_long )
633646 __weak_alias( getopt_long_only, _getopt_long_only )
634647 #endif
635648
636-/* $RCSfile$Revision$: end of file */
649+/* $RCSfile$Revision: 1.1 $: end of file */