diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-09-14 20:46:39 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-14 20:46:39 -0700 |
commit | dabdc0178ec043ad42f6b3ab80e54f9c9404ab42 (patch) | |
tree | 3d95ce8b23f406b2ad3a5cf4b708cc034b0810ca /test-regex.c | |
parent | f463cc5306dd25844195b167aee4e5642e3bad16 (diff) | |
parent | c91841594c2f08bec0c8b2d46da27add18fb4854 (diff) | |
download | git-dabdc0178ec043ad42f6b3ab80e54f9c9404ab42.tar.gz git-dabdc0178ec043ad42f6b3ab80e54f9c9404ab42.tar.xz |
Merge branch 'rj/test-regex' into maint-1.7.11
* rj/test-regex:
test-regex: Add a test to check for a bug in the regex routines
Diffstat (limited to 'test-regex.c')
-rw-r--r-- | test-regex.c | 20 |
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); +} |