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 2c20a3ed 2020-09-22 stsp off_t outoff = 0, outlen = 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 2c20a3ed 2020-09-22 stsp outoff += rc;
138 2c20a3ed 2020-09-22 stsp *offp = outoff;
139 2c20a3ed 2020-09-22 stsp
140 2c20a3ed 2020-09-22 stsp }
141 2c20a3ed 2020-09-22 stsp rc = fprintf(dest, "+++ %s\n", info->right_path ? : "b");
142 2c20a3ed 2020-09-22 stsp if (rc < 0)
143 2c20a3ed 2020-09-22 stsp return errno;
144 2c20a3ed 2020-09-22 stsp if (outinfo) {
145 2c20a3ed 2020-09-22 stsp ARRAYLIST_ADD(offp, outinfo->line_offsets);
146 2c20a3ed 2020-09-22 stsp outoff += rc;
147 2c20a3ed 2020-09-22 stsp *offp = outoff;
148 2c20a3ed 2020-09-22 stsp
149 2c20a3ed 2020-09-22 stsp }
150 11caa5cc 2020-09-22 stsp state->header_printed = true;
151 3b0f3d61 2020-01-22 neels }
152 3b0f3d61 2020-01-22 neels
153 2c20a3ed 2020-09-22 stsp rc = fprintf(dest, "@@ -%d,%d +%d,%d @@\n",
154 3b0f3d61 2020-01-22 neels cc->left.start + 1, cc->left.end - cc->left.start,
155 3b0f3d61 2020-01-22 neels cc->right.start + 1, cc->right.end - cc->right.start);
156 2c20a3ed 2020-09-22 stsp if (rc < 0)
157 2c20a3ed 2020-09-22 stsp return errno;
158 2c20a3ed 2020-09-22 stsp if (outinfo) {
159 2c20a3ed 2020-09-22 stsp ARRAYLIST_ADD(offp, outinfo->line_offsets);
160 2c20a3ed 2020-09-22 stsp outoff += rc;
161 2c20a3ed 2020-09-22 stsp *offp = outoff;
162 3b0f3d61 2020-01-22 neels
163 2c20a3ed 2020-09-22 stsp }
164 2c20a3ed 2020-09-22 stsp
165 0d27172a 2020-05-06 neels /* Got the absolute line numbers where to start printing, and the index
166 0d27172a 2020-05-06 neels * of the interesting (non-context) chunk.
167 0d27172a 2020-05-06 neels * To print context lines above the interesting chunk, nipping on the
168 0d27172a 2020-05-06 neels * previous chunk index may be necessary.
169 0d27172a 2020-05-06 neels * It is guaranteed to be only context lines where left == right, so it
170 0d27172a 2020-05-06 neels * suffices to look on the left. */
171 0d27172a 2020-05-06 neels const struct diff_chunk *first_chunk;
172 0d27172a 2020-05-06 neels int chunk_start_line;
173 0d27172a 2020-05-06 neels first_chunk = &result->chunks.head[cc->chunk.start];
174 0d27172a 2020-05-06 neels chunk_start_line = diff_atom_root_idx(&result->left,
175 0d27172a 2020-05-06 neels first_chunk->left_start);
176 2c20a3ed 2020-09-22 stsp if (cc->left.start < chunk_start_line) {
177 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest, " ",
178 0d27172a 2020-05-06 neels &result->left.atoms.head[cc->left.start],
179 3b0f3d61 2020-01-22 neels chunk_start_line - cc->left.start);
180 2c20a3ed 2020-09-22 stsp if (rc)
181 2c20a3ed 2020-09-22 stsp return rc;
182 2c20a3ed 2020-09-22 stsp }
183 3b0f3d61 2020-01-22 neels
184 3b0f3d61 2020-01-22 neels /* Now write out all the joined chunks and contexts between them */
185 3b0f3d61 2020-01-22 neels int c_idx;
186 3b0f3d61 2020-01-22 neels for (c_idx = cc->chunk.start; c_idx < cc->chunk.end; c_idx++) {
187 3b0f3d61 2020-01-22 neels const struct diff_chunk *c = &result->chunks.head[c_idx];
188 3b0f3d61 2020-01-22 neels
189 3b0f3d61 2020-01-22 neels if (c->left_count && c->right_count)
190 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
191 0d27172a 2020-05-06 neels c->solved ? " " : "?",
192 0d27172a 2020-05-06 neels c->left_start, c->left_count);
193 3b0f3d61 2020-01-22 neels else if (c->left_count && !c->right_count)
194 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
195 0d27172a 2020-05-06 neels c->solved ? "-" : "?",
196 0d27172a 2020-05-06 neels c->left_start, c->left_count);
197 3b0f3d61 2020-01-22 neels else if (c->right_count && !c->left_count)
198 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest,
199 0d27172a 2020-05-06 neels c->solved ? "+" : "?",
200 0d27172a 2020-05-06 neels c->right_start, c->right_count);
201 2c20a3ed 2020-09-22 stsp if (rc)
202 2c20a3ed 2020-09-22 stsp return rc;
203 3b0f3d61 2020-01-22 neels }
204 3b0f3d61 2020-01-22 neels
205 3b0f3d61 2020-01-22 neels /* Trailing context? */
206 0d27172a 2020-05-06 neels const struct diff_chunk *last_chunk;
207 0d27172a 2020-05-06 neels int chunk_end_line;
208 0d27172a 2020-05-06 neels last_chunk = &result->chunks.head[cc->chunk.end - 1];
209 0d27172a 2020-05-06 neels chunk_end_line = diff_atom_root_idx(&result->left,
210 0d27172a 2020-05-06 neels last_chunk->left_start
211 0d27172a 2020-05-06 neels + last_chunk->left_count);
212 2c20a3ed 2020-09-22 stsp if (cc->left.end > chunk_end_line) {
213 2c20a3ed 2020-09-22 stsp rc = diff_output_lines(outinfo, dest, " ",
214 0d27172a 2020-05-06 neels &result->left.atoms.head[chunk_end_line],
215 3b0f3d61 2020-01-22 neels cc->left.end - chunk_end_line);
216 2c20a3ed 2020-09-22 stsp if (rc)
217 2c20a3ed 2020-09-22 stsp return rc;
218 2c20a3ed 2020-09-22 stsp }
219 2c20a3ed 2020-09-22 stsp
220 2c20a3ed 2020-09-22 stsp return DIFF_RC_OK;
221 3b0f3d61 2020-01-22 neels }
222 3b0f3d61 2020-01-22 neels
223 3e6cba3a 2020-08-13 stsp int
224 2c20a3ed 2020-09-22 stsp diff_output_unidiff_chunk(struct diff_output_info **output_info, FILE *dest,
225 2c20a3ed 2020-09-22 stsp struct diff_output_unidiff_state *state,
226 2c20a3ed 2020-09-22 stsp const struct diff_input_info *info,
227 2c20a3ed 2020-09-22 stsp const struct diff_result *result,
228 2c20a3ed 2020-09-22 stsp const struct diff_chunk_context *cc)
229 2c20a3ed 2020-09-22 stsp {
230 2c20a3ed 2020-09-22 stsp struct diff_output_info *outinfo = NULL;
231 2c20a3ed 2020-09-22 stsp
232 2c20a3ed 2020-09-22 stsp if (output_info) {
233 2c20a3ed 2020-09-22 stsp *output_info = diff_output_info_alloc();
234 2c20a3ed 2020-09-22 stsp if (*output_info == NULL)
235 2c20a3ed 2020-09-22 stsp return ENOMEM;
236 2c20a3ed 2020-09-22 stsp outinfo = *output_info;
237 2c20a3ed 2020-09-22 stsp }
238 2c20a3ed 2020-09-22 stsp
239 2c20a3ed 2020-09-22 stsp return output_unidiff_chunk(outinfo, dest, state, info,
240 2c20a3ed 2020-09-22 stsp result, cc);
241 2c20a3ed 2020-09-22 stsp }
242 2c20a3ed 2020-09-22 stsp
243 2c20a3ed 2020-09-22 stsp int
244 2c20a3ed 2020-09-22 stsp diff_output_unidiff(struct diff_output_info **output_info,
245 2c20a3ed 2020-09-22 stsp FILE *dest, const struct diff_input_info *info,
246 0d27172a 2020-05-06 neels const struct diff_result *result,
247 0d27172a 2020-05-06 neels unsigned int context_lines)
248 3b0f3d61 2020-01-22 neels {
249 11caa5cc 2020-09-22 stsp struct diff_output_unidiff_state *state;
250 11caa5cc 2020-09-22 stsp struct diff_chunk_context cc = {};
251 2c20a3ed 2020-09-22 stsp struct diff_output_info *outinfo = NULL;
252 11caa5cc 2020-09-22 stsp int i;
253 11caa5cc 2020-09-22 stsp
254 3b0f3d61 2020-01-22 neels if (!result)
255 3e6cba3a 2020-08-13 stsp return EINVAL;
256 3b0f3d61 2020-01-22 neels if (result->rc != DIFF_RC_OK)
257 3b0f3d61 2020-01-22 neels return result->rc;
258 3b0f3d61 2020-01-22 neels
259 2c20a3ed 2020-09-22 stsp if (output_info) {
260 2c20a3ed 2020-09-22 stsp *output_info = diff_output_info_alloc();
261 2c20a3ed 2020-09-22 stsp if (*output_info == NULL)
262 2c20a3ed 2020-09-22 stsp return ENOMEM;
263 2c20a3ed 2020-09-22 stsp outinfo = *output_info;
264 2c20a3ed 2020-09-22 stsp }
265 2c20a3ed 2020-09-22 stsp
266 11caa5cc 2020-09-22 stsp state = diff_output_unidiff_state_alloc();
267 2c20a3ed 2020-09-22 stsp if (state == NULL) {
268 2c20a3ed 2020-09-22 stsp if (output_info) {
269 2c20a3ed 2020-09-22 stsp diff_output_info_free(*output_info);
270 2c20a3ed 2020-09-22 stsp *output_info = NULL;
271 2c20a3ed 2020-09-22 stsp }
272 11caa5cc 2020-09-22 stsp return ENOMEM;
273 2c20a3ed 2020-09-22 stsp }
274 3b0f3d61 2020-01-22 neels
275 2c20a3ed 2020-09-22 stsp
276 3b0f3d61 2020-01-22 neels for (i = 0; i < result->chunks.len; i++) {
277 3b0f3d61 2020-01-22 neels struct diff_chunk *c = &result->chunks.head[i];
278 8546b045 2020-09-20 neels enum diff_chunk_type t = diff_chunk_type(c);
279 f374e913 2020-09-22 stsp struct diff_chunk_context next;
280 3b0f3d61 2020-01-22 neels
281 9cc49695 2020-05-05 neels if (t != CHUNK_MINUS && t != CHUNK_PLUS)
282 9cc49695 2020-05-05 neels continue;
283 9cc49695 2020-05-05 neels
284 9cc49695 2020-05-05 neels if (chunk_context_empty(&cc)) {
285 9cc49695 2020-05-05 neels /* These are the first lines being printed.
286 0d27172a 2020-05-06 neels * Note down the start point, any number of subsequent
287 0d27172a 2020-05-06 neels * chunks may be joined up to this unidiff chunk by
288 0d27172a 2020-05-06 neels * context lines or by being directly adjacent. */
289 f374e913 2020-09-22 stsp diff_chunk_context_get(&cc, result, i, context_lines);
290 0d27172a 2020-05-06 neels debug("new chunk to be printed:"
291 0d27172a 2020-05-06 neels " chunk %d-%d left %d-%d right %d-%d\n",
292 9cc49695 2020-05-05 neels cc.chunk.start, cc.chunk.end,
293 9cc49695 2020-05-05 neels cc.left.start, cc.left.end,
294 9cc49695 2020-05-05 neels cc.right.start, cc.right.end);
295 9cc49695 2020-05-05 neels continue;
296 3b0f3d61 2020-01-22 neels }
297 3b0f3d61 2020-01-22 neels
298 0d27172a 2020-05-06 neels /* There already is a previous chunk noted down for being
299 0d27172a 2020-05-06 neels * printed. Does it join up with this one? */
300 f374e913 2020-09-22 stsp diff_chunk_context_get(&next, result, i, context_lines);
301 0d27172a 2020-05-06 neels debug("new chunk to be printed:"
302 0d27172a 2020-05-06 neels " chunk %d-%d left %d-%d right %d-%d\n",
303 9cc49695 2020-05-05 neels next.chunk.start, next.chunk.end,
304 9cc49695 2020-05-05 neels next.left.start, next.left.end,
305 9cc49695 2020-05-05 neels next.right.start, next.right.end);
306 9cc49695 2020-05-05 neels
307 9cc49695 2020-05-05 neels if (chunk_contexts_touch(&cc, &next)) {
308 0d27172a 2020-05-06 neels /* This next context touches or overlaps the previous
309 0d27172a 2020-05-06 neels * one, join. */
310 9cc49695 2020-05-05 neels chunk_contexts_merge(&cc, &next);
311 0d27172a 2020-05-06 neels debug("new chunk to be printed touches previous chunk,"
312 0d27172a 2020-05-06 neels " now: left %d-%d right %d-%d\n",
313 9cc49695 2020-05-05 neels cc.left.start, cc.left.end,
314 9cc49695 2020-05-05 neels cc.right.start, cc.right.end);
315 9cc49695 2020-05-05 neels continue;
316 9cc49695 2020-05-05 neels }
317 9cc49695 2020-05-05 neels
318 0d27172a 2020-05-06 neels /* No touching, so the previous context is complete with a gap
319 0d27172a 2020-05-06 neels * between it and this next one. Print the previous one and
320 0d27172a 2020-05-06 neels * start fresh here. */
321 0d27172a 2020-05-06 neels debug("new chunk to be printed does not touch previous chunk;"
322 0d27172a 2020-05-06 neels " print left %d-%d right %d-%d\n",
323 9cc49695 2020-05-05 neels cc.left.start, cc.left.end, cc.right.start, cc.right.end);
324 2c20a3ed 2020-09-22 stsp output_unidiff_chunk(outinfo, dest, state, info, result, &cc);
325 9cc49695 2020-05-05 neels cc = next;
326 9cc49695 2020-05-05 neels debug("new unprinted chunk is left %d-%d right %d-%d\n",
327 9cc49695 2020-05-05 neels cc.left.start, cc.left.end, cc.right.start, cc.right.end);
328 3b0f3d61 2020-01-22 neels }
329 3b0f3d61 2020-01-22 neels
330 3b0f3d61 2020-01-22 neels if (!chunk_context_empty(&cc))
331 2c20a3ed 2020-09-22 stsp output_unidiff_chunk(outinfo, dest, state, info, result, &cc);
332 11caa5cc 2020-09-22 stsp diff_output_unidiff_state_free(state);
333 3b0f3d61 2020-01-22 neels return DIFF_RC_OK;
334 3b0f3d61 2020-01-22 neels }