diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-18 11:08:21 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-03-18 11:08:21 +0000 |
commit | ee8f08ae575e9024cf752040bb8cd94c448894d5 (patch) | |
tree | 5911e9488f7f5b2436c0574a9a22f3f60753340f /fastjar | |
parent | 56059d899d9eb0acf9c5cf34aa81105a077c3bf6 (diff) | |
download | gcc-ee8f08ae575e9024cf752040bb8cd94c448894d5.tar.gz |
* jartool.c (expand_options): Handle tar-style argument list with a
leading "-".
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50957 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'fastjar')
-rw-r--r-- | fastjar/ChangeLog | 5 | ||||
-rw-r--r-- | fastjar/jartool.c | 17 |
2 files changed, 19 insertions, 3 deletions
diff --git a/fastjar/ChangeLog b/fastjar/ChangeLog index ea908d41648..25859629281 100644 --- a/fastjar/ChangeLog +++ b/fastjar/ChangeLog @@ -1,3 +1,8 @@ +2002-03-18 Bryce McKinlay <bryce@waitaki.otago.ac.nz> + + * jartool.c (expand_options): Handle tar-style argument list with a + leading "-". + 2002-02-23 Anthony Green <green@redhat.com> * jartool.c (main): Fix handling of -C. diff --git a/fastjar/jartool.c b/fastjar/jartool.c index bd5d1fc43a3..2436606d502 100644 --- a/fastjar/jartool.c +++ b/fastjar/jartool.c @@ -1938,24 +1938,34 @@ expand_options (int *argcp, char ***argvp) 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 @@ expand_options (int *argcp, char ***argvp) usage(argv[0]); } } + ++p; } /* Copy remaining options. */ |