A couple more stylistic changes to uudecode(1)

This commit is contained in:
sin 2014-02-04 14:44:43 +00:00
parent ed9985205b
commit bf2b270946

View File

@ -40,23 +40,19 @@ main(int argc, char *argv[])
if (argc == 0) {
checkheader(stdin, "<stdin>", "begin ", &mode, &fname);
nfp = checkfile(fname);
if (nfp == NULL)
if ((nfp = checkfile(fname)) == NULL)
eprintf("fopen %s:", fname);
uudecode(stdin, nfp);
fclose(nfp);
} else {
if (!(fp = fopen(argv[0], "r")))
if ((fp = fopen(argv[0], "r")) == NULL)
eprintf("fopen %s:", argv[0]);
checkheader(fp, argv[0], "begin ", &mode, &fname);
nfp = checkfile(fname);
if (nfp == NULL) {
fclose(fp);
if ((nfp = checkfile(fname)) == NULL)
eprintf("fopen %s:", fname);
}
uudecode(fp, nfp);
fclose(fp);
fclose(nfp);
fclose(fp);
}
if (fchmod(fileno(nfp), mode) < 0)
eprintf("chmod %s:", fname);
@ -126,9 +122,8 @@ checkmode(const char *str,mode_t *validmode)
if (str == NULL || str == '\0')
eprintf("invalid mode\n");
octal = strtol(str, &end, 8);
if (*end == '\0') { /* successful conversion from a valid str */
if (*end == '\0') {
if (octal >= 0 && octal <= 07777) {
if(octal & 04000) *validmode |= S_ISUID;
if(octal & 02000) *validmode |= S_ISGID;
@ -142,7 +137,6 @@ checkmode(const char *str,mode_t *validmode)
if(octal & 00004) *validmode |= S_IROTH;
if(octal & 00002) *validmode |= S_IWOTH;
if(octal & 00001) *validmode |= S_IXOTH;
*validmode &= 07777;
}
}
}
@ -167,7 +161,8 @@ uudecode(FILE *fp, FILE *outfp)
*nl = '\0';
else
eprintf("no newline found, aborting\n");
if ((i = DEC(*p)) <= 0) /* check for last line */
/* check for last line */
if ((i = DEC(*p)) <= 0)
break;
for (++p; i > 0; p += 4, i -= 3) {
if (i >= 3) {