From nobody Wed Oct 19 08:01:34 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MsjqM0Wmlz4gDK5; Wed, 19 Oct 2022 08:01:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MsjqL75THz3ymx; Wed, 19 Oct 2022 08:01:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666166495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q0RTq5V+JRL1DO0XaN2YoUEa5B4JqhicVrCBuflwbn4=; b=nfdti1i0f/eymY/jblQlUUTAfRkaprroL1VUJpdQh/DHkuRDiPd5c1Bz01PLhbMzenZdvx KMZX2xqwLuM345NNpEkrw5EMMraeKDinsOL0sTBeFEdXGDjdXwHukp4/xF9GppsMwDrRZG clBuYBq4e5xiAqA3+MTPiClVRk9vNP5ZATCwBMiUtLv4Q2b3jh8T5cfgR/upucAk4tCG5x VtvLnBJc9JFAUKRdhqzRxoRog8USJItuFLuChunlYEvHcIvy5XUCEeD6lJyxWCsgVcYep1 qyUyx8LFsY/UGyKRv7g9UkAICXnDVHkZBxpJS+f39DybNj84BAdAu8Go/Usakg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MsjqL5tqSzSTN; Wed, 19 Oct 2022 08:01:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29J81YwH061366; Wed, 19 Oct 2022 08:01:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29J81YQN061365; Wed, 19 Oct 2022 08:01:34 GMT (envelope-from git) Date: Wed, 19 Oct 2022 08:01:34 GMT Message-Id: <202210190801.29J81YQN061365@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: e3231f459f54 - stable/13 - sort: deindent openfile List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e3231f459f54e733d4ea86463b71de4c78e7e199 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666166495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q0RTq5V+JRL1DO0XaN2YoUEa5B4JqhicVrCBuflwbn4=; b=XNblsZpdrKzjdpnhlmpghx2qEQTonhGqx3TVV7H3RRzXQpBzHEQprtNnDZ1g5jiW1SfZ+z NMKggsJSICWte1Xc5Jiqk7eJbxv1fLbJHNKz+z7l9XYJZcl9rwGJd9mprJD6luVhxEM9H7 PxnSMfk0ALDZdp7u3REKzrMWw6nsYND+BeTMzve0ti6dtG4H/QZXzZ+wKiTa+yUS3qhde9 xk7EKZzko3pe/ksJyqqV/spDCYOrQch6xXnMoN3tofBlE+g4qwBjMTtiqKaCZONgF0Wev/ RnNBC+vWs2xcASfEIh9CadlwADqpyoTtTR4DZXlJIEwUPVBCmZXyxC5pyYxhNA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666166495; a=rsa-sha256; cv=none; b=w68ZWBYslRFKT1bnMMVj5y6QuiJJ18rVUszJuWwMvXOsQBAdvx/1sJFg9G2tumVceRA3nz cfj2JQKh81kA/UhWbrRcHqsrHerEwi9n0B0maYDOnitn6BiYA7/VjVMhmJPDH2k8w4OxsL kTaNJn4a5Yw9v7WABbZcdyoMOqCkLL3MPpbOnR2OX3NOB3VrSY1+U/mzySHHy8D+2d4sLm Kp4b6V8Z9IcjaT3aMr2txTmSEPqoECoSKI41qSGKqY51rpS8dYCp2M7K057C3Kev4PQXD5 2DCNLKj5bDaHCAYGbAA75Yfcsc1ZgPEREoeACBf9pDSYa1xUwPr3pXb8FKY8hw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=e3231f459f54e733d4ea86463b71de4c78e7e199 commit e3231f459f54e733d4ea86463b71de4c78e7e199 Author: Baptiste Daroussin AuthorDate: 2022-10-13 08:31:08 +0000 Commit: Baptiste Daroussin CommitDate: 2022-10-19 07:59:30 +0000 sort: deindent openfile (cherry picked from commit 958b0d46425395f8f4606ac5d12681d623282e9d) --- usr.bin/sort/file.c | 59 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c index 2e3b4e0a4350..c390b4c2a71f 100644 --- a/usr.bin/sort/file.c +++ b/usr.bin/sort/file.c @@ -527,46 +527,45 @@ openfile(const char *fn, const char *mode) { FILE *file; - if (strcmp(fn, "-") == 0) { + if (strcmp(fn, "-") == 0) return ((mode && mode[0] == 'r') ? stdin : stdout); - } else { - mode_t orig_file_mask = 0; - int is_tmp = file_is_tmp(fn); - if (is_tmp && (mode[0] == 'w')) - orig_file_mask = umask(S_IWGRP | S_IWOTH | - S_IRGRP | S_IROTH); + mode_t orig_file_mask = 0; + int is_tmp = file_is_tmp(fn); - if (is_tmp && (compress_program != NULL)) { - char *cmd; - size_t cmdsz; + if (is_tmp && (mode[0] == 'w')) + orig_file_mask = umask(S_IWGRP | S_IWOTH | + S_IRGRP | S_IROTH); - cmdsz = strlen(fn) + 128; - cmd = sort_malloc(cmdsz); + if (is_tmp && (compress_program != NULL)) { + char *cmd; + size_t cmdsz; - fflush(stdout); + cmdsz = strlen(fn) + 128; + cmd = sort_malloc(cmdsz); - if (mode[0] == 'r') - snprintf(cmd, cmdsz - 1, "cat %s | %s -d", - fn, compress_program); - else if (mode[0] == 'w') - snprintf(cmd, cmdsz - 1, "%s > %s", - compress_program, fn); - else - err(2, "%s", getstr(7)); + fflush(stdout); - if ((file = popen(cmd, mode)) == NULL) - err(2, NULL); + if (mode[0] == 'r') + snprintf(cmd, cmdsz - 1, "cat %s | %s -d", + fn, compress_program); + else if (mode[0] == 'w') + snprintf(cmd, cmdsz - 1, "%s > %s", + compress_program, fn); + else + err(2, "%s", getstr(7)); - sort_free(cmd); + if ((file = popen(cmd, mode)) == NULL) + err(2, NULL); - } else - if ((file = fopen(fn, mode)) == NULL) - err(2, NULL); + sort_free(cmd); - if (is_tmp && (mode[0] == 'w')) - umask(orig_file_mask); - } + } else + if ((file = fopen(fn, mode)) == NULL) + err(2, NULL); + + if (is_tmp && (mode[0] == 'w')) + umask(orig_file_mask); return (file); }