git: d5d3f5dab209 - main - uu{encode,decode}: improve style

From: Piotr Pawel Stefaniak <pstef_at_FreeBSD.org>
Date: Mon, 28 Mar 2022 07:21:42 UTC
The branch main has been updated by pstef:

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

commit d5d3f5dab209a4643dd189b2012b60329c220662
Author:     Piotr Pawel Stefaniak <pstef@FreeBSD.org>
AuthorDate: 2021-11-08 14:31:01 +0000
Commit:     Piotr Pawel Stefaniak <pstef@FreeBSD.org>
CommitDate: 2022-03-28 07:01:35 +0000

    uu{encode,decode}: improve style
---
 usr.bin/uudecode/uudecode.c | 27 ++++++++++++++-------------
 usr.bin/uuencode/uuencode.c | 17 +++++++++--------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/usr.bin/uudecode/uudecode.c b/usr.bin/uudecode/uudecode.c
index a0cfcf23fb13..6d31d96ad958 100644
--- a/usr.bin/uudecode/uudecode.c
+++ b/usr.bin/uudecode/uudecode.c
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <libgen.h>
 #include <pwd.h>
 #include <resolv.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -69,7 +70,7 @@ __FBSDID("$FreeBSD$");
 
 static const char *infile, *outfile;
 static FILE *infp, *outfp;
-static int base64, cflag, iflag, oflag, pflag, rflag, sflag;
+static bool base64, cflag, iflag, oflag, pflag, rflag, sflag;
 
 static void	usage(void);
 static int	decode(void);
@@ -83,42 +84,42 @@ main(int argc, char *argv[])
 	int rval, ch;
 
 	if (strcmp(basename(argv[0]), "b64decode") == 0)
-		base64 = 1;
+		base64 = true;
 
 	while ((ch = getopt(argc, argv, "cimo:prs")) != -1) {
 		switch (ch) {
 		case 'c':
 			if (oflag || rflag)
 				usage();
-			cflag = 1; /* multiple uudecode'd files */
+			cflag = true; /* multiple uudecode'd files */
 			break;
 		case 'i':
-			iflag = 1; /* ask before override files */
+			iflag = true; /* ask before override files */
 			break;
 		case 'm':
-			base64 = 1;
+			base64 = true;
 			break;
 		case 'o':
 			if (cflag || pflag || rflag || sflag)
 				usage();
-			oflag = 1; /* output to the specified file */
-			sflag = 1; /* do not strip pathnames for output */
+			oflag = true; /* output to the specified file */
+			sflag = true; /* do not strip pathnames for output */
 			outfile = optarg; /* set the output filename */
 			break;
 		case 'p':
 			if (oflag)
 				usage();
-			pflag = 1; /* print output to stdout */
+			pflag = true; /* print output to stdout */
 			break;
 		case 'r':
 			if (cflag || oflag)
 				usage();
-			rflag = 1; /* decode raw data */
+			rflag = true; /* decode raw data */
 			break;
 		case 's':
 			if (oflag)
 				usage();
-			sflag = 1; /* do not strip pathnames for output */
+			sflag = true; /* do not strip pathnames for output */
 			break;
 		default:
 			usage();
@@ -185,14 +186,14 @@ decode2(void)
 	struct stat st;
 	char buf[MAXPATHLEN + 1];
 
-	base64 = 0;
+	base64 = false;
 	/* search for header line */
 	for (;;) {
 		if (fgets(buf, sizeof(buf), infp) == NULL)
 			return (EOF);
 		p = buf;
 		if (strncmp(p, "begin-base64 ", 13) == 0) {
-			base64 = 1;
+			base64 = true;
 			p += 13;
 		} else if (strncmp(p, "begin ", 6) == 0)
 			p += 6;
@@ -378,7 +379,7 @@ uu_decode(void)
 			} else {
 				if (i >= 1) {
 					if (!(IS_DEC(*p) && IS_DEC(*(p + 1))))
-	                                	OUT_OF_RANGE;
+						OUT_OF_RANGE;
 					ch = DEC(p[0]) << 2 | DEC(p[1]) >> 4;
 					putc(ch, outfp);
 				}
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c
index 05ead32c7183..b5eff44f1651 100644
--- a/usr.bin/uuencode/uuencode.c
+++ b/usr.bin/uuencode/uuencode.c
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include <libgen.h>
 #include <resolv.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -68,18 +69,18 @@ static void usage(void);
 
 static FILE *output;
 static int mode;
-static char raw = 0;
+static bool raw;
 static char **av;
 
 int
 main(int argc, char *argv[])
 {
 	struct stat sb;
-	int base64;
+	bool base64;
 	int ch;
 	const char *outfile;
 
-	base64 = 0;
+	base64 = false;
 	outfile = NULL;
 
 	if (strcmp(basename(argv[0]), "b64encode") == 0)
@@ -88,13 +89,13 @@ main(int argc, char *argv[])
 	while ((ch = getopt(argc, argv, "mo:r")) != -1) {
 		switch (ch) {
 		case 'm':
-			base64 = 1;
+			base64 = true;
 			break;
 		case 'o':
 			outfile = optarg;
 			break;
 		case 'r':
-			raw = 1;
+			raw = true;
 			break;
 		case '?':
 		default:
@@ -104,7 +105,7 @@ main(int argc, char *argv[])
 	argv += optind;
 	argc -= optind;
 
-	switch(argc) {
+	switch (argc) {
 	case 2:			/* optional first argument is input file */
 		if (!freopen(*argv, "r", stdin) || fstat(fileno(stdin), &sb))
 			err(1, "%s", *argv);
@@ -179,8 +180,8 @@ base64_encode(void)
 static void
 encode(void)
 {
-	register int ch, n;
-	register char *p;
+	int ch, n;
+	char *p;
 	char buf[80];
 
 	if (!raw)