summaryrefslogtreecommitdiff
path: root/test-regex.c
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2012-09-01 17:46:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-09-03 01:57:21 (GMT)
commitc91841594c2f08bec0c8b2d46da27add18fb4854 (patch)
tree6fe9bead7c13729dcdfc12c54c79ccf31f62bf7a /test-regex.c
parentd0f1ea6003d97e63110fa7d50bb07f546a909b6e (diff)
downloadgit-c91841594c2f08bec0c8b2d46da27add18fb4854.zip
git-c91841594c2f08bec0c8b2d46da27add18fb4854.tar.gz
git-c91841594c2f08bec0c8b2d46da27add18fb4854.tar.bz2
test-regex: Add a test to check for a bug in the regex routines
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-regex.c')
-rw-r--r--test-regex.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test-regex.c b/test-regex.c
new file mode 100644
index 0000000..b5bfd54
--- /dev/null
+++ b/test-regex.c
@@ -0,0 +1,20 @@
+#include <git-compat-util.h>
+
+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);
+}