=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/paste/paste.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/paste/paste.c 1998/11/16 06:09:12 1.5 --- src/usr.bin/paste/paste.c 1999/08/23 23:58:23 1.6 *************** *** 1,4 **** ! /* $OpenBSD: paste.c,v 1.5 1998/11/16 06:09:12 deraadt Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: paste.c,v 1.6 1999/08/23 23:58:23 aaron Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. *************** *** 44,58 **** #ifndef lint /*static char sccsid[] = "from: @(#)paste.c 5.7 (Berkeley) 10/30/90";*/ ! static char rcsid[] = "$OpenBSD: paste.c,v 1.5 1998/11/16 06:09:12 deraadt Exp $"; #endif /* not lint */ #include - #include #include #include #include #include char *delim; int delimcnt; --- 44,59 ---- #ifndef lint /*static char sccsid[] = "from: @(#)paste.c 5.7 (Berkeley) 10/30/90";*/ ! static char rcsid[] = "$OpenBSD: paste.c,v 1.6 1999/08/23 23:58:23 aaron Exp $"; #endif /* not lint */ #include #include #include #include + #include #include + #include char *delim; int delimcnt; *************** *** 115,121 **** register char ch, *p; LIST *head, *tmp; int opencnt, output; ! char buf[_POSIX2_LINE_MAX + 1], *malloc(); for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) { --- 116,122 ---- register char ch, *p; LIST *head, *tmp; int opencnt, output; ! size_t len; for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) { *************** *** 148,154 **** putchar(ch); continue; } ! if (!fgets(buf, sizeof(buf), lp->fp)) { if (!--opencnt) break; lp->fp = NULL; --- 149,155 ---- putchar(ch); continue; } ! if (!(p = fgetln(lp->fp, &len))) { if (!--opencnt) break; lp->fp = NULL; *************** *** 157,169 **** putchar(ch); continue; } ! if (!(p = strchr(buf, '\n'))) { (void)fprintf(stderr, ! "paste: %s: input line too long.\n", lp->name); exit(1); } - *p = '\0'; /* * make sure that we don't print any delimiters * unless there's a non-empty file. --- 158,171 ---- putchar(ch); continue; } ! if (*(p + len - 1) == '\n') ! *(p + len - 1) = '\0'; ! else { (void)fprintf(stderr, ! "paste: %s: incomplete line.\n", lp->name); exit(1); } /* * make sure that we don't print any delimiters * unless there's a non-empty file. *************** *** 175,181 **** putchar(ch); } else if ((ch = delim[(lp->cnt - 1) % delimcnt])) putchar(ch); ! (void)printf("%s", buf); } if (output) putchar('\n'); --- 177,183 ---- putchar(ch); } else if ((ch = delim[(lp->cnt - 1) % delimcnt])) putchar(ch); ! (void)printf("%s", p); } if (output) putchar('\n');