=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/split/split.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/split/split.c 2006/08/09 22:42:08 1.12 --- src/usr.bin/split/split.c 2006/08/10 22:44:17 1.13 *************** *** 1,4 **** ! /* $OpenBSD: split.c,v 1.12 2006/08/09 22:42:08 millert Exp $ */ /* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: split.c,v 1.13 2006/08/10 22:44:17 millert Exp $ */ /* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */ /* *************** *** 40,46 **** #if 0 static char sccsid[] = "@(#)split.c 8.3 (Berkeley) 4/25/94"; #else ! static char rcsid[] = "$OpenBSD: split.c,v 1.12 2006/08/09 22:42:08 millert Exp $"; #endif #endif /* not lint */ --- 40,46 ---- #if 0 static char sccsid[] = "@(#)split.c 8.3 (Berkeley) 4/25/94"; #else ! static char rcsid[] = "$OpenBSD: split.c,v 1.13 2006/08/10 22:44:17 millert Exp $"; #endif #endif /* not lint */ *************** *** 50,55 **** --- 50,56 ---- #include #include #include + #include #include #include #include *************** *** 59,65 **** #define DEFLINE 1000 /* Default num lines per file. */ ! long bytecnt; /* Byte count to split on. */ long numlines; /* Line count to split on. */ int file_open; /* If a file open. */ int ifd = -1, ofd = -1; /* Input/output file descriptors. */ --- 60,66 ---- #define DEFLINE 1000 /* Default num lines per file. */ ! ssize_t bytecnt; /* Byte count to split on. */ long numlines; /* Line count to split on. */ int file_open; /* If a file open. */ int ifd = -1, ofd = -1; /* Input/output file descriptors. */ *************** *** 72,83 **** void newfile(void); void split1(void); void split2(void); ! void usage(void); int main(int argc, char *argv[]) { ! int ch; char *ep, *p; const char *errstr; --- 73,84 ---- void newfile(void); void split1(void); void split2(void); ! __dead void usage(void); int main(int argc, char *argv[]) { ! int ch, scale; char *ep, *p; const char *errstr; *************** *** 117,125 **** errx(EX_USAGE, "%s: illegal byte count", optarg); if (*ep == 'k') ! bytecnt *= 1024; else if (*ep == 'm') ! bytecnt *= 1048576; break; case 'p' : /* pattern matching. */ if (regcomp(&rgx, optarg, REG_EXTENDED|REG_NOSUB) != 0) --- 118,132 ---- errx(EX_USAGE, "%s: illegal byte count", optarg); if (*ep == 'k') ! scale = 1024; else if (*ep == 'm') ! scale = 1048576; ! else ! scale = 1; ! if (bytecnt > SSIZE_MAX / scale) ! errx(EX_USAGE, "%s: byte count too large", ! optarg); ! bytecnt *= scale; break; case 'p' : /* pattern matching. */ if (regcomp(&rgx, optarg, REG_EXTENDED|REG_NOSUB) != 0) *************** *** 180,187 **** void split1(void) { ! long bcnt; ! int dist, len; char *C; for (bcnt = 0;;) --- 187,193 ---- void split1(void) { ! ssize_t bcnt, dist, len; char *C; for (bcnt = 0;;) *************** *** 202,209 **** for (C = bfr + dist; len >= bytecnt; len -= bytecnt, C += bytecnt) { newfile(); ! if (write(ofd, ! C, (int)bytecnt) != bytecnt) err(EX_IOERR, "write"); } if (len != 0) { --- 208,214 ---- for (C = bfr + dist; len >= bytecnt; len -= bytecnt, C += bytecnt) { newfile(); ! if (write(ofd, C, bytecnt) != bytecnt) err(EX_IOERR, "write"); } if (len != 0) { *************** *** 325,331 **** file_open = 1; } ! void usage(void) { extern char *__progname; --- 330,336 ---- file_open = 1; } ! __dead void usage(void) { extern char *__progname;