From: montnaro@spyder.crd.ge.com (Skip Montanaro)
Newsgroups: gnu.emacs.help
Subject: Re: the Motif black hole.
Date: 3 Sep 92 15:09:48 GMT
	<1992Sep2.041137.10661@digi.lonestar.org>
Reply-To: montanaro@crd.ge.com (Skip Montanaro)
Organization: GE Corporate Research & Development, Schenectady, NY

In article <1992Sep2.041137.10661@digi.lonestar.org>
kgallagh@digi.lonestar.org (Kevin Gallagher) writes:

   Another utility sorely missed is a tool which will diff two versions of a
   texinfo source file and automatically generate a third version containing
   the necessary instructions to print the updated version with change bars.
   (I have yet to find a decent way to do this in TeX and LaTeX, as well.)

Appended is a shell archive containing cbar and some simple wrapper stuff to
make it work with LaTeX. I know little about TeX anymore, so I can't be any
help converting the LaTeX macros for use with texinfo. Cbar was written by
Alan Croswell at Columbia University. From the looks of the RCS header in
cbar.c, it was written in early 1987. I haven't used it or the other stuff
(the ecbar script and LaTeX macros) for over three years.

Have fun with it.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Makefile README cbar.c cbar.l cbar.latex.macros ecbar
# Wrapped by montnaro@ausable on Thu Sep  3 10:04:33 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(216 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X##  Makefile for cbar
X
XDISTFILES = Makefile cbar.c cbar.l cbar.latex.macros ecbar README
X
Xall: cbar
X
Xclean:
X	rm -f cbar cbar.shark *~
X
Xdistrib : cbar.shark
X
Xcbar.shark : $(DISTFILES)
X	shark $(DISTFILES) > cbar.shark
END_OF_Makefile
if test 216 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(666 characters\)
sed "s/^X//" >README <<'END_OF_README'
XHere's the stuff I cooked up for the EDGE project. The ecbar.sh shell script
Xassumes you use SCCS. If you can't figure out how to use it on a pair of
Xfiles that aren't under SCCS, let me know.
X
XThe two LaTeX macros of interest are marginalbegin and marginalend. They are
Xdefined in cbar.latex.macros. Place them and the three utility macros on
Xwhich they are based in your LaTeX file in the document header, probably
Xwhere there's a "Define global macros here" comment.
X
XEcbar calls cbar to do the real work. Just type 'make' to compile cbar.c,
Xand put the resulting cbar somewhere in your PATH. If you're curious about
Xcbar, try 'nroff -man cbar.l | col | more'.
X
X
END_OF_README
if test 666 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f cbar.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"cbar.c\"
else
echo shar: Extracting \"cbar.c\" \(2037 characters\)
sed "s/^X//" >cbar.c <<'END_OF_cbar.c'
Xstatic char *RCSid = "$Header: cbar.c,v 1.1 87/04/22 10:31:51 alan Exp $";
X/* 
X * cbar [bar-on bar-off]
X *
X * Inserts change bar commands around diff -e output.  
X *
X * Alan Crosswell, Columbia University
X *
X * Tacks on a "1,$p" at the end so that you can do something like this:
X *
X *  diff -b -e old.mss updated.mss | cbar | ed - old.mss >updated-bar.mss
X *
X * Input looks like this:
X *------------------------------
X * 746,747d
X * 138a
X * NOTE: Change this for LISTSERV.
X * .
X * 89c
X * followed by a blank or hyphen (e.g. "220 ").
X * .
X *------------------------------
X * Output looks like:
X *------------------------------
X * 746,747d
X * 138,138a
X * @CBON
X * NOTE: Change this for LISTSERV.
X * @CBOFF
X * .
X * 91,91c
X * @CBON
X * followed by a blank or hyphen (e.g. "220 ").
X * @CBOFF
X * .
X * 1,$p
X *------------------------------
X *
X * NOTE:  It is imperitave that the line numbers appear in highest-first
X *  order since extra lines are being added.
X *
X * The default change bar commands are those used by Scribe (@CBON, @CBOFF).
X * You may provide your own (e.g. cbar ".mc |" ".mc" for nroff).
X *
X * $Log:	cbar.c,v $
X * Revision 1.1  87/04/22  10:31:51  alan
X * Initial revision
X * 
X * 
X */
X#include <stdio.h>
X
Xstatic char *cbon = "@CBON";
Xstatic char *cboff = "@CBOFF";
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X    char buf[1024];
X    enum {ed_cmd, in_data} state = ed_cmd;
X    
X    if (argc == 3) {
X	cbon = argv[1];
X	cboff = argv[2];
X    } else if (argc != 1) {
X	fprintf(stderr,"Usage: cbar [bar_on bar_off]\n");
X	exit(1);
X    }
X
X    while(gets(buf) != NULL) {
X	switch (state) {
X	  case ed_cmd:
X	    if (buf[strlen(buf)-1] == 'd') {
X		state = ed_cmd;	/* 'd' has no data */
X		puts(buf);
X	    } else {
X		state = in_data; /* 'a' and 'c' do */
X		printf("%s\n%s\n", buf, cbon);
X	    }
X	    break;
X
X	  case in_data:
X	    if (buf[0] == '.' && buf[1] == '\0') { /* end of data */
X		state = ed_cmd;
X		printf("%s\n.\n", cboff);
X	    } else
X	      puts(buf);
X	    break;
X	} /* end switch(state) */
X    } /* end while */
X    puts("1,$p");
X}
END_OF_cbar.c
if test 2037 -ne `wc -c <cbar.c`; then
    echo shar: \"cbar.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f cbar.l -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"cbar.l\"
