Fix an obscure option parsing bug.

This commit is contained in:
Eric Andersen 2000-09-23 22:36:24 +00:00
parent 2da90d3b58
commit 0102a9fd48
2 changed files with 8 additions and 2 deletions

View File

@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
int createFlag = FALSE;
int verboseFlag = FALSE;
int tostdoutFlag = FALSE;
int firstOpt = TRUE;
int stopIt;
@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
usage(tar_usage);
/* do normal option parsing */
while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
while (--argc > 0 && ((*argv && **(++argv) == '-') ||
(firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
firstOpt=FALSE;
stopIt=FALSE;
while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {

5
tar.c
View File

@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
int createFlag = FALSE;
int verboseFlag = FALSE;
int tostdoutFlag = FALSE;
int firstOpt = TRUE;
int stopIt;
@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
usage(tar_usage);
/* do normal option parsing */
while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
while (--argc > 0 && ((*argv && **(++argv) == '-') ||
(firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
firstOpt=FALSE;
stopIt=FALSE;
while (stopIt==FALSE && *argv && **argv) {
switch (**argv) {