From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Alex Riesen <raa.lkml@gmail.com>, Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] grep: don't call regexec() for fixed strings
Date: Tue, 13 Jan 2009 00:13:18 -0800 [thread overview]
Message-ID: <7vy6xfd3oh.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 496B9780.3030000@lsrfire.ath.cx
René Scharfe <rene.scharfe@lsrfire.ath.cx> 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.
next prev parent reply other threads:[~2009-01-13 8:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-09 23:08 [PATCH 1/2] grep -w: forward to next possible position after rejected match René Scharfe
2009-01-09 23:18 ` [PATCH 2/2] grep: don't call regexec() for fixed strings René Scharfe
2009-01-10 20:37 ` Junio C Hamano
2009-01-12 12:25 ` Mikael Magnusson
2009-01-12 13:33 ` Johannes Schindelin
2009-01-12 15:32 ` Alex Riesen
2009-01-12 19:18 ` René Scharfe
2009-01-13 8:13 ` Junio C Hamano [this message]
2009-01-17 15:50 ` [PATCH 1/4] Add ctype test René Scharfe
2009-01-17 15:50 ` [PATCH 2/4] Reformat ctype.c René Scharfe
2009-01-17 15:50 ` [PATCH 3/4] Change NUL char handling of isspecial() René Scharfe
2009-01-17 15:50 ` [PATCH 4/4] Add is_regex_special() René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vy6xfd3oh.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=raa.lkml@gmail.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.