vcdiff 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #! /bin/sh
  2. # Enhanced sccs diff utility for use with vc mode.
  3. # This version is more compatible with rcsdiff(1).
  4. # Copyright (C) 1992-1993, 1995, 1997, 2001-2012
  5. # Free Software Foundation, Inc.
  6. # Author: Paul Eggert
  7. # (according to authors.el)
  8. # This file is part of GNU Emacs.
  9. # GNU Emacs is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. # GNU Emacs is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. # You should have received a copy of the GNU General Public License
  18. # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  19. DIFF="diff"
  20. usage="$0: Usage: vcdiff [--brief] [-q] [-r<sid1>] [-r<sid2>] [diffopts] sccsfile..."
  21. # Now that we use `sccs get' rather than just `get', we don't need this.
  22. # PATH=$PATH:/usr/ccs/bin:/usr/sccs:/usr/xpg4/bin # common SCCS hangouts
  23. echo="echo"
  24. sid1= sid2=
  25. for f
  26. do
  27. case $f in
  28. -*)
  29. case $f in
  30. --brief)
  31. DIFF=cmp;;
  32. -q)
  33. echo=:;;
  34. -r?*)
  35. case $sid1 in
  36. '')
  37. sid1=$f
  38. ;;
  39. *)
  40. case $sid2 in
  41. ?*) echo "$usage" >&2; exit 2 ;;
  42. esac
  43. sid2=$f
  44. ;;
  45. esac
  46. ;;
  47. *)
  48. options="$options $f"
  49. ;;
  50. esac
  51. shift
  52. ;;
  53. *)
  54. break
  55. ;;
  56. esac
  57. done
  58. case $# in
  59. 0)
  60. echo "$usage" >&2
  61. exit 2
  62. esac
  63. rev1= rev2= status=0
  64. trap 'status=2; exit' 1 2 13 15
  65. trap 'rm -f $rev1 $rev2 || status=2; exit $status' 0
  66. for f
  67. do
  68. s=2
  69. case $f in
  70. s.* | */s.*)
  71. if
  72. rev1=`mktemp /tmp/geta.XXXXXXXX`
  73. sccs get -s -p -k $sid1 "$f" > $rev1 &&
  74. case $sid2 in
  75. '')
  76. workfile=`expr " /$f" : '.*/s.\(.*\)'`
  77. ;;
  78. *)
  79. rev2=`mktemp /tmp/getb.XXXXXXXX`
  80. sccs get -s -p -k $sid2 "$f" > $rev2
  81. workfile=$rev2
  82. esac
  83. then
  84. $echo $DIFF $options $rev1 $workfile >&2
  85. $DIFF $options $rev1 $workfile
  86. s=$?
  87. fi
  88. ;;
  89. *)
  90. echo "$0: $f is not an SCCS file" >&2
  91. esac
  92. if test $status -lt $s
  93. then status=$s
  94. fi
  95. done