Skip to content

Commit c841aa8

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b4285c7 commit c841aa8

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

ctype.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,21 @@
55
*/
66
#include "cache.h"
77

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+
};
1814

1915
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 */
2824
/* Nothing in the 128.. range */
2925
};

0 commit comments

Comments
 (0)