File: pdiff.m4

package info (click to toggle)
a2ps 1%3A4.14-1.1%2Bdeb6u1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,324 kB
  • ctags: 4,908
  • sloc: ansic: 26,659; sh: 13,155; lex: 2,286; perl: 1,156; yacc: 757; makefile: 605; lisp: 398; ada: 263; objc: 189; f90: 109; ml: 85; sql: 74; pascal: 57; modula3: 33; haskell: 32; sed: 30; java: 29; python: 24
file content (112 lines) | stat: -rw-r--r-- 3,077 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
include(shell.m4)dnl -*- shell-script -*-
#! /bin/sh
# -*- sh -*-
# pdiff --- Print diff in a nice way

GPL([Copyright (c) 1998, 1999 Akim Demaille, Miguel Santana])

# Author: Akim Demaille <demaille@inf.enst.fr>

# Get the name of the program
program=`echo $0 | sed 's#.*/##g'`

changequote(, )
# Local vars
a2ps=${A2PS:-a2ps}
a2ps_options=
debug=
diff_on=words
diff_prog=${DIFF:-diff}
diff_options='-u'
file=
output=
tmpdir=`mktemp -d -t pdiff.XXXXXX` || { echo "$program: Cannot create temporary dir!" >&2 ; exit 1; }
verbose=echo
wdiff_prog=${WDIFF:-wdiff}
wdiff_options='-w[wd- -x-wd] -y{wd+ -z+wd}'
# The version/usage strings
version="pdiff 0.4 (@GNU_PACKAGE@ @VERSION@)
Written by Akim Demaille.

Copyright (c) 1997-1999 Akim Demaille, Miguel Santana
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."

usage="\
Usage: $program FILE1 FILE2 [-- A2PS-OPTIONS...]
Pretty print the differences between FILE1 and FILE2.

Options:
 -h, --help           display this help and exit
 -v, --version        display version information and exit
 -q, --quiet          don't print informational messages
 -l, --lines          search for line differences (\`diff')
 -w, --words          search for word differences (\`wdiff')
 -o, --output=FILE    save the output in FILE

Options for a2ps are given after \`--', for instance

    $ pdiff COPYING COPYING.LIB -- -Pdisplay

News, updates and documentation: http://www.inf.enst.fr/~demaille/a2ps/.
Report bugs to <bug-a2ps@gnu.org>."

help="Try \`$program --help' for more information."
changequote([, ])

# Parse command line arguments.
option_without_arguments='vhsqDlw'
GETOPT([    -v | --v*) echo "$version"; exit 0;;
    -h | --h*) echo "$usage"; exit 0;;
    -s|-q|--q*|--s*) verbose=: ;;
    -D | --debug) debug=: ;;
    -o|--output) shift
                 a2ps_options="$a2ps_options --output=$1" ;;
    -l|--lines) diff_on=lines;;
    -w|--words) diff_on=words;;
    -) # We are working with stdin
    set dummy "${1+"$@"}" "$1"; shift;;])

# What remains is ORIG NEW [A2PS_OPTIONS...]
if test $# -lt 2; then
 exec 1>&2
 echo "$program: not enough arguments"
 echo "$help"
 exit 1
fi

file1="$1"
shift
file2="$1"
shift

# Set the titles
a2ps_options="--left-title=$file1 --right-title=$file2 $a2ps_options"
a2ps_options="--center-title $a2ps_options"

# Use the right prologue
a2ps_options="--prolog=diff $a2ps_options"

# Give the additional arguments given by the user
a2ps_options="$@ $a2ps_options"

# Set -x now if debugging
test $debug && set -x

# Call the correct diffing program, and pipe into a2ps
case $diff_on in
  words) # Word differences
    $wdiff_prog $wdiff_options $file1 $file2	\
       | $a2ps -Ewdiff $a2ps_options || exit 1
    ;;

  lines) # Line differences
    # We need the total number of lines
    lines=`wc -l $file1 $file2 | sed -n 3p`
    lines=`set -- $lines && echo $1`
    $diff_prog $diff_options -$lines $file1 $file2	\
       | $a2ps -gEudiff $a2ps_options || exit 1
    ;;
esac

exit 0