No empty .Rs/.Re
[netbsd-mini2440.git] / regress / lib / libc / gen / vis / vistest.c
blobed3556ca9706efe0dcc79e78e4a02238dedb6f28
1 /* $NetBSD: vistest.c,v 1.1 2002/03/23 17:42:21 christos Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code was contributed to The NetBSD Foundation by Christos Zoulas.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #include <string.h>
32 #include <stdlib.h>
33 #include <err.h>
34 #include <vis.h>
36 static int styles[] = {
37 VIS_OCTAL,
38 VIS_CSTYLE,
39 VIS_SP,
40 VIS_TAB,
41 VIS_NL,
42 VIS_WHITE,
43 VIS_SAFE,
44 #if 0 /* Not reversible */
45 VIS_NOSLASH,
46 #endif
47 #ifdef VIS_HTTPSTYLE
48 VIS_HTTPSTYLE
49 #endif
52 #define SIZE 256
54 int
55 main(int argc, char *argv[])
57 char *srcbuf = malloc(SIZE);
58 char *dstbuf = malloc(SIZE);
59 char *visbuf = malloc(SIZE * 4 + 1);
60 int i, j;
61 int n = sizeof(styles) / sizeof(styles[0]);
63 for (i = 0; i < SIZE; i++)
64 srcbuf[i] = (char)i;
66 for (i = 0; i < n; i++) {
67 strsvisx(visbuf, srcbuf, SIZE, styles[i], "");
69 * XXX: The strunvisx api is busted; flags should be
70 * UNVIS_ flags, buf we follow FreeBSD's lead. This
71 * needs to be redone, by moving UNVIS_END into the
72 * VIS_ space, and bump the library/symbol.
74 strunvisx(dstbuf, visbuf, styles[i] & VIS_HTTPSTYLE);
75 for (j = 0; j < SIZE; j++)
76 if (dstbuf[j] != (char)j)
77 errx(1, "Failed for style %x, char %d [%d]",
78 styles[i], j, dstbuf[j]);
80 return 0;