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