forked from bonsai/harakit
dj(1): more formatting
This commit is contained in:
parent
6cf7fd9794
commit
db0dd02d55
26
src/dj.c
26
src/dj.c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user