Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
a7df4a91
Commit
a7df4a91
authored
Oct 07, 2016
by
Carlos Martín Nieto
Committed by
GitHub
Oct 07, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3955 from arthurschreiber/arthur/fix-regcomp_l-check
Fix the existence check for `regcomp_l`.
parents
45dc219f
36117978
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
CMakeLists.txt
+1
-1
tests/core/posix.c
+29
-7
No files found.
CMakeLists.txt
View file @
a7df4a91
...
...
@@ -508,7 +508,7 @@ ELSE ()
ENDIF
()
ENDIF
()
CHECK_SYMBOL_EXISTS
(
regcomp_l
"xlocale.h"
HAVE_REGCOMP_L
)
CHECK_SYMBOL_EXISTS
(
regcomp_l
"
regex.h;
xlocale.h"
HAVE_REGCOMP_L
)
IF
(
HAVE_REGCOMP_L
)
ADD_DEFINITIONS
(
-DHAVE_REGCOMP_L
)
ENDIF
()
...
...
tests/core/posix.c
View file @
a7df4a91
...
...
@@ -9,6 +9,8 @@
# endif
#endif
#include <locale.h>
#include "clar_libgit2.h"
#include "posix.h"
#include "userdiff.h"
...
...
@@ -148,26 +150,46 @@ void test_core_posix__utimes(void)
p_unlink
(
"foo"
);
}
void
test_core_posix__p_regcomp_
compile_single_byte_regexps
(
void
)
void
test_core_posix__p_regcomp_
ignores_global_locale_ctype
(
void
)
{
regex_t
preg
;
int
error
=
0
;
const
char
*
oldlocale
=
setlocale
(
LC_CTYPE
,
NULL
);
cl_must_pass
(
p_regcomp
(
&
preg
,
"[
\xc0
-
\xff
][
\x80
-
\xbf
]"
,
REG_EXTENDED
));
if
(
!
setlocale
(
LC_CTYPE
,
"UTF-8"
)
&&
!
setlocale
(
LC_CTYPE
,
"c.utf8"
)
&&
!
setlocale
(
LC_CTYPE
,
"en_US.UTF-8"
))
cl_skip
();
if
(
MB_CUR_MAX
==
1
)
{
setlocale
(
LC_CTYPE
,
oldlocale
);
cl_fail
(
"Expected locale to be switched to multibyte"
);
}
p_regcomp
(
&
preg
,
"[
\xc0
-
\xff
][
\x80
-
\xbf
]"
,
REG_EXTENDED
);
regfree
(
&
preg
);
setlocale
(
LC_CTYPE
,
oldlocale
);
cl_must_pass
(
error
);
}
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
];
int
error
=
0
;
regex_t
preg
;
cl_must_pass
(
p_regcomp
(
&
preg
,
ddef
.
fns
,
REG_EXTENDED
|
ddef
.
flags
)
);
cl_must_pass
(
p_regcomp
(
&
preg
,
ddef
.
words
,
REG_EXTENDED
)
);
}
error
=
p_regcomp
(
&
preg
,
ddef
.
fns
,
REG_EXTENDED
|
ddef
.
flags
);
regfree
(
&
preg
);
cl_must_pass
(
error
);
regfree
(
&
preg
);
error
=
p_regcomp
(
&
preg
,
ddef
.
words
,
REG_EXTENDED
);
regfree
(
&
preg
);
cl_must_pass
(
error
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment