From 6c0fd53b323fe1e401dc8c67516a053bfe61f962 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 13 Nov 1996 20:00:03 +0000 Subject: Bruce says: "You have been programming in the kernel for too long :-)." and he's right ... I forgot about this floating point stuff you can use in user-land :-) Increase precision of duration to microseconds. No heuristics to avoid overflow in calculation needed - just depend on DBL_MAX being a bit larger than LONG_MAX. Use double instead of `struct timeval' in dd.h so that everything doesn't have to include . Fixed style bugs in recent and old FreeBSD changes. Reviewed by: phk Submitted by: bde --- bin/dd/conv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'bin/dd/conv.c') diff --git a/bin/dd/conv.c b/bin/dd/conv.c index 41c5909..09ee56a 100644 --- a/bin/dd/conv.c +++ b/bin/dd/conv.c @@ -34,7 +34,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: conv.c,v 1.3 1994/09/24 02:54:44 davidg Exp $ + * $Id: conv.c,v 1.4 1996/11/12 23:09:04 phk Exp $ */ #ifndef lint @@ -45,7 +45,6 @@ static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94"; #include #include -#include #include "dd.h" #include "extern.h" @@ -62,7 +61,7 @@ def() int cnt; u_char *inp, *t; - if ((t = ctab)) + if ((t = ctab) != NULL) for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp) *inp = t[*inp]; @@ -106,7 +105,6 @@ block() int ch, cnt, maxlen; u_char *inp, *outp, *t; - ch = 0; /* * Record truncation can cross block boundaries. If currently in a * truncation state, keep tossing characters until reach a newline. @@ -131,9 +129,10 @@ block() * Copy records (max cbsz size chunks) into the output buffer. The * translation is done as we copy into the output buffer. */ + ch = 0; /* Help the compiler. */ for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) { maxlen = MIN(cbsz, in.dbcnt); - if ((t = ctab)) + if ((t = ctab) != NULL) for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n'; ++cnt) *outp++ = t[ch]; @@ -217,7 +216,7 @@ unblock() u_char *inp, *t; /* Translation and case conversion. */ - if ((t = ctab)) + if ((t = ctab) != NULL) for (cnt = in.dbrcnt, inp = in.dbp; cnt--;) *--inp = t[*inp]; /* -- cgit v1.1