Blame


1 1dfba055 2020-10-07 stsp /* Diff output generators and invocation shims. */
2 1dfba055 2020-10-07 stsp /*
3 1dfba055 2020-10-07 stsp * Copyright (c) 2020 Neels Hofmeyr <neels@hofmeyr.de>
4 1dfba055 2020-10-07 stsp *
5 1dfba055 2020-10-07 stsp * Permission to use, copy, modify, and distribute this software for any
6 1dfba055 2020-10-07 stsp * purpose with or without fee is hereby granted, provided that the above
7 1dfba055 2020-10-07 stsp * copyright notice and this permission notice appear in all copies.
8 1dfba055 2020-10-07 stsp *
9 1dfba055 2020-10-07 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 1dfba055 2020-10-07 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 1dfba055 2020-10-07 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 1dfba055 2020-10-07 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 1dfba055 2020-10-07 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 1dfba055 2020-10-07 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 1dfba055 2020-10-07 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 1dfba055 2020-10-07 stsp */
17 1dfba055 2020-10-07 stsp
18 1dfba055 2020-10-07 stsp struct diff_input_info {
19 1dfba055 2020-10-07 stsp const char *left_path;
20 1dfba055 2020-10-07 stsp const char *right_path;
21 1dfba055 2020-10-07 stsp };
22 1dfba055 2020-10-07 stsp
23 1dfba055 2020-10-07 stsp struct diff_output_info {
24 1dfba055 2020-10-07 stsp /*
25 1dfba055 2020-10-07 stsp * Byte offset to each line in the generated output file.
26 1dfba055 2020-10-07 stsp * The total number of lines in the file is line_offsets.len - 1.
27 1dfba055 2020-10-07 stsp * The last offset in this array corresponds to end-of-file.
28 1dfba055 2020-10-07 stsp */
29 1dfba055 2020-10-07 stsp ARRAYLIST(off_t) line_offsets;
30 1dfba055 2020-10-07 stsp };
31 1dfba055 2020-10-07 stsp
32 1dfba055 2020-10-07 stsp void diff_output_info_free(struct diff_output_info *output_info);
33 1dfba055 2020-10-07 stsp
34 1dfba055 2020-10-07 stsp struct diff_chunk_context {
35 1dfba055 2020-10-07 stsp struct diff_range chunk;
36 1dfba055 2020-10-07 stsp struct diff_range left, right;
37 1dfba055 2020-10-07 stsp };
38 1dfba055 2020-10-07 stsp
39 1dfba055 2020-10-07 stsp int diff_output_plain(struct diff_output_info **output_info, FILE *dest,
40 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
41 1dfba055 2020-10-07 stsp const struct diff_result *result);
42 1dfba055 2020-10-07 stsp int diff_output_unidiff(struct diff_output_info **output_info,
43 1dfba055 2020-10-07 stsp FILE *dest, const struct diff_input_info *info,
44 1dfba055 2020-10-07 stsp const struct diff_result *result,
45 1dfba055 2020-10-07 stsp unsigned int context_lines);
46 b7ba71f0 2020-10-07 stsp int diff_output_edscript(struct diff_output_info **output_info,
47 b7ba71f0 2020-10-07 stsp FILE *dest, const struct diff_input_info *info,
48 b7ba71f0 2020-10-07 stsp const struct diff_result *result);
49 1dfba055 2020-10-07 stsp int diff_chunk_get_left_start(const struct diff_chunk *c,
50 1dfba055 2020-10-07 stsp const struct diff_result *r,
51 1dfba055 2020-10-07 stsp int context_lines);
52 1dfba055 2020-10-07 stsp int diff_chunk_get_left_end(const struct diff_chunk *c,
53 1dfba055 2020-10-07 stsp const struct diff_result *r,
54 1dfba055 2020-10-07 stsp int context_lines);
55 1dfba055 2020-10-07 stsp int diff_chunk_get_right_start(const struct diff_chunk *c,
56 1dfba055 2020-10-07 stsp const struct diff_result *r,
57 1dfba055 2020-10-07 stsp int context_lines);
58 1dfba055 2020-10-07 stsp int diff_chunk_get_right_end(const struct diff_chunk *c,
59 1dfba055 2020-10-07 stsp const struct diff_result *r,
60 1dfba055 2020-10-07 stsp int context_lines);
61 1dfba055 2020-10-07 stsp void diff_chunk_context_get(struct diff_chunk_context *cc,
62 1dfba055 2020-10-07 stsp const struct diff_result *r,
63 1dfba055 2020-10-07 stsp int chunk_idx, int context_lines);
64 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state;
65 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state *diff_output_unidiff_state_alloc(void);
66 1dfba055 2020-10-07 stsp void diff_output_unidiff_state_reset(struct diff_output_unidiff_state *state);
67 1dfba055 2020-10-07 stsp void diff_output_unidiff_state_free(struct diff_output_unidiff_state *state);
68 1dfba055 2020-10-07 stsp int diff_output_unidiff_chunk(struct diff_output_info **output_info, FILE *dest,
69 1dfba055 2020-10-07 stsp struct diff_output_unidiff_state *state,
70 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
71 1dfba055 2020-10-07 stsp const struct diff_result *result,
72 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);
73 1dfba055 2020-10-07 stsp int diff_output_chunk_left_version(struct diff_output_info **output_info,
74 1dfba055 2020-10-07 stsp FILE *dest,
75 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
76 1dfba055 2020-10-07 stsp const struct diff_result *result,
77 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);
78 1dfba055 2020-10-07 stsp int diff_output_chunk_right_version(struct diff_output_info **output_info,
79 1dfba055 2020-10-07 stsp FILE *dest,
80 1dfba055 2020-10-07 stsp const struct diff_input_info *info,
81 1dfba055 2020-10-07 stsp const struct diff_result *result,
82 1dfba055 2020-10-07 stsp const struct diff_chunk_context *cc);