commit - 3b95caf0b7910e22d23ee16cd50fab25471e1e20
commit + b16ee0699b6283b06cc57cca68c87d89a96630dc
blob - dd6b2aa9dd850690d77fb00149d2331f76b827e3
blob + 238ecb9d0ee975efd8eacc55de14b8cfb69792de
--- lib/diff_atomize_text.c
+++ lib/diff_atomize_text.c
while (eol == 0 && line_end < end) {
r = fread(buf, sizeof(char), sizeof(buf), d->root->f);
if (r == 0 && ferror(d->root->f))
- return errno;
+ return EIO;
i = 0;
while (eol == 0 && i < r) {
if (buf[i] != '\r' && buf[i] != '\n') {
return errno;
r = fread(buf, sizeof(char), sizeof(buf), d->root->f);
if (r == 0 && ferror(d->root->f))
- return errno;
+ return EIO;
if (r > 0 && buf[0] == '\n')
line_end++;
}
blob - 0ed8a5e2244549f0bc385a02aa8eb6f5d610deac
blob + 4b7ec8090638d2752cd946046f2333347bf244ae
--- lib/diff_debug.h
+++ lib/diff_debug.h
int i;
r = fread(buf, 1, MIN(remain, sizeof(buf)),
atom->root->f);
- if (r == -1)
- abort(); /* cannot return error */
if (r == 0)
break;
remain -= r;
blob - be72763dedcb12e2baabb6fda64e06d2fcf5f598
blob + 7c2bfddb8f77a9026ec782026f3775a07e004f5e
--- lib/diff_internal.h
+++ lib/diff_internal.h
return r->end - r->start;
}
-/* List of all possible return codes of a diff invocation. */
-#define DIFF_RC_USE_DIFF_ALGO_FALLBACK -1
-#define DIFF_RC_OK 0
-/* Any positive return values are errno values from sys/errno.h */
-
/* Indicate whether two given diff atoms match. */
int
diff_atom_same(bool *same,
blob - c531ad29bc45c650dd4e3dbc4773479aafd7676b
blob + 00a42243cafc3f305b117bd3a861bb075aeee435
--- lib/diff_main.c
+++ lib/diff_main.c
return errno;
r = fread(buf, sizeof(char), len, f);
if ((r == 0 || r < len) && ferror(f))
- return errno;
+ return EIO;
if (r != len)
return EIO;
return 0;
return;
ARRAYLIST_FREE(result->chunks);
free(result);
+}
+
+int
+diff_result_contains_printable_chunks(struct diff_result *result)
+{
+ struct diff_chunk *c;
+ enum diff_chunk_type t;
+
+ for (int i = 0; i < result->chunks.len; i++) {
+ c = &result->chunks.head[i];
+ t = diff_chunk_type(c);
+ if (t == CHUNK_MINUS || t == CHUNK_PLUS)
+ return 1;
+ }
+
+ return 0;
}
blob - 5e816ae10b5948c0aeacd27365a91f3147b96baf
blob + fa9dc982956eab298f65b4b9ffca114a46b50b76
--- lib/diff_main.h
+++ lib/diff_main.h
struct diff_data *left,
struct diff_data *right);
void diff_result_free(struct diff_result *result);
+int diff_result_contains_printable_chunks(struct diff_result *result);
blob - 74b22eb8207ab2c5f154a22229051900a3d7b1ce
blob + b20dabf6658691770d21bfe3c1227ae815223474
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
cc->left.end - chunk_end_line);
if (rc)
return rc;
+
+ rc = diff_output_trailing_newline_msg(outinfo, dest,
+ &result->chunks.head[result->chunks.len - 1]);
+ if (rc != DIFF_RC_OK)
+ return rc;
}
return DIFF_RC_OK;