=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/paste/paste.c,v retrieving revision 1.24 retrieving revision 1.25 diff -c -r1.24 -r1.25 *** src/usr.bin/paste/paste.c 2018/08/04 16:14:03 1.24 --- src/usr.bin/paste/paste.c 2018/08/04 16:47:05 1.25 *************** *** 1,4 **** ! /* $OpenBSD: paste.c,v 1.24 2018/08/04 16:14:03 schwarze Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: paste.c,v 1.25 2018/08/04 16:47:05 schwarze Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. *************** *** 46,52 **** int delimcnt; int tr(char *); ! void usage(void); void parallel(char **); void sequential(char **); --- 46,52 ---- int delimcnt; int tr(char *); ! __dead void usage(void); void parallel(char **); void sequential(char **); *************** *** 80,86 **** if (argc == 0) usage(); ! if (!delim) { delimcnt = 1; delim = "\t"; } --- 80,86 ---- if (argc == 0) usage(); ! if (delim == NULL) { delimcnt = 1; delim = "\t"; } *************** *** 89,95 **** sequential(argv); else parallel(argv); ! exit(0); } struct list { --- 89,95 ---- sequential(argv); else parallel(argv); ! return 0; } struct list { *************** *** 110,122 **** int opencnt, output; char ch; ! 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; --- 110,122 ---- int opencnt, output; char ch; ! for (cnt = 0; (p = *argv) != NULL; ++argv, ++cnt) { ! if ((lp = malloc(sizeof(*lp))) == NULL) ! err(1, NULL); ! if (p[0] == '-' && p[1] == '\0') lp->fp = stdin; ! else if ((lp->fp = fopen(p, "r")) == NULL) err(1, "%s", p); lp->cnt = cnt; lp->name = p; *************** *** 129,135 **** for (opencnt = cnt; opencnt;) { output = 0; SIMPLEQ_FOREACH(lp, &head, entries) { ! if (!lp->fp) { if (output && lp->cnt && (ch = delim[(lp->cnt - 1) % delimcnt])) putchar(ch); --- 129,135 ---- for (opencnt = cnt; opencnt;) { output = 0; SIMPLEQ_FOREACH(lp, &head, entries) { ! if (lp->fp == NULL) { if (output && lp->cnt && (ch = delim[(lp->cnt - 1) % delimcnt])) putchar(ch); *************** *** 139,148 **** if (ferror(lp->fp)) err(1, "%s", lp->fp == stdin ? "getline" : lp->name); ! if (!--opencnt) break; if (lp->fp != stdin) ! (void)fclose(lp->fp); lp->fp = NULL; if (output && lp->cnt && (ch = delim[(lp->cnt - 1) % delimcnt])) --- 139,148 ---- if (ferror(lp->fp)) err(1, "%s", lp->fp == stdin ? "getline" : lp->name); ! if (--opencnt == 0) break; if (lp->fp != stdin) ! fclose(lp->fp); lp->fp = NULL; if (output && lp->cnt && (ch = delim[(lp->cnt - 1) % delimcnt])) *************** *** 180,189 **** line = NULL; linesize = 0; ! for (; (p = *argv); ++argv) { ! if (p[0] == '-' && !p[1]) fp = stdin; ! else if (!(fp = fopen(p, "r"))) { warn("%s", p); continue; } --- 180,189 ---- line = NULL; linesize = 0; ! for (; (p = *argv) != NULL; ++argv) { ! if (p[0] == '-' && p[1] == '\0') fp = stdin; ! else if ((fp = fopen(p, "r")) == NULL) { warn("%s", p); continue; } *************** *** 202,208 **** if (cnt >= 0) putchar('\n'); if (fp != stdin) ! (void)fclose(fp); } free(line); } --- 202,208 ---- if (cnt >= 0) putchar('\n'); if (fp != stdin) ! fclose(fp); } free(line); } *************** *** 213,219 **** int cnt; char ch, *p; ! for (p = arg, cnt = 0; (ch = *p++); ++arg, ++cnt) { if (ch == '\\') { switch (ch = *p++) { case 'n': --- 213,219 ---- int cnt; char ch, *p; ! for (p = arg, cnt = 0; (ch = *p++) != '\0'; ++arg, ++cnt) { if (ch == '\\') { switch (ch = *p++) { case 'n': *************** *** 233,248 **** *arg = ch; } ! if (!cnt) errx(1, "no delimiters specified"); ! return (cnt); } ! void usage(void) { extern char *__progname; ! (void)fprintf(stderr, "usage: %s [-s] [-d list] file ...\n", ! __progname); exit(1); } --- 233,247 ---- *arg = ch; } ! if (cnt == 0) errx(1, "no delimiters specified"); ! return cnt; } ! __dead void usage(void) { extern char *__progname; ! fprintf(stderr, "usage: %s [-s] [-d list] file ...\n", __progname); exit(1); }