home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / emacs / help / 3982 < prev    next >
Encoding:
Text File  |  1992-09-03  |  11.1 KB  |  359 lines

  1. Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!crdgw1!rdsunx.crd.ge.com!rdsunx!montnaro
  2. From: montnaro@spyder.crd.ge.com (Skip Montanaro)
  3. Newsgroups: gnu.emacs.help
  4. Subject: Re: the Motif black hole.
  5. Message-ID: <MONTNARO.92Sep3100948@spyder.crd.ge.com>
  6. Date: 3 Sep 92 15:09:48 GMT
  7. References: <FELIX.92Sep1103526@idefix.laas.fr> <9209011816.AA19239@mole.gnu.ai.mit.edu>
  8.     <1992Sep2.041137.10661@digi.lonestar.org>
  9. Sender: usenet@crd.ge.com (Required for NNTP)
  10. Reply-To: montanaro@crd.ge.com (Skip Montanaro)
  11. Organization: GE Corporate Research & Development, Schenectady, NY
  12. Lines: 343
  13. In-Reply-To: kgallagh@digi.lonestar.org's message of 2 Sep 92 04:11:37 GMT
  14. Nntp-Posting-Host: spyder.crd.ge.com
  15.  
  16. In article <1992Sep2.041137.10661@digi.lonestar.org>
  17. kgallagh@digi.lonestar.org (Kevin Gallagher) writes:
  18.  
  19.    Another utility sorely missed is a tool which will diff two versions of a
  20.    texinfo source file and automatically generate a third version containing
  21.    the necessary instructions to print the updated version with change bars.
  22.    (I have yet to find a decent way to do this in TeX and LaTeX, as well.)
  23.  
  24. Appended is a shell archive containing cbar and some simple wrapper stuff to
  25. make it work with LaTeX. I know little about TeX anymore, so I can't be any
  26. help converting the LaTeX macros for use with texinfo. Cbar was written by
  27. Alan Croswell at Columbia University. From the looks of the RCS header in
  28. cbar.c, it was written in early 1987. I haven't used it or the other stuff
  29. (the ecbar script and LaTeX macros) for over three years.
  30.  
  31. Have fun with it.
  32.  
  33. #! /bin/sh
  34. # This is a shell archive.  Remove anything before this line, then unpack
  35. # it by saving it into a file and typing "sh file".  To overwrite existing
  36. # files, type "sh file -c".  You can also feed this as standard input via
  37. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  38. # will see the following message at the end:
  39. #        "End of shell archive."
  40. # Contents:  Makefile README cbar.c cbar.l cbar.latex.macros ecbar
  41. # Wrapped by montnaro@ausable on Thu Sep  3 10:04:33 1992
  42. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  43. if test -f Makefile -a "${1}" != "-c" ; then 
  44.   echo shar: Will not over-write existing file \"Makefile\"
  45. else
  46. echo shar: Extracting \"Makefile\" \(216 characters\)
  47. sed "s/^X//" >Makefile <<'END_OF_Makefile'
  48. X##  Makefile for cbar
  49. X
  50. XDISTFILES = Makefile cbar.c cbar.l cbar.latex.macros ecbar README
  51. X
  52. Xall: cbar
  53. X
  54. Xclean:
  55. X    rm -f cbar cbar.shark *~
  56. X
  57. Xdistrib : cbar.shark
  58. X
  59. Xcbar.shark : $(DISTFILES)
  60. X    shark $(DISTFILES) > cbar.shark
  61. END_OF_Makefile
  62. if test 216 -ne `wc -c <Makefile`; then
  63.     echo shar: \"Makefile\" unpacked with wrong size!
  64. fi
  65. # end of overwriting check
  66. fi
  67. if test -f README -a "${1}" != "-c" ; then 
  68.   echo shar: Will not over-write existing file \"README\"
  69. else
  70. echo shar: Extracting \"README\" \(666 characters\)
  71. sed "s/^X//" >README <<'END_OF_README'
  72. XHere's the stuff I cooked up for the EDGE project. The ecbar.sh shell script
  73. Xassumes you use SCCS. If you can't figure out how to use it on a pair of
  74. Xfiles that aren't under SCCS, let me know.
  75. X
  76. XThe two LaTeX macros of interest are marginalbegin and marginalend. They are
  77. Xdefined in cbar.latex.macros. Place them and the three utility macros on
  78. Xwhich they are based in your LaTeX file in the document header, probably
  79. Xwhere there's a "Define global macros here" comment.
  80. X
  81. XEcbar calls cbar to do the real work. Just type 'make' to compile cbar.c,
  82. Xand put the resulting cbar somewhere in your PATH. If you're curious about
  83. Xcbar, try 'nroff -man cbar.l | col | more'.
  84. X
  85. X
  86. END_OF_README
  87. if test 666 -ne `wc -c <README`; then
  88.     echo shar: \"README\" unpacked with wrong size!
  89. fi
  90. # end of overwriting check
  91. fi
  92. if test -f cbar.c -a "${1}" != "-c" ; then 
  93.   echo shar: Will not over-write existing file \"cbar.c\"
  94. else
  95. echo shar: Extracting \"cbar.c\" \(2037 characters\)
  96. sed "s/^X//" >cbar.c <<'END_OF_cbar.c'
  97. Xstatic char *RCSid = "$Header: cbar.c,v 1.1 87/04/22 10:31:51 alan Exp $";
  98. X/* 
  99. X * cbar [bar-on bar-off]
  100. X *
  101. X * Inserts change bar commands around diff -e output.  
  102. X *
  103. X * Alan Crosswell, Columbia University
  104. X *
  105. X * Tacks on a "1,$p" at the end so that you can do something like this:
  106. X *
  107. X *  diff -b -e old.mss updated.mss | cbar | ed - old.mss >updated-bar.mss
  108. X *
  109. X * Input looks like this:
  110. X *------------------------------
  111. X * 746,747d
  112. X * 138a
  113. X * NOTE: Change this for LISTSERV.
  114. X * .
  115. X * 89c
  116. X * followed by a blank or hyphen (e.g. "220 ").
  117. X * .
  118. X *------------------------------
  119. X * Output looks like:
  120. X *------------------------------
  121. X * 746,747d
  122. X * 138,138a
  123. X * @CBON
  124. X * NOTE: Change this for LISTSERV.
  125. X * @CBOFF
  126. X * .
  127. X * 91,91c
  128. X * @CBON
  129. X * followed by a blank or hyphen (e.g. "220 ").
  130. X * @CBOFF
  131. X * .
  132. X * 1,$p
  133. X *------------------------------
  134. X *
  135. X * NOTE:  It is imperitave that the line numbers appear in highest-first
  136. X *  order since extra lines are being added.
  137. X *
  138. X * The default change bar commands are those used by Scribe (@CBON, @CBOFF).
  139. X * You may provide your own (e.g. cbar ".mc |" ".mc" for nroff).
  140. X *
  141. X * $Log:    cbar.c,v $
  142. X * Revision 1.1  87/04/22  10:31:51  alan
  143. X * Initial revision
  144. X * 
  145. X * 
  146. X */
  147. X#include <stdio.h>
  148. X
  149. Xstatic char *cbon = "@CBON";
  150. Xstatic char *cboff = "@CBOFF";
  151. X
  152. Xmain(argc,argv)
  153. Xint argc;
  154. Xchar **argv;
  155. X{
  156. X    char buf[1024];
  157. X    enum {ed_cmd, in_data} state = ed_cmd;
  158. X    
  159. X    if (argc == 3) {
  160. X    cbon = argv[1];
  161. X    cboff = argv[2];
  162. X    } else if (argc != 1) {
  163. X    fprintf(stderr,"Usage: cbar [bar_on bar_off]\n");
  164. X    exit(1);
  165. X    }
  166. X
  167. X    while(gets(buf) != NULL) {
  168. X    switch (state) {
  169. X      case ed_cmd:
  170. X        if (buf[strlen(buf)-1] == 'd') {
  171. X        state = ed_cmd;    /* 'd' has no data */
  172. X        puts(buf);
  173. X        } else {
  174. X        state = in_data; /* 'a' and 'c' do */
  175. X        printf("%s\n%s\n", buf, cbon);
  176. X        }
  177. X        break;
  178. X
  179. X      case in_data:
  180. X        if (buf[0] == '.' && buf[1] == '\0') { /* end of data */
  181. X        state = ed_cmd;
  182. X        printf("%s\n.\n", cboff);
  183. X        } else
  184. X          puts(buf);
  185. X        break;
  186. X    } /* end switch(state) */
  187. X    } /* end while */
  188. X    puts("1,$p");
  189. X}
  190. END_OF_cbar.c
  191. if test 2037 -ne `wc -c <cbar.c`; then
  192.     echo shar: \"cbar.c\" unpacked with wrong size!
  193. fi
  194. # end of overwriting check
  195. fi
  196. if test -f cbar.l -a "${1}" != "-c" ; then 
  197.   echo shar: Will not over-write existing file \"cbar.l\"
  198. else
  199. echo shar: Extracting \"cbar.l\" \(1036 characters\)
  200. sed "s/^X//" >cbar.l <<'END_OF_cbar.l'
  201. X.TH CBAR LOCAL
  202. X.SH NAME
  203. Xcbar \- add change bars to a document
  204. X.SH SYNOPSIS
  205. X.B cbar
  206. X[
  207. X.I bar-on bar-off
  208. X]
  209. X
  210. X.SH DESCRIPTION
  211. X.B Cbar
  212. Xinserts text-formatter commands into diff -e output to turn
  213. Xon and off change bars.  This can then be fed back into 
  214. X.B ed(1)
  215. Xalong with the original document to produce a new document
  216. Xthat contains change bars wherever the new and old version of
  217. Xa document have differences.
  218. X
  219. X.I bar-on
  220. Xand
  221. X.I bar-off
  222. Xmay be specified as the commands to turn on and off change bars,
  223. Xrespecively.  If not specified, 
  224. X.B @CBON
  225. Xand 
  226. X.B @CBOFF
  227. X(for Scribe) are used.
  228. X
  229. X.SH EXAMPLE
  230. X.nf
  231. Xdiff -b -e old.mss new.mss | cbar | ed - old.mss >bars.mss
  232. X.fi
  233. X.SH SEE ALSO
  234. Xdiff(1), ed(1)
  235. X
  236. X.SH BUGS
  237. X.B ed(1)
  238. Xcommands on stdin must appear in decreasing line number order
  239. Xso that lines at the end of the file get edited first and lines at
  240. Xthe beginning get edited last (diff -e does this).
  241. XThis restriction exists because additional lines are
  242. Xadded to the file which will mess up the line numbering scheme if
  243. Xdone in lowest-to-highest order.
  244. END_OF_cbar.l
  245. if test 1036 -ne `wc -c <cbar.l`; then
  246.     echo shar: \"cbar.l\" unpacked with wrong size!
  247. fi
  248. # end of overwriting check
  249. fi
  250. if test -f cbar.latex.macros -a "${1}" != "-c" ; then 
  251.   echo shar: Will not over-write existing file \"cbar.latex.macros\"
  252. else
  253. echo shar: Extracting \"cbar.latex.macros\" \(374 characters\)
  254. sed "s/^X//" >cbar.latex.macros <<'END_OF_cbar.latex.macros'
  255. X\def\strutdepth{\dp\strutbox}
  256. X\def\marginalbegin{\strut\vadjust{\kern-\strutdepth\specialuarrow}}
  257. X\def\marginalend{\strut\vadjust{\kern-\strutdepth\specialdarrow}}
  258. X\def\specialuarrow{\vtop to \strutdepth{
  259. X    \baselineskip\strutdepth
  260. X    \vss\llap{$\uparrow$ }\null}}
  261. X\def\specialdarrow{\vtop to \strutdepth{
  262. X    \baselineskip\strutdepth
  263. X    \vss\llap{$\downarrow$ }\null}}
  264. END_OF_cbar.latex.macros
  265. if test 374 -ne `wc -c <cbar.latex.macros`; then
  266.     echo shar: \"cbar.latex.macros\" unpacked with wrong size!
  267. fi
  268. # end of overwriting check
  269. fi
  270. if test -f ecbar -a "${1}" != "-c" ; then 
  271.   echo shar: Will not over-write existing file \"ecbar\"
  272. else
  273. echo shar: Extracting \"ecbar\" \(2449 characters\)
  274. sed "s/^X//" >ecbar <<'END_OF_ecbar'
  275. X#!/bin/sh
  276. X
  277. X#+---------------------------------------------------------------------------
  278. X# Program:    ecbar.sh
  279. X# Version:    @(#)ecbar.sh    1.1 2/24/88 12:13:17
  280. X# Author:    Skip Montanaro
  281. X# Date:        24 Feb 88
  282. X# Synopsis:    ecbar.sh module
  283. X# Purpose:
  284. X#    Insert LaTeX changebars in a document under SCCS control
  285. X# Inputs:
  286. X#    Module to have change bars added
  287. X# Outputs:
  288. X#    Modified document with \marginalbegin/\marginalend pairs wrapped
  289. X#    around the changes is output on stdout
  290. X# Notes:
  291. X#    1. The program which inserts the changebar notation knows nothing
  292. X#    about LaTeX. It is driven off diff output, so you will have to
  293. X#    filter the output to remove changebar notation from unwanted areas
  294. X#    such as the title page, improperly nested with LaTeX blocks, and so
  295. X#    forth.
  296. X#
  297. X# Revision History:
  298. X#    Name        Date        Comments
  299. X#    ----        ----        --------
  300. X#    Skip Montanaro    18 Feb 88    Created
  301. X#
  302. X#+---------------------------------------------------------------------------
  303. X
  304. X#----------------------------------------------------------------------------
  305. X# Variable declaration and initialization
  306. X#----------------------------------------------------------------------------
  307. X
  308. Xpname=`basename $0`    # for pretty printing errors and warnings
  309. Xmodule=            # module to get change bars
  310. Xold=            # second to last SCCS version
  311. Xnew=            # latest SCCS version
  312. Xctla=`echo '\001'`    # avoid placing literal ctl-A in script
  313. X
  314. X#----------------------------------------------------------------------------
  315. X# Global recovery from signals and unexpected errors
  316. X#----------------------------------------------------------------------------
  317. X
  318. Xtrap "exit 1" 1 2 3 15
  319. X
  320. X#----------------------------------------------------------------------------
  321. X# Module name is required and must be first argument
  322. X#----------------------------------------------------------------------------
  323. X
  324. Xif [ $# -eq 0 ] ; then
  325. X    # no module name given. Fatal error
  326. X    echo "usage: $pname module"
  327. X    exit 1
  328. Xfi
  329. X
  330. Xmodule=$1
  331. Xshift
  332. X
  333. X# determine the last two versions of $module.
  334. Xold=`egrep "^${ctla}d" < SCCS/s.$module|head -2|tail -1|awk '{print $3}'`
  335. Xnew=`egrep "^${ctla}d" < SCCS/s.$module|head -1|awk '{print $3}'`
  336. X
  337. Xif [ X$old = X ] ; then
  338. X    echo $pname: Two versions of $module do not exist.
  339. X    exit 1
  340. Xelse
  341. X    sccs get -s -r$old $module -G$module.$old
  342. X    sccs get -s -r$new $module -G$module.$new
  343. X    diff -b -e $module.$old $module.$new | \
  344. X    cbar "\marginalbegin" "\marginalend" | \
  345. X    ed - $module.$old
  346. X    rm -f $module.$old $module.$new
  347. Xfi
  348. END_OF_ecbar
  349. if test 2449 -ne `wc -c <ecbar`; then
  350.     echo shar: \"ecbar\" unpacked with wrong size!
  351. fi
  352. chmod +x ecbar
  353. # end of overwriting check
  354. fi
  355. echo shar: End of shell archive.
  356. exit 0
  357. --
  358. Skip (montanaro@crd.ge.com)
  359.