svn commit: trunk/busybox: archival libbb

vda at busybox.net vda at busybox.net
Thu Mar 15 13:28:47 UTC 2007


Author: vda
Date: 2007-03-15 06:28:46 -0700 (Thu, 15 Mar 2007)
New Revision: 18118

Log:
fix TODO: getopt32 should reset optind to 1 itself


Modified:
   trunk/busybox/archival/gzip.c
   trunk/busybox/libbb/getopt32.c


Changeset:
Modified: trunk/busybox/archival/gzip.c
===================================================================
--- trunk/busybox/archival/gzip.c	2007-03-15 08:36:18 UTC (rev 18117)
+++ trunk/busybox/archival/gzip.c	2007-03-15 13:28:46 UTC (rev 18118)
@@ -2041,8 +2041,6 @@
 	//if (opt & 0x4) // -v
 #if ENABLE_GUNZIP /* gunzip_main may not be visible... */
 	if (opt & 0x8) { // -d
-		/* FIXME: getopt32 should not depend on optind */
-		optind = 1;
 		return gunzip_main(argc, argv);
 	}
 #endif

Modified: trunk/busybox/libbb/getopt32.c
===================================================================
--- trunk/busybox/libbb/getopt32.c	2007-03-15 08:36:18 UTC (rev 18117)
+++ trunk/busybox/libbb/getopt32.c	2007-03-15 13:28:46 UTC (rev 18118)
@@ -454,6 +454,10 @@
 				spec_flgs |= FREE_FIRST_ARGV_IS_OPT;
 		}
 	}
+
+	/* In case getopt32 was already called, reinit some state */
+	optind = 1;
+
 	/* Note: just "getopt() <= 0" will not work good for
 	 * "fake" short options, like this one:
 	 * wget $'-\203' "Test: test" http://kernel.org/
@@ -463,9 +467,9 @@
 				 applet_long_options, NULL)) != -1) {
 #else
 	while ((c = getopt(argc, argv, applet_opts)) != -1) {
-#endif /* ENABLE_GETOPT_LONG */
+#endif
 		c &= 0xff; /* fight libc's sign extends */
-loop_arg_is_opt:
+ loop_arg_is_opt:
 		for (on_off = complementary; on_off->opt != c; on_off++) {
 			/* c==0 if long opt have non NULL flag */
 			if (on_off->opt == 0 && c != 0)




More information about the busybox-cvs mailing list