]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/perf/util/sane_ctype.h
Merge tag 'bcm2835-dt-next-2017-03-30' into devicetree/next
[mirror_ubuntu-bionic-kernel.git] / tools / perf / util / sane_ctype.h
1 #ifndef _PERF_SANE_CTYPE_H
2 #define _PERF_SANE_CTYPE_H
3
4 extern const char *graph_line;
5 extern const char *graph_dotted_line;
6 extern const char *spaces;
7 extern const char *dots;
8
9 /* Sane ctype - no locale, and works with signed chars */
10 #undef isascii
11 #undef isspace
12 #undef isdigit
13 #undef isxdigit
14 #undef isalpha
15 #undef isprint
16 #undef isalnum
17 #undef islower
18 #undef isupper
19 #undef tolower
20 #undef toupper
21
22 extern unsigned char sane_ctype[256];
23 #define GIT_SPACE 0x01
24 #define GIT_DIGIT 0x02
25 #define GIT_ALPHA 0x04
26 #define GIT_GLOB_SPECIAL 0x08
27 #define GIT_REGEX_SPECIAL 0x10
28 #define GIT_PRINT_EXTRA 0x20
29 #define GIT_PRINT 0x3E
30 #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
31 #define isascii(x) (((x) & ~0x7f) == 0)
32 #define isspace(x) sane_istest(x,GIT_SPACE)
33 #define isdigit(x) sane_istest(x,GIT_DIGIT)
34 #define isxdigit(x) \
35 (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')
36 #define isalpha(x) sane_istest(x,GIT_ALPHA)
37 #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
38 #define isprint(x) sane_istest(x,GIT_PRINT)
39 #define islower(x) (sane_istest(x,GIT_ALPHA) && (x & 0x20))
40 #define isupper(x) (sane_istest(x,GIT_ALPHA) && !(x & 0x20))
41 #define tolower(x) sane_case((unsigned char)(x), 0x20)
42 #define toupper(x) sane_case((unsigned char)(x), 0)
43
44 static inline int sane_case(int x, int high)
45 {
46 if (sane_istest(x, GIT_ALPHA))
47 x = (x & ~0x20) | high;
48 return x;
49 }
50
51 #endif /* _PERF_SANE_CTYPE_H */