bundle-uri: mark unused parameters in callbacks
[alt-git.git] / sane-ctype.h
blobcbea1b299b79a5abfb5b1bd214cdd049bc559db2
1 #ifndef SANE_CTYPE_H
2 #define SANE_CTYPE_H
4 /* Sane ctype - no locale, and works with signed chars */
5 #undef isascii
6 #undef isspace
7 #undef isdigit
8 #undef isalpha
9 #undef isalnum
10 #undef isprint
11 #undef islower
12 #undef isupper
13 #undef tolower
14 #undef toupper
15 #undef iscntrl
16 #undef ispunct
17 #undef isxdigit
19 extern const unsigned char sane_ctype[256];
20 extern const signed char hexval_table[256];
21 #define GIT_SPACE 0x01
22 #define GIT_DIGIT 0x02
23 #define GIT_ALPHA 0x04
24 #define GIT_GLOB_SPECIAL 0x08
25 #define GIT_REGEX_SPECIAL 0x10
26 #define GIT_PATHSPEC_MAGIC 0x20
27 #define GIT_CNTRL 0x40
28 #define GIT_PUNCT 0x80
29 #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
30 #define isascii(x) (((x) & ~0x7f) == 0)
31 #define isspace(x) sane_istest(x,GIT_SPACE)
32 #define isdigit(x) sane_istest(x,GIT_DIGIT)
33 #define isalpha(x) sane_istest(x,GIT_ALPHA)
34 #define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
35 #define isprint(x) ((x) >= 0x20 && (x) <= 0x7e)
36 #define islower(x) sane_iscase(x, 1)
37 #define isupper(x) sane_iscase(x, 0)
38 #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
39 #define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
40 #define iscntrl(x) (sane_istest(x,GIT_CNTRL))
41 #define ispunct(x) sane_istest(x, GIT_PUNCT | GIT_REGEX_SPECIAL | \
42 GIT_GLOB_SPECIAL | GIT_PATHSPEC_MAGIC)
43 #define isxdigit(x) (hexval_table[(unsigned char)(x)] != -1)
44 #define tolower(x) sane_case((unsigned char)(x), 0x20)
45 #define toupper(x) sane_case((unsigned char)(x), 0)
46 #define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
48 static inline int sane_case(int x, int high)
50 if (sane_istest(x, GIT_ALPHA))
51 x = (x & ~0x20) | high;
52 return x;
55 static inline int sane_iscase(int x, int is_lower)
57 if (!sane_istest(x, GIT_ALPHA))
58 return 0;
60 if (is_lower)
61 return (x & 0x20) != 0;
62 else
63 return (x & 0x20) == 0;
66 #endif