summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Modules/FindPCRE2.cmake5
-rw-r--r--src/common.h1
-rw-r--r--src/errors.c15
-rw-r--r--src/errors.h7
-rw-r--r--src/posix_regex.h73
-rw-r--r--tests/core/posix.c120
6 files changed, 2 insertions, 219 deletions
diff --git a/cmake/Modules/FindPCRE2.cmake b/cmake/Modules/FindPCRE2.cmake
index 122f0e9d4..f8c5639d5 100644
--- a/cmake/Modules/FindPCRE2.cmake
+++ b/cmake/Modules/FindPCRE2.cmake
@@ -20,15 +20,14 @@ FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
# Look for the library.
FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
-FIND_LIBRARY(PCRE2_POSIX_LIBRARY NAMES pcre2-posix)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_POSIX_LIBRARY PCRE2_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE2_FOUND)
- SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY} ${PCRE2_POSIX_LIBRARY})
+ SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
ELSE(PCRE2_FOUND)
SET(PCRE2_LIBRARIES)
diff --git a/src/common.h b/src/common.h
index 8a5761abc..a4152caf2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -88,7 +88,6 @@
#include "git2/deprecated.h"
#include "posix.h"
-#include "posix_regex.h"
#define DEFAULT_BUFSIZE 65536
#define FILEIO_BUFSIZE DEFAULT_BUFSIZE
diff --git a/src/errors.c b/src/errors.c
index 18d6c2dc8..c75f6b17a 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -110,21 +110,6 @@ void git_error_set_str(int error_class, const char *string)
set_error_from_buffer(error_class);
}
-int git_error_set_regex(const p_regex_t *regex, int error_code)
-{
- char error_buf[1024];
-
- assert(error_code);
-
- p_regerror(error_code, regex, error_buf, sizeof(error_buf));
- git_error_set_str(GIT_ERROR_REGEX, error_buf);
-
- if (error_code == P_REG_NOMATCH)
- return GIT_ENOTFOUND;
-
- return GIT_EINVALIDSPEC;
-}
-
void git_error_clear(void)
{
if (GIT_GLOBAL->last_error != NULL) {
diff --git a/src/errors.h b/src/errors.h
index 86f06f9c7..a2f60f752 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -8,7 +8,6 @@
#ifndef INCLUDE_errors_h__
#define INCLUDE_errors_h__
-#include "posix_regex.h"
#include "common.h"
/*
@@ -18,12 +17,6 @@ void git_error_set(int error_class, const char *fmt, ...) GIT_FORMAT_PRINTF(2, 3
void git_error_vset(int error_class, const char *fmt, va_list ap);
/**
- * Set the error message for a regex failure, using the internal regex
- * error code lookup and return a libgit error code.
- */
-int git_error_set_regex(const p_regex_t *regex, int error_code);
-
-/**
* Set error message for user callback if needed.
*
* If the error code in non-zero and no error message is set, this
diff --git a/src/posix_regex.h b/src/posix_regex.h
deleted file mode 100644
index 421ffeba1..000000000
--- a/src/posix_regex.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) the libgit2 contributors. All rights reserved.
- *
- * This file is part of libgit2, distributed under the GNU GPL v2 with
- * a Linking Exception. For full terms see the included COPYING file.
- */
-#ifndef INCLUDE_posix_regex_h__
-#define INCLUDE_posix_regex_h__
-
-#include "common.h"
-
-/*
- * Regular expressions: if we were asked to use PCRE (either our
- * bundled version or a system version) then use their regcomp
- * compatible implementation.
- */
-
-#ifdef GIT_REGEX_BUILTIN
-
-# include "pcreposix.h"
-
-# define P_REG_EXTENDED PCRE_REG_EXTENDED
-# define P_REG_ICASE PCRE_REG_ICASE
-# define P_REG_NOMATCH PCRE_REG_NOMATCH
-
-# define p_regex_t pcre_regex_t
-# define p_regmatch_t pcre_regmatch_t
-# define p_regcomp pcre_regcomp
-# define p_regerror pcre_regerror
-# define p_regexec pcre_regexec
-# define p_regfree pcre_regfree
-
-/*
- * Use the system-provided `regex` routines, whether that's via the
- * PCRE emulation layer, or libc, preferring `regcomp_l` it's available.
- */
-
-#else
-
-# if defined(GIT_REGEX_PCRE2)
-# include <pcre2posix.h>
-# elif defined(GIT_REGEX_PCRE)
-# include <pcreposix.h>
-# else
-# include <regex.h>
-# endif
-
-# define P_REG_EXTENDED REG_EXTENDED
-# define P_REG_ICASE REG_ICASE
-# define P_REG_NOMATCH REG_NOMATCH
-
-# define p_regex_t regex_t
-# define p_regmatch_t regmatch_t
-
-# define p_regerror regerror
-# define p_regexec regexec
-# define p_regfree regfree
-
-# ifdef GIT_REGEX_REGCOMP_L
-# include <xlocale.h>
-
-GIT_INLINE(int) p_regcomp(p_regex_t *preg, const char *pattern, int cflags)
-{
- return regcomp_l(preg, pattern, cflags, (locale_t) 0);
-}
-
-# else
-# define p_regcomp regcomp
-# endif /* GIT_REGEX_REGCOMP_L */
-
-#endif
-
-#endif
diff --git a/tests/core/posix.c b/tests/core/posix.c
index dcc619f22..77ac65ad6 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -9,23 +9,12 @@
# endif
#endif
-#include <locale.h>
-
#include "clar_libgit2.h"
#include "futils.h"
#include "posix.h"
-#include "userdiff.h"
-
-#if LC_ALL > 0
-static const char *old_locales[LC_ALL];
-#endif
void test_core_posix__initialize(void)
{
-#if LC_ALL > 0
- memset(&old_locales, 0, sizeof(old_locales));
-#endif
-
#ifdef GIT_WIN32
/* on win32, the WSA context needs to be initialized
* before any socket calls can be performed */
@@ -156,115 +145,6 @@ void test_core_posix__utimes(void)
cl_must_pass(p_unlink("foo"));
}
-static void try_set_locale(int category)
-{
-#if LC_ALL > 0
- old_locales[category] = setlocale(category, NULL);
-#endif
-
- if (!setlocale(category, "UTF-8") &&
- !setlocale(category, "c.utf8") &&
- !setlocale(category, "en_US.UTF-8"))
- cl_skip();
-
- if (MB_CUR_MAX == 1)
- cl_fail("Expected locale to be switched to multibyte");
-}
-
-void test_core_posix__p_regcomp_ignores_global_locale_ctype(void)
-{
- p_regex_t preg;
-
- try_set_locale(LC_CTYPE);
-
- cl_assert(!p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", P_REG_EXTENDED));
-
- p_regfree(&preg);
-}
-
-void test_core_posix__p_regcomp_ignores_global_locale_collate(void)
-{
- p_regex_t preg;
-
-#ifdef GIT_WIN32
- cl_skip();
-#endif
-
- try_set_locale(LC_COLLATE);
- cl_assert(!p_regcomp(&preg, "[\xc0-\xff][\x80-\xbf]", P_REG_EXTENDED));
-
- p_regfree(&preg);
-}
-
-void test_core_posix__p_regcomp_matches_digits_with_locale(void)
-{
- p_regex_t preg;
- char c, str[2];
-
-#ifdef GIT_WIN32
- cl_skip();
-#endif
-
- try_set_locale(LC_COLLATE);
- try_set_locale(LC_CTYPE);
-
- cl_assert(!p_regcomp(&preg, "[[:digit:]]", P_REG_EXTENDED));
-
- str[1] = '\0';
- for (c = '0'; c <= '9'; c++) {
- str[0] = c;
- cl_assert(!p_regexec(&preg, str, 0, NULL, 0));
- }
-
- p_regfree(&preg);
-}
-
-void test_core_posix__p_regcomp_matches_alphabet_with_locale(void)
-{
- p_regex_t preg;
- char c, str[2];
-
-#ifdef GIT_WIN32
- cl_skip();
-#endif
-
- try_set_locale(LC_COLLATE);
- try_set_locale(LC_CTYPE);
-
- cl_assert(!p_regcomp(&preg, "[[:alpha:]]", P_REG_EXTENDED));
-
- str[1] = '\0';
- for (c = 'a'; c <= 'z'; c++) {
- str[0] = c;
- cl_assert(!p_regexec(&preg, str, 0, NULL, 0));
- }
- for (c = 'A'; c <= 'Z'; c++) {
- str[0] = c;
- cl_assert(!p_regexec(&preg, str, 0, NULL, 0));
- }
-
- p_regfree(&preg);
-}
-
-void test_core_posix__p_regcomp_compile_userdiff_regexps(void)
-{
- size_t idx;
-
- for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
- git_diff_driver_definition ddef = builtin_defs[idx];
- int error = 0;
- p_regex_t preg;
-
- error = p_regcomp(&preg, ddef.fns, P_REG_EXTENDED | ddef.flags);
- p_regfree(&preg);
- cl_assert(!error);
-
- error = p_regcomp(&preg, ddef.words, P_REG_EXTENDED);
- p_regfree(&preg);
- cl_assert(!error);
- }
-}
-
void test_core_posix__unlink_removes_symlink(void)
{
if (!git_path_supports_symlinks(clar_sandbox_path()))