| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $ */ | | 1 | /* $NetBSD: unvis.c,v 1.42 2014/09/26 12:59:28 roy 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. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #if defined(LIBC_SCCS) && !defined(lint) | | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
34 | #if 0 | | 34 | #if 0 |
35 | static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; | | 35 | static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; |
36 | #else | | 36 | #else |
37 | __RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $"); | | 37 | __RCSID("$NetBSD: unvis.c,v 1.42 2014/09/26 12:59:28 roy Exp $"); |
38 | #endif | | 38 | #endif |
39 | #endif /* LIBC_SCCS and not lint */ | | 39 | #endif /* LIBC_SCCS and not lint */ |
40 | | | 40 | |
41 | #include "namespace.h" | | 41 | #include "namespace.h" |
42 | #include <sys/types.h> | | 42 | #include <sys/types.h> |
43 | | | 43 | |
44 | #include <assert.h> | | 44 | #include <assert.h> |
45 | #include <ctype.h> | | 45 | #include <ctype.h> |
46 | #include <stdint.h> | | 46 | #include <stdint.h> |
47 | #include <stdio.h> | | 47 | #include <stdio.h> |
48 | #include <errno.h> | | 48 | #include <errno.h> |
49 | #include <vis.h> | | 49 | #include <vis.h> |
50 | | | 50 | |
| @@ -303,26 +303,32 @@ unvis(char *cp, int c, int *astate, int | | | @@ -303,26 +303,32 @@ unvis(char *cp, int c, int *astate, int |
303 | return UNVIS_NOCHAR; | | 303 | return UNVIS_NOCHAR; |
304 | case '\n': | | 304 | case '\n': |
305 | /* | | 305 | /* |
306 | * hidden newline | | 306 | * hidden newline |
307 | */ | | 307 | */ |
308 | *astate = SS(0, S_GROUND); | | 308 | *astate = SS(0, S_GROUND); |
309 | return UNVIS_NOCHAR; | | 309 | return UNVIS_NOCHAR; |
310 | case '$': | | 310 | case '$': |
311 | /* | | 311 | /* |
312 | * hidden marker | | 312 | * hidden marker |
313 | */ | | 313 | */ |
314 | *astate = SS(0, S_GROUND); | | 314 | *astate = SS(0, S_GROUND); |
315 | return UNVIS_NOCHAR; | | 315 | return UNVIS_NOCHAR; |
| | | 316 | default: |
| | | 317 | if (isgraph(c)) { |
| | | 318 | *cp = c; |
| | | 319 | *astate = SS(0, S_GROUND); |
| | | 320 | return UNVIS_VALID; |
| | | 321 | } |
316 | } | | 322 | } |
317 | goto bad; | | 323 | goto bad; |
318 | | | 324 | |
319 | case S_META: | | 325 | case S_META: |
320 | if (c == '-') | | 326 | if (c == '-') |
321 | *astate = SS(0, S_META1); | | 327 | *astate = SS(0, S_META1); |
322 | else if (c == '^') | | 328 | else if (c == '^') |
323 | *astate = SS(0, S_CTRL); | | 329 | *astate = SS(0, S_CTRL); |
324 | else | | 330 | else |
325 | goto bad; | | 331 | goto bad; |
326 | return UNVIS_NOCHAR; | | 332 | return UNVIS_NOCHAR; |
327 | | | 333 | |
328 | case S_META1: | | 334 | case S_META1: |