General cleanups

- spelling fixes
- remove ifdefed-out code
- white space adjustments
- etc

Signed-off-by: NeilBrown <neilb@suse.de>
.gitignore updates

Signed-off-by: NeilBrown <neilb@suse.de>
Fix 'make version'

Since I change the format for the version string, this hasn't worked.

NeilBrown <neilb@suse.de>
Replace hash.h with better hash function from CCAN

Signed-off-by: NeilBrown <neilb@suse.de>
split 'extact' out of 'main' into a separate function.

Signed-off-by: NeilBrown <neilb@suse.de>
Split do_diff() out from main()

Signed-off-by: NeilBrown <neilb@suse.de>
Split do_merge out from main() as a separate function.

Signed-off-by: NeilBrown <neilb@suse.de>
Remove extraction of base-name of command.

We don't use this any more (as use of the name 'vpatch' was discarded)
so don't bother to extract it.

Signed-off-by: NeilBrown <neilb@suse.de>
Minor cleaning up in man page wiggle.1

Signed-off-by: NeilBrown <neilb@suse.de>
Split do_diff_words and do_diff_lines out from do_diff

Signed-off-by: NeilBrown <neilb@suse.de>
Better error message if split_patch fails for --extract

Signed-off-by: NeilBrown <neilb@suse.de>
Refactor do_diff slightly

Combine come code that is common to 'word' and 'line' branches.

Signed-off-by: NeilBrown <neilb@suse.de>
Introduce xmalloc and use it.

Instead of sometimes calling die() when malloc fails and
sometimes not, introduce xmalloc() which always reports a message
and dies, and use it uniformly.

Signed-off-by: NeilBrown <neilb@suse.de>
Make tracing code a bit cleaner and more organised.

 WIGGLE_TRACE=1 ./wiggle ....

will turn on tracing.

Signed-off-by: NeilBrown <neilb@suse.de>
Handle some errors better in Browse mode.

If the target file is missing or the patch is corrupt,
we really don't want to just crash.

Signed-off-by: NeilBrown <neilb@suse.de>
Add --show-wiggle flag.

--show-wiggle modifies --merge so that chunks which need to be
wiggled into place are presented as full conflicts with an
extra stanza which shows what the resulting wiggle would look like.

Suggested-by:  Alessandro Salvatori <sandr8@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
browser: clear the end of the split-window when needed.

We would get some garbage when near the end of the diff.

Signed-off-by: NeilBrown <neilb@suse.de>
Ensure that a hunk-header never appears in the middle of an Extraneous range.

A hunk header is always Extraneous.  However Extraneous text before it is
quite separate and is best kept separate.
Start a new Extraneous merger with each hunk header will make it easier
to detect hunk headers and handle them better.

Signed-off-by: NeilBrown <neilb@suse.de>
Improve handling of hunk-header when merging.

If we are merging a patch, the patch will contain a number of
hunk-headers (essentially the @@ NN,MM @@) lines.

These should never appear in the merge, and must always line up with
end-of-line in the original as they represent a number of lines having
been deleted.

So:
  Cause these to each create a simple Extraneous merger, never
    combined with adjacent texts

  exclude them from any conflicts in isolate_conflict, so they
    can never appear in a merge

  Ensure that a preceeding 'Unmatched' finishes on an end-of-line.

Also update lots of self tests with improved results.

Signed-off-by: NeilBrown <neilb@suse.de>
merge: factor out is_cutpoint.

We perform the same test several times, so make a function for it.

Signed-off-by: NeilBrown <neilb@suse.de>