Fix an obscure option parsing bug.
This commit is contained in:
parent
2da90d3b58
commit
0102a9fd48
@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
int createFlag = FALSE;
|
int createFlag = FALSE;
|
||||||
int verboseFlag = FALSE;
|
int verboseFlag = FALSE;
|
||||||
int tostdoutFlag = FALSE;
|
int tostdoutFlag = FALSE;
|
||||||
|
int firstOpt = TRUE;
|
||||||
int stopIt;
|
int stopIt;
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
|
|||||||
usage(tar_usage);
|
usage(tar_usage);
|
||||||
|
|
||||||
/* do normal option parsing */
|
/* 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;
|
stopIt=FALSE;
|
||||||
while (stopIt==FALSE && *argv && **argv) {
|
while (stopIt==FALSE && *argv && **argv) {
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
|
5
tar.c
5
tar.c
@ -149,6 +149,7 @@ extern int tar_main(int argc, char **argv)
|
|||||||
int createFlag = FALSE;
|
int createFlag = FALSE;
|
||||||
int verboseFlag = FALSE;
|
int verboseFlag = FALSE;
|
||||||
int tostdoutFlag = FALSE;
|
int tostdoutFlag = FALSE;
|
||||||
|
int firstOpt = TRUE;
|
||||||
int stopIt;
|
int stopIt;
|
||||||
|
|
||||||
|
|
||||||
@ -156,7 +157,9 @@ extern int tar_main(int argc, char **argv)
|
|||||||
usage(tar_usage);
|
usage(tar_usage);
|
||||||
|
|
||||||
/* do normal option parsing */
|
/* 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;
|
stopIt=FALSE;
|
||||||
while (stopIt==FALSE && *argv && **argv) {
|
while (stopIt==FALSE && *argv && **argv) {
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user