Hi, I'm not sure if I'm using diffseq correctly here, but comparing two vectors of different lengths and no common elements seems to cause a segfault, as in the following toy example:
#include <stdlib.h> #include <unistd.h> #include <limits.h> #include <stdbool.h> #include "minmax.h" #define ELEMENT char #define EQUAL(a,b) (a == b) #define OFFSET ssize_t #define USE_HEURISTIC #define EXTRA_CONTEXT_FIELDS #define NOTE_INSERT(ctxt,xoff) #define NOTE_DELETE(ctxt,yoff) #define lint #include "diffseq.h" int main(void) { char *expected = "abcd"; char *actual = "efg"; ssize_t expected_limit = 4; ssize_t actual_limit = 3; ssize_t *work_buffer; struct context ctxt; /* Allocate a work buffer */ work_buffer = calloc(2 * (expected_limit + actual_limit + 3), sizeof(ssize_t)); /* Call the Gnulib diff algorithm */ ctxt.xvec = expected; ctxt.yvec = actual; ctxt.fdiag = work_buffer + actual_limit + 1; ctxt.bdiag = work_buffer + expected_limit + actual_limit + 3; ctxt.heuristic = 1; compareseq(0, expected_limit, 0, actual_limit, &ctxt); free(work_buffer); return 0; } This seems to be because diag() doesn't find a point of correspondence and therefore the comparison proceeds with garbage. Specifically, dmin is initialized to a negative value at the start of diag(). However, the comment at the top of diag() does say > Compare in detail contiguous subsequences of the two vectors which are known, as a whole, to match each other. and of course, I do know in this toy example that the vectors don't match each other as a whole. Am I trying to do something that diffseq isn't meant to do? Regards, -- Philip