1 | // RUN: %clang %s -o %t && %run %t 2>&1 | FileCheck %s |
---|---|
2 | |
3 | #include <ctype.h> |
4 | #include <limits.h> |
5 | #include <locale.h> |
6 | #include <stddef.h> |
7 | #include <stdio.h> |
8 | #include <stdlib.h> |
9 | |
10 | void check_ctype(void) { |
11 | unsigned char c; |
12 | volatile size_t i = 0; /* a dummy variable to prevent optimizing code out */ |
13 | |
14 | for (c = 0; c < UCHAR_MAX; c++) |
15 | i += !!isalpha(c: c); |
16 | for (c = 0; c < UCHAR_MAX; c++) |
17 | i += !!isascii(c); |
18 | for (c = 0; c < UCHAR_MAX; c++) |
19 | i += !!isblank(c: c); |
20 | for (c = 0; c < UCHAR_MAX; c++) |
21 | i += !!iscntrl(c: c); |
22 | for (c = 0; c < UCHAR_MAX; c++) |
23 | i += !!isdigit(c: c); |
24 | for (c = 0; c < UCHAR_MAX; c++) |
25 | i += !!isgraph(c: c); |
26 | for (c = 0; c < UCHAR_MAX; c++) |
27 | i += !!islower(c: c); |
28 | for (c = 0; c < UCHAR_MAX; c++) |
29 | i += !!isprint(c: c); |
30 | for (c = 0; c < UCHAR_MAX; c++) |
31 | i += !!ispunct(c: c); |
32 | for (c = 0; c < UCHAR_MAX; c++) |
33 | i += !!isspace(c: c); |
34 | for (c = 0; c < UCHAR_MAX; c++) |
35 | i += !!isupper(c: c); |
36 | for (c = 0; c < UCHAR_MAX; c++) |
37 | i += !!isxdigit(c: c); |
38 | for (c = 0; c < UCHAR_MAX; c++) |
39 | i += !!isalnum(c: c); |
40 | |
41 | for (c = 0; c < UCHAR_MAX; c++) |
42 | i += !!tolower(c: c); |
43 | for (c = 0; c < UCHAR_MAX; c++) |
44 | i += !!toupper(c: c); |
45 | |
46 | i += !!isalpha(EOF); |
47 | i += !!isascii(EOF); |
48 | i += !!isblank(EOF); |
49 | i += !!iscntrl(EOF); |
50 | i += !!isdigit(EOF); |
51 | i += !!isgraph(EOF); |
52 | i += !!islower(EOF); |
53 | i += !!isprint(EOF); |
54 | i += !!ispunct(EOF); |
55 | i += !!isspace(EOF); |
56 | i += !!isupper(EOF); |
57 | i += !!isxdigit(EOF); |
58 | i += !!isalnum(EOF); |
59 | |
60 | i += !!tolower(EOF); |
61 | i += !!toupper(EOF); |
62 | |
63 | if (i) |
64 | return; |
65 | else |
66 | return; |
67 | } |
68 | |
69 | int main(int argc, char **argv) { |
70 | check_ctype(); |
71 | |
72 | setlocale(LC_ALL, locale: ""); |
73 | |
74 | check_ctype(); |
75 | |
76 | setlocale(LC_ALL, locale: "en_US.UTF-8"); |
77 | |
78 | check_ctype(); |
79 | |
80 | setlocale(LC_CTYPE, locale: "pl_PL.UTF-8"); |
81 | |
82 | check_ctype(); |
83 | |
84 | printf(format: "OK\n"); |
85 | |
86 | // CHECK: OK |
87 | |
88 | return 0; |
89 | } |
90 |