Blame


1 3b0f3d61 2020-01-22 neels /* Produce a unidiff output from a diff_result. */
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 e10a628a 2020-09-16 stsp #include <errno.h>
19 e10a628a 2020-09-16 stsp #include <inttypes.h>
20 e10a628a 2020-09-16 stsp #include <stdbool.h>
21 e10a628a 2020-09-16 stsp #include <stdio.h>
22 e10a628a 2020-09-16 stsp #include <stdlib.h>
23 e10a628a 2020-09-16 stsp
24 e10a628a 2020-09-16 stsp #include <diff/arraylist.h>
25 e10a628a 2020-09-16 stsp #include <diff/diff_main.h>
26 3b0f3d61 2020-01-22 neels #include <diff/diff_output.h>
27 3b0f3d61 2020-01-22 neels
28 e4464189 2020-09-20 stsp #include "diff_debug.h"
29 85ab4559 2020-09-22 stsp #include "diff_internal.h"
30 3b0f3d61 2020-01-22 neels
31 61a7b578 2020-05-06 neels static bool
32 f374e913 2020-09-22 stsp chunk_context_empty(const struct diff_chunk_context *cc)
33 3b0f3d61 2020-01-22 neels {
34 d362ea2e 2020-07-25 stsp return diff_range_empty(&cc->chunk);
35 3b0f3d61 2020-01-22 neels }
36 3b0f3d61 2020-01-22 neels
37 f374e913 2020-09-22 stsp void
38 f374e913 2020-09-22 stsp diff_chunk_context_get(struct diff_chunk_context *cc, const struct diff_result *r,
39 0d27172a 2020-05-06 neels int chunk_idx, int context_lines)
40 3b0f3d61 2020-01-22 neels {
41 3b0f3d61 2020-01-22 neels const struct diff_chunk *c = &r->chunks.head[chunk_idx];
42 3b0f3d61 2020-01-22 neels int left_start = diff_atom_root_idx(&r->left, c->left_start);
43 0d27172a 2020-05-06 neels int left_end = MIN(r->left.atoms.len,
44 0d27172a 2020-05-06 neels left_start + c->left_count + context_lines);
45 3b0f3d61 2020-01-22 neels int right_start = diff_atom_root_idx(&r->right, c->right_start);
46 0d27172a 2020-05-06 neels int right_end = MIN(r->right.atoms.len,
47 0d27172a 2020-05-06 neels right_start + c->right_count + context_lines);
48 3b0f3d61 2020-01-22 neels
49 0d27172a 2020-05-06 neels left_start = MAX(0, left_start - context_lines);
50 0d27172a 2020-05-06 neels right_start = MAX(0, right_start - context_lines);
51 0d27172a 2020-05-06 neels
52 f374e913 2020-09-22 stsp *cc = (struct diff_chunk_context){
53 3b0f3d61 2020-01-22 neels .chunk = {
54 3b0f3d61 2020-01-22 neels .start = chunk_idx,
55 3b0f3d61 2020-01-22 neels .end = chunk_idx + 1,
56 3b0f3d61 2020-01-22 neels },
57 3b0f3d61 2020-01-22 neels .left = {
58 0d27172a 2020-05-06 neels .start = left_start,
59 0d27172a 2020-05-06 neels .end = left_end,
60 3b0f3d61 2020-01-22 neels },
61 3b0f3d61 2020-01-22 neels .right = {
62 0d27172a 2020-05-06 neels .start = right_start,
63 0d27172a 2020-05-06 neels .end = right_end,
64 3b0f3d61 2020-01-22 neels },
65 3b0f3d61 2020-01-22 neels };
66 3b0f3d61 2020-01-22 neels }
67 3b0f3d61 2020-01-22 neels
68 61a7b578 2020-05-06 neels static bool
69 f374e913 2020-09-22 stsp chunk_contexts_touch(const struct diff_chunk_context *cc,
70 f374e913 2020-09-22 stsp const struct diff_chunk_context *other)
71 3b0f3d61 2020-01-22 neels {
72 d362ea2e 2020-07-25 stsp return diff_ranges_touch(&cc->chunk, &other->chunk)
73 d362ea2e 2020-07-25 stsp || diff_ranges_touch(&cc->left, &other->left)
74 d362ea2e 2020-07-25 stsp || diff_ranges_touch(&cc->right, &other->right);
75 3b0f3d61 2020-01-22 neels }
76 3b0f3d61 2020-01-22 neels
77 61a7b578 2020-05-06 neels static void
78 f374e913 2020-09-22 stsp chunk_contexts_merge(struct diff_chunk_context *cc,
79 f374e913 2020-09-22 stsp const struct diff_chunk_context *other)
80 3b0f3d61 2020-01-22 neels {
81 d362ea2e 2020-07-25 stsp diff_ranges_merge(&cc->chunk, &other->chunk);
82 d362ea2e 2020-07-25 stsp diff_ranges_merge(&cc->left, &other->left);
83 d362ea2e 2020-07-25 stsp diff_ranges_merge(&cc->right, &other->right);
84 3b0f3d61 2020-01-22 neels }
85 3b0f3d61 2020-01-22 neels
86 11caa5cc 2020-09-22 stsp struct diff_output_unidiff_state {
87 11caa5cc 2020-09-22 stsp bool header_printed;
88 11caa5cc 2020-09-22 stsp };
89 11caa5cc 2020-09-22 stsp
90 11caa5cc 2020-09-22 stsp struct diff_output_unidiff_state *
91 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_alloc(void)
92 11caa5cc 2020-09-22 stsp {
93 11caa5cc 2020-09-22 stsp struct diff_output_unidiff_state *state;
94 11caa5cc 2020-09-22 stsp
95 11caa5cc 2020-09-22 stsp state = calloc(1, sizeof(struct diff_output_unidiff_state));
96 11caa5cc 2020-09-22 stsp if (state != NULL)
97 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_reset(state);
98 11caa5cc 2020-09-22 stsp return state;
99 11caa5cc 2020-09-22 stsp }
100 11caa5cc 2020-09-22 stsp
101 f374e913 2020-09-22 stsp void
102 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_reset(struct diff_output_unidiff_state *state)
103 11caa5cc 2020-09-22 stsp {
104 11caa5cc 2020-09-22 stsp state->header_printed = false;
105 11caa5cc 2020-09-22 stsp }
106 11caa5cc 2020-09-22 stsp
107 11caa5cc 2020-09-22 stsp void
108 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_free(struct diff_output_unidiff_state *state)
109 11caa5cc 2020-09-22 stsp {
110 11caa5cc 2020-09-22 stsp free(state);
111 11caa5cc 2020-09-22 stsp }
112 11caa5cc 2020-09-22 stsp
113 2c20a3ed 2020-09-22 stsp static int
114 2c20a3ed 2020-09-22 stsp output_unidiff_chunk(struct diff_output_info *outinfo, FILE *dest,
115 2c20a3ed 2020-09-22 stsp struct diff_output_unidiff_state *state,
116 2c20a3ed 2020-09-22 stsp const struct diff_input_info *info,
117 2c20a3ed 2020-09-22 stsp const struct diff_result *result,
118 2c20a3ed 2020-09-22 stsp const struct diff_chunk_context *cc)
119 3b0f3d61 2020-01-22 neels {
120 2c20a3ed 2020-09-22 stsp int rc;
121 ab528e22 2020-09-22 stsp off_t outoff = 0, *offp;
122 2c20a3ed 2020-09-22 stsp
123 d362ea2e 2020-07-25 stsp if (diff_range_empty(&cc->left) && diff_range_empty(&cc->right))
124 2c20a3ed 2020-09-22 stsp return DIFF_RC_OK;
125 3b0f3d61 2020-01-22 neels
126 2c20a3ed 2020-09-22 stsp if (outinfo && outinfo->line_offsets.len > 0) {
127 2c20a3ed 2020-09-22 stsp unsigned int idx = outinfo->line_offsets.len - 1;
128 2c20a3ed 2020-09-22 stsp outoff = outinfo->line_offsets.head[idx];
129 2c20a3ed 2020-09-22 stsp }
130 2c20a3ed 2020-09-22 stsp
131 11caa5cc 2020-09-22 stsp if (!(state->header_printed)) {
132 2c20a3ed 2020-09-22 stsp rc = fprintf(dest, "--- %s\n", info->left_path ? : "a");
133 2c20a3ed 2020-09-22 stsp if (rc < 0)
134 2c20a3ed 2020-09-22 stsp return errno;
135 2c20a3ed 2020-09-22 stsp if (outinfo) {
136 2c20a3ed 2020-09-22 stsp ARRAYLIST_ADD(offp, outinfo->line_offsets);
137 dabc1008 2020-09-22 stsp if (offp == NULL)
138 dabc1008 2020-09-22 stsp return ENOMEM;
139 2c20a3ed 2020-09-22 stsp outoff += rc;
140 2c20a3ed 2020-09-22 stsp *offp = outoff;
141 2c20a3ed 2020-09-22 stsp
142 2c20a3ed 2020-09-22 stsp }
143 2c20a3ed 2020-09-22 stsp rc = fprintf(dest, "+++ %s\n", info->right_path ? : "b");
144 2c20a3ed 2020-09-22 stsp if (rc < 0)
145 2c20a3ed 2020-09-22 stsp return errno;
146 2c20a3ed 2020-09-22 stsp if (outinfo) {
147 2c20a3ed 2020-09-22 stsp ARRAYLIST_ADD(offp, outinfo->line_offsets);
148 dabc1008 2020-09-22 stsp if (offp == NULL)
149 dabc1008 2020-09-22 stsp return ENOMEM;
150 2c20a3ed 2020-09-22 stsp outoff += rc;
151 2c20a3ed 2020-09-22 stsp *offp = outoff;
152 2c20a3ed 2020-09-22 stsp
153 2c20a3ed 2020-09-22 stsp }
154 11caa5cc 2020-09-22 stsp state->header_printed = true;
155 3b0f3d61 2020-01-22 neels }
156 3b0f3d61 2020-01-22 neels
157 2c20a3ed 2020-09-22 stsp rc = fprintf(dest, "@@ -%d,%d +%d,%d @@\n",
158 3b0f3d61 2020-01-22 neels cc->left.start + 1, cc->left.end - cc->left.start,
159 3b0f3d61 2020-01-22 neels cc->right.start + 1, cc->right.end - cc->right.start);
160 2c20a3ed 2020-09-22 stsp if (rc < 0)
161 2c20a3ed 2020-09-22 stsp return errno;
162 2c20a3ed 2020-09-22 stsp if (outinfo) {
163 2c20a3ed 2020-09-22 stsp ARRAYLIST_ADD(offp, outinfo->line_offsets);
164 dabc1008 2020-09-22 stsp if (offp == NULL)
165 dabc1008 2020-09-22 stsp return ENOMEM;
166 2c20a3ed 2020-09-22 stsp outoff += rc;
167 2c20a3ed 2020-09-22 stsp *offp = outoff;
168 3b0f3d61 2020-01-22 neels
169 2c20a3ed 2020-09-22 stsp }
170 2c20a3ed 2020-09-22 stsp
171 0d27172a 2020-05-06 neels /* Got the absolute line numbers where to start printing, and the index
172 0d27172a 2020-05-06 neels * of the interesting (non-context) chunk.
173 0d27172a 2020-05-06 neels * To print context lines above the interesting chunk, nipping on the
174 0d27172a 2020-05-06 neels * previous chunk index may be necessary.
175 0d27172a 2020-05-06 neels * It is guaranteed to be only context lines where left == right, so it
176 0d27172a 2020-05-06 neels * suffices to look on the left. */
177 0d27172a 2020-05-06 neels const struct diff_chunk *first_chunk;
178 0d27172a 2020-05-06 neels int chunk_start_line;
179 0d27172a 2020-05-06 neels first_chunk = &result->chunks.head[cc->chunk.start];
180 0d27172a 2020-05-06 neels chunk_start_line = diff_atom_root_idx(&result->left,
181 0d27172a 2020-05-06 neels first_chunk->left_start);
182 2c20a3ed 2020-09-22 stsp if (cc->left.start < chunk_start_line) {
183 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest, " ",
184 0d27172a 2020-05-06 neels &result->left.atoms.head[cc->left.start],
185 3b0f3d61 2020-01-22 neels chunk_start_line - cc->left.start);
186 2c20a3ed 2020-09-22 stsp if (rc)
187 2c20a3ed 2020-09-22 stsp return rc;
188 2c20a3ed 2020-09-22 stsp }
189 3b0f3d61 2020-01-22 neels
190 3b0f3d61 2020-01-22 neels /* Now write out all the joined chunks and contexts between them */
191 3b0f3d61 2020-01-22 neels int c_idx;
192 3b0f3d61 2020-01-22 neels for (c_idx = cc->chunk.start; c_idx < cc->chunk.end; c_idx++) {
193 3b0f3d61 2020-01-22 neels const struct diff_chunk *c = &result->chunks.head[c_idx];
194 3b0f3d61 2020-01-22 neels
195 3b0f3d61 2020-01-22 neels if (c->left_count && c->right_count)
196 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
197 0d27172a 2020-05-06 neels c->solved ? " " : "?",
198 0d27172a 2020-05-06 neels c->left_start, c->left_count);
199 3b0f3d61 2020-01-22 neels else if (c->left_count && !c->right_count)
200 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
201 0d27172a 2020-05-06 neels c->solved ? "-" : "?",
202 0d27172a 2020-05-06 neels c->left_start, c->left_count);
203 3b0f3d61 2020-01-22 neels else if (c->right_count && !c->left_count)
204 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
205 0d27172a 2020-05-06 neels c->solved ? "+" : "?",
206 0d27172a 2020-05-06 neels c->right_start, c->right_count);
207 2c20a3ed 2020-09-22 stsp if (rc)
208 2c20a3ed 2020-09-22 stsp return rc;
209 3b0f3d61 2020-01-22 neels }
210 3b0f3d61 2020-01-22 neels
211 3b0f3d61 2020-01-22 neels /* Trailing context? */
212 0d27172a 2020-05-06 neels const struct diff_chunk *last_chunk;
213 0d27172a 2020-05-06 neels int chunk_end_line;
214 0d27172a 2020-05-06 neels last_chunk = &result->chunks.head[cc->chunk.end - 1];
215 0d27172a 2020-05-06 neels chunk_end_line = diff_atom_root_idx(&result->left,
216 0d27172a 2020-05-06 neels last_chunk->left_start
217 0d27172a 2020-05-06 neels + last_chunk->left_count);
218 2c20a3ed 2020-09-22 stsp if (cc->left.end > chunk_end_line) {
219 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest, " ",
220 0d27172a 2020-05-06 neels &result->left.atoms.head[chunk_end_line],
221 3b0f3d61 2020-01-22 neels cc->left.end - chunk_end_line);
222 2c20a3ed 2020-09-22 stsp if (rc)
223 2c20a3ed 2020-09-22 stsp return rc;
224 2c20a3ed 2020-09-22 stsp }
225 2c20a3ed 2020-09-22 stsp
226 2c20a3ed 2020-09-22 stsp return DIFF_RC_OK;
227 3b0f3d61 2020-01-22 neels }
228 3b0f3d61 2020-01-22 neels
229 3e6cba3a 2020-08-13 stsp int
230 2c20a3ed 2020-09-22 stsp diff_output_unidiff_chunk(struct diff_output_info **output_info, FILE *dest,
231 2c20a3ed 2020-09-22 stsp struct diff_output_unidiff_state *state,
232 2c20a3ed 2020-09-22 stsp const struct diff_input_info *info,
233 2c20a3ed 2020-09-22 stsp const struct diff_result *result,
234 2c20a3ed 2020-09-22 stsp const struct diff_chunk_context *cc)
235 2c20a3ed 2020-09-22 stsp {
236 2c20a3ed 2020-09-22 stsp struct diff_output_info *outinfo = NULL;
237 2c20a3ed 2020-09-22 stsp
238 2c20a3ed 2020-09-22 stsp if (output_info) {
239 2c20a3ed 2020-09-22 stsp *output_info = diff_output_info_alloc();
240 2c20a3ed 2020-09-22 stsp if (*output_info == NULL)
241 2c20a3ed 2020-09-22 stsp return ENOMEM;
242 2c20a3ed 2020-09-22 stsp outinfo = *output_info;
243 2c20a3ed 2020-09-22 stsp }
244 2c20a3ed 2020-09-22 stsp
245 2c20a3ed 2020-09-22 stsp return output_unidiff_chunk(outinfo, dest, state, info,
246 2c20a3ed 2020-09-22 stsp result, cc);
247 2c20a3ed 2020-09-22 stsp }
248 2c20a3ed 2020-09-22 stsp
249 2c20a3ed 2020-09-22 stsp int
250 2c20a3ed 2020-09-22 stsp diff_output_unidiff(struct diff_output_info **output_info,
251 2c20a3ed 2020-09-22 stsp FILE *dest, const struct diff_input_info *info,
252 0d27172a 2020-05-06 neels const struct diff_result *result,
253 0d27172a 2020-05-06 neels unsigned int context_lines)
254 3b0f3d61 2020-01-22 neels {
255 11caa5cc 2020-09-22 stsp struct diff_output_unidiff_state *state;
256 11caa5cc 2020-09-22 stsp struct diff_chunk_context cc = {};
257 2c20a3ed 2020-09-22 stsp struct diff_output_info *outinfo = NULL;
258 11caa5cc 2020-09-22 stsp int i;
259 11caa5cc 2020-09-22 stsp
260 3b0f3d61 2020-01-22 neels if (!result)
261 3e6cba3a 2020-08-13 stsp return EINVAL;
262 3b0f3d61 2020-01-22 neels if (result->rc != DIFF_RC_OK)
263 3b0f3d61 2020-01-22 neels return result->rc;
264 3b0f3d61 2020-01-22 neels
265 2c20a3ed 2020-09-22 stsp if (output_info) {
266 2c20a3ed 2020-09-22 stsp *output_info = diff_output_info_alloc();
267 2c20a3ed 2020-09-22 stsp if (*output_info == NULL)
268 2c20a3ed 2020-09-22 stsp return ENOMEM;
269 2c20a3ed 2020-09-22 stsp outinfo = *output_info;
270 2c20a3ed 2020-09-22 stsp }
271 2c20a3ed 2020-09-22 stsp
272 11caa5cc 2020-09-22 stsp state = diff_output_unidiff_state_alloc();
273 2c20a3ed 2020-09-22 stsp if (state == NULL) {
274 2c20a3ed 2020-09-22 stsp if (output_info) {
275 2c20a3ed 2020-09-22 stsp diff_output_info_free(*output_info);
276 2c20a3ed 2020-09-22 stsp *output_info = NULL;
277 2c20a3ed 2020-09-22 stsp }
278 11caa5cc 2020-09-22 stsp return ENOMEM;
279 2c20a3ed 2020-09-22 stsp }
280 3b0f3d61 2020-01-22 neels
281 2c20a3ed 2020-09-22 stsp
282 3b0f3d61 2020-01-22 neels for (i = 0; i < result->chunks.len; i++) {
283 3b0f3d61 2020-01-22 neels struct diff_chunk *c = &result->chunks.head[i];
284 8546b045 2020-09-20 neels enum diff_chunk_type t = diff_chunk_type(c);
285 f374e913 2020-09-22 stsp struct diff_chunk_context next;
286 3b0f3d61 2020-01-22 neels
287 9cc49695 2020-05-05 neels if (t != CHUNK_MINUS && t != CHUNK_PLUS)
288 9cc49695 2020-05-05 neels continue;
289 9cc49695 2020-05-05 neels
290 9cc49695 2020-05-05 neels if (chunk_context_empty(&cc)) {
291 9cc49695 2020-05-05 neels /* These are the first lines being printed.
292 0d27172a 2020-05-06 neels * Note down the start point, any number of subsequent
293 0d27172a 2020-05-06 neels * chunks may be joined up to this unidiff chunk by
294 0d27172a 2020-05-06 neels * context lines or by being directly adjacent. */
295 f374e913 2020-09-22 stsp diff_chunk_context_get(&cc, result, i, context_lines);
296 0d27172a 2020-05-06 neels debug("new chunk to be printed:"
297 0d27172a 2020-05-06 neels " chunk %d-%d left %d-%d right %d-%d\n",
298 9cc49695 2020-05-05 neels cc.chunk.start, cc.chunk.end,
299 9cc49695 2020-05-05 neels cc.left.start, cc.left.end,
300 9cc49695 2020-05-05 neels cc.right.start, cc.right.end);
301 9cc49695 2020-05-05 neels continue;
302 3b0f3d61 2020-01-22 neels }
303 3b0f3d61 2020-01-22 neels
304 0d27172a 2020-05-06 neels /* There already is a previous chunk noted down for being
305 0d27172a 2020-05-06 neels * printed. Does it join up with this one? */
306 f374e913 2020-09-22 stsp diff_chunk_context_get(&next, result, i, context_lines);
307 0d27172a 2020-05-06 neels debug("new chunk to be printed:"
308 0d27172a 2020-05-06 neels " chunk %d-%d left %d-%d right %d-%d\n",
309 9cc49695 2020-05-05 neels next.chunk.start, next.chunk.end,
310 9cc49695 2020-05-05 neels next.left.start, next.left.end,
311 9cc49695 2020-05-05 neels next.right.start, next.right.end);
312 9cc49695 2020-05-05 neels
313 9cc49695 2020-05-05 neels if (chunk_contexts_touch(&cc, &next)) {
314 0d27172a 2020-05-06 neels /* This next context touches or overlaps the previous
315 0d27172a 2020-05-06 neels * one, join. */
316 9cc49695 2020-05-05 neels chunk_contexts_merge(&cc, &next);
317 0d27172a 2020-05-06 neels debug("new chunk to be printed touches previous chunk,"
318 0d27172a 2020-05-06 neels " now: left %d-%d right %d-%d\n",
319 9cc49695 2020-05-05 neels cc.left.start, cc.left.end,
320 9cc49695 2020-05-05 neels cc.right.start, cc.right.end);
321 9cc49695 2020-05-05 neels continue;
322 9cc49695 2020-05-05 neels }
323 9cc49695 2020-05-05 neels
324 0d27172a 2020-05-06 neels /* No touching, so the previous context is complete with a gap
325 0d27172a 2020-05-06 neels * between it and this next one. Print the previous one and
326 0d27172a 2020-05-06 neels * start fresh here. */
327 0d27172a 2020-05-06 neels debug("new chunk to be printed does not touch previous chunk;"
328 0d27172a 2020-05-06 neels " print left %d-%d right %d-%d\n",
329 9cc49695 2020-05-05 neels cc.left.start, cc.left.end, cc.right.start, cc.right.end);
330 2c20a3ed 2020-09-22 stsp output_unidiff_chunk(outinfo, dest, state, info, result, &cc);
331 9cc49695 2020-05-05 neels cc = next;
332 9cc49695 2020-05-05 neels debug("new unprinted chunk is left %d-%d right %d-%d\n",
333 9cc49695 2020-05-05 neels cc.left.start, cc.left.end, cc.right.start, cc.right.end);
334 3b0f3d61 2020-01-22 neels }
335 3b0f3d61 2020-01-22 neels
336 3b0f3d61 2020-01-22 neels if (!chunk_context_empty(&cc))
337 2c20a3ed 2020-09-22 stsp output_unidiff_chunk(outinfo, dest, state, info, result, &cc);
338 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_free(state);
339 3b0f3d61 2020-01-22 neels return DIFF_RC_OK;
340 3b0f3d61 2020-01-22 neels }