This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
fastjar: Handle "-cvf"
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Mar 2002 23:03:10 +1200
- Subject: fastjar: Handle "-cvf"
fastjar handles tar-style arguments like "jar cvf ..." but it didn't
work when the argument list is preceded by a "-", like "jar -cvf", which
freenet's makefile wants to do. This patch makes it ignore the initial
"-" if present.
I'm checking this in.
regards
Bryce.
2002-03-18 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* jartool.c (expand_options): Handle tar-style argument list with a
leading "-".
Index: jartool.c
===================================================================
RCS file: /cvs/gcc/egcs/fastjar/jartool.c,v
retrieving revision 1.13
diff -u -r1.13 jartool.c
--- jartool.c 2002/02/24 19:59:46 1.13
+++ jartool.c 2002/03/18 10:57:57
@@ -1938,24 +1938,34 @@
int argc = *argcp;
char **argv = *argvp;
- if (argc > 1 && argv[1][0] != '-')
+ /* Accept arguments with a leading "-" (eg "-cvf"), but don't do expansion
+ if a long argument (like "--help") is detected. */
+ if (argc > 1 && argv[1][1] != '-')
{
char buf[3];
char **new_argv;
int new_argc;
+ int args_to_expand;
char *p;
char **in, **out;
buf[0] = '-';
buf[2] = '\0';
- new_argc = argc - 1 + strlen (argv[1]);
+ args_to_expand = strlen (argv[1]);
+ if (argv[1][0] == '-')
+ --args_to_expand;
+
+ new_argc = argc - 1 + args_to_expand;
new_argv = (char **) malloc (new_argc * sizeof (char *));
in = argv;
out = new_argv;
*out++ = *in++;
- for (p = *in++; *p; ++p)
+ p = *in++;
+ if (*p == '-')
+ p++;
+ while (*p != '\0')
{
char *opt;
buf[1] = *p;
@@ -1974,6 +1984,7 @@
usage(argv[0]);
}
}
+ ++p;
}
/* Copy remaining options. */