commit - e450035c854c7301e281718ffd136dfe4647e681
commit + 9343b92549173e00690f24756a633423770f56d7
blob - 6cd959e4159e40e5fcc467e4f69c7318fd54d3d5
blob + 304efb917050acadd79aae06eec9473ae5fdc797
--- include/diff_output.h
+++ include/diff_output.h
* The last offset in this array corresponds to end-of-file.
*/
ARRAYLIST(off_t) line_offsets;
+ /*
+ * Type (i.e., context, minus, plus) of each line generated by the diff.
+ * nb. 0x00 to 0x3b reserved for client-defined line types.
+ */
+ ARRAYLIST(uint8_t) line_types;
+#define DIFF_LINE_HUNK 0x3c
+#define DIFF_LINE_MINUS 0x3d
+#define DIFF_LINE_PLUS 0x3e
+#define DIFF_LINE_CONTEXT 0x3f
+#define DIFF_LINE_NONE 0x40 /* binary or no EOF newline msg, etc. */
};
void diff_output_info_free(struct diff_output_info *output_info);
blob - e44ac0a4e3f7fe9caf5b350a89c7e5c5beba00be
blob + f9f748fd298e5716a0fbfa2a0ff0277abc7a331e
--- lib/diff_output.c
+++ lib/diff_output.c
{
struct diff_atom *atom;
off_t outoff = 0, *offp;
+ uint8_t *typep;
int rc;
if (outinfo && outinfo->line_offsets.len > 0) {
return ENOMEM;
outoff += outlen;
*offp = outoff;
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = *prefix == ' ' ? DIFF_LINE_CONTEXT :
+ *prefix == '-' ? DIFF_LINE_MINUS :
+ *prefix == '+' ? DIFF_LINE_PLUS : DIFF_LINE_NONE;
}
}
unsigned int atom_count;
int rc, ch;
off_t outoff = 0, *offp;
+ uint8_t *typep;
+
if (chunk_type == CHUNK_MINUS || chunk_type == CHUNK_SAME) {
start_atom = c->left_start;
atom_count = c->left_count;
return ENOMEM;
outoff += rc;
*offp = outoff;
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = DIFF_LINE_NONE;
}
}
{
struct diff_output_info *output_info;
off_t *offp;
+ uint8_t *typep;
output_info = malloc(sizeof(*output_info));
if (output_info != NULL) {
return NULL;
}
*offp = 0;
+ ARRAYLIST_INIT(output_info->line_types, 128);
+ ARRAYLIST_ADD(typep, output_info->line_types);
+ if (typep == NULL) {
+ diff_output_info_free(output_info);
+ return NULL;
+ }
+ *typep = DIFF_LINE_NONE;
}
return output_info;
}
diff_output_info_free(struct diff_output_info *output_info)
{
ARRAYLIST_FREE(output_info->line_offsets);
+ ARRAYLIST_FREE(output_info->line_types);
free(output_info);
}
blob - f3f4ad74c807d77b28b7b0af68f0d0ef2435d5c1
blob + 18bff74063081228c1c525cce2b35ad26a527bf8
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
{
int rc, left_start, left_len, right_start, right_len;
off_t outoff = 0, *offp;
+ uint8_t *typep;
if (diff_range_empty(&cc->left) && diff_range_empty(&cc->right))
return DIFF_RC_OK;
return ENOMEM;
outoff += rc;
*offp = outoff;
-
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = DIFF_LINE_MINUS;
}
rc = fprintf(dest, "+++ %s\n",
diff_output_get_label_right(info));
return ENOMEM;
outoff += rc;
*offp = outoff;
-
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = DIFF_LINE_PLUS;
}
state->header_printed = true;
}
return ENOMEM;
outoff += rc;
*offp = outoff;
-
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = DIFF_LINE_HUNK;
}
/* Got the absolute line numbers where to start printing, and the index
bool force_text = (flags & DIFF_FLAG_FORCE_TEXT_DATA);
bool have_binary = (atomizer_flags & DIFF_ATOMIZER_FOUND_BINARY_DATA);
off_t outoff = 0, *offp;
+ uint8_t *typep;
int rc, i;
if (!result)
return ENOMEM;
outoff += rc;
*offp = outoff;
-
+ ARRAYLIST_ADD(typep, outinfo->line_types);
+ if (typep == NULL)
+ return ENOMEM;
+ *typep = DIFF_LINE_NONE;
}
break;
}