Blame


1 3b0f3d61 2020-01-22 neels /* Output all lines of 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 3b0f3d61 2020-01-22 neels #include <diff/diff_output.h>
19 3b0f3d61 2020-01-22 neels
20 61a7b578 2020-05-06 neels enum diff_rc
21 61a7b578 2020-05-06 neels diff_output_plain(FILE *dest, const struct diff_input_info *info,
22 61a7b578 2020-05-06 neels const struct diff_result *result)
23 3b0f3d61 2020-01-22 neels {
24 3b0f3d61 2020-01-22 neels if (!result)
25 3b0f3d61 2020-01-22 neels return DIFF_RC_EINVAL;
26 3b0f3d61 2020-01-22 neels if (result->rc != DIFF_RC_OK)
27 3b0f3d61 2020-01-22 neels return result->rc;
28 3b0f3d61 2020-01-22 neels
29 3b0f3d61 2020-01-22 neels int i;
30 3b0f3d61 2020-01-22 neels for (i = 0; i < result->chunks.len; i++) {
31 3b0f3d61 2020-01-22 neels struct diff_chunk *c = &result->chunks.head[i];
32 3b0f3d61 2020-01-22 neels if (c->left_count && c->right_count)
33 0d27172a 2020-05-06 neels diff_output_lines(dest, c->solved ? " " : "?",
34 0d27172a 2020-05-06 neels c->left_start, c->left_count);
35 3b0f3d61 2020-01-22 neels else if (c->left_count && !c->right_count)
36 0d27172a 2020-05-06 neels diff_output_lines(dest, c->solved ? "-" : "?",
37 0d27172a 2020-05-06 neels c->left_start, c->left_count);
38 3b0f3d61 2020-01-22 neels else if (c->right_count && !c->left_count)
39 0d27172a 2020-05-06 neels diff_output_lines(dest, c->solved ? "+" : "?",
40 0d27172a 2020-05-06 neels c->right_start, c->right_count);
41 3b0f3d61 2020-01-22 neels }
42 3b0f3d61 2020-01-22 neels return DIFF_RC_OK;
43 3b0f3d61 2020-01-22 neels }