From nobody Thu Oct 13 08:36:47 2022 X-Original-To: dev-commits-src-main@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 4Mp2tl3s9Pz4fRLQ; Thu, 13 Oct 2022 08:36:47 +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 4Mp2tl3Pnsz3syZ; Thu, 13 Oct 2022 08:36:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665650207; 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=LlrHv4gg8yVlKhVSB6lWtoy1ot39ppc4d7kN6j6dXx8=; b=cWuo7y2agXZ8CAcD6U0I5fbtlBIn88+MlV2jUjEXJSuAXgenK1DQV4xAYtQ+NzrD+0rvKR +bH6w2xGO+MwKHOlKcu/e6/mfyWX273SNm+QlK+yh3gqidTO+8JP6GHI7PGjAPlKHJ/Vch 3VbJtg8N130/6YvoWEErB4KV11FFTJ7ziNhLLbnjV0LHAgURTWdDlvXzb0xq7S9IqLcAk4 IxFsm3eilIGOjXfxgUkoYfY30M/GOY0xV/Q8me79J7L975mQtQmcYhHiqGdkzt9gSdD4j/ xDQRbzg+ZZwJBY9nUxc0PL0Ej9dUoN/2KgSmp7MH7/LXnA8nXHqmqMtq3vImXA== 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 4Mp2tl2SCczMgM; Thu, 13 Oct 2022 08:36:47 +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 29D8alKq089088; Thu, 13 Oct 2022 08:36:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29D8alb3089087; Thu, 13 Oct 2022 08:36:47 GMT (envelope-from git) Date: Thu, 13 Oct 2022 08:36:47 GMT Message-Id: <202210130836.29D8alb3089087@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 958b0d464253 - main - sort: deindent openfile List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 958b0d46425395f8f4606ac5d12681d623282e9d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665650207; 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=LlrHv4gg8yVlKhVSB6lWtoy1ot39ppc4d7kN6j6dXx8=; b=pS1H+c4zeMP1hr1cLy05OHEVudhZFKDdUI61ymHIznKTxvyaGd/y4irI6MsL+d+huEfJLI vIFGgCsSN7Nwg8Im0HCE/1PGe/FKhQ2ydvoxHhkBrREu1jX9HmWvbBeNyYHTVpcYwWD1yM gbFUbwx2cIuXcwOEu9pO35hdu+zPtPhOxEa+hftgD7OluYBup421CxPe+u36GwsIPJKu5S vgiIeYxZ3fyJOX1WIPSZt6y90eLEvO5mqmVzC8xHLvIkLRWZLO1QXGrq5Qq7iQxPusIblr MuCuaags5RXf55XjqvzqzPW/mtG5V74CMZoMZji5Djp813L2yQrZm1+NvOgg1g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665650207; a=rsa-sha256; cv=none; b=jOkNGaaa0q6zKyN1o9a7ESBGpCgnDtfkwRe+3zChQZXvGXhtYvz2RsiDDt0RtiQkXRQIgB XDLS9Fhn8bw3querkn/kdsN4ntwZlhVDd1Jaom3fID9GFYHMIXOtiiLpUdeJ3IH/8/YqTk uTy2fSaCZM9qCz08j0eKlGxGLR9alQ+mZVo0YgnX1SZpKxXLp5elY69b98FZjzL/1bnC3m 08zyavfm6VhkQpa3cLaGHM7S2vxFmMNnVQuEtDPiEIAza9B/XpGpF5BhJzRWaQgmTwD/98 GYgwYfzH49kWe1fLyYgFJLBCOaCHKOzcDNypLvwNJxSUIi2VN05BJ2dx5ltz2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=958b0d46425395f8f4606ac5d12681d623282e9d commit 958b0d46425395f8f4606ac5d12681d623282e9d Author: Baptiste Daroussin AuthorDate: 2022-10-13 08:31:08 +0000 Commit: Baptiste Daroussin CommitDate: 2022-10-13 08:31:34 +0000 sort: deindent openfile --- 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); }