dj(1): more work adapting hard skipping to the main loop
This commit is contained in:
parent
1fab60d779
commit
9f420131ee
16
src/dj.c
16
src/dj.c
@ -270,23 +270,27 @@ int main(int argc, char *argv[]){
|
||||
return oserr(io[i].fn);
|
||||
|
||||
do{
|
||||
assert(io[0].bufuse == 0);
|
||||
|
||||
{ /* read */
|
||||
static char skipping = 0;
|
||||
int t;
|
||||
|
||||
if(io[0].seek > 0)
|
||||
skipping = 1;
|
||||
|
||||
if(Io_read(&io[0])->bufuse == 0 && !noerror)
|
||||
t = io[0].bufuse;
|
||||
if(Io_read(&io[0])->bufuse == t && !noerror)
|
||||
Io_read(&io[0]); /* second chance */
|
||||
if(io[0].bufuse == 0) /* that's all she wrote */
|
||||
if(io[0].bufuse == t) /* that's all she wrote */
|
||||
break;
|
||||
|
||||
if(io[0].bufuse < io[0].bs){
|
||||
if(/* t < io[0].bufuse && */ io[0].bufuse < io[0].bs){
|
||||
fprintf(stderr, "%s: Partial read:\n\t", program_name);
|
||||
fprintio(stderr, fmt, io);
|
||||
if(!noerror)
|
||||
count = 1;
|
||||
if(align >= 0){
|
||||
if(!skipping && align >= 0){
|
||||
/* fill the rest of the ibuf with padding */
|
||||
memset(&(io[0].buf)[io[0].bufuse], align,
|
||||
io[0].bs - io[0].bufuse);
|
||||
@ -315,7 +319,7 @@ int main(int argc, char *argv[]){
|
||||
(n = MIN(io[0].bufuse, io[1].bs - io[1].bufuse)));
|
||||
io[1].bufuse += n;
|
||||
/* permute out the copied units */
|
||||
memmove(io[0].buf, &{io[0].buf)[n], io[0].bs - n);
|
||||
memmove(io[0].buf, &(io[0].buf)[n], io[0].bs - n);
|
||||
io[0].bufuse -= n;
|
||||
|
||||
if(io[0].bs + io[1].bufuse <= io[1].bs && count != 1)
|
||||
@ -330,7 +334,7 @@ int main(int argc, char *argv[]){
|
||||
break;
|
||||
}
|
||||
|
||||
if(0 < io[1].bufuse && io[1].bufuse < t){
|
||||
if(0 < io[1].bufuse /* && io[1].bufuse < t */){
|
||||
fprintf(stderr, "%s: Partial write:\n\t", program_name);
|
||||
fprintio(stderr, fmt, io);
|
||||
if(!noerror)
|
||||
|
Loading…
Reference in New Issue
Block a user