henry@utzoo.UUCP (Henry Spencer) (07/31/85)
From watmath!rjwhite Wed Jul 31 14:16:25 1985 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!rjwhite From: rjwhite@watmath.UUCP (RJ White) Newsgroups: to.utzoo Subject: test1 Message-ID: <15939@watmath.UUCP> Date: Tue, 30-Jul-85 02:04:03 EDT Article-I.D.: watmath.15939 Posted: Tue Jul 30 02:04:03 1985 Date-Received: Wed, 31-Jul-85 02:24:52 EDT Organization: University of Waterloo [MFCF] Lines: 200 Here's a little Bourne shell script which allow you to have "change bars" in your nroff/troff text to show what has changed from the last version of your document. In case, there's not enough disclaimers in the script itself, I did write this, but I didn't come up with the idea originally. This also isn't necessairly the best way to do it (and if there is a better way, I'd be real interested in hearing about it). We had a need for something quick and this ended up being it. I don't make any claims as to how it works with other things in between it and troff (like pic, I know that's a little wierd, but it's still usable). Because of n/troff's strangeness with the ".mc" command, this doesn't come out with only the lines that was changed having the "|" at the end. When it's wrong, though, there should be too many "|"s, not too few. Enjoy. -King ARPA: ables@mcc UUCP: {ihnp4,seismo,ctvax}!ut-sally!mcc-db!ables #--------CUT---------CUT---------CUT---------CUT--------# ######################################################### # # # This is a shell archive file. To extract files: # # # # 1) Make a directory for the files. # # 2) Write a file, such as "file.shar", containing # # this archive file into the directory. # # 3) Type "sh file.shar". Do not use csh. # # # ######################################################### # # echo Extracting diffmark: sed 's/^Z//' >diffmark <<\DARTHVADERSUCKS6831WILLRODGERSNEVERMETBARRYSWITZER Z#! /bin/sh Z# Z# diffmark - mark differences in nroff/troff source Z# write result to stdout (for pipe into n/troff) Z# Z# By King Ables Z# Latest update: 15-Jul-85 Z# Z# usage is: Z# Z# diffmark source-file | {n,t}roff ... Z# or Z# diffmark new-source-file old-source-file | {n,t}roff ... Z# Z# if only one parameter is used, then the old source is Z# expected to be in either source-file.bak or source-file.BAK. Z# Z# At someone's request, if the filename is in the form Z# "file.ext" (Tops-10/20 style), then "file.BAK" and "file.bak" are Z# also looked for (though, this is not usually an optimistic pursuit!). Z# NOTE: I am NOT responsible for things like "file.ext.a" because it'll Z# look for "file.ext.BAK" and "file.ext.bak" (it only takes off the last Z# extension, in this case, ".a"). Z# Z# If a second parameter is provided, that will reference the Z# original source file. Z# Z# Differences are marked with a "|" in the right margin. Z# missing lines are marked with a "-" in the right margin of Z# the line in the area of the missing text. Z# Z# This was not my idea... many people have had this idea. I most Z# recently heard that it had existed at Los Alamos National Labs Z# (lanl.arpa) but may not any longer. We had a need for this and Z# couldn't find a version already in existence, so here is one. Z# Zif test "$1" = "" Zthen Z echo $0: no file name specified. Z exit 1 Zfi Z# Z# get original (backup) name Z# Zif test "$2" = "" Zthen Z if test -r $1.bak Z then Z bak=$1.bak Z else Z if test -r $1.BAK Z then Z bak=$1.BAK Z else Z name=`expr "$1" : '\(.*\)\..*'` Z if test "$name" = "" Z then Z echo "$0: original file not specified/found." Z exit Z else Z if test -r $name.bak Z then Z bak=$name.bak Z else Z if test -r $name.BAK Z then Z bak=$name.BAK Z else Z echo "$0: original file not specified/found." Z exit Z fi Z fi Z fi Z fi Z fi Z else Z bak=$2 Zfi Z# Zcp $bak /tmp/$$.dmscr Z# Z# awk script to put in .mc commands Z# Z# all but the first 'print ".mc"' of the first line of the Z# following awk script is a hack to make sure the change Z# bars are always on all lines of changed text (so the Z# last line isn't left unmarked). This could cause more Z# changebars than needed (on unchanged lines adjacent to Z# changed lines) but that's better than leaving out a changed Z# line, right? Z# Zcat >/tmp/$$.dmawkcmd <<% Z/^\.$/ { print ".mc" ; print ".mc |" ; print ".mc" } Z {print} Z/^[0-9,]*[ac]$/ { print ".mc |" } Z/^[0-9,]*d$/ { print ".i" ; print ".mc -" ; print ".mc" ; Z print ".mc -" ; print ".mc" ; print "." } ZEND {print "w" ; print "q"} Z% Z# Zdiff -e $bak $1 | awk -f /tmp/$$.dmawkcmd | ed /tmp/$$.dmscr >>/dev/null Z# Z# send to stdout (this is kinda gross) Z# Zcat /tmp/$$.dmscr Zrm -f /tmp/$$.dmscr /tmp/$$.dmawkcmd DARTHVADERSUCKS6831WILLRODGERSNEVERMETBARRYSWITZER set `sum diffmark` if test 59439 != $1 then echo diffmark: Checksum error. Is: $1, should be: 59439. fi # # echo Extracting diffmark.1l: sed 's/^Z//' >diffmark.1l <<\DARTHVADERSUCKS6831WILLRODGERSNEVERMETBARRYSWITZER Z.TH DIFFMARK LOCAL "10 July 1985" Z.UC 4 Z.SH NAME Zdiffmark \- add difference marks (or change bars) to nroff sources. Z.SH SYNOPSIS Z.B diffmark Zfile1 [ file2 ] Z.br Z.SH DESCRIPTION ZIf two files are specified, Z.I diffmark Zexamines both and adds the nroff command `.mc' into the stream of Z.I file1 Zto mark text that is different from the older Z.I file2. Z.PP ZIf only one file is specified, Z.I diffmark Ztrys to figure out the name of the backup (original) file. ZIf the file specified is `abc' attempts will be made to Zopen `abc.bak' and `abc.BAK' (in that order) as the older file. If Zthe filename is of the form `file.ext' (Tops-10/20 style), for Zexample, `report.nr', then `report.bak' and `report.BAK' will Zalso be tried. Note that a filename like `report.part1.nr' will Z(failing `report.part1.nr.bak' and `report.part1.nr.BAK') cause Z.I diffmark Zto try to open `report.part1.bak' and `report.part1.BAK' (which Zworks, but consider the name `report.nr.part.1'). Z.PP ZThe new nroff source is written to stdout suitable for piping into Zanother preprocessor and/or into nroff or troff. Z.SH FILES Z/tmp/$$.dmscr Z.br Z/tmp/$$.dmawkcmd Z.SH SEE ALSO Zdiff(1), nroff(1) Z.SH DIAGNOSTICS ZWhen no files are specified or when none of the guessed original files Zcan be found. DARTHVADERSUCKS6831WILLRODGERSNEVERMETBARRYSWITZER set `sum diffmark.1l` if test 58919 != $1 then echo diffmark.1l: Checksum error. Is: $1, should be: 58919. fi echo Th.. Th.. Thats all f-f-folks. echo exit 0 -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry