ar: Fix deterministic mode default with options other than -q or -r
Reported by: jhibbits Reviewed by: jhibbits Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3237
This commit is contained in:
parent
8328babdd0
commit
a80ac30b2d
@ -100,12 +100,12 @@ main(int argc, char **argv)
|
|||||||
struct bsdar *bsdar, bsdar_storage;
|
struct bsdar *bsdar, bsdar_storage;
|
||||||
char *p;
|
char *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
int i, opt;
|
int i, opt, Dflag, Uflag;
|
||||||
|
|
||||||
bsdar = &bsdar_storage;
|
bsdar = &bsdar_storage;
|
||||||
memset(bsdar, 0, sizeof(*bsdar));
|
memset(bsdar, 0, sizeof(*bsdar));
|
||||||
/* Enable deterministic mode by default. */
|
Dflag = 0;
|
||||||
bsdar->options |= AR_D;
|
Uflag = 0;
|
||||||
|
|
||||||
if ((bsdar->progname = getprogname()) == NULL)
|
if ((bsdar->progname = getprogname()) == NULL)
|
||||||
bsdar->progname = "ar";
|
bsdar->progname = "ar";
|
||||||
@ -122,10 +122,12 @@ main(int argc, char **argv)
|
|||||||
/* Ignored. */
|
/* Ignored. */
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
bsdar->options |= AR_D;
|
Dflag = 1;
|
||||||
|
Uflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
bsdar->options &= ~AR_D;
|
Uflag = 1;
|
||||||
|
Dflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
ranlib_version();
|
ranlib_version();
|
||||||
@ -182,7 +184,8 @@ main(int argc, char **argv)
|
|||||||
set_mode(bsdar, opt);
|
set_mode(bsdar, opt);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
bsdar->options |= AR_D;
|
Dflag = 1;
|
||||||
|
Uflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
case 'T':
|
case 'T':
|
||||||
@ -222,7 +225,8 @@ main(int argc, char **argv)
|
|||||||
set_mode(bsdar, opt);
|
set_mode(bsdar, opt);
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
bsdar->options &= ~AR_D;
|
Uflag = 1;
|
||||||
|
Dflag = 0;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
bsdar->options |= AR_U;
|
bsdar->options |= AR_U;
|
||||||
@ -275,6 +279,10 @@ main(int argc, char **argv)
|
|||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set determinstic mode for -D, and by default without -U. */
|
||||||
|
if (Dflag || (Uflag == 0 && (bsdar->mode == 'q' || bsdar->mode == 'r')))
|
||||||
|
bsdar->options |= AR_D;
|
||||||
|
|
||||||
if (bsdar->options & AR_A)
|
if (bsdar->options & AR_A)
|
||||||
only_mode(bsdar, "-a", "mqr");
|
only_mode(bsdar, "-a", "mqr");
|
||||||
if (bsdar->options & AR_B)
|
if (bsdar->options & AR_B)
|
||||||
@ -283,8 +291,10 @@ main(int argc, char **argv)
|
|||||||
only_mode(bsdar, "-c", "qr");
|
only_mode(bsdar, "-c", "qr");
|
||||||
if (bsdar->options & AR_CC)
|
if (bsdar->options & AR_CC)
|
||||||
only_mode(bsdar, "-C", "x");
|
only_mode(bsdar, "-C", "x");
|
||||||
if (bsdar->options & AR_D)
|
if (Dflag)
|
||||||
only_mode(bsdar, "-D", "qr");
|
only_mode(bsdar, "-D", "qr");
|
||||||
|
if (Uflag)
|
||||||
|
only_mode(bsdar, "-U", "qr");
|
||||||
if (bsdar->options & AR_O)
|
if (bsdar->options & AR_O)
|
||||||
only_mode(bsdar, "-o", "x");
|
only_mode(bsdar, "-o", "x");
|
||||||
if (bsdar->options & AR_SS)
|
if (bsdar->options & AR_SS)
|
||||||
|
Loading…
Reference in New Issue
Block a user