diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-07-14 13:29:29 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-11-11 17:06:23 +0000 |
commit | 65dcb6453457fee640fe62008f9a395de58fd39a (patch) | |
tree | 2653363f67577e971da17936e831bf0c0f56cd72 | |
parent | ef1395f315ba137be64744a3a6b9d784db44fded (diff) | |
download | libgit2-65dcb6453457fee640fe62008f9a395de58fd39a.tar.gz |
patch_parse: use git_parse_contains_s
Instead of manually checking the parsing context's remaining length and
comparing the leading bytes with a specific string, we can simply re-use
the function `git_parse_ctx_contains_s`. Do so to avoid code duplication
and to further decouple patch parsing from the parsing context's struct
members.
-rw-r--r-- | src/patch_parse.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/patch_parse.c b/src/patch_parse.c index 506a1bdcb..0b3ad8f08 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -36,7 +36,7 @@ typedef struct { static int header_path_len(git_patch_parse_ctx *ctx) { bool inquote = 0; - bool quoted = (ctx->parse_ctx.line_len > 0 && ctx->parse_ctx.line[0] == '"'); + bool quoted = git_parse_ctx_contains_s(&ctx->parse_ctx, "\""); size_t len; for (len = quoted; len < ctx->parse_ctx.line_len; len++) { @@ -531,7 +531,7 @@ static int parse_hunk_body( for (; ctx->parse_ctx.remain_len > 1 && (oldlines || newlines) && - (ctx->parse_ctx.remain_len <= 4 || memcmp(ctx->parse_ctx.line, "@@ -", 4) != 0); + !git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -"); git_parse_advance_line(&ctx->parse_ctx)) { int origin; |