git: e3231f459f54 - stable/13 - sort: deindent openfile

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 19 Oct 2022 08:01:34 UTC
The branch stable/13 has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=e3231f459f54e733d4ea86463b71de4c78e7e199

commit e3231f459f54e733d4ea86463b71de4c78e7e199
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-13 08:31:08 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
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);
 }