Debian Codegraph @

share/libc/ctype.h

raw
1 /**************************************************************************/
2 /* */
3 /* This file is part of Frama-C. */
4 /* */
5 /* Copyright (C) 2007-2022 */
6 /* CEA (Commissariat à l'énergie atomique et aux énergies */
7 /* alternatives) */
8 /* */
9 /* you can redistribute it and/or modify it under the terms of the GNU */
10 /* Lesser General Public License as published by the Free Software */
11 /* Foundation, version 2.1. */
12 /* */
13 /* It is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
16 /* GNU Lesser General Public License for more details. */
17 /* */
18 /* See the GNU Lesser General Public License version 2.1 */
19 /* for more details (enclosed in the file licenses/LGPLv2.1). */
20 /* */
21 /**************************************************************************/
22
23 #ifndef __FC_CTYPE
24 #define __FC_CTYPE
25 #include "features.h"
26 __PUSH_FC_STDLIB
27 #include "__fc_define_eof.h"
28
29 /* ISO C : 7.4.1 */
30
31 __BEGIN_DECLS
32
33 /* Functions which have no complete behaviors are either due to
34 locale-dependent characters, or under-specification by the
35 C standard. */
36
37 /* Note: most functions use '\result < 0 || \result > 0' instead of
38 of '\result != 0' for better precision if there is enough slevel. */
39
40 /*@
41 requires c_uchar_or_eof_or_EOF: 0 <= c <= 255 || c == EOF;
42 assigns \result \from c;
43 behavior definitely_match:
44 assumes c_alnum: 'A' <= c <= 'Z' || 'a' <= c <= 'z' || '0' <= c <= '9';
45 ensures nonzero_result: \result < 0 || \result > 0;
46 behavior definitely_not_match:
47 assumes c_non_alnum: c == EOF || 0 <= c <= 47 || 58 <= c <= 64 ||
48 91 <= c <= 96 || 123 <= c <= 127;
49 ensures zero_result: \result == 0;
50 disjoint behaviors;
51 */
52 extern int isalnum(int c);
53
54 /*@
55 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
56 assigns \result \from c;
57 behavior definitely_match:
58 assumes c_alpha: 'A' <= c <= 'Z' || 'a' <= c <= 'z';
59 ensures nonzero_result: \result < 0 || \result > 0;
60 behavior definitely_not_match:
61 assumes c_non_alpha: c == EOF || 0 <= c <= 64 || 91 <= c <= 96 || 123 <= c <= 127;
62 ensures zero_result: \result == 0;
63 disjoint behaviors;
64 */
65 extern int isalpha(int c);
66
67 /*@
68 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
69 assigns \result \from c;
70 behavior match:
71 assumes c_tab_or_space: c == ' ' || c == '\t';
72 ensures nonzero_result: \result < 0 || \result > 0;
73 behavior no_match:
74 assumes c_non_blank: c != ' ' && c != '\t';
75 ensures zero_result: \result == 0;
76 disjoint behaviors;
77 complete behaviors;
78 */
79 extern int isblank(int c);
80
81 /*@
82 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
83 assigns \result \from c;
84 behavior definitely_match:
85 assumes c_control_char: 0 <= c <= 31 || c == 127;
86 ensures nonzero_result: \result < 0 || \result > 0;
87 behavior definitely_not_match:
88 assumes c_non_control_char: c == EOF || 32 <= c <= 126;
89 ensures zero_result: \result == 0;
90 disjoint behaviors;
91 */
92 extern int iscntrl(int c);
93
94 /*@ requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
95 assigns \result \from c;
96 behavior match:
97 assumes c_digit: '0' <= c <= '9';
98 ensures nonzero_result: \result < 0 || \result > 0;
99 behavior no_match:
100 assumes c_non_digit: c < '0' || c > '9';
101 ensures zero_result: \result == 0;
102 disjoint behaviors;
103 complete behaviors;
104 */
105 extern int isdigit(int c);
106
107 /*@
108 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
109 assigns \result \from c;
110 behavior definitely_match:
111 assumes c_graphical: 33 <= c <= 126;
112 ensures nonzero_result: \result < 0 || \result > 0;
113 behavior definitely_not_match:
114 assumes c_non_graphical: c == EOF || 0 <= c <= 32 || c == 127;
115 ensures zero_result: \result == 0;
116 disjoint behaviors;
117 */
118 extern int isgraph(int c);
119
120 /*@
121 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
122 assigns \result \from c;
123 behavior definitely_match:
124 assumes c_lower: 'a' <= c <= 'z';
125 ensures nonzero_result: \result < 0 || \result > 0;
126 behavior definitely_not_match:
127 assumes c_non_lower: c == EOF || 0 <= c < 'a' || 'z' < c < 127;
128 ensures zero_result: \result == 0;
129 disjoint behaviors;
130 */
131 extern int islower(int c);
132
133 /*@
134 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
135 assigns \result \from c;
136 behavior definitely_match:
137 assumes c_printable: 32 <= c <= 126;
138 ensures nonzero_result: \result < 0 || \result > 0;
139 behavior definitely_not_match:
140 assumes c_non_printable: c == EOF || 0 <= c <= 31 || c == 127;
141 ensures zero_result: \result == 0;
142 disjoint behaviors;
143 */
144 extern int isprint(int c);
145
146 /*@
147 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
148 assigns \result \from c;
149 behavior definitely_match:
150 assumes c_punct: 33 <= c <= 47 || 58 <= c <= 64 || 91 <= c <= 96 || 123 <= c <= 126;
151 ensures nonzero_result: \result < 0 || \result > 0;
152 behavior definitely_not_match:
153 assumes c_non_punct: c == EOF || 0 <= c <= 32 || 48 <= c <= 57 || 65 <= c <= 90 ||
154 97 <= c <= 122 || c == 127;
155 ensures zero_result: \result == 0;
156 disjoint behaviors;
157 */
158 extern int ispunct(int c);
159
160 /*@
161 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
162 assigns \result \from c;
163 behavior definitely_match:
164 assumes c_space: 9 <= c <= 13 || c == ' ';
165 ensures nonzero_result: \result < 0 || \result > 0;
166 behavior definitely_not_match:
167 assumes c_non_space: c == EOF || 0 <= c <= 8 || 14 <= c < ' ' || ' ' < c <= 127;
168 ensures zero_result: \result == 0;
169 disjoint behaviors;
170 */
171 extern int isspace(int c);
172
173 /*@
174 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
175 assigns \result \from c;
176 behavior definitely_match:
177 assumes c_upper: 'A' <= c <= 'Z';
178 ensures nonzero_result: \result < 0 || \result > 0;
179 behavior definitely_not_match:
180 assumes c_non_upper: c == EOF || 0 <= c < 'A' || 'Z' < c <= 127;
181 ensures zero_result: \result == 0;
182 disjoint behaviors;
183 */
184 extern int isupper(int c);
185
186 /*@
187 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
188 assigns \result \from c;
189 behavior match:
190 assumes c_hexa_digit: '0' <= c <= '9' || 'A' <= c <= 'F' || 'a' <= c <= 'f';
191 ensures nonzero_result: \result < 0 || \result > 0;
192 behavior no_match:
193 assumes c_non_hexa_digit: !('0' <= c <= '9' || 'A' <= c <= 'F' || 'a' <= c <= 'f');
194 ensures zero_result: \result == 0;
195 disjoint behaviors;
196 complete behaviors;
197 */
198 extern int isxdigit(int c);
199
200 /* ISO C : 7.4.2 */
201
202 /*@
203 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
204 assigns \result \from c;
205 ensures result_uchar_of_eof: 0 <= \result <= 255 || \result == EOF;
206 behavior definitely_changed:
207 assumes c_ascii_upper: 'A' <= c <= 'Z';
208 ensures result_ascii_lower: \result == c + 32;
209 behavior definitely_not_changed:
210 assumes c_ascii_but_non_upper: c == EOF || 0 <= c < 'A' || 'Z' < c <= 127;
211 ensures result_unchanged: \result == c;
212 disjoint behaviors;
213 */
214 extern int tolower(int c);
215
216 /*@
217 requires c_uchar_of_eof: 0 <= c <= 255 || c == EOF;
218 assigns \result \from c;
219 ensures result_uchar_of_eof: 0 <= \result <= 255 || \result == EOF;
220 behavior definitely_changed:
221 assumes c_ascii_lower: 'a' <= c <= 'z';
222 ensures result_ascii_upper: \result == c - 32;
223 behavior definitely_not_changed:
224 assumes c_ascii_but_non_lower: c == EOF || 0 <= c < 'a' || 'z' < c <= 127;
225 ensures result_unchanged: \result == c;
226 disjoint behaviors;
227 */
228 extern int toupper(int c);
229
230 /* POSIX */
231 /*@
232 requires c_uchar_or_eof: 0 <= c <= 255 || c == EOF;
233 assigns \result \from c;
234 behavior match:
235 assumes c_ascii: 0 <= c <= 127;
236 ensures nonzero_result: \result < 0 || \result > 0;
237 behavior no_match:
238 assumes c_non_ascii: !(0 <= c <= 127);
239 ensures zero_result: \result == 0;
240 disjoint behaviors;
241 complete behaviors;
242 */
243 extern int isascii(int c);
244
245 __END_DECLS
246
247 __POP_FC_STDLIB
248 #endif