summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArthur Schreiber <arthurschreiber@github.com>2016-10-06 13:15:31 +0200
committerArthur Schreiber <arthurschreiber@github.com>2016-10-06 13:15:31 +0200
commitab96ca5572f1aae6bc7f889fbd46f56fc959ba2b (patch)
tree4bb04769f4b5b9081d4516a4075953fc4c80ec63 /src
parente8ab13b3fd8485086c2a906dac85ecc8fa162d84 (diff)
downloadlibgit2-ab96ca5572f1aae6bc7f889fbd46f56fc959ba2b.tar.gz
Make sure we use the `C` locale for `regcomp` on macOS.
Diffstat (limited to 'src')
-rw-r--r--src/config.c6
-rw-r--r--src/config_file.c5
-rw-r--r--src/diff_driver.c7
-rw-r--r--src/revparse.c2
-rw-r--r--src/unix/posix.h10
-rw-r--r--src/win32/posix.h3
6 files changed, 22 insertions, 11 deletions
diff --git a/src/config.c b/src/config.c
index f4d4cb2b9..403b7090d 100644
--- a/src/config.c
+++ b/src/config.c
@@ -478,7 +478,7 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
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;
@@ -512,7 +512,7 @@ int git_config_backend_foreach_match(
int error = 0;
if (regexp != NULL) {
- if ((error = regcomp(&regex, regexp, REG_EXTENDED)) != 0) {
+ if ((error = p_regcomp(&regex, regexp, REG_EXTENDED)) != 0) {
giterr_set_regex(&regex, error);
regfree(&regex);
return -1;
@@ -1003,7 +1003,7 @@ int git_config_multivar_iterator_new(git_config_iterator **out, const git_config
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;
diff --git a/src/config_file.c b/src/config_file.c
index e33b83738..9ff021e7e 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -570,7 +570,7 @@ static int config_set_multivar(
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;
@@ -657,7 +657,7 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
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;
@@ -1957,4 +1957,3 @@ done:
git_buf_free(&reader->buffer);
return result;
}
-
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 14a898c4f..1a7f09a44 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -114,7 +114,7 @@ static int diff_driver_add_patterns(
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
*/
@@ -210,7 +210,7 @@ static int git_diff_driver_builtin(
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);
@@ -314,7 +314,7 @@ static int git_diff_driver_load(
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 */
@@ -519,4 +519,3 @@ void git_diff_find_context_clear(git_diff_find_context_payload *payload)
payload->driver = NULL;
}
}
-
diff --git a/src/revparse.c b/src/revparse.c
index e0ec3941d..aa7e0bd98 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -50,7 +50,7 @@ static int build_regex(regex_t *regex, const char *pattern)
return GIT_EINVALIDSPEC;
}
- error = regcomp(regex, pattern, REG_EXTENDED);
+ error = p_regcomp(regex, pattern, REG_EXTENDED);
if (!error)
return 0;
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 482d2c803..ad13291e8 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -80,4 +80,14 @@ GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2])
# 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
diff --git a/src/win32/posix.h b/src/win32/posix.h
index 5fab267c2..73705fb2b 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -57,4 +57,7 @@ extern int p_lstat_posixly(const char *filename, struct stat *buf);
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