dj(1): fix some type issues
This commit is contained in:
parent
6ed7089b25
commit
abfe7046e7
22
src/dj.c
22
src/dj.c
@ -73,15 +73,16 @@ Io_read(struct Io *io){
|
|||||||
assert(io->bs > 0);
|
assert(io->bs > 0);
|
||||||
assert(io->bufuse < io->bs);
|
assert(io->bufuse < io->bs);
|
||||||
|
|
||||||
io->bufuse += (t = read(io->fd, &(io->buf)[io->bufuse],
|
if((t = read(io->fd, &(io->buf)[io->bufuse], io->bs - io->bufuse)) < 0)
|
||||||
io->bs - io->bufuse));
|
t = 0;
|
||||||
|
|
||||||
|
io->bufuse += t;
|
||||||
|
io->bytes += t;
|
||||||
|
io->prec += (0 < io->bufuse && io->bufuse < io->bs);
|
||||||
|
io->rec += (io->bufuse == io->bs);
|
||||||
|
|
||||||
assert(io->bufuse <= io->bs);
|
assert(io->bufuse <= io->bs);
|
||||||
|
|
||||||
io->bytes += t;
|
|
||||||
io->prec += (0 < io->bufuse && io->bufuse < io->bs);
|
|
||||||
io->rec += (io->bufuse == io->bs);
|
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +97,8 @@ Io_write(struct Io *io){
|
|||||||
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
||||||
|
|
||||||
io->bytes += t;
|
io->bytes += t;
|
||||||
io->prec += (0 < io->bufuse && 0 < t);
|
io->prec += (t > 0 && io->bufuse > 0);
|
||||||
io->rec += (io->bufuse == 0 && 0 < t);
|
io->rec += (t > 0 && io->bufuse == 0);
|
||||||
|
|
||||||
return io;
|
return io;
|
||||||
}
|
}
|
||||||
@ -258,8 +259,9 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
{ /* read */
|
{ /* read */
|
||||||
char skipping;
|
char skipping;
|
||||||
int t;
|
size_t t;
|
||||||
|
|
||||||
|
/* hack to intentionally get a partial read from Io_read */
|
||||||
if((skipping = (io[0].seek > 0)) && io[0].seek < io[0].bs)
|
if((skipping = (io[0].seek > 0)) && io[0].seek < io[0].bs)
|
||||||
io[0].bufuse = io[0].bs - io[0].seek;
|
io[0].bufuse = io[0].bs - io[0].seek;
|
||||||
|
|
||||||
@ -270,8 +272,6 @@ int main(int argc, char *argv[]){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if(/* t < io[0].bufuse && */ io[0].bufuse < io[0].bs){
|
if(/* t < io[0].bufuse && */ io[0].bufuse < io[0].bs){
|
||||||
assert(!skipping);
|
|
||||||
|
|
||||||
fprintf(stderr, "%s: Partial read:\n\t", program_name);
|
fprintf(stderr, "%s: Partial read:\n\t", program_name);
|
||||||
fprintio(stderr, fmt, io);
|
fprintio(stderr, fmt, io);
|
||||||
if(!noerror)
|
if(!noerror)
|
||||||
|
Loading…
Reference in New Issue
Block a user