From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: GIT Mailing-list <git@vger.kernel.org>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
trast@student.ethz.ch, Junio C Hamano <gitster@pobox.com>
Subject: [RFC/PATCH] userdiff.c: Avoid old glibc regex bug causing t4034-*.sh test failures
Date: Tue, 03 May 2011 18:49:21 +0100 [thread overview]
Message-ID: <4DC04021.1040606@ramsay1.demon.co.uk> (raw)
In particular, this bug affects the word-diff regex for 'bibtex' and
'html', leading to the test failures in t4034-diff-words.sh. The bug
is described here:
http://sourceware.org/bugzilla/show_bug.cgi?id=3957
and was fixed on 12-07-2007. In summary, when the REG_NEWLINE flag is
passed to regcomp(), a non-matching list ([^...]) not containing a
newline should not match a newline. However, in some old versions of
the glibc regex library, the newline character was indeed matched.
In order to fix the problem, we add an explicit '\n' to the list in
the non-matching list expression.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Junio,
I recently mentioned that a couple of tests in t4034-*.sh were
failing for me on Linux. I have now looked into it, and the problem
turned out to be an old bug in the glibc regex routines. :-(
This is an RFC because:
- A simple fix would be for me to put NO_REGEX=1 in my config.mak,
since the compat/regex routines don't suffer this problem.
- I suspect this bug is old enough that it will not affect many users.
- I have not audited the other non-matching list expressions in
userdiff.c
- blame, grep and pickaxe all call regcomp() with the REG_NEWLINE
flag, but get the regex from the user (eg from command line).
ATB,
Ramsay Jones
userdiff.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/userdiff.c b/userdiff.c
index 1ff4797..2f9ba37 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -28,7 +28,7 @@ IPATTERN("fortran",
"|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
"|//|\\*\\*|::|[/<>=]="),
PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
- "[^<>= \t]+"),
+ "[^<>= \t\n]+"),
PATTERNS("java",
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
"^[ \t]*(([A-Za-z_][A-Za-z_0-9]*[ \t]+)+[A-Za-z_][A-Za-z_0-9]*[ \t]*\\([^;]*)$",
@@ -94,7 +94,7 @@ PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$",
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?."
"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"),
PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
- "[={}\"]|[^={}\" \t]+"),
+ "[={}\"]|[^={}\" \t\n]+"),
PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
"\\\\[a-zA-Z@]+|\\\\.|[a-zA-Z0-9\x80-\xff]+"),
PATTERNS("cpp",
--
1.7.5
next reply other threads:[~2011-05-03 17:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 17:49 Ramsay Jones [this message]
2011-05-03 21:07 ` [RFC/PATCH] userdiff.c: Avoid old glibc regex bug causing t4034-*.sh test failures Jonathan Nieder
2011-05-07 17:54 ` Ramsay Jones
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=4DC04021.1040606@ramsay1.demon.co.uk \
--to=ramsay@ramsay1.demon.co.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=trast@student.ethz.ch \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).