Stylify of uudecode(1)

Part of PR bin/124739.

PR:		bin/124739
Submitted by:	Mark Andrews <marka@isc.org>
This commit is contained in:
Edwin Groothuis 2010-10-18 03:59:55 +00:00
parent 4bc8fad7bd
commit 4b26f3413e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=214002

View file

@ -128,7 +128,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (*argv) {
if (*argv != NULL) {
rval = 0;
do {
infp = fopen(infile = *argv, "r");
@ -305,6 +305,7 @@ decode2(void)
static int
getline(char *buf, size_t size)
{
if (fgets(buf, size, infp) != NULL)
return (2);
if (rflag)
@ -341,8 +342,10 @@ uu_decode(void)
/* for each input line */
for (;;) {
switch (getline(buf, sizeof(buf))) {
case 0: return (0);
case 1: return (1);
case 0:
return (0);
case 1:
return (1);
}
#define DEC(c) (((c) - ' ') & 077) /* single character decode */
@ -373,8 +376,7 @@ uu_decode(void)
putc(ch, outfp);
ch = DEC(p[2]) << 6 | DEC(p[3]);
putc(ch, outfp);
}
else {
} else {
if (i >= 1) {
if (!(IS_DEC(*p) && IS_DEC(*(p + 1))))
OUT_OF_RANGE;
@ -399,9 +401,12 @@ uu_decode(void)
}
}
switch (getline(buf, sizeof(buf))) {
case 0: return (0);
case 1: return (1);
default: return (checkend(buf, "end", "no \"end\" line"));
case 0:
return (0);
case 1:
return (1);
default:
return (checkend(buf, "end", "no \"end\" line"));
}
}
@ -418,17 +423,18 @@ base64_decode(void)
case 1: return (1);
}
n = b64_pton(inbuf, outbuf, sizeof(outbuf));
if (n < 0)
break;
fwrite(outbuf, 1, n, outfp);
}
return (checkend(inbuf, "====",
"error decoding base64 input stream"));
return (checkend(inbuf, "====", "error decoding base64 input stream"));
}
static void
usage(void)
{
(void)fprintf(stderr,
"usage: uudecode [-cimprs] [file ...]\n"
" uudecode [-i] -o output_file [file]\n"