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