dj(1): no more pointer arithmetic
This commit is contained in:
parent
fe175cab19
commit
1fab60d779
10
src/dj.c
10
src/dj.c
@ -90,7 +90,7 @@ Io_write(struct Io *io){
|
||||
assert(io->bufuse <= io->bs);
|
||||
|
||||
if((t = write(io->fd, io->buf, io->bufuse)) > 0)
|
||||
memmove(io->buf, io->buf + t, (io->bufuse -= t));
|
||||
memmove(io->buf, &(io->buf)[t], (io->bufuse -= t));
|
||||
|
||||
io->bytes += t;
|
||||
io->prec += (t > 0 && io->bufuse > 0);
|
||||
@ -288,7 +288,7 @@ int main(int argc, char *argv[]){
|
||||
count = 1;
|
||||
if(align >= 0){
|
||||
/* fill the rest of the ibuf with padding */
|
||||
memset(io[0].buf + io[0].bufuse, align,
|
||||
memset(&(io[0].buf)[io[0].bufuse], align,
|
||||
io[0].bs - io[0].bufuse);
|
||||
io->bufuse = io->bs;
|
||||
}
|
||||
@ -306,16 +306,16 @@ int main(int argc, char *argv[]){
|
||||
memcpy(io[1].buf, io[0].buf,
|
||||
(io[1].bufuse = (n = MIN(io[0].bufuse, io[1].bs))));
|
||||
/* permute the copied units out of ibuf */
|
||||
memmove(io[0].buf, io[0].buf + n, (io[0].bufuse -= n));
|
||||
memmove(io[0].buf, &(io[0].buf)[n], (io[0].bufuse -= n));
|
||||
}else /* if(io[0].bs < io[1].bs) */ {
|
||||
int n;
|
||||
|
||||
/* drain what we can from ibuf */
|
||||
memcpy(io[1].buf + io[1].bufuse, io[0].buf,
|
||||
memcpy(&(io[1].buf)[io[1].bufuse], io[0].buf,
|
||||
(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)
|
||||
|
Loading…
Reference in New Issue
Block a user