Re: [dev] [sbase] diff

From: Mattias Andrée <>
Date: Wed, 27 Jan 2016 23:22:55 +0100

Nice, I did not know about that.

I have removed the macro in my branch, I will submitted
when other suggestions have been implemented, assuming
any are suggested.

Perhaps I should describe how the program works
(although it is very simple.) The documents are
compared just like of they were words, but with
lines rather than characters, and only add and
remove are valid changes, not substitution. This
is implemented using dynamic programming. It
procedure fills in two matrices. One that describes
how many changes have to be made to get from the
old document to the new document. In the other it
is registered changes have to be made. This can be
extrapolated from the first matrix, but to keep it
simple it is written to the another matrix.
For any index-pair (i, j) in the matrices, the
corresponding element describes the changes to get
from the i first lines of old document to the j first
lines of the new document. The next part of the
program is just print the differences. Any time an
edit is about to be printed, it is cached, then when
all directly subsequent edits have been cached, it
prints the line removals followed by the line
additions. This is to make the output more readable.

On Wed, 27 Jan 2016 23:05:09 +0100
FRIGN <> wrote:

> On Wed, 27 Jan 2016 20:18:17 +0100
> Mattias Andrée <> wrote:
> Hey Mattias,
> thanks for your patch. I haven't looked at it in-depth,
> but would like to advise you instead of using this
> macro-beast:
> > +#define printf(...) do {if (printf(__VA_ARGS__) < 0)
> > perror("printf"), exit(EXIT_FAILURE); } while(0)
> to rather call fshut on stdout at the end of the program.
> This will ensure that in case a write fails, it is
> well-reported. It's already bad enough we see these
> macro-wonders in glibc.
> Cheers

Received on Wed Jan 27 2016 - 23:22:55 CET

This archive was generated by hypermail 2.3.0 : Wed Jan 27 2016 - 23:24:10 CET