=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/paste/paste.c,v retrieving revision 1.14 retrieving revision 1.15 diff -c -r1.14 -r1.15 *** src/usr.bin/paste/paste.c 2004/10/10 03:29:29 1.14 --- src/usr.bin/paste/paste.c 2006/05/04 05:55:33 1.15 *************** *** 1,4 **** ! /* $OpenBSD: paste.c,v 1.14 2004/10/10 03:29:29 mickey Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: paste.c,v 1.15 2006/05/04 05:55:33 ray Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. *************** *** 40,48 **** #ifndef lint /*static char sccsid[] = "from: @(#)paste.c 5.7 (Berkeley) 10/30/90";*/ ! static char rcsid[] = "$OpenBSD: paste.c,v 1.14 2004/10/10 03:29:29 mickey Exp $"; #endif /* not lint */ #include #include #include --- 40,49 ---- #ifndef lint /*static char sccsid[] = "from: @(#)paste.c 5.7 (Berkeley) 10/30/90";*/ ! static char rcsid[] = "$OpenBSD: paste.c,v 1.15 2006/05/04 05:55:33 ray Exp $"; #endif /* not lint */ + #include #include #include #include *************** *** 95,139 **** exit(0); } ! typedef struct _list { ! struct _list *next; FILE *fp; int cnt; char *name; ! } LIST; void parallel(char **argv) { ! LIST *lp; int cnt; char ch, *p; - LIST *head, *tmp; int opencnt, output; char *buf, *lbuf; size_t len; ! for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { ! if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) err(1, "malloc"); if (p[0] == '-' && !p[1]) lp->fp = stdin; else if (!(lp->fp = fopen(p, "r"))) err(1, "%s", p); - lp->next = NULL; lp->cnt = cnt; lp->name = p; ! if (!head) ! head = tmp = lp; ! else { ! tmp->next = lp; ! tmp = lp; ! } } for (opencnt = cnt; opencnt;) { ! for (output = 0, lp = head; lp; lp = lp->next) { lbuf = NULL; if (!lp->fp) { if (output && lp->cnt && --- 96,135 ---- exit(0); } ! struct list { ! SIMPLEQ_ENTRY(list) entries; FILE *fp; int cnt; char *name; ! }; void parallel(char **argv) { ! SIMPLEQ_HEAD(, list) head = SIMPLEQ_HEAD_INITIALIZER(head); ! struct list *lp; int cnt; char ch, *p; int opencnt, output; char *buf, *lbuf; size_t len; ! for (cnt = 0; (p = *argv); ++argv, ++cnt) { ! if (!(lp = malloc(sizeof(struct list)))) err(1, "malloc"); if (p[0] == '-' && !p[1]) lp->fp = stdin; else if (!(lp->fp = fopen(p, "r"))) err(1, "%s", p); lp->cnt = cnt; lp->name = p; ! SIMPLEQ_INSERT_TAIL(&head, lp, entries); } for (opencnt = cnt; opencnt;) { ! output = 0; ! SIMPLEQ_FOREACH(lp, &head, entries) { lbuf = NULL; if (!lp->fp) { if (output && lp->cnt &&