dj(1): more formatting

This commit is contained in:
Emma Tebibyte 2024-07-12 15:32:30 -06:00
parent 6cf7fd9794
commit db0dd02d55
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270

View File

@ -138,9 +138,7 @@ static long parse(char *s){
errno = 0;
r = strtol(s, &s, 0);
return (*s == '\0' /* no chars left unparsed */ && errno == 0)
? r
: -1;
return (*s == '\0' && errno == 0) ? r : -1; /* no chars left unparsed */
}
static int usage(char *s){
@ -197,10 +195,10 @@ int main(int argc, char *argv[]) {
} else {
int fd;
if ((
fd = open(optarg, io[i].fl, creat_mode)) != -1
&& (fdisstd(io[i].fd) || close(io[i].fd) == 0
)) {
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;
@ -224,10 +222,10 @@ int main(int argc, char *argv[]) {
i = (c >= 'A' && c <= 'Z');
c |= 0b00100000; /* (ASCII) make lowercase */
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:
@ -243,8 +241,10 @@ int main(int argc, char *argv[]) {
for (i = 0; i < (sizeof io) / (sizeof *io); ++i) {
/* buffer allocation */
if ((io[i].buf = malloc(io[i].bs * (sizeof *(io[i].buf)))) == NULL) {
fprintf(stderr, "%s: Failed to allocate %zd bytes\n",
program_name, io[i].bs);
fprintf(
stderr, "%s: Failed to allocate %zd bytes\n",
program_name, io[i].bs
);
return EX_OSERR;
}