diff options
author | green <green@FreeBSD.org> | 1999-06-19 19:49:35 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 1999-06-19 19:49:35 +0000 |
commit | 90290405cf286aa3cad1ac14a252091d056f8001 (patch) | |
tree | 48c102bddfafea67547cedd3bec973c1e7ff91c9 /bin/dd/conv.c | |
parent | 63ed685667d63c71e409de1ac005284dad01bf15 (diff) | |
download | FreeBSD-src-90290405cf286aa3cad1ac14a252091d056f8001.zip FreeBSD-src-90290405cf286aa3cad1ac14a252091d056f8001.tar.gz |
Miscellaneous dd(1) changes: mainly fixing variable types (size_t, ssize_t,
off_t, int, u_int64_t, etc.). dd(1) should now work properly with REALLY
big amounts of data.
Diffstat (limited to 'bin/dd/conv.c')
-rw-r--r-- | bin/dd/conv.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/bin/dd/conv.c b/bin/dd/conv.c index 84552a2..d0cfe15 100644 --- a/bin/dd/conv.c +++ b/bin/dd/conv.c @@ -40,7 +40,7 @@ static char sccsid[] = "@(#)conv.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id: conv.c,v 1.9 1998/05/06 06:51:30 charnier Exp $"; + "$Id: conv.c,v 1.10 1998/05/13 07:33:39 charnier Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -60,7 +60,7 @@ static const char rcsid[] = void def() { - int cnt; + size_t cnt; u_char *inp, *t; if ((t = ctab) != NULL) @@ -104,7 +104,8 @@ void block() { static int intrunc; - int ch, cnt, maxlen; + int ch; + size_t cnt, maxlen; u_char *inp, *outp, *t; /* @@ -114,8 +115,8 @@ block() * left empty. */ if (intrunc) { - for (inp = in.db, cnt = in.dbrcnt; - cnt && *inp++ != '\n'; --cnt); + for (inp = in.db, cnt = in.dbrcnt; cnt && *inp++ != '\n'; --cnt) + ; if (!cnt) { in.dbcnt = 0; in.dbp = in.db; @@ -135,12 +136,12 @@ block() for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) { maxlen = MIN(cbsz, in.dbcnt); if ((t = ctab) != NULL) - for (cnt = 0; - cnt < maxlen && (ch = *inp++) != '\n'; ++cnt) + for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n'; + ++cnt) *outp++ = t[ch]; else - for (cnt = 0; - cnt < maxlen && (ch = *inp++) != '\n'; ++cnt) + for (cnt = 0; cnt < maxlen && (ch = *inp++) != '\n'; + ++cnt) *outp++ = ch; /* * Check for short record without a newline. Reassemble the @@ -198,8 +199,8 @@ block_close() if (in.dbcnt) { ++st.trunc; memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt); - (void)memset(out.dbp + in.dbcnt, - ctab ? ctab[' '] : ' ', cbsz - in.dbcnt); + (void)memset(out.dbp + in.dbcnt, ctab ? ctab[' '] : ' ', + cbsz - in.dbcnt); out.dbcnt += cbsz; } } @@ -214,7 +215,7 @@ block_close() void unblock() { - int cnt; + size_t cnt; u_char *inp, *t; /* Translation and case conversion. */ @@ -227,16 +228,16 @@ unblock() * spaces. */ for (inp = in.db; in.dbcnt >= cbsz; inp += cbsz, in.dbcnt -= cbsz) { - for (t = inp + cbsz - 1; t >= inp && *t == ' '; --t); + for (t = inp + cbsz - 1; t >= inp && *t == ' '; --t) + ; if (t >= inp) { cnt = t - inp + 1; memmove(out.dbp, inp, cnt); out.dbp += cnt; out.dbcnt += cnt; } - ++out.dbcnt; *out.dbp++ = '\n'; - if (out.dbcnt >= out.dbsz) + if (++out.dbcnt >= out.dbsz) dd_out(0); } if (in.dbcnt) @@ -247,12 +248,13 @@ unblock() void unblock_close() { - int cnt; + size_t cnt; u_char *t; if (in.dbcnt) { warnx("%s: short input record", in.name); - for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t); + for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t) + ; if (t >= in.db) { cnt = t - in.db + 1; memmove(out.dbp, in.db, cnt); |