getopt32: fix recently broken opt_complementary "--"
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 21 Apr 2008 22:04:21 +0000 (22:04 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 21 Apr 2008 22:04:21 +0000 (22:04 -0000)
libbb/getopt32.c

index cd890323e41c48edcb12b3f550d88e1406954216..913a009b0655f655e1f47b3e70ea0253435e51d6 100644 (file)
@@ -497,8 +497,9 @@ getopt32(char **argv, const char *applet_opts, ...)
                if (argv[1] && argv[1][0] != '-' && argv[1][1] != '\0') {
 #if DONT_USE_PRINTF
                        char *pp = alloca(strlen(argv[1]) + 2);
-                       *pp++ = '-';
-                       argv[1] = strcpy(pp, argv[1]);
+                       *pp = '-';
+                       strcpy(pp + 1, argv[1]);
+                       argv[1] = pp;
 #else
                        argv[1] = xasprintf("-%s", argv[1]);
                        if (ENABLE_FEATURE_CLEAN_UP)