INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
+INCLUDE(CheckSymbolExists)
INCLUDE(CheckStructHasMember)
INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgConfig)
ENDIF ()
ENDIF()
+CHECK_SYMBOL_EXISTS(regcomp_l "xlocale.h" HAVE_REGCOMP_L)
+IF (HAVE_REGCOMP_L)
+ ADD_DEFINITIONS(-DHAVE_REGCOMP_L)
+ENDIF ()
+
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
IF (HAVE_FUTIMENS)
ADD_DEFINITIONS(-DHAVE_FUTIMENS)
iter = git__calloc(1, sizeof(all_iter));
GITERR_CHECK_ALLOC(iter);
- if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
+ if ((result = p_regcomp(&iter->regex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&iter->regex, result);
git__free(iter);
return -1;
int error = 0;
if (regexp != NULL) {
- if ((error = regcomp(®ex, regexp, REG_EXTENDED)) != 0) {
+ if ((error = p_regcomp(®ex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(®ex, error);
regfree(®ex);
return -1;
goto on_error;
if (regexp != NULL) {
- error = regcomp(&iter->regex, regexp, REG_EXTENDED);
+ error = p_regcomp(&iter->regex, regexp, REG_EXTENDED);
if (error != 0) {
giterr_set_regex(&iter->regex, error);
error = -1;
if ((result = git_config__normalize_name(name, &key)) < 0)
return result;
- result = regcomp(&preg, regexp, REG_EXTENDED);
+ result = p_regcomp(&preg, regexp, REG_EXTENDED);
if (result != 0) {
giterr_set_regex(&preg, result);
result = -1;
refcounted_strmap_free(map);
- result = regcomp(&preg, regexp, REG_EXTENDED);
+ result = p_regcomp(&preg, regexp, REG_EXTENDED);
if (result != 0) {
giterr_set_regex(&preg, result);
result = -1;
git_buf_free(&reader->buffer);
return result;
}
-
if (error < 0)
break;
- if ((error = regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
+ if ((error = p_regcomp(&pat->re, buf.ptr, regex_flags)) != 0) {
/*
* TODO: issue a warning
*/
goto done;
if (ddef->words &&
- (error = regcomp(
+ (error = p_regcomp(
&drv->word_pattern, ddef->words, ddef->flags | REG_EXTENDED)))
{
error = giterr_set_regex(&drv->word_pattern, error);
goto done;
if (!ce || !ce->value)
/* no diff.<driver>.wordregex, so just continue */;
- else if (!(error = regcomp(&drv->word_pattern, ce->value, REG_EXTENDED)))
+ else if (!(error = p_regcomp(&drv->word_pattern, ce->value, REG_EXTENDED)))
found_driver = true;
else {
/* TODO: warn about bad regex instead of failure */
payload->driver = NULL;
}
}
-
return GIT_EINVALIDSPEC;
}
- error = regcomp(regex, pattern, REG_EXTENDED);
+ error = p_regcomp(regex, pattern, REG_EXTENDED);
if (!error)
return 0;
# define p_futimes futimes
#endif
+#ifdef HAVE_REGCOMP_L
+#include <xlocale.h>
+GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags)
+{
+ return regcomp_l(preg, pattern, cflags, (locale_t) 0);
+}
+#else
+# define p_regcomp regcomp
+#endif
+
#endif
extern struct tm * p_localtime_r(const time_t *timer, struct tm *result);
extern struct tm * p_gmtime_r(const time_t *timer, struct tm *result);
+/* Use the bundled regcomp */
+#define p_regcomp regcomp
+
#endif
#include "clar_libgit2.h"
#include "posix.h"
+#include "userdiff.h"
void test_core_posix__initialize(void)
{
struct in_addr addr;
struct in6_addr addr6;
size_t i;
-
+
struct in_addr_data {
const char *p;
const uint8_t n[4];
p_unlink("foo");
}
+
+void test_core_posix__p_regcomp_compile_single_byte_regexps(void)
+{
+ regex_t preg;
+
+ cl_must_pass(p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", REG_EXTENDED));
+
+ regfree(&preg);
+}
+
+void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
+{
+ regex_t preg;
+ size_t idx;
+
+ for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
+ git_diff_driver_definition ddef = builtin_defs[idx];
+
+ cl_must_pass(p_regcomp(&preg, ddef.fns, REG_EXTENDED | ddef.flags));
+ cl_must_pass(p_regcomp(&preg, ddef.words, REG_EXTENDED));
+ }
+
+ regfree(&preg);
+}