| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: vis.c,v 1.13 2009/02/10 23:06:31 christos Exp $ */ | | 1 | /* $NetBSD: vis.c,v 1.14 2009/02/11 03:04:52 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1989, 1993 | | 4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1989, 1993\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93"; | | 40 | static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 6/6/93"; |
41 | #endif | | 41 | #endif |
42 | __RCSID("$NetBSD: vis.c,v 1.13 2009/02/10 23:06:31 christos Exp $"); | | 42 | __RCSID("$NetBSD: vis.c,v 1.14 2009/02/11 03:04:52 christos Exp $"); |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <stdio.h> | | 45 | #include <stdio.h> |
46 | #include <string.h> | | 46 | #include <string.h> |
47 | #include <stdlib.h> | | 47 | #include <stdlib.h> |
48 | #include <unistd.h> | | 48 | #include <unistd.h> |
49 | #include <err.h> | | 49 | #include <err.h> |
50 | #include <vis.h> | | 50 | #include <vis.h> |
51 | | | 51 | |
52 | #include "extern.h" | | 52 | #include "extern.h" |
53 | | | 53 | |
54 | static int eflags, fold, foldwidth = 80, none, markeol; | | 54 | static int eflags, fold, foldwidth = 80, none, markeol; |
55 | #ifdef DEBUG | | 55 | #ifdef DEBUG |
| @@ -116,48 +116,48 @@ main(int argc, char *argv[]) | | | @@ -116,48 +116,48 @@ main(int argc, char *argv[]) |
116 | eflags |= VIS_TAB; | | 116 | eflags |= VIS_TAB; |
117 | break; | | 117 | break; |
118 | case 'w': | | 118 | case 'w': |
119 | eflags |= VIS_WHITE; | | 119 | eflags |= VIS_WHITE; |
120 | break; | | 120 | break; |
121 | case '?': | | 121 | case '?': |
122 | default: | | 122 | default: |
123 | (void)fprintf(stderr, | | 123 | (void)fprintf(stderr, |
124 | "Usage: %s [-bcfhlmmnostw] [-e extra]" | | 124 | "Usage: %s [-bcfhlmmnostw] [-e extra]" |
125 | " [-F foldwidth] [file ...]\n", getprogname()); | | 125 | " [-F foldwidth] [file ...]\n", getprogname()); |
126 | return 1; | | 126 | return 1; |
127 | } | | 127 | } |
128 | | | 128 | |
129 | if (eflags & (VIS_HTTPSTYLE|VIS_MIMESTYLE) == | | 129 | if ((eflags & (VIS_HTTPSTYLE|VIS_MIMESTYLE)) == |
130 | (VIS_HTTPSTYLE|VIS_MIMESTYLE)) | | 130 | (VIS_HTTPSTYLE|VIS_MIMESTYLE)) |
131 | errx(1, "Can't specify -m and -h at the same time"); | | 131 | errx(1, "Can't specify -m and -h at the same time"); |
132 | | | 132 | |
133 | argc -= optind; | | 133 | argc -= optind; |
134 | argv += optind; | | 134 | argv += optind; |
135 | | | 135 | |
136 | rval = 0; | | 136 | rval = 0; |
137 | | | 137 | |
138 | if (*argv) | | 138 | if (*argv) |
139 | while (*argv) { | | 139 | while (*argv) { |
140 | if ((fp = fopen(*argv, "r")) != NULL) { | | 140 | if ((fp = fopen(*argv, "r")) != NULL) { |
141 | process(fp); | | 141 | process(fp); |
142 | (void)fclose(fp); | | 142 | (void)fclose(fp); |
143 | } else { | | 143 | } else { |
144 | warn("%s", *argv); | | 144 | warn("%s", *argv); |
145 | rval = 1; | | 145 | rval = 1; |
146 | } | | 146 | } |
147 | argv++; | | 147 | argv++; |
148 | } | | 148 | } |
149 | else | | 149 | else |
150 | process(stdin, "<stdin>"); | | 150 | process(stdin); |
151 | return rval; | | 151 | return rval; |
152 | } | | 152 | } |
153 | | | 153 | |
154 | static void | | 154 | static void |
155 | process(FILE *fp) | | 155 | process(FILE *fp) |
156 | { | | 156 | { |
157 | static int col = 0; | | 157 | static int col = 0; |
158 | static char nul[] = "\0"; | | 158 | static char nul[] = "\0"; |
159 | char *cp = nul + 1; /* so *(cp-1) starts out != '\n' */ | | 159 | char *cp = nul + 1; /* so *(cp-1) starts out != '\n' */ |
160 | int c, rachar; | | 160 | int c, rachar; |
161 | char buff[5]; | | 161 | char buff[5]; |
162 | | | 162 | |
163 | c = getc(fp); | | 163 | c = getc(fp); |