commit - 810479a563ffd6176105f64cb49f9829d45d36df
commit + 9230203d371721cf5bde99f526fe40740aea3b21
blob - 1ead91212f5b867edc7e7187ec03e3d6eaf1f565
blob + 60533bd949aeec8ada84abec88bf7e58e93f5ff5
--- lib/diff_output_plain.c
+++ lib/diff_output_plain.c
output_plain_chunk(struct diff_output_info *outinfo,
FILE *dest, const struct diff_input_info *info,
const struct diff_result *result,
- struct diff_chunk_context *cc)
+ struct diff_chunk_context *cc, off_t *outoff)
{
- off_t outoff = 0, *offp;
+ off_t *offp;
int left_start, left_len, right_start, right_len;
int rc;
bool change = false;
cc->left.end, right_start, cc->right.end);
}
}
+ if (rc < 0)
+ return errno;
+ if (outinfo) {
+ ARRAYLIST_ADD(offp, outinfo->line_offsets);
+ if (offp == NULL)
+ return ENOMEM;
+ *outoff += rc;
+ *offp = *outoff;
+ }
/*
* Now write out all the joined chunks.
c->solved ? "< " : "?",
c->left_start, c->left_count);
else if (c->right_count && !c->left_count) {
- if (change)
- fprintf(dest, "---\n");
+ if (change) {
+ rc = fprintf(dest, "---\n");
+ if (rc < 0)
+ return errno;
+ if (outinfo) {
+ ARRAYLIST_ADD(offp,
+ outinfo->line_offsets);
+ if (offp == NULL)
+ return ENOMEM;
+ *outoff += rc;
+ *offp = *outoff;
+ }
+ }
rc = diff_output_lines(outinfo, dest,
c->solved ? "> " : "?",
c->right_start, c->right_count);
}
}
- if (rc < 0)
- return errno;
- if (outinfo) {
- ARRAYLIST_ADD(offp, outinfo->line_offsets);
- if (offp == NULL)
- return ENOMEM;
- outoff += rc;
- *offp = outoff;
- }
-
return DIFF_RC_OK;
}
bool force_text = (flags & DIFF_FLAG_FORCE_TEXT_DATA);
bool have_binary = (atomizer_flags & DIFF_ATOMIZER_FOUND_BINARY_DATA);
int i, rc;
+ off_t outoff = 0, *offp;
if (!result)
return EINVAL;
if (t != CHUNK_MINUS && t != CHUNK_PLUS)
continue;
- fprintf(dest, "Binary files %s and %s differ\n",
+ rc = fprintf(dest, "Binary files %s and %s differ\n",
diff_output_get_label_left(info),
diff_output_get_label_right(info));
+ if (rc < 0)
+ return errno;
+ if (outinfo) {
+ ARRAYLIST_ADD(offp, outinfo->line_offsets);
+ if (offp == NULL)
+ return ENOMEM;
+ outoff += rc;
+ *offp = outoff;
+ }
break;
}
* loop */
continue;
}
- rc = output_plain_chunk(outinfo, dest, info, result, &cc);
+ rc = output_plain_chunk(outinfo, dest, info, result, &cc,
+ &outoff);
if (rc != DIFF_RC_OK)
return rc;
cc = next;
}
if (!diff_chunk_context_empty(&cc))
- return output_plain_chunk(outinfo, dest, info, result, &cc);
+ return output_plain_chunk(outinfo, dest, info, result, &cc,
+ &outoff);
return DIFF_RC_OK;
}