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
6890e00c
Commit
6890e00c
authored
Aug 21, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1801 from ethomson/utf8_bom
Skip UTF-8 BOM in binary detection
parents
5e1fb282
c0b01b75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
src/buf_text.c
+6
-0
tests-clar/core/buffer.c
+6
-0
No files found.
src/buf_text.c
View file @
6890e00c
...
@@ -170,8 +170,14 @@ int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings)
...
@@ -170,8 +170,14 @@ int git_buf_text_common_prefix(git_buf *buf, const git_strarray *strings)
bool
git_buf_text_is_binary
(
const
git_buf
*
buf
)
bool
git_buf_text_is_binary
(
const
git_buf
*
buf
)
{
{
const
char
*
scan
=
buf
->
ptr
,
*
end
=
buf
->
ptr
+
buf
->
size
;
const
char
*
scan
=
buf
->
ptr
,
*
end
=
buf
->
ptr
+
buf
->
size
;
git_bom_t
bom
;
int
printable
=
0
,
nonprintable
=
0
;
int
printable
=
0
,
nonprintable
=
0
;
scan
+=
git_buf_text_detect_bom
(
&
bom
,
buf
,
0
);
if
(
bom
>
GIT_BOM_UTF8
)
return
1
;
while
(
scan
<
end
)
{
while
(
scan
<
end
)
{
unsigned
char
c
=
*
scan
++
;
unsigned
char
c
=
*
scan
++
;
...
...
tests-clar/core/buffer.c
View file @
6890e00c
...
@@ -718,6 +718,8 @@ void test_core_buffer__classify_with_utf8(void)
...
@@ -718,6 +718,8 @@ void test_core_buffer__classify_with_utf8(void)
size_t
data1len
=
31
;
size_t
data1len
=
31
;
char
*
data2
=
"Internal NUL!!!
\000\n\n
I see you!
\n
"
;
char
*
data2
=
"Internal NUL!!!
\000\n\n
I see you!
\n
"
;
size_t
data2len
=
29
;
size_t
data2len
=
29
;
char
*
data3
=
"
\xef\xbb\xbf
This is UTF-8 with a BOM.
\n
"
;
size_t
data3len
=
20
;
git_buf
b
;
git_buf
b
;
b
.
ptr
=
data0
;
b
.
size
=
b
.
asize
=
data0len
;
b
.
ptr
=
data0
;
b
.
size
=
b
.
asize
=
data0len
;
...
@@ -731,6 +733,10 @@ void test_core_buffer__classify_with_utf8(void)
...
@@ -731,6 +733,10 @@ void test_core_buffer__classify_with_utf8(void)
b
.
ptr
=
data2
;
b
.
size
=
b
.
asize
=
data2len
;
b
.
ptr
=
data2
;
b
.
size
=
b
.
asize
=
data2len
;
cl_assert
(
git_buf_text_is_binary
(
&
b
));
cl_assert
(
git_buf_text_is_binary
(
&
b
));
cl_assert
(
git_buf_text_contains_nul
(
&
b
));
cl_assert
(
git_buf_text_contains_nul
(
&
b
));
b
.
ptr
=
data3
;
b
.
size
=
b
.
asize
=
data3len
;
cl_assert
(
!
git_buf_text_is_binary
(
&
b
));
cl_assert
(
!
git_buf_text_contains_nul
(
&
b
));
}
}
#define SIMILARITY_TEST_DATA_1 \
#define SIMILARITY_TEST_DATA_1 \
...
...
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