From c91841594c2f08bec0c8b2d46da27add18fb4854 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 1 Sep 2012 18:46:54 +0100 Subject: test-regex: Add a test to check for a bug in the regex routines Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- test-regex.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test-regex.c (limited to 'test-regex.c') diff --git a/test-regex.c b/test-regex.c new file mode 100644 index 0000000000..b5bfd54139 --- /dev/null +++ b/test-regex.c @@ -0,0 +1,20 @@ +#include + +int main(int argc, char **argv) +{ + char *pat = "[^={} \t]+"; + char *str = "={}\nfred"; + regex_t r; + regmatch_t m[1]; + + if (regcomp(&r, pat, REG_EXTENDED | REG_NEWLINE)) + die("failed regcomp() for pattern '%s'", pat); + if (regexec(&r, str, 1, m, 0)) + die("no match of pattern '%s' to string '%s'", pat, str); + + /* http://sourceware.org/bugzilla/show_bug.cgi?id=3957 */ + if (m[0].rm_so == 3) /* matches '\n' when it should not */ + die("regex bug confirmed: re-build git with NO_REGEX=1"); + + exit(0); +} -- cgit v1.2.1