File: ps-diff

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (67 lines) | stat: -rwxr-xr-x 1,560 bytes parent folder | download
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
#!/bin/csh -f
#
# PS-DIFF - compare PostScript files upto roundoff
#

set FileA = a.tmp
set FileB = b.tmp

rm -f $FileA $FileB

set iline = 0

# sort the numbers by pairs into a file
while (1)
   set Line = `echo $<`
   if ($#Line == 0) then
      echo "PS-DIFF: Comparison succeeded ($iline)"
      rm -f $FileA $FileB
      exit(0)
   endif
   set iline = `expr $iline + 1`
   if ("$Line[1]" == "<") then
      set STDOUT = $FileA   
   else if ("$Line[1]" == ">") then
      set STDOUT = $FileB   
   else
      if ((-e $FileA) && (-e $FileB)) then
         set BufA = `cat $FileA`
         set BufB = `cat $FileB`
         while ($#BufA > 0)
            if ("$BufA[1]" != "$BufB[1]") then
               set Diff = `expr "$BufA[1]" - "$BufB[1]"`
               switch ("$Diff")
                  case -1 :
                       breaksw
                  case  0 :
                       breaksw
                  case  1 :
                       breaksw
                  default :
                       echo "PS-DIFF: Comparison failed"
                       rm -f $FileA $FileB
                       exit(1)
               endsw
            endif
            shift BufA
            shift BufB
         end
         rm -f $FileA $FileB         
      endif
      continue
   endif

   shift Line
   if (`expr "$Line[1]" : '%%.*'` == 0) then
      while ($#Line > 0)
         if (`expr "$Line[1]" : '[0-9]*'` > 0) then
            echo "$Line[1]" >> $STDOUT
         endif
         shift Line
      end
   endif
end

rm -f $FileA $FileB

exit($status)