emaste created this revision.
emaste added reviewers: jhibbits, bapt, brooks.
emaste added subscribers: freebsd-toolchain-list, jhibbits.

REVISION SUMMARY
  Reported by: @jhibbits

REVISION DETAIL
  https://reviews.freebsd.org/D3237

AFFECTED FILES
  usr.bin/ar/ar.c

CHANGE DETAILS
  diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c
  --- a/usr.bin/ar/ar.c
  +++ b/usr.bin/ar/ar.c
  @@ -101,11 +101,12 @@
        char            *p;
        size_t           len;
        int              i, opt;
  +     int              Dflag, Uflag;
   
        bsdar = &bsdar_storage;
        memset(bsdar, 0, sizeof(*bsdar));
  -     /* Enable deterministic mode by default. */
  -     bsdar->options |= AR_D;
  +     Dflag = 0;
  +     Uflag = 0;
   
        if ((bsdar->progname = getprogname()) == NULL)
                bsdar->progname = "ar";
  @@ -122,10 +123,12 @@
                                /* Ignored. */
                                break;
                        case 'D':
  -                             bsdar->options |= AR_D;
  +                             Dflag = 1;
  +                             Uflag = 0;
                                break;
                        case 'U':
  -                             bsdar->options &= ~AR_D;
  +                             Uflag = 1;
  +                             Dflag = 0;
                                break;
                        case 'V':
                                ranlib_version();
  @@ -182,7 +185,8 @@
                        set_mode(bsdar, opt);
                        break;
                case 'D':
  -                     bsdar->options |= AR_D;
  +                     Dflag = 1;
  +                     Uflag = 0;
                        break;
                case 'f':
                case 'T':
  @@ -222,7 +226,8 @@
                        set_mode(bsdar, opt);
                        break;
                case 'U':
  -                     bsdar->options &= ~AR_D;
  +                     Uflag = 1;
  +                     Dflag = 0;
                        break;
                case 'u':
                        bsdar->options |= AR_U;
  @@ -275,16 +280,22 @@
                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)
                only_mode(bsdar, "-a", "mqr");
        if (bsdar->options & AR_B)
                only_mode(bsdar, "-b", "mqr");
        if (bsdar->options & AR_C)
                only_mode(bsdar, "-c", "qr");
        if (bsdar->options & AR_CC)
                only_mode(bsdar, "-C", "x");
  -     if (bsdar->options & AR_D)
  +     if (Dflag)
                only_mode(bsdar, "-D", "qr");
  +     if (Uflag)
  +             only_mode(bsdar, "-U", "qr");
        if (bsdar->options & AR_O)
                only_mode(bsdar, "-o", "x");
        if (bsdar->options & AR_SS)

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: emaste, jhibbits, bapt, brooks
Cc: jhibbits, freebsd-toolchain-list
diff --git a/usr.bin/ar/ar.c b/usr.bin/ar/ar.c
--- a/usr.bin/ar/ar.c
+++ b/usr.bin/ar/ar.c
@@ -101,11 +101,12 @@
 	char		*p;
 	size_t		 len;
 	int		 i, opt;
+	int		 Dflag, Uflag;
 
 	bsdar = &bsdar_storage;
 	memset(bsdar, 0, sizeof(*bsdar));
-	/* Enable deterministic mode by default. */
-	bsdar->options |= AR_D;
+	Dflag = 0;
+	Uflag = 0;
 
 	if ((bsdar->progname = getprogname()) == NULL)
 		bsdar->progname = "ar";
@@ -122,10 +123,12 @@
 				/* Ignored. */
 				break;
 			case 'D':
-				bsdar->options |= AR_D;
+				Dflag = 1;
+				Uflag = 0;
 				break;
 			case 'U':
-				bsdar->options &= ~AR_D;
+				Uflag = 1;
+				Dflag = 0;
 				break;
 			case 'V':
 				ranlib_version();
@@ -182,7 +185,8 @@
 			set_mode(bsdar, opt);
 			break;
 		case 'D':
-			bsdar->options |= AR_D;
+			Dflag = 1;
+			Uflag = 0;
 			break;
 		case 'f':
 		case 'T':
@@ -222,7 +226,8 @@
 			set_mode(bsdar, opt);
 			break;
 		case 'U':
-			bsdar->options &= ~AR_D;
+			Uflag = 1;
+			Dflag = 0;
 			break;
 		case 'u':
 			bsdar->options |= AR_U;
@@ -275,16 +280,22 @@
 		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)
 		only_mode(bsdar, "-a", "mqr");
 	if (bsdar->options & AR_B)
 		only_mode(bsdar, "-b", "mqr");
 	if (bsdar->options & AR_C)
 		only_mode(bsdar, "-c", "qr");
 	if (bsdar->options & AR_CC)
 		only_mode(bsdar, "-C", "x");
-	if (bsdar->options & AR_D)
+	if (Dflag)
 		only_mode(bsdar, "-D", "qr");
+	if (Uflag)
+		only_mode(bsdar, "-U", "qr");
 	if (bsdar->options & AR_O)
 		only_mode(bsdar, "-o", "x");
 	if (bsdar->options & AR_SS)

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[email protected]"

Reply via email to