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
00e63b36
Commit
00e63b36
authored
Nov 21, 2015
by
Edward Thomson
Committed by
Edward Thomson
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch: provide static string `advance_expected`
parent
a03952f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/patch_parse.c
+13
-10
No files found.
src/patch_parse.c
View file @
00e63b36
...
...
@@ -72,6 +72,9 @@ static int parse_advance_expected(
return
0
;
}
#define parse_advance_expected_s(ctx, str) \
parse_advance_expected(ctx, str, sizeof(str) - 1)
static
int
parse_advance_ws
(
patch_parse_ctx
*
ctx
)
{
int
ret
=
-
1
;
...
...
@@ -215,7 +218,7 @@ static int parse_header_git_index(
{
if
(
parse_header_oid
(
&
patch
->
base
.
delta
->
old_file
.
id
,
&
patch
->
base
.
delta
->
old_file
.
id_abbrev
,
ctx
)
<
0
||
parse_advance_expected
(
ctx
,
".."
,
2
)
<
0
||
parse_advance_expected
_s
(
ctx
,
".."
)
<
0
||
parse_header_oid
(
&
patch
->
base
.
delta
->
new_file
.
id
,
&
patch
->
base
.
delta
->
new_file
.
id_abbrev
,
ctx
)
<
0
)
return
-
1
;
...
...
@@ -317,7 +320,7 @@ static int parse_header_percent(uint16_t *out, patch_parse_ctx *ctx)
parse_advance_chars
(
ctx
,
(
end
-
ctx
->
line
));
if
(
parse_advance_expected
(
ctx
,
"%"
,
1
)
<
0
)
if
(
parse_advance_expected
_s
(
ctx
,
"%"
)
<
0
)
return
-
1
;
if
(
val
>
100
)
...
...
@@ -382,7 +385,7 @@ static int parse_header_git(
int
error
=
0
;
/* Parse the diff --git line */
if
(
parse_advance_expected
(
ctx
,
"diff --git "
,
11
)
<
0
)
if
(
parse_advance_expected
_s
(
ctx
,
"diff --git "
)
<
0
)
return
parse_err
(
"corrupt git diff header at line %d"
,
ctx
->
line_num
);
if
(
parse_header_path
(
&
patch
->
header_old_path
,
ctx
)
<
0
)
...
...
@@ -416,7 +419,7 @@ static int parse_header_git(
goto
done
;
parse_advance_ws
(
ctx
);
parse_advance_expected
(
ctx
,
"
\n
"
,
1
);
parse_advance_expected
_s
(
ctx
,
"
\n
"
);
if
(
ctx
->
line_len
>
0
)
{
error
=
parse_err
(
"trailing data at line %d"
,
ctx
->
line_num
);
...
...
@@ -471,27 +474,27 @@ static int parse_hunk_header(
hunk
->
hunk
.
old_lines
=
1
;
hunk
->
hunk
.
new_lines
=
1
;
if
(
parse_advance_expected
(
ctx
,
"@@ -"
,
4
)
<
0
||
if
(
parse_advance_expected
_s
(
ctx
,
"@@ -"
)
<
0
||
parse_int
(
&
hunk
->
hunk
.
old_start
,
ctx
)
<
0
)
goto
fail
;
if
(
ctx
->
line_len
>
0
&&
ctx
->
line
[
0
]
==
','
)
{
if
(
parse_advance_expected
(
ctx
,
","
,
1
)
<
0
||
if
(
parse_advance_expected
_s
(
ctx
,
","
)
<
0
||
parse_int
(
&
hunk
->
hunk
.
old_lines
,
ctx
)
<
0
)
goto
fail
;
}
if
(
parse_advance_expected
(
ctx
,
" +"
,
2
)
<
0
||
if
(
parse_advance_expected
_s
(
ctx
,
" +"
)
<
0
||
parse_int
(
&
hunk
->
hunk
.
new_start
,
ctx
)
<
0
)
goto
fail
;
if
(
ctx
->
line_len
>
0
&&
ctx
->
line
[
0
]
==
','
)
{
if
(
parse_advance_expected
(
ctx
,
","
,
1
)
<
0
||
if
(
parse_advance_expected
_s
(
ctx
,
","
)
<
0
||
parse_int
(
&
hunk
->
hunk
.
new_lines
,
ctx
)
<
0
)
goto
fail
;
}
if
(
parse_advance_expected
(
ctx
,
" @@"
,
3
)
<
0
)
if
(
parse_advance_expected
_s
(
ctx
,
" @@"
)
<
0
)
goto
fail
;
parse_advance_line
(
ctx
);
...
...
@@ -745,7 +748,7 @@ static int parsed_patch_binary(
{
int
error
;
if
(
parse_advance_expected
(
ctx
,
"GIT binary patch"
,
16
)
<
0
||
if
(
parse_advance_expected
_s
(
ctx
,
"GIT binary patch"
)
<
0
||
parse_advance_nl
(
ctx
)
<
0
)
return
parse_err
(
"corrupt git binary header at line %d"
,
ctx
->
line_num
);
...
...
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