From: Junio C Hamano Date: Tue, 13 Jan 2009 08:13:18 GMT Subject: Re: [PATCH 2/2] grep: don't call regexec() for fixed strings Message-ID: <7vy6xfd3oh.fsf@gitster.siamese.dyndns.org> In-Reply-To: <496B9780.3030000@lsrfire.ath.cx> René Scharfe writes: > +#define RR GIT_REGEX_SPECIAL /* $, (, ), +, ., ^, {, | */ > +#define US GIT_UNDERSCORE > +#define Ah (GIT_ALPHA | GIT_LOWER_XDIGIT) > > unsigned char sane_ctype[256] = { > GS, 0, 0, 0, 0, 0, 0, 0, 0, SS, SS, 0, 0, SS, 0, 0, /* 0-15 */ Mental note. NUL is marked as GIT_SPECIAL. > #define isspecial(x) sane_istest(x,GIT_SPECIAL) > +#define isregexspecial(x) sane_istest(x,GIT_SPECIAL | GIT_REGEX_SPECIAL) Perhaps isspecial() is misnamed if we were to enhance git-ctype in this way. It is about a byte being shell glob pattern or a NUL (!!!), and it should be renamed to isglobspecial() or something. dir.c uses isspecial() in two places, and both callers rely on NUL being a part of special to terminate the loops they are in, like this: for (;;) { unsigned char c = *match++; len++; if (isspecial(c)) return len; } It may be a cunning and cute logic, but I do not particularly like it. It might be cleaner to rename it to isglobspecial(), drop NUL from it, and have these two call existing call sites to explicitly check for (c == NUL) for loop termination.