aboutsummaryrefslogtreecommitdiff
path: root/contrib/libdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2024-03-27 10:03:29 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2024-03-27 10:03:29 +0000
commit5fbe8912d6a2d1178468d1994c301d4c7cd4f975 (patch)
tree487d7d5646ebbdd0f01c5da933cd4b94ebb18bed /contrib/libdiff
parentd72a37b535386fa4551288e9b39ff45b82d6a035 (diff)
Diffstat (limited to 'contrib/libdiff')
-rw-r--r--contrib/libdiff/lib/diff_internal.h2
-rw-r--r--contrib/libdiff/lib/diff_output.c9
-rw-r--r--contrib/libdiff/lib/diff_output_unidiff.c24
3 files changed, 18 insertions, 17 deletions
diff --git a/contrib/libdiff/lib/diff_internal.h b/contrib/libdiff/lib/diff_internal.h
index 46bbadf3cb64..16ee6776a71f 100644
--- a/contrib/libdiff/lib/diff_internal.h
+++ b/contrib/libdiff/lib/diff_internal.h
@@ -148,7 +148,7 @@ int diff_output_trailing_newline_msg(struct diff_output_info *outinfo,
int diff_output_match_function_prototype(char *prototype, size_t prototype_size,
int *last_prototype_idx,
const struct diff_result *result,
- const struct diff_chunk_context *cc);
+ int chunk_start_line);
struct diff_output_info *diff_output_info_alloc(void);
diff --git a/contrib/libdiff/lib/diff_output.c b/contrib/libdiff/lib/diff_output.c
index 7ac63bb6c433..78d9b8942077 100644
--- a/contrib/libdiff/lib/diff_output.c
+++ b/contrib/libdiff/lib/diff_output.c
@@ -255,7 +255,8 @@ diff_output_trailing_newline_msg(struct diff_output_info *outinfo, FILE *dest,
static bool
is_function_prototype(unsigned char ch)
{
- return (isalpha((unsigned char)ch) || ch == '_' || ch == '$');
+ return (isalpha((unsigned char)ch) || ch == '_' || ch == '$' ||
+ ch == '-' || ch == '+');
}
#define begins_with(s, pre) (strncmp(s, pre, sizeof(pre)-1) == 0)
@@ -263,7 +264,7 @@ is_function_prototype(unsigned char ch)
int
diff_output_match_function_prototype(char *prototype, size_t prototype_size,
int *last_prototype_idx, const struct diff_result *result,
- const struct diff_chunk_context *cc)
+ int chunk_start_line)
{
struct diff_atom *start_atom, *atom;
const struct diff_data *data;
@@ -271,9 +272,9 @@ diff_output_match_function_prototype(char *prototype, size_t prototype_size,
const char *state = NULL;
int rc, i, ch;
- if (result->left->atoms.len > 0 && cc->left.start > 0) {
+ if (result->left->atoms.len > 0 && chunk_start_line > 0) {
data = result->left;
- start_atom = &data->atoms.head[cc->left.start - 1];
+ start_atom = &data->atoms.head[chunk_start_line - 1];
} else
return DIFF_RC_OK;
diff --git a/contrib/libdiff/lib/diff_output_unidiff.c b/contrib/libdiff/lib/diff_output_unidiff.c
index d480a022a9a7..88c98c663c00 100644
--- a/contrib/libdiff/lib/diff_output_unidiff.c
+++ b/contrib/libdiff/lib/diff_output_unidiff.c
@@ -301,10 +301,21 @@ output_unidiff_chunk(struct diff_output_info *outinfo, FILE *dest,
else
right_start = cc->right.start + 1;
+ /* Got the absolute line numbers where to start printing, and the index
+ * of the interesting (non-context) chunk.
+ * To print context lines above the interesting chunk, nipping on the
+ * previous chunk index may be necessary.
+ * It is guaranteed to be only context lines where left == right, so it
+ * suffices to look on the left. */
+ const struct diff_chunk *first_chunk;
+ int chunk_start_line;
+ first_chunk = &result->chunks.head[cc->chunk.start];
+ chunk_start_line = diff_atom_root_idx(result->left,
+ first_chunk->left_start);
if (show_function_prototypes) {
rc = diff_output_match_function_prototype(state->prototype,
sizeof(state->prototype), &state->last_prototype_idx,
- result, cc);
+ result, chunk_start_line);
if (rc)
return rc;
}
@@ -344,17 +355,6 @@ output_unidiff_chunk(struct diff_output_info *outinfo, FILE *dest,
*typep = DIFF_LINE_HUNK;
}
- /* Got the absolute line numbers where to start printing, and the index
- * of the interesting (non-context) chunk.
- * To print context lines above the interesting chunk, nipping on the
- * previous chunk index may be necessary.
- * It is guaranteed to be only context lines where left == right, so it
- * suffices to look on the left. */
- const struct diff_chunk *first_chunk;
- int chunk_start_line;
- first_chunk = &result->chunks.head[cc->chunk.start];
- chunk_start_line = diff_atom_root_idx(result->left,
- first_chunk->left_start);
if (cc->left.start < chunk_start_line) {
rc = diff_output_lines(outinfo, dest, " ",
&result->left->atoms.head[cc->left.start],