aboutsummaryrefslogtreecommitdiff
path: root/test-regex.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-14 21:20:40 -0700
committerJunio C Hamano <gitster@pobox.com>2012-09-14 21:20:40 -0700
commitc336bc104c47cc9c2f7caf6bce468fe00a8f6850 (patch)
tree501143681bb20b9d4642e5029a77bec2d321482c /test-regex.c
parente70d1632bdaf25a9ee528e78133cab319083eade (diff)
parentbafc478f1618534fcb85bedc0fa224bd2d462441 (diff)
downloadgit-c336bc104c47cc9c2f7caf6bce468fe00a8f6850.tar.gz
git-c336bc104c47cc9c2f7caf6bce468fe00a8f6850.tar.xz
Sync with 1.7.11.7
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 000000000..b5bfd5413
--- /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);
+}