version 1.5, 1998/11/16 06:09:12 |
version 1.6, 1999/08/23 23:58:23 |
|
|
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <unistd.h> |
|
#include <errno.h> |
#include <errno.h> |
#include <limits.h> |
#include <limits.h> |
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <unistd.h> |
|
|
char *delim; |
char *delim; |
int delimcnt; |
int delimcnt; |
|
|
register char ch, *p; |
register char ch, *p; |
LIST *head, *tmp; |
LIST *head, *tmp; |
int opencnt, output; |
int opencnt, output; |
char buf[_POSIX2_LINE_MAX + 1], *malloc(); |
size_t len; |
|
|
for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { |
for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { |
if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) { |
if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) { |
|
|
putchar(ch); |
putchar(ch); |
continue; |
continue; |
} |
} |
if (!fgets(buf, sizeof(buf), lp->fp)) { |
if (!(p = fgetln(lp->fp, &len))) { |
if (!--opencnt) |
if (!--opencnt) |
break; |
break; |
lp->fp = NULL; |
lp->fp = NULL; |
|
|
putchar(ch); |
putchar(ch); |
continue; |
continue; |
} |
} |
if (!(p = strchr(buf, '\n'))) { |
if (*(p + len - 1) == '\n') |
|
*(p + len - 1) = '\0'; |
|
else { |
(void)fprintf(stderr, |
(void)fprintf(stderr, |
"paste: %s: input line too long.\n", |
"paste: %s: incomplete line.\n", |
lp->name); |
lp->name); |
exit(1); |
exit(1); |
} |
} |
*p = '\0'; |
|
/* |
/* |
* make sure that we don't print any delimiters |
* make sure that we don't print any delimiters |
* unless there's a non-empty file. |
* unless there's a non-empty file. |
|
|
putchar(ch); |
putchar(ch); |
} else if ((ch = delim[(lp->cnt - 1) % delimcnt])) |
} else if ((ch = delim[(lp->cnt - 1) % delimcnt])) |
putchar(ch); |
putchar(ch); |
(void)printf("%s", buf); |
(void)printf("%s", p); |
} |
} |
if (output) |
if (output) |
putchar('\n'); |
putchar('\n'); |