dj(1): Io_write: don't add to bufuse
This commit is contained in:
parent
abfe7046e7
commit
bab3cdd90e
6
src/dj.c
6
src/dj.c
@ -93,7 +93,9 @@ Io_write(struct Io *io){
|
|||||||
assert(io->bufuse > 0);
|
assert(io->bufuse > 0);
|
||||||
assert(io->bufuse <= io->bs);
|
assert(io->bufuse <= io->bs);
|
||||||
|
|
||||||
if((t = write(io->fd, io->buf, io->bufuse)) > 0)
|
if((t = write(io->fd, io->buf, io->bufuse)) < 0)
|
||||||
|
t = 0;
|
||||||
|
else if(t > 0)
|
||||||
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
||||||
|
|
||||||
io->bytes += t;
|
io->bytes += t;
|
||||||
@ -268,6 +270,7 @@ int main(int argc, char *argv[]){
|
|||||||
t = io[0].bufuse;
|
t = io[0].bufuse;
|
||||||
if(Io_read(&io[0])->bufuse == t && !noerror)
|
if(Io_read(&io[0])->bufuse == t && !noerror)
|
||||||
Io_read(&io[0]); /* second chance */
|
Io_read(&io[0]); /* second chance */
|
||||||
|
assert(io[0].bufuse >= t);
|
||||||
if(io[0].bufuse == t) /* that's all she wrote */
|
if(io[0].bufuse == t) /* that's all she wrote */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -321,6 +324,7 @@ int main(int argc, char *argv[]){
|
|||||||
t = io[1].bufuse;
|
t = io[1].bufuse;
|
||||||
if(Io_write(&io[1])->bufuse == t && !noerror)
|
if(Io_write(&io[1])->bufuse == t && !noerror)
|
||||||
Io_write(&io[1]); /* second chance */
|
Io_write(&io[1]); /* second chance */
|
||||||
|
assert(io[1].bufuse <= t);
|
||||||
if(io[1].bufuse == t){ /* no more love */
|
if(io[1].bufuse == t){ /* no more love */
|
||||||
count = 1;
|
count = 1;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user