Blame


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