#!/bin/sh
# Copyright (C) 2012 Etersoft, Vitaly Lipatov <lav@etersoft.ru>
# Redistribution of this file is permitted under the terms of the
# GNU Public License (GPL)

REG1="$1"
REG2="$2"

if [ -z "$REG1" ] || [ "$REG1" = "-h" ] || [ "$REG1" = "--help" ] ; then
    echo "$0: compare two wine registry files without any garbage"
    echo "Usage: $0 user1.reg user2.reg"
    exit
fi

# FIXME: use mktempfile
TREG1=/tmp/cwr1
TREG2=/tmp/cwr2

unface_file()
{
	test -f "$1" || { echo "File '$1' does not exists" ; exit -1 ; }
	cat $1 | sed -e "s|] [0-9]*\$|]|g" > $2
}

unface_file "$REG1" "$TREG1"
unface_file "$REG2" "$TREG2"

diff -u $TREG1 $TREG2 | less
rm -f "$TREG1" "$TREG2"
