forked from bonsai/harakit
dj(1): more refactor (get rid of the c scratch variable, use scoping)
This commit is contained in:
parent
2cfae0e8d7
commit
3a66022c6d
17
src/dj.c
17
src/dj.c
@ -287,7 +287,7 @@ int main(int argc, char *argv[]){
|
|||||||
program_name = argv[0];
|
program_name = argv[0];
|
||||||
while((c = getopt(argc, argv, "a:b:B:c:i:hHns:S:o:")) != -1)
|
while((c = getopt(argc, argv, "a:b:B:c:i:hHns:S:o:")) != -1)
|
||||||
switch(c){
|
switch(c){
|
||||||
case 'i': case 'o': i = (c == 'o')
|
case 'i': case 'o': i = (c == 'o');
|
||||||
if(optarg[0] == '-' && optarg[1] == '\0'){ /* optarg == "-" */
|
if(optarg[0] == '-' && optarg[1] == '\0'){ /* optarg == "-" */
|
||||||
io[i].fd = i ? STDIN_FILENO : STDOUT_FILENO;
|
io[i].fd = i ? STDIN_FILENO : STDOUT_FILENO;
|
||||||
io[i].fn = i ? stdin_name : stdout_name;
|
io[i].fn = i ? stdin_name : stdout_name;
|
||||||
@ -356,27 +356,30 @@ int main(int argc, char *argv[]){
|
|||||||
++io[0].rec;
|
++io[0].rec;
|
||||||
|
|
||||||
/* write */
|
/* write */
|
||||||
do{ if(io[1].bs > io[0].bs){
|
do{
|
||||||
|
int t;
|
||||||
|
|
||||||
|
if(io[1].bs > io[0].bs){
|
||||||
Io_bufxapp(&io[1], &io[0]);
|
Io_bufxapp(&io[1], &io[0]);
|
||||||
if(io[0].bs + io[1].bufuse <= io[1].bs && count != 1)
|
if(io[0].bs + io[1].bufuse <= io[1].bs && count != 1)
|
||||||
continue; /* we could write more */
|
continue; /* we could write more */
|
||||||
}else
|
}else
|
||||||
Io_bufxfer(&io[1], &io[0], MIN(io[0].bufuse, io[1].bs));
|
Io_bufxfer(&io[1], &io[0], MIN(io[0].bufuse, io[1].bs));
|
||||||
|
|
||||||
c = io[1].bufuse;
|
t = io[1].bufuse;
|
||||||
Io_write(&io[1]);
|
Io_write(&io[1]);
|
||||||
if(!noerror && io[1].bufuse == c)
|
if(!noerror && io[1].bufuse == t)
|
||||||
Io_write(&io[1]); /* second chance */
|
Io_write(&io[1]); /* second chance */
|
||||||
if(c == io[1].bufuse){ /* no more love */
|
if(t == io[1].bufuse){ /* no more love */
|
||||||
count = 1;
|
count = 1;
|
||||||
break;
|
break;
|
||||||
}else if(c > io[1].bufuse && io[1].bufuse > 0){
|
}else if(t > io[1].bufuse && io[1].bufuse > 0){
|
||||||
io[1].prec += 1;
|
io[1].prec += 1;
|
||||||
fprintf(stderr, "%s: Partial write:\n\t", program_name);
|
fprintf(stderr, "%s: Partial write:\n\t", program_name);
|
||||||
output(io, fmt_output);
|
output(io, fmt_output);
|
||||||
if(!noerror)
|
if(!noerror)
|
||||||
count = 1;
|
count = 1;
|
||||||
}else if(io[1].bufuse == 0 && c < io[1].bs)
|
}else if(io[1].bufuse == 0 && t < io[1].bs)
|
||||||
++io[1].prec;
|
++io[1].prec;
|
||||||
else
|
else
|
||||||
++io[1].rec;
|
++io[1].rec;
|
||||||
|
Loading…
Reference in New Issue
Block a user