home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / gediff.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  80 lines

  1. ############################################################################
  2. #
  3. #    File:      gediff.icn
  4. #
  5. #    Subject:  Program to "diff" for use with ged
  6. #
  7. #    Author:      Robert J. Alexander
  8. #
  9. #    Date:      July 9, 1993
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  Program to produce diff output in a format for use with ged's
  18. #  "FindFileAndLine" (esc-S) command.  It causes the "diffed" files
  19. #  to be open in the editor with the differing portions selected.
  20. #
  21. ############################################################################
  22. #
  23. #  Links: options, word
  24. #
  25. ############################################################################
  26. #
  27. #  Requires: pipes, a "diff" command in the environment
  28. #
  29. ############################################################################
  30. #
  31. #  See also: diffn.icn (a diff-type program)
  32. #
  33. ############################################################################
  34.  
  35. link options,word
  36.  
  37. global Diff,ArgStr
  38.  
  39. procedure Options(arg)
  40.    local opt,c
  41.    opt := options(arg,"dbitwrsS:")
  42.    Diff := \opt["d"] | "diff"
  43.    ArgStr := ""
  44.    ArgStr ||:= " -S " || \opt["S"]
  45.    every c := !"bitwrs" do {     # single-character options passed to diff
  46.       if \opt[c] then ArgStr ||:= " -" || c
  47.       }
  48.    return opt
  49. end
  50.  
  51. procedure main(arg)
  52.    local argstr,fn1,fn2,p,dargs,cmd
  53.    Options(arg)
  54.    every ArgStr ||:= " " || !arg
  55.    fn1 := arg[-2]
  56.    fn2 := arg[-1]
  57.    cmd := Diff || ArgStr
  58.    #write(&errout,cmd)
  59.    p := open(cmd,"pr")
  60.    while read(p) ? {
  61.       if any(&digits) then {
  62.      write(fn1,":",tab(upto(&letters)))
  63.      move(1)
  64.      write(fn2,":",tab(0))
  65.      }
  66.       else if ="diff" & tab(many(' \t')) then {
  67.      write(&subject)
  68.      dargs := []
  69.      while put(dargs,word_dequote(tab(word()))) do tab(many(' \t'))
  70.      fn1 := dargs[-2]
  71.      fn2 := dargs[-1]
  72.      while match("./",fn1) do fn1[1+:2] := ""
  73.      while match("./",fn2) do fn2[1+:2] := ""
  74.      }
  75.       else write(tab(0))
  76.       {}
  77.       }
  78.    exit(close(p))
  79. end
  80.