From owner-freebsd-toolchain@freebsd.org Wed Jul 29 17:03:06 2015 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92C979ACEB9 for ; Wed, 29 Jul 2015 17:03:06 +0000 (UTC) (envelope-from daemon-user@freebsd.org) Received: from phabric-backend.isc.freebsd.org (phabric-backend.isc.freebsd.org [IPv6:2001:4f8:3:ffe0:406a:0:50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7CD521A5E for ; Wed, 29 Jul 2015 17:03:06 +0000 (UTC) (envelope-from daemon-user@freebsd.org) Received: by phabric-backend.isc.freebsd.org (Postfix, from userid 1346) id 784BB9FFC; Wed, 29 Jul 2015 17:03:06 +0000 (UTC) Date: Wed, 29 Jul 2015 17:03:06 +0000 To: freebsd-toolchain@freebsd.org From: "emaste (Ed Maste)" Reply-to: D3237+334+69ead51bad8cf2b5@reviews.freebsd.org Subject: [Differential] [Request, 25 lines] D3237: Fix ar default deterministic mode for -x Message-ID: X-Priority: 3 Thread-Topic: D3237: Fix ar default deterministic mode for -x X-Herald-Rules: none X-Phabricator-To: X-Phabricator-To: X-Phabricator-To: X-Phabricator-To: X-Phabricator-Cc: X-Phabricator-Cc: Thread-Index: ZjZmNTFiYzZhOGY5YmYzYzlkNGVkOGQ0YmFl Precedence: bulk X-Phabricator-Sent-This-Message: Yes X-Mail-Transport-Agent: MetaMTA X-Auto-Response-Suppress: All X-Phabricator-Mail-Tags: , , , MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="b1_bd48a8bb23acfa48e2533338ce90c80a" X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.20 List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2015 17:03:06 -0000 --b1_bd48a8bb23acfa48e2533338ce90c80a Content-Type: text/plain; charset = "utf-8" Content-Transfer-Encoding: 8bit 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 --b1_bd48a8bb23acfa48e2533338ce90c80a Content-Type: text/x-patch; charset=utf-8; name="D3237.7472.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="D3237.7472.patch" ZGlmZiAtLWdpdCBhL3Vzci5iaW4vYXIvYXIuYyBiL3Vzci5iaW4vYXIvYXIuYwotLS0gYS91c3Iu YmluL2FyL2FyLmMKKysrIGIvdXNyLmJpbi9hci9hci5jCkBAIC0xMDEsMTEgKzEwMSwxMiBAQAog CWNoYXIJCSpwOwogCXNpemVfdAkJIGxlbjsKIAlpbnQJCSBpLCBvcHQ7CisJaW50CQkgRGZsYWcs IFVmbGFnOwogCiAJYnNkYXIgPSAmYnNkYXJfc3RvcmFnZTsKIAltZW1zZXQoYnNkYXIsIDAsIHNp emVvZigqYnNkYXIpKTsKLQkvKiBFbmFibGUgZGV0ZXJtaW5pc3RpYyBtb2RlIGJ5IGRlZmF1bHQu ICovCi0JYnNkYXItPm9wdGlvbnMgfD0gQVJfRDsKKwlEZmxhZyA9IDA7CisJVWZsYWcgPSAwOwog CiAJaWYgKChic2Rhci0+cHJvZ25hbWUgPSBnZXRwcm9nbmFtZSgpKSA9PSBOVUxMKQogCQlic2Rh ci0+cHJvZ25hbWUgPSAiYXIiOwpAQCAtMTIyLDEwICsxMjMsMTIgQEAKIAkJCQkvKiBJZ25vcmVk LiAqLwogCQkJCWJyZWFrOwogCQkJY2FzZSAnRCc6Ci0JCQkJYnNkYXItPm9wdGlvbnMgfD0gQVJf RDsKKwkJCQlEZmxhZyA9IDE7CisJCQkJVWZsYWcgPSAwOwogCQkJCWJyZWFrOwogCQkJY2FzZSAn VSc6Ci0JCQkJYnNkYXItPm9wdGlvbnMgJj0gfkFSX0Q7CisJCQkJVWZsYWcgPSAxOworCQkJCURm b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