dj(1): revert some formatting changes

This commit is contained in:
Emma Tebibyte 2024-07-15 13:16:05 -06:00
parent c2e6744e2b
commit a3ceb845e3
Signed by: emma
GPG Key ID: 06FA419A1698C270

View File

@ -142,7 +142,7 @@ parse(char *s) {
errno = 0;
r = strtol(s, &s, 0);
return (*s == '\0' && errno == 0) ? r : -1; /* no chars left unparsed */
return (*s == '\0' /* no chars left unparsed */ && errno == 0) ? r : -1;
}
static int
@ -182,59 +182,59 @@ int main(int argc, char *argv[]) {
io[i].seek = 0;
}
if (!(argc < 0)) { usage(program_name); }
if (argc > 0) {
int c;
int c;
program_name = argv[0];
while ((c = getopt(argc, argv, "a:b:B:c:i:hHns:S:o:")) != -1) {
switch (c) {
case 'i': case 'o': /* input, output */
i = (c == 'o');
program_name = argv[0];
while ((c = getopt(argc, argv, "a:b:B:c:i:hHns:S:o:")) != -1) {
switch (c) {
case 'i': case 'o': /* input, output */
i = (c == 'o');
/* optarg == "-" (stdin/stdout) */
if (optarg[0] == '-' && optarg[1] == '\0') {
io[i].fd = i == 0 ? STDIN_FILENO : STDOUT_FILENO;
io[i].fn = i == 0 ? stdin_name : stdout_name;
break;
} else {
int fd;
/* optarg == "-" (stdin/stdout) */
if (optarg[0] == '-' && optarg[1] == '\0') {
io[i].fd = i == 0 ? STDIN_FILENO : STDOUT_FILENO;
io[i].fn = i == 0 ? stdin_name : stdout_name;
break;
} else {
int fd;
if (
(fd = open(optarg, io[i].fl, creat_mode)) != -1
&& (fdisstd(io[i].fd) || close(io[i].fd) == 0)
) {
io[i].fd = fd;
io[i].fn = optarg;
break;
}
}
if (
(fd = open(optarg, io[i].fl, creat_mode)) != -1
&& (fdisstd(io[i].fd) || close(io[i].fd) == 0)
) {
io[i].fd = fd;
io[i].fn = optarg;
return oserr(optarg, errno); /* break; */
case 'n': noerror = 1; break; /* retry failed reads once */
case 'H': fmt = fmt_human; break; /* human-readable output */
case 'a': /* input buffer padding */
if (optarg[0] == '\0' || optarg[1] == '\0') {
align = optarg[0];
break;
}
}
/* FALLTHROUGH */
case 'c': /* number of reads */
case 'b': case 'B': /* input/output block size */
case 's': case 'S': /* (s)kip/(S)eek in input/output */
if (c == 'c' && (count = parse(optarg)) >= 0) { break; }
return oserr(optarg, errno); /* break; */
case 'n': noerror = 1; break; /* retry failed reads once */
case 'H': fmt = fmt_human; break; /* human-readable output */
case 'a': /* input buffer padding */
if (optarg[0] == '\0' || optarg[1] == '\0') {
align = optarg[0];
break;
}
/* FALLTHROUGH */
case 'c': /* number of reads */
case 'b': case 'B': /* input/output block size */
case 's': case 'S': /* (s)kip/(S)eek in input/output */
if (c == 'c' && (count = parse(optarg)) >= 0) { break; }
i = (c >= 'A' && c <= 'Z');
c |= 0x20; /* 0b 0010 0000 (ASCII make lowercase) */
i = (c >= 'A' && c <= 'Z');
c |= 0x20 /* ASCII make lowercase 0b 0010 0000 */
if (
(c == 'b' && (io[i].bs = parse(optarg)) > 0)
|| (c == 's' && (io[i].seek = parse(optarg)) >= 0)
) { break; }
if (
(c == 'b' && (io[i].bs = parse(optarg)) > 0)
|| (c == 's' && (io[i].seek = parse(optarg)) >= 0)
) { break; }
/* FALLTHROUGH */
default:
return usage(program_name);
/* FALLTHROUGH */
default:
return usage(program_name);
}
}
}
@ -272,7 +272,9 @@ int main(int argc, char *argv[]) {
if (Io_write(&io[1])->bufuse == t && !noerror && io[1].error == 0) {
Io_write(&io[1]); /* second chance */
}
if (io[1].error != 0) { return oserr(io[1].fn, io[1].error); }
if (io[1].error != 0) {
return oserr(io[1].fn, io[1].error);
}
} while ((io[1].seek -= (t - io[1].bufuse)) > 0 && io[1].bufuse != t);
io[1].bufuse = 0;