mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
regex: apple's regcomp got weird with locales
This commit is contained in:
@@ -22,7 +22,7 @@ void test_regexp__cleanup(void)
|
|||||||
git_regexp_dispose(®ex);
|
git_regexp_dispose(®ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void try_set_locale(int category)
|
GIT_UNUSED_FUNCTION static void try_set_locale(int category)
|
||||||
{
|
{
|
||||||
#if LC_ALL > 0
|
#if LC_ALL > 0
|
||||||
old_locales[category] = setlocale(category, NULL);
|
old_locales[category] = setlocale(category, NULL);
|
||||||
@@ -40,27 +40,30 @@ static void try_set_locale(int category)
|
|||||||
|
|
||||||
void test_regexp__compile_ignores_global_locale_ctype(void)
|
void test_regexp__compile_ignores_global_locale_ctype(void)
|
||||||
{
|
{
|
||||||
|
#if defined(GIT_WIN32) || defined(__APPLE__)
|
||||||
|
cl_skip();
|
||||||
|
#else
|
||||||
try_set_locale(LC_CTYPE);
|
try_set_locale(LC_CTYPE);
|
||||||
cl_git_pass(git_regexp_compile(®ex, "[\xc0-\xff][\x80-\xbf]", 0));
|
cl_git_pass(git_regexp_compile(®ex, "[\xc0-\xff][\x80-\xbf]", 0));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_regexp__compile_ignores_global_locale_collate(void)
|
void test_regexp__compile_ignores_global_locale_collate(void)
|
||||||
{
|
{
|
||||||
#ifdef GIT_WIN32
|
#if defined(GIT_WIN32) || defined(__APPLE__)
|
||||||
cl_skip();
|
cl_skip();
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
try_set_locale(LC_COLLATE);
|
try_set_locale(LC_COLLATE);
|
||||||
cl_git_pass(git_regexp_compile(®ex, "[\xc0-\xff][\x80-\xbf]", 0));
|
cl_git_pass(git_regexp_compile(®ex, "[\xc0-\xff][\x80-\xbf]", 0));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_regexp__regex_matches_digits_with_locale(void)
|
void test_regexp__regex_matches_digits_with_locale(void)
|
||||||
{
|
{
|
||||||
char c, str[2];
|
#if defined(GIT_WIN32) || defined(__APPLE__)
|
||||||
|
|
||||||
#ifdef GIT_WIN32
|
|
||||||
cl_skip();
|
cl_skip();
|
||||||
#endif
|
#else
|
||||||
|
char c, str[2];
|
||||||
|
|
||||||
try_set_locale(LC_COLLATE);
|
try_set_locale(LC_COLLATE);
|
||||||
try_set_locale(LC_CTYPE);
|
try_set_locale(LC_CTYPE);
|
||||||
@@ -72,15 +75,15 @@ void test_regexp__regex_matches_digits_with_locale(void)
|
|||||||
str[0] = c;
|
str[0] = c;
|
||||||
cl_git_pass(git_regexp_match(®ex, str));
|
cl_git_pass(git_regexp_match(®ex, str));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_regexp__regex_matches_alphabet_with_locale(void)
|
void test_regexp__regex_matches_alphabet_with_locale(void)
|
||||||
{
|
{
|
||||||
char c, str[2];
|
#if defined(GIT_WIN32) || defined(__APPLE__)
|
||||||
|
|
||||||
#ifdef GIT_WIN32
|
|
||||||
cl_skip();
|
cl_skip();
|
||||||
#endif
|
#else
|
||||||
|
char c, str[2];
|
||||||
|
|
||||||
try_set_locale(LC_COLLATE);
|
try_set_locale(LC_COLLATE);
|
||||||
try_set_locale(LC_CTYPE);
|
try_set_locale(LC_CTYPE);
|
||||||
@@ -96,6 +99,7 @@ void test_regexp__regex_matches_alphabet_with_locale(void)
|
|||||||
str[0] = c;
|
str[0] = c;
|
||||||
cl_git_pass(git_regexp_match(®ex, str));
|
cl_git_pass(git_regexp_match(®ex, str));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_regexp__simple_search_matches(void)
|
void test_regexp__simple_search_matches(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user