diff options
| author | David Schultz <das@FreeBSD.org> | 2009-01-17 05:38:14 +0000 | 
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2009-01-17 05:38:14 +0000 | 
| commit | 6ec351236802ad416d6f03498db9df75b09dacec (patch) | |
| tree | 63323577b957802abb4175fe8fa7aa2744defe9f /lib/libc/stdio/printfcommon.h | |
| parent | 589d604bf94ac7bd516772c9ee98afc800713680 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/printfcommon.h')
| -rw-r--r-- | lib/libc/stdio/printfcommon.h | 36 | 
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/libc/stdio/printfcommon.h b/lib/libc/stdio/printfcommon.h index a3a32f68d9aa..ab49b313233f 100644 --- a/lib/libc/stdio/printfcommon.h +++ b/lib/libc/stdio/printfcommon.h @@ -64,14 +64,13 @@ struct io_state {  	FILE *fp;  	struct __suio uio;	/* output information: summary */  	struct __siov iov[NIOV];/* ... and individual io vectors */ -	struct __siov *iovp;	/* pointer to next free slot in iov */  };  static inline void  io_init(struct io_state *iop, FILE *fp)  { -	iop->uio.uio_iov = iop->iovp = iop->iov; +	iop->uio.uio_iov = iop->iov;  	iop->uio.uio_resid = 0;  	iop->uio.uio_iovcnt = 0;  	iop->fp = fp; @@ -85,15 +84,13 @@ static inline int  io_print(struct io_state *iop, const CHAR * __restrict ptr, int len)  { -	iop->iovp->iov_base = (char *)ptr; -	iop->iovp->iov_len = len; +	iop->iov[iop->uio.uio_iovcnt].iov_base = (char *)ptr; +	iop->iov[iop->uio.uio_iovcnt].iov_len = len;  	iop->uio.uio_resid += len; -	iop->iovp++; -	if (++iop->uio.uio_iovcnt >= NIOV) { -		iop->iovp = iop->iov; +	if (++iop->uio.uio_iovcnt >= NIOV)  		return (__sprint(iop->fp, &iop->uio)); -	} -	return (0); +	else +		return (0);  }  /* @@ -114,14 +111,14 @@ static const CHAR zeroes[PADSIZE] =  static inline int  io_pad(struct io_state *iop, int howmany, const CHAR * __restrict with)  { +	int n; -	while (howmany > PADSIZE) { -		if (io_print(iop, with, PADSIZE)) +	while (howmany > 0) { +		n = (howmany >= PADSIZE) ? PADSIZE : howmany; +		if (io_print(iop, with, n))  			return (-1); -		howmany -= PADSIZE; +		howmany -= n;  	} -	if (howmany > 0 && io_print(iop, with, howmany)) -		return (-1);  	return (0);  } @@ -138,16 +135,19 @@ io_printandpad(struct io_state *iop, const CHAR *p, const CHAR *ep,  	p_len = ep - p;  	if (p_len > len)  		p_len = len; -	if (p_len > 0 && io_print(iop, p, p_len)) -		return (-1); -	return (io_pad(iop, len - (p_len > 0 ? p_len : 0), with)); +	if (p_len > 0) { +		if (io_print(iop, p, p_len)) +			return (-1); +	} else { +		p_len = 0; +	} +	return (io_pad(iop, len - p_len, with));  }  static inline int  io_flush(struct io_state *iop)  { -	iop->iovp = iop->iov;  	return (__sprint(iop->fp, &iop->uio));  }  | 