else
echo shar: Extracting \"cbar.l\" \(1036 characters\)
sed "s/^X//" >cbar.l <<'END_OF_cbar.l'
X.TH CBAR LOCAL
X.SH NAME
Xcbar \- add change bars to a document
X.SH SYNOPSIS
X.B cbar
X[
X.I bar-on bar-off
X]
X
X.SH DESCRIPTION
X.B Cbar
Xinserts text-formatter commands into diff -e output to turn
Xon and off change bars.  This can then be fed back into 
X.B ed(1)
Xalong with the original document to produce a new document
Xthat contains change bars wherever the new and old version of
Xa document have differences.
X
X.I bar-on
Xand
X.I bar-off
Xmay be specified as the commands to turn on and off change bars,
Xrespecively.  If not specified, 
X.B @CBON
Xand 
X.B @CBOFF
X(for Scribe) are used.
X
X.SH EXAMPLE
X.nf
Xdiff -b -e old.mss new.mss | cbar | ed - old.mss >bars.mss
X.fi
X.SH SEE ALSO
Xdiff(1), ed(1)
X
X.SH BUGS
X.B ed(1)
Xcommands on stdin must appear in decreasing line number order
Xso that lines at the end of the file get edited first and lines at
Xthe beginning get edited last (diff -e does this).
XThis restriction exists because additional lines are
Xadded to the file which will mess up the line numbering scheme if
Xdone in lowest-to-highest order.
END_OF_cbar.l
if test 1036 -ne `wc -c <cbar.l`; then
    echo shar: \"cbar.l\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f cbar.latex.macros -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"cbar.latex.macros\"
else
echo shar: Extracting \"cbar.latex.macros\" \(374 characters\)
sed "s/^X//" >cbar.latex.macros <<'END_OF_cbar.latex.macros'
X\def\strutdepth{\dp\strutbox}
X\def\marginalbegin{\strut\vadjust{\kern-\strutdepth\specialuarrow}}
X\def\marginalend{\strut\vadjust{\kern-\strutdepth\specialdarrow}}
X\def\specialuarrow{\vtop to \strutdepth{
X    \baselineskip\strutdepth
X    \vss\llap{$\uparrow$ }\null}}
X\def\specialdarrow{\vtop to \strutdepth{
X    \baselineskip\strutdepth
X    \vss\llap{$\downarrow$ }\null}}
END_OF_cbar.latex.macros
if test 374 -ne `wc -c <cbar.latex.macros`; then
    echo shar: \"cbar.latex.macros\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ecbar -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"ecbar\"
else
echo shar: Extracting \"ecbar\" \(2449 characters\)
sed "s/^X//" >ecbar <<'END_OF_ecbar'
X#!/bin/sh
X
X#+---------------------------------------------------------------------------
X# Program:	ecbar.sh
X# Version:	@(#)ecbar.sh	1.1 2/24/88 12:13:17
X# Author:	Skip Montanaro
X# Date:		24 Feb 88
X# Synopsis:	ecbar.sh module
X# Purpose:
X#	Insert LaTeX changebars in a document under SCCS control
X# Inputs:
X#	Module to have change bars added
X# Outputs:
X#	Modified document with \marginalbegin/\marginalend pairs wrapped
X#	around the changes is output on stdout
X# Notes:
X#	1. The program which inserts the changebar notation knows nothing
X#	about LaTeX. It is driven off diff output, so you will have to
X#	filter the output to remove changebar notation from unwanted areas
X#	such as the title page, improperly nested with LaTeX blocks, and so
X#	forth.
X#
X# Revision History:
X#	Name		Date		Comments
X#	----		----		--------
X#	Skip Montanaro	18 Feb 88	Created
X#
X#+---------------------------------------------------------------------------
X
X#----------------------------------------------------------------------------
X# Variable declaration and initialization
X#----------------------------------------------------------------------------
X
Xpname=`basename $0`	# for pretty printing errors and warnings
Xmodule=			# module to get change bars
Xold=			# second to last SCCS version
Xnew=			# latest SCCS version
Xctla=`echo '\001'`	# avoid placing literal ctl-A in script
X
X#----------------------------------------------------------------------------
X# Global recovery from signals and unexpected errors
X#----------------------------------------------------------------------------
X
Xtrap "exit 1" 1 2 3 15
X
X#----------------------------------------------------------------------------
X# Module name is required and must be first argument
X#----------------------------------------------------------------------------
X
Xif [ $# -eq 0 ] ; then
X    # no module name given. Fatal error
X    echo "usage: $pname module"
X    exit 1
Xfi
X
Xmodule=$1
Xshift
X
X# determine the last two versions of $module.
Xold=`egrep "^${ctla}d" < SCCS/s.$module|head -2|tail -1|awk '{print $3}'`
Xnew=`egrep "^${ctla}d" < SCCS/s.$module|head -1|awk '{print $3}'`
X
Xif [ X$old = X ] ; then
X    echo $pname: Two versions of $module do not exist.
X    exit 1
Xelse
X    sccs get -s -r$old $module -G$module.$old
X    sccs get -s -r$new $module -G$module.$new
X    diff -b -e $module.$old $module.$new | \
X	cbar "\marginalbegin" "\marginalend" | \
X	ed - $module.$old
X    rm -f $module.$old $module.$new
Xfi
END_OF_ecbar
if test 2449 -ne `wc -c <ecbar`; then
    echo shar: \"ecbar\" unpacked with wrong size!
fi
chmod +x ecbar
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
--
Skip (montanaro@crd.ge.com)
Newsgroups: gnu.emacs.help