/ src / include / ctype.h
ctype.h
 1  /* SPDX-License-Identifier: GPL-2.0-only */
 2  
 3  #ifndef CTYPE_H
 4  #define CTYPE_H
 5  
 6  static inline int isspace(int c)
 7  {
 8  	switch (c) {
 9  	case ' ': case '\f': case '\n':
10  	case '\r': case '\t': case '\v':
11  		return 1;
12  	default:
13  		return 0;
14  	}
15  }
16  
17  static inline int isprint(int c)
18  {
19  	return c >= ' ' && c <= '~';
20  }
21  
22  static inline int isdigit(int c)
23  {
24  	return (c >= '0' && c <= '9');
25  }
26  
27  static inline int isxdigit(int c)
28  {
29  	return ((c >= '0' && c <= '9') ||
30  		(c >= 'a' && c <= 'f') ||
31  		(c >= 'A' && c <= 'F'));
32  }
33  
34  static inline int isupper(int c)
35  {
36  	return (c >= 'A' && c <= 'Z');
37  }
38  
39  static inline int islower(int c)
40  {
41  	return (c >= 'a' && c <= 'z');
42  }
43  
44  static inline int toupper(int c)
45  {
46  	if (islower(c))
47  		c -= 'a'-'A';
48  	return c;
49  }
50  
51  static inline int tolower(int c)
52  {
53  	if (isupper(c))
54  		c -= 'A'-'a';
55  	return c;
56  }
57  
58  #endif /* CTYPE_H */