@matheusbsbs / matheus-bagliano / commits / c841aa8b90
Fork 0

Reformat ctype.c

Enhance the readability of ctype.c by using an enum instead of macros to initialize the character class table. This allows the use of a single letter to mark a char, making the table fit within 80 columns. Also list the index of the last entry in each row in the following comment. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 17, 2009 at 16:50 UTC c841aa8b903200f5d7830c7c4ab8d62b5ef44c5c
1 file changed +14 -18
ctype.c
+14 -18
@@ -5,25 +5,21 @@
5 */
6 #include "cache.h"
7
8 -/* Just so that no insane platform contaminate namespace with these symbols */
9 -#undef SS
10 -#undef AA
11 -#undef DD
12 -#undef GS
13 -
14 -#define SS GIT_SPACE
15 -#define AA GIT_ALPHA
16 -#define DD GIT_DIGIT
17 -#define GS GIT_SPECIAL /* \0, *, ?, [, \\ */
8 +enum {
9 + S = GIT_SPACE,
10 + A = GIT_ALPHA,
11 + D = GIT_DIGIT,
12 + G = GIT_SPECIAL, /* \0, *, ?, [, \\ */
13 +};
14
15 unsigned char sane_ctype[256] = {
20 - GS, 0, 0, 0, 0, 0, 0, 0, 0, SS, SS, 0, 0, SS, 0, 0, /* 0-15 */
21 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16-15 */
22 - SS, 0, 0, 0, 0, 0, 0, 0, 0, 0, GS, 0, 0, 0, 0, 0, /* 32-15 */
23 - DD, DD, DD, DD, DD, DD, DD, DD, DD, DD, 0, 0, 0, 0, 0, GS, /* 48-15 */
24 - 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 64-15 */
25 - AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, GS, GS, 0, 0, 0, /* 80-15 */
26 - 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 96-15 */
27 - AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 112-15 */
16 + G, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0, /* 0.. 15 */
17 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16.. 31 */
18 + S, 0, 0, 0, 0, 0, 0, 0, 0, 0, G, 0, 0, 0, 0, 0, /* 32.. 47 */
19 + D, D, D, D, D, D, D, D, D, D, 0, 0, 0, 0, 0, G, /* 48.. 63 */
20 + 0, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */
21 + A, A, A, A, A, A, A, A, A, A, A, G, G, 0, 0, 0, /* 80.. 95 */
22 + 0, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */
23 + A, A, A, A, A, A, A, A, A, A, A, 0, 0, 0, 0, 0, /* 112..127 */
24 /* Nothing in the 128.. range */
25 };