YDQLW2ZOAH7PZ7HHVTSFUO5IWE6O7FDNXVNIN7GG4TJ3P2B2BM4AC
QYRJIOYPM7SAB3OHMALL67K44U5HPBRQ2AFNWUKATPXM6BUYRKBQC
XTKRT6OQYN4LARQRDLI2KBSAJTOFZNT4AMBZ46CPUDZXD7IDYYWQC
RIWSVVASWLJQQTSVRHIIUPENOZWOMHQLZMTQVGJUS2ZUGDPSWWIQC
Q7TKZCJP2Z75EICZYKCEZDHKGERSOKZGMTSU3UXETBHTF663T66AC
QEFCNNVCEDFUV7O4ASWVI4QUTUFWLHAOTJMDCZ3DFJIUQWTAN3SAC
KDJUAAALIKZDRTVNUZKXYYA5UYMZNYBCI3CCRKS4YONBVRUADPXAC
3FT3XTJMUAXQ257T5GB7YWWTI7QBKKVC7WA6DCH5UY26RLQO5PFQC
* TODO To properly print EDGE_MAP types we need access to referenced changes to pull deleted lines
*/
void
print_atom(Atom *a, uint8_t *contents)
{
Newvertex *v;
Edgemap *m;
char *c, x;
int i, waseol;
switch (a->atomtype) {
case NEW_VERTEX:
v = &a->newvertex;
printf("up: ");
print_positionlist(&v->upcontext);
printf(", ");
printf("new: %lu:%lu, down: ", v->start, v->end);
print_positionlist(&v->downcontext);
printf("\n");
waseol = 1;
for (i = v->start; i < v->end; i++) {
if (waseol) {
printf("+ ");
waseol = 0;
}
x = contents[i];
putchar(x);
if (x == '\n')
waseol = 1;
}
printf("\n");
break;
case EDGE_MAP:
m = &a->edgemap;
printf("EdgeMap... \n");
break;
default:
abort();
}
}
/**
/**
* Seek to the point in the file where contents begin. Keep in mind,
* we've already read 56 bytes.
*/
if (lseek(fd, off.contents_off, SEEK_SET) == -1) {
perror("lseek");
goto out;
}
contents = change_read_contents(fd, &off);
if (verbose)
dump_buf("contents", contents, off.contents_len);
/**
* Seek to the point in the file where contents begin. Keep in mind,
* we've already read 56 bytes.
*/
if (lseek(fd, off.contents_off, SEEK_SET) == -1) {
perror("lseek");
goto out;
/* FIXME: Put all the hashes of dependencies in a big list, and number them from 2 */
for (i = 0; i < hashed.hunks.len; i++) {
Basehunk *hunk = &hashed.hunks.entries[i];
printf("%d. %s", i + 1, hunk_basehunk_type_str(hunk->hunktype));
switch (hunk->hunktype) {
case EDIT:
Edit *e = &hunk->edit;
Atom *c = &e->change;
printf(" in %s:%u (%s)", e->local.path, e->local.line,
e->encoding);
printf("\n");
print_atom(c, contents);
break;
case REPLACEMENT:
Replacement *r = &hunk->replacement;
printf(" in %s:%u (%s)", r->local.path, r->local.line,
r->encoding);
printf("\n");
break;
default:
printf(" [not yet implemented]\n");
break;
}