Sync usage with man page.
[netbsd-mini2440.git] / regress / lib / libc / int_fmtio / fmtio_check.c
blob4ac0ca7b29b97832f875bd775a5e12f0b38f8cd7
1 /* $NetBSD: fmtio_check.c,v 1.2 2002/02/21 07:38:17 itojun Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <inttypes.h>
30 #include <stdio.h>
31 #include <stdlib.h>
33 int main(int, char *[]);
35 #define PRINT(fmt, var) \
36 snprintf(buf, sizeof(buf), "%" fmt, var)
38 #define SCAN(fmt, var) \
39 sscanf(buf, "%" fmt, &var)
41 int
42 main(int argc, char *argv[])
44 char buf[64];
46 int8_t i8;
47 int16_t i16;
48 int32_t i32;
49 int64_t i64;
50 int_least8_t il8;
51 int_least16_t il16;
52 int_least32_t il32;
53 int_least64_t il64;
54 int_fast8_t if8;
55 int_fast16_t if16;
56 int_fast32_t if32;
57 int_fast64_t if64;
58 intmax_t im;
59 intptr_t ip;
60 uint8_t ui8;
61 uint16_t ui16;
62 uint32_t ui32;
63 uint64_t ui64;
64 uint_least8_t uil8;
65 uint_least16_t uil16;
66 uint_least32_t uil32;
67 uint_least64_t uil64;
68 uint_fast8_t uif8;
69 uint_fast16_t uif16;
70 uint_fast32_t uif32;
71 uint_fast64_t uif64;
72 uintmax_t uim;
73 uintptr_t uip;
75 PRINT(PRId8, i8);
76 PRINT(PRId16, i16);
77 PRINT(PRId32, i32);
78 PRINT(PRId64, i64);
79 PRINT(PRIdLEAST8, il8);
80 PRINT(PRIdLEAST16, il16);
81 PRINT(PRIdLEAST32, il32);
82 PRINT(PRIdLEAST64, il64);
83 PRINT(PRIdFAST8, if8);
84 PRINT(PRIdFAST16, if16);
85 PRINT(PRIdFAST32, if32);
86 PRINT(PRIdFAST64, if64);
87 PRINT(PRIdMAX, im);
88 PRINT(PRIdPTR, ip);
90 PRINT(PRIi8, i8);
91 PRINT(PRIi16, i16);
92 PRINT(PRIi32, i32);
93 PRINT(PRIi64, i64);
94 PRINT(PRIiLEAST8, il8);
95 PRINT(PRIiLEAST16, il16);
96 PRINT(PRIiLEAST32, il32);
97 PRINT(PRIiLEAST64, il64);
98 PRINT(PRIiFAST8, if8);
99 PRINT(PRIiFAST16, if16);
100 PRINT(PRIiFAST32, if32);
101 PRINT(PRIiFAST64, if64);
102 PRINT(PRIiMAX, im);
103 PRINT(PRIiPTR, ip);
105 PRINT(PRIo8, ui8);
106 PRINT(PRIo16, ui16);
107 PRINT(PRIo32, ui32);
108 PRINT(PRIo64, ui64);
109 PRINT(PRIoLEAST8, uil8);
110 PRINT(PRIoLEAST16, uil16);
111 PRINT(PRIoLEAST32, uil32);
112 PRINT(PRIoLEAST64, uil64);
113 PRINT(PRIoFAST8, uif8);
114 PRINT(PRIoFAST16, uif16);
115 PRINT(PRIoFAST32, uif32);
116 PRINT(PRIoFAST64, uif64);
117 PRINT(PRIoMAX, uim);
118 PRINT(PRIoPTR, uip);
120 PRINT(PRIu8, ui8);
121 PRINT(PRIu16, ui16);
122 PRINT(PRIu32, ui32);
123 PRINT(PRIu64, ui64);
124 PRINT(PRIuLEAST8, uil8);
125 PRINT(PRIuLEAST16, uil16);
126 PRINT(PRIuLEAST32, uil32);
127 PRINT(PRIuLEAST64, uil64);
128 PRINT(PRIuFAST8, uif8);
129 PRINT(PRIuFAST16, uif16);
130 PRINT(PRIuFAST32, uif32);
131 PRINT(PRIuFAST64, uif64);
132 PRINT(PRIuMAX, uim);
133 PRINT(PRIuPTR, uip);
135 PRINT(PRIx8, ui8);
136 PRINT(PRIx16, ui16);
137 PRINT(PRIx32, ui32);
138 PRINT(PRIx64, ui64);
139 PRINT(PRIxLEAST8, uil8);
140 PRINT(PRIxLEAST16, uil16);
141 PRINT(PRIxLEAST32, uil32);
142 PRINT(PRIxLEAST64, uil64);
143 PRINT(PRIxFAST8, uif8);
144 PRINT(PRIxFAST16, uif16);
145 PRINT(PRIxFAST32, uif32);
146 PRINT(PRIxFAST64, uif64);
147 PRINT(PRIxMAX, uim);
148 PRINT(PRIxPTR, uip);
150 PRINT(PRIX8, ui8);
151 PRINT(PRIX16, ui16);
152 PRINT(PRIX32, ui32);
153 PRINT(PRIX64, ui64);
154 PRINT(PRIXLEAST8, uil8);
155 PRINT(PRIXLEAST16, uil16);
156 PRINT(PRIXLEAST32, uil32);
157 PRINT(PRIXLEAST64, uil64);
158 PRINT(PRIXFAST8, uif8);
159 PRINT(PRIXFAST16, uif16);
160 PRINT(PRIXFAST32, uif32);
161 PRINT(PRIXFAST64, uif64);
162 PRINT(PRIXMAX, uim);
163 PRINT(PRIXPTR, uip);
166 SCAN(SCNd8, i8);
167 SCAN(SCNd16, i16);
168 SCAN(SCNd32, i32);
169 SCAN(SCNd64, i64);
170 SCAN(SCNdLEAST8, il8);
171 SCAN(SCNdLEAST16, il16);
172 SCAN(SCNdLEAST32, il32);
173 SCAN(SCNdLEAST64, il64);
174 SCAN(SCNdFAST8, if8);
175 SCAN(SCNdFAST16, if16);
176 SCAN(SCNdFAST32, if32);
177 SCAN(SCNdFAST64, if64);
178 SCAN(SCNdMAX, im);
179 SCAN(SCNdPTR, ip);
181 SCAN(SCNi8, i8);
182 SCAN(SCNi16, i16);
183 SCAN(SCNi32, i32);
184 SCAN(SCNi64, i64);
185 SCAN(SCNiLEAST8, il8);
186 SCAN(SCNiLEAST16, il16);
187 SCAN(SCNiLEAST32, il32);
188 SCAN(SCNiLEAST64, il64);
189 SCAN(SCNiFAST8, if8);
190 SCAN(SCNiFAST16, if16);
191 SCAN(SCNiFAST32, if32);
192 SCAN(SCNiFAST64, if64);
193 SCAN(SCNiMAX, im);
194 SCAN(SCNiPTR, ip);
196 SCAN(SCNo8, ui8);
197 SCAN(SCNo16, ui16);
198 SCAN(SCNo32, ui32);
199 SCAN(SCNo64, ui64);
200 SCAN(SCNoLEAST8, uil8);
201 SCAN(SCNoLEAST16, uil16);
202 SCAN(SCNoLEAST32, uil32);
203 SCAN(SCNoLEAST64, uil64);
204 SCAN(SCNoFAST8, uif8);
205 SCAN(SCNoFAST16, uif16);
206 SCAN(SCNoFAST32, uif32);
207 SCAN(SCNoFAST64, uif64);
208 SCAN(SCNoMAX, uim);
209 SCAN(SCNoPTR, uip);
211 SCAN(SCNu8, ui8);
212 SCAN(SCNu16, ui16);
213 SCAN(SCNu32, ui32);
214 SCAN(SCNu64, ui64);
215 SCAN(SCNuLEAST8, uil8);
216 SCAN(SCNuLEAST16, uil16);
217 SCAN(SCNuLEAST32, uil32);
218 SCAN(SCNuLEAST64, uil64);
219 SCAN(SCNuFAST8, uif8);
220 SCAN(SCNuFAST16, uif16);
221 SCAN(SCNuFAST32, uif32);
222 SCAN(SCNuFAST64, uif64);
223 SCAN(SCNuMAX, uim);
224 SCAN(SCNuPTR, uip);
226 SCAN(SCNx8, ui8);
227 SCAN(SCNx16, ui16);
228 SCAN(SCNx32, ui32);
229 SCAN(SCNx64, ui64);
230 SCAN(SCNxLEAST8, uil8);
231 SCAN(SCNxLEAST16, uil16);
232 SCAN(SCNxLEAST32, uil32);
233 SCAN(SCNxLEAST64, uil64);
234 SCAN(SCNxFAST8, uif8);
235 SCAN(SCNxFAST16, uif16);
236 SCAN(SCNxFAST32, uif32);
237 SCAN(SCNxFAST64, uif64);
238 SCAN(SCNxMAX, uim);
239 SCAN(SCNxPTR, uip);
241 exit(0);