https://github.com/git/git
Raw File
Tip revision: 74b67638166ca2e66497ede559dbf393e7af8b40 authored by Junio C Hamano on 04 September 2015, 17:36:00 UTC
Git 2.4.9
Tip revision: 74b6763
test-regex.c
#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);
}
back to top