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];
|
||||
while((c = getopt(argc, argv, "a:b:B:c:i:hHns:S:o:")) != -1)
|
||||
switch(c){
|
||||
case 'i': case 'o': i = (c == 'o')
|
||||
case 'i': case 'o': i = (c == 'o');
|
||||
if(optarg[0] == '-' && optarg[1] == '\0'){ /* optarg == "-" */
|
||||
io[i].fd = i ? STDIN_FILENO : STDOUT_FILENO;
|
||||
io[i].fn = i ? stdin_name : stdout_name;
|
||||
@ -356,27 +356,30 @@ int main(int argc, char *argv[]){
|
||||
++io[0].rec;
|
||||
|
||||
/* 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]);
|
||||
if(io[0].bs + io[1].bufuse <= io[1].bs && count != 1)
|
||||
continue; /* we could write more */
|
||||
}else
|
||||
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]);
|
||||
if(!noerror && io[1].bufuse == c)
|
||||
if(!noerror && io[1].bufuse == t)
|
||||
Io_write(&io[1]); /* second chance */
|
||||
if(c == io[1].bufuse){ /* no more love */
|
||||
if(t == io[1].bufuse){ /* no more love */
|
||||
count = 1;
|
||||
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;
|
||||
fprintf(stderr, "%s: Partial write:\n\t", program_name);
|
||||
output(io, fmt_output);
|
||||
if(!noerror)
|
||||
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;
|
||||
else
|
||||
++io[1].rec;
|
||||
|
Loading…
Reference in New Issue
Block a user