home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / sources / 2886 < prev    next >
Encoding:
Internet Message Format  |  1992-12-25  |  42.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!utgpu!attcan!sobeco!philmtl!altitude!matrox!IRO.UMontreal.CA!pinard
  2. From: pinard@IRO.UMontreal.CA (Francois Pinard)
  3. Newsgroups: alt.sources
  4. Subject: wdiff - Patch 4, Part (3/3) - brings 0.03 to 0.04
  5. Message-ID: <PINARD.92Dec24003722@kovic.IRO.UMontreal.CA>
  6. Date: 24 Dec 92 05:37:22 GMT
  7. Sender: news@IRO.UMontreal.CA
  8. Distribution: alt
  9. Organization: Universite' de Montre'al
  10. Lines: 1002
  11.  
  12. ---- Cut Here and feed the following to sh ----
  13. #!/bin/sh
  14. # this is x.03 (part 3 of a multipart archive)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file Patch4 continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 3; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping Patch4'
  32. else
  33. echo 'x - continuing file Patch4'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'Patch4' &&
  35. X    Permission is granted to make and distribute verbatim copies of this
  36. X manual provided the copyright notice and this permission notice are
  37. X@@ -24,9 +24,9 @@
  38. X File: wdiff.info,  Node: Top,  Next: Copying,  Prev: (dir),  Up: (dir)
  39. X-   This file documents the the `wdiff' command, which compares two
  40. X-files, finding which words have been deleted or added to the first for
  41. X-getting the second.
  42. X+   This file documents the `wdiff' command, as of release 0.04.  This
  43. X+command compares two files, finding which words have been deleted or
  44. X+added to the first for getting the second.
  45. X * Menu:
  46. X@@ -33,9 +33,10 @@
  47. X * Copying::            How you can copy and share `wdiff'.
  48. X * Overview::                    Preliminary information.
  49. X * Invoking wdiff::              How to run `wdiff'.
  50. X-* Examples::            How some people used `wdiff'.
  51. X-* Problems::                    Reporting bugs.
  52. X+* Examples::                    Actual examples of `wdiff' usage.
  53. X+ -- The Detailed Node Listing --
  54. X+
  55. X File: wdiff.info,  Node: Copying,  Next: Overview,  Prev: Top,  Up: Top
  56. X@@ -410,20 +411,24 @@
  57. X a word per word basis.  A word is anything between whitespace. This is
  58. X useful for comparing two texts in which a few words have been changed
  59. X and for which paragraphs have been refilled.  It works by creating two
  60. X-temporary files, one word per line, then execute `diff' on these.  It
  61. X-collects the `diff' output and uses it to produce a nicer display of
  62. X-word differences in the original files.
  63. X+temporary files, one word per line, and then executes `diff' on these
  64. X+files.  It collects the `diff' output and uses it to produce a nicer
  65. X+display of word differences between the original files.
  66. X    Ideally, `wdiff' should avoid calling `diff' and do all the work
  67. X-internally, being more polished and speedy.  However, I loathe
  68. X-replicating `diff' algorithm and effort elsewhere, instead of improving
  69. X-`diff' itself.  It would be more sensible to integrate `wdiff' in
  70. X-`diff' than the other way around.  I did it this way only because I had
  71. X-a sudden and urgent need for it, and it would have taken more time to
  72. X-do it correctly into GNU `diff'.  Your advices or opinions about this
  73. X-are welcome.
  74. X-
  75. X-   `wdiff' was written by Francois Pinard.
  76. X+internally, allowing it to be faster and more polished.  However, I
  77. X+loathe replicating the `diff' algorithm and development effort, instead
  78. X+of improving `diff' itself.  It would be more sensible to integrate
  79. X+`wdiff' into `diff' than the other way around.  I did it this way only
  80. X+because I had a sudden and urgent need for it, and it would have taken
  81. X+too much time to integrate it correctly into GNU `diff'.  Your advice
  82. X+or opinions about this are welcome.
  83. X+
  84. X+   `wdiff' was written by Francois Pinard. Please report bugs to
  85. X+`bug-gnu-utils@prep.ai.mit.edu'. Include the version number, which you
  86. X+can find by running `wdiff --version'.  Include in your message
  87. X+sufficient input to reproduce the problem and also, the output you
  88. X+expected.
  89. X File: wdiff.info,  Node: Invoking wdiff,  Next: Examples,  Prev: Overview,  Up: Top
  90. X@@ -433,20 +438,19 @@
  91. X    The format for running the `wdiff' program is:
  92. X-     wdiff OPTION ... FILE_1 FILE_2
  93. X+     wdiff OPTION ... OLD_FILE NEW_FILE
  94. X-   `wdiff' will compare files FILE_1 and FILE_2, considering FILE_1 as
  95. X-the old version of the text and FILE_2 as the new version of the same
  96. X-text, and produce an annotated copy of FILE_2 on standard output.
  97. X-
  98. X-   `wdiff' will exit with a status of 0 if no difference were found,
  99. X-with a status of 1 if any difference was found or with a status of 2 for
  100. X-any other kind of reason of error.
  101. X-
  102. X-   Usually, underlining is used to mark deleted words, while bolding or
  103. X-reverse video is used to makr added words; this is adjustable in many
  104. X-ways.  `wdiff' supports the following options:
  105. X+   `wdiff' compares files OLD_FILE and NEW_FILE and produces an
  106. X+annotated copy of NEW_FILE on standard output. `wdiff' will exit with a
  107. X+status of 0 if no differences were found, a status of 1 if any
  108. X+differences were found, or a status of 2 for any error.
  109. X+
  110. X+   In this documentation, "deleted text" refers to text in OLD_FILE
  111. X+which is not in NEW_FILE, while "inserted text" refers to text on
  112. X+NEW_FILE which is not in OLD_FILE.
  113. X+   `wdiff' supports the following command line options:
  114. X+
  115. X `--help'
  116. X `-h'
  117. X      Print an informative help message describing the options.
  118. X@@ -457,130 +461,218 @@
  119. X `--no-deleted'
  120. X `-1'
  121. X-     Avoid producing deleted words on the output.  If none of `-1' and
  122. X-     `-2' is selected, it might happen that the right margin will be
  123. X-     exceeded for some lines, respective to the original formatting.
  124. X+     Avoid producing deleted words on the output.  If neither `-1' or
  125. X+     `-2' is selected, the original right margin may be exceeded for
  126. X+     some lines.
  127. X `--no-inserted'
  128. X `-2'
  129. X-     Avoid producing inserted words on the output.  If none of `-1' and
  130. X-     `-2' is selected, it might happen that the right margin will be
  131. X-     exceeded for some lines, respective to the original formatting.
  132. X+     Avoid producing inserted words on the output.  When this flag is
  133. X+     given, the whitespace in the output is taken from OLD_FILE instead
  134. X+     of NEW_FILE.  If neither `-1' or `-2' is selected, the original
  135. X+     right margin may be exceeded for some lines.
  136. X `--no-common'
  137. X `-3'
  138. X      Avoid producing common words on the output.  When this option is
  139. X-     not selected, common words and whitespace are taken from FILE_2. 
  140. X-     When selected, differences are segregated from one other by lines
  141. X-     containing only a few dashes.  Moreover, if this option is
  142. X-     selected at the same time `-1' or `-2' is, then all of the output,
  143. X-     if any, would have the same kind of emphasis; `wdiff' rather
  144. X-     selects to do no emphasis at all.  Finally, if this option is not
  145. X-     selected, but both `-1' and `-2' are, sections of common words
  146. X-     between differences are segregated from one other by lines
  147. X-     containing only a few dashes.
  148. X+     not selected, common words and whitespace are taken from NEW_FILE,
  149. X+     unless option `-2' is given, in which case common words and
  150. X+     whitespace are rather taken from OLD_FILE.  When selected,
  151. X+     differences are separated from one another by lines of dashes.
  152. X+     Moreover, if this option is selected at the same time as `-1' or
  153. X+     `-2', then none of the output will have any emphasis, i.e. no bold
  154. X+     or underlining.  Finally, if this option is not selected, but both
  155. X+     `-1' and `-2' are, then sections of common words between
  156. X+     differences are segregated by lines of dashes.
  157. X+
  158. X+`--statistics'
  159. X+`-s'
  160. X+     On completion, for each file, the total number of words, the
  161. X+     number of common words between the files, the number of words
  162. X+     deleted or inserted and the number of words that have changed is
  163. X+     output.  (A changed word is one that has been replaced or is part
  164. X+     of a replacement.)  Except for the total number of words, all of
  165. X+     the numbers are followed by a percentage relative to the total
  166. X+     number of words in the file.
  167. X+
  168. X+`--auto-pager'
  169. X+`-a'
  170. X+     Some initiatives which were previously automatically taken in
  171. X+     previous versions of `wdiff' are now put under the control of this
  172. X+     option. By using it, a pager is interposed whenever the `wdiff'
  173. X+     output is directed to the user's terminal.  Without this option,
  174. X+     no pager will be called, the user is then responsible for
  175. X+     explicitly piping `wdiff' output into a pager, if required.
  176. X+
  177. X+     The pager is selected by the value of the `PAGER' environment
  178. X+     variable when `wdiff' is run.  If `PAGER' is not defined at run
  179. X+     time, then a default pager, selected at installation time, will be
  180. X+     used instead.  A defined but empty value of `PAGER' means no pager
  181. X+     at all.
  182. X+
  183. X+     When a pager is interposed through the use of this option, one of
  184. X+     the options `-l' or `-t' is also selected, depending on whether
  185. X+     the string `less' appears in the pager's name or not.
  186. X+
  187. X+     It is often useful to define `wdiff' as an alias for `wdiff -a'. 
  188. X+     However, this *hides* the normal `wdiff' behaviour.  The default
  189. X+     behaviour may be restored simply by piping the output from `wdiff'
  190. X+     through `cat'.  This dissociates the output from the user's
  191. X+     terminal.
  192. X `--printer'
  193. X `-p'
  194. X-     Use overstriking to emphasize parts of output.  Each character of
  195. X-     the deleted words is underlined by writing an underscore `_' first,
  196. X-     than a backspace and the letter to be underlined.  Each character
  197. X-     of the added words are bolded by writing them twice, with a
  198. X-     backspace in between.  This option is not selected by default.
  199. X+     Use over-striking to emphasize parts of the output.  Each
  200. X+     character of the deleted text is underlined by writing an
  201. X+     underscore `_' first, then a backspace and then the letter to be
  202. X+     underlined.  Each character of the inserted text is emboldened by
  203. X+     writing it twice, with a backspace in between.  This option is not
  204. X+     selected by default.
  205. X+
  206. X+`--less-mode'
  207. X+`-l'
  208. X+     Use over-striking to emphasize parts of output.  This option works
  209. X+     as option `-p', but also over-strikes whitespace associated with
  210. X+     inserted text.  `less' shows such whitespace using reverse video.
  211. X+     This option is not selected by default.  However, it is
  212. X+     automatically turned on whenever `wdiff' launches the pager
  213. X+     `less'.  See option `-a'.
  214. X-`--statistics'
  215. X-`-s'
  216. X-     At end of program, tell for each file the total number of words,
  217. X-     how many words were common between files, how many were deleted or
  218. X-     inserted and, finally, how many have changed (a changed word has
  219. X-     been replaced or is part of a replacement).  Save for the total
  220. X-     number of words itself, numbers are followed by a percentage
  221. X-     relative to the total number of words for the file.
  222. X+     This option is commonly used in conjunction with `less':
  223. X+
  224. X+          wdiff -l OLD_FILE NEW_FILE | less
  225. X `--terminal'
  226. X `-t'
  227. X-     Force the production of `termcap' strings for emphasizing parts of
  228. X+     Force the production of `termcap' strings for emphasising parts of
  229. X      output, even if the standard output is not associated with a
  230. X-     terminal. The `TERM' environment variable should still contain the
  231. X-     name of a valid `termcap' entry, however.  This option is
  232. X-     automatically selected whenever the standard output is associated
  233. X-     with a terminal.  If you ever need to deselect this option while
  234. X-     still getting the output to the terminal, simply pipe the output
  235. X-     of `wdiff' through `cat' as in:
  236. X-
  237. X-          wdiff FILE_1 FILE_2 | cat
  238. X-
  239. X-`--start-delete'
  240. X-`-w'
  241. X-     Use the following argument as the "start delete" string.  This
  242. X-     string would be output prior to any sequence of deleted text, to
  243. X-     mark where it starts.  By default, there is no start delete string
  244. X-     unless there is no other means of distinguishing where such text
  245. X-     starts; in which case the start delete string is `[-'.
  246. X-
  247. X-`--end-delete'
  248. X-`-x'
  249. X-     Use the following argument as the "end delete" string.  This string
  250. X-     would be output after any sequence of deleted text, to mark where
  251. X-     it ends.  By default, there is no end delete string unless there
  252. X-     is no other means of distinguishing where such text ends; in which
  253. X-     case the end delete string is `-]'.
  254. X-
  255. X-`--start-insert'
  256. X-`-y'
  257. X-     Use the following argument as the "start insert" string.  This
  258. X-     string would be output prior to any sequence of inserted text, to
  259. X-     mark where it starts.  By default, there is no start insert string
  260. X-     unless there is no other means of distinguishing where such text
  261. X-     starts; in which case the start insert string is `{+'.
  262. X-
  263. X-`--end-insert'
  264. X-`-z'
  265. X-     Use the following argument as the "end insert" string.  This string
  266. X-     would be output after any sequence of inserted text, to mark where
  267. X-     it ends.  By default, there is no end insert string unless there
  268. X-     is no other means of distinguishing where such text ends; in which
  269. X-     case the end insert string is `+}'.
  270. X-
  271. X-   If your system has the program `less' or else, the program `more',
  272. X-and if the output of `wdiff' is directly associated to a terminal, the
  273. X-program will then automatically pipe its output through one of these
  274. X-pagers.  The `PAGER' environment variable, if set, overrides the
  275. X-built-in selection of a pager.  When a pager is selected, the `-t'
  276. X-option is forced so the pager will still display the emphasized parts
  277. X-of the text.  However, in the special case `wdiff' is paging to the
  278. X-`less' program, the `-p' option is forced instead of the `-t' option,
  279. X-taking advantage of the fact that `less' recognizes overstrike
  280. X-sequences and renders them appropriately on the user screen.
  281. X-
  282. X-   On a final note, options `-p', `-t', `-[1234]' are not mutually
  283. X-exclusive.  If you use many of them, you will merely accumulate the
  284. X-effect of each.
  285. X+     terminal. The `TERM' environment variable must contain the name of
  286. X+     a valid `termcap' entry.  If the terminal description permits,
  287. X+     underlining is used for marking deleted text, while bold or
  288. X+     reverse video is used for marking inserted text.  This option is
  289. X+     not selected by default. However, it is automatically turned on
  290. X+     whenever `wdiff' launches a pager, and it is known that the pager
  291. X+     is *not* `less'.  See option `-a'.
  292. X+
  293. X+     This option is commonly used when `wdiff' output is not redirected,
  294. X+     but sent directly to the user terminal, as in:
  295. X+
  296. X+          wdiff -t OLD_FILE NEW_FILE
  297. X+
  298. X+     A common kludge uses `wdiff' together with the pager `more', as in:
  299. X+
  300. X+          wdiff -t OLD_FILE NEW_FILE | more
  301. X+
  302. X+     However, some versions of `more' use `termcap' emphasis for their
  303. X+     own purposes, so strange interactions are possible.
  304. X+
  305. X+`--start-delete ARGUMENT'
  306. X+`-w ARGUMENT'
  307. X+     Use ARGUMENT as the "start delete" string.  This string will be
  308. X+     output prior to any sequence of deleted text, to mark where it
  309. X+     starts.  By default, no start delete string is used unless there
  310. X+     is no other means of distinguishing where such text starts; in
  311. X+     this case the default start delete string is `[-'.
  312. X+
  313. X+`--end-delete ARGUMENT'
  314. X+`-x ARGUMENT'
  315. X+     Use ARGUMENT as the "end delete" string.  This string will be
  316. X+     output after any sequence of deleted text, to mark where it ends. 
  317. X+     By default, no end delete string is used unless there is no other
  318. X+     means of distinguishing where such text ends; in this case the
  319. X+     default end delete string is `-]'.
  320. X+
  321. X+`--start-insert ARGUMENT'
  322. X+`-y ARGUMENT'
  323. X+     Use ARGUMENT as the "start insert" string.  This string will be
  324. X+     output prior to any sequence of inserted text, to mark where it
  325. X+     starts.  By default, no start insert string is used unless there
  326. X+     is no other means of distinguishing where such text starts; in
  327. X+     this case the default start insert string is `{+'.
  328. X+
  329. X+`--end-insert ARGUMENT'
  330. X+`-z ARGUMENT'
  331. X+     Use ARGUMENT as the "end insert" string.  This string will be
  332. X+     output after any sequence of inserted text, to mark where it ends.
  333. X+      By default, no end insert string is used unless there is no other
  334. X+     means of distinguishing where such text ends; in this case the
  335. X+     default end insert string is `+}'.
  336. X+
  337. X+`--avoid-wraps'
  338. X+`-n'
  339. X+     Avoid spanning the end of line while showing deleted or inserted
  340. X+     text. Any single fragment of deleted or inserted text spanning
  341. X+     many lines will be considered as being made up of many smaller
  342. X+     fragments not containing a newline.  So deleted text, for example,
  343. X+     will have an end delete string at the end of each line, just
  344. X+     before the new line, and a start delete string at the beginning of
  345. X+     the next line.  A long paragraph of inserted text will have each
  346. X+     line bracketed between start insert and end insert strings.  This
  347. X+     behaviour is not selected by default.
  348. X+
  349. X+   Note that options `-p', `-t', and `-[wxyz]' are not mutually
  350. X+exclusive.  If you use a combination of them, you will merely
  351. X+accumulate the effect of each.  Option `-l' is a variant of option `-p'.
  352. X-File: wdiff.info,  Node: Examples,  Next: Problems,  Prev: Invoking wdiff,  Up: Top
  353. X+File: wdiff.info,  Node: Examples,  Prev: Invoking wdiff,  Up: Top
  354. X+
  355. X+Actual examples of `wdiff' usage
  356. X+********************************
  357. X+
  358. X+   This section presents a few examples of usage, most of them have been
  359. X+contributed by `wdiff' users.
  360. X+
  361. X+   * Change bars example.
  362. X+
  363. X+     This example comes from a discussion with Joe Wells,
  364. X+     `jbw@cs.bu.edu'.
  365. X+
  366. X+     The following command produces a copy of NEW_FILE, shifted right
  367. X+     one space to accommodate change bars since the last revision,
  368. X+     ignoring those changes coming only from paragraph refilling.  Any
  369. X+     line with new or changed text will get a `|' in column 1. 
  370. X+     However, deleted text is not shown nor marked.
  371. X-How some people used `wdiff'
  372. X-****************************
  373. X+          wdiff -1n OLD_FILE NEW_FILE |
  374. X+            sed -e 's/^/  /;/{+/s/^ /|/;s/{+//g;s/+}//g'
  375. X-   This section will contain user-contributed examples.
  376. X+     Here is how it works.  Word differences are found, paying
  377. X+     attention only to additions, as requested by option `-1'.  For
  378. X+     bigger changes which span line boundaries, the insert bracket
  379. X+     strings are repeated on each output line, as requested by option
  380. X+     `-n'.  This output is then reformatted with a `sed' script which
  381. X+     shifts the text right two columns, turns the initial space into a
  382. X+     bar only if there is some new text on that line, then removes all
  383. X+     insert bracket strings.
  384. X+   * `LaTeX' example.
  385. X+
  386. X+     This example has been provided by Steve Fisk,
  387. X+     `fisk@polar.bowdoin.edu'.
  388. X+
  389. X+     The following uses LaTeX to put deleted text in boxes, and new text
  390. X+     in double boxes:
  391. X+
  392. X+          wdiff -w "\fbox{" -x "}" -y "\fbox{\fbox{" -z "}}" ...
  393. X+
  394. X+     works nicely.
  395. X+
  396. X    * `troff' example.
  397. X-     By Paul Fox, `pgf@cayman.com'.
  398. X+     This example comes from Paul Fox, `pgf@cayman.com'.
  399. X      Using `wdiff', with some `troff'-specific delimiters gives *much*
  400. X-     better output.  The delimeters I used (extra shell-quoting removed
  401. X-     for clarity) :
  402. X+     better output.  The delimiters I used:
  403. X-          wdiff -d -1\s-5 -2\s0 -3\fB -4\fP
  404. X+          wdiff -w'\s-5' -x'\s0' -y'\fB' -z'\fP' ...
  405. X      This makes the pointsize of deletions 5 points smaller than
  406. X      normal, and emboldens insertions.  Fantastic!
  407. X-     I experimented with
  408. X+     I experimented with:
  409. X-          wdiff -d -1\fI -2\fP -3\fB -4\fP
  410. X+          wdiff -w'\fI' -x'\fP' -y'\fB' -z'\fP'
  411. X      since that's more like the defaults you use for
  412. X      terminals/printers, but since I actually use italics for emphasis
  413. X@@ -588,35 +680,13 @@
  414. X      I tried it on code, and it works surprisingly well there, too...
  415. X-
  416. X-File: wdiff.info,  Node: Problems,  Prev: Examples,  Up: Top
  417. X-
  418. X-Reporting Bugs
  419. X-**************
  420. X-
  421. X-   If you find a bug in `wdiff', please send electronic mail to
  422. X-`pinard@iro.umontreal.ca'.  Include the version number, which you can
  423. X-find by running `wdiff --version'.  Include in your message sufficient
  424. X-input to reproduce the problem and also, the output you expected.
  425. X-
  426. X-   Here are some received, unprocessed suggestions.
  427. X-
  428. X-   * Make an MSDOS port.
  429. X-
  430. X-   * Select by options exactly what is whitespace.
  431. X-
  432. X-   * Have a `wpatch' program.  I do not see good ways of doing this.
  433. X-     Any ideas?  Suggested by Zhuo Zang <zzang@stat.ufl.edu>, August
  434. X-     13'th, 1992.
  435. X-
  436. X Tag Table:
  437. X-Node: Top963
  438. X-Node: Copying1458
  439. X-Node: Overview20609
  440. X-Node: Invoking wdiff21716
  441. X-Node: Examples27422
  442. X-Node: Problems28343
  443. X+Node: Top968
  444. X+Node: Copying1494
  445. X+Node: Overview20645
  446. X+Node: Invoking wdiff22032
  447. X+Node: Examples29912
  448. X End Tag Table
  449. X--- wdiff-0.03/wdiff.texi    Tue Aug 18 06:31:08 1992
  450. X+++ wdiff-0.04/wdiff.texi    Wed Dec 23 17:38:43 1992
  451. X@@ -7,11 +7,11 @@
  452. X @c %**end of header
  453. X @ifinfo
  454. X-This file documents the the @code{wdiff} command, which compares two
  455. X+This file documents the @code{wdiff} command, which compares two
  456. X files, finding which words have been deleted or added to the first
  457. X for getting the second.
  458. X-Copyright (C) 1992 Free Software Foundation, Inc.
  459. X+Copyright (C) 1992 by the Free Software Foundation, Inc.
  460. X Permission is granted to make and distribute verbatim copies of
  461. X this manual provided the copyright notice and this permission notice
  462. X@@ -38,8 +38,8 @@
  463. X @titlepage
  464. X @title wdiff
  465. X @subtitle The word difference finder
  466. X-@subtitle Edition 1.0, for wdiff Version 1.0
  467. X-@subtitle June 1992
  468. X+@subtitle Edition 0.04, for wdiff Version 0.04
  469. X+@subtitle November 1992
  470. X @author by Francois Pinard
  471. X @page
  472. X@@ -64,9 +64,9 @@
  473. X @node Top, Copying, (dir), (dir)
  474. X @ifinfo
  475. X-This file documents the the @code{wdiff} command, which compares two
  476. X-files, finding which words have been deleted or added to the first for
  477. X-getting the second.
  478. X+This file documents the @code{wdiff} command, as of release 0.04.  This
  479. X+command compares two files, finding which words have been deleted or
  480. X+added to the first for getting the second.
  481. X @end ifinfo
  482. X @menu
  483. X@@ -73,8 +73,9 @@
  484. X * Copying::            How you can copy and share @code{wdiff}.
  485. X * Overview::                    Preliminary information.
  486. X * Invoking wdiff::              How to run @code{wdiff}.
  487. X-* Examples::            How some people used @code{wdiff}.
  488. X-* Problems::                    Reporting bugs.
  489. X+* Examples::                    Actual examples of @code{wdiff} usage.
  490. X+
  491. X+ --- The Detailed Node Listing ---
  492. X @end menu
  493. X @node Copying, Overview, Top, Top
  494. X@@ -87,21 +88,26 @@
  495. X files on a word per word basis.  A word is anything between whitespace.
  496. X This is useful for comparing two texts in which a few words have been
  497. X changed and for which paragraphs have been refilled.  It works by
  498. X-creating two temporary files, one word per line, then execute
  499. X-@code{diff} on these.  It collects the @code{diff} output and uses it to
  500. X-produce a nicer display of word differences in the original files.
  501. X+creating two temporary files, one word per line, and then executes
  502. X+@code{diff} on these files.  It collects the @code{diff} output and uses
  503. X+it to produce a nicer display of word differences between the original
  504. X+files.
  505. X Ideally, @code{wdiff} should avoid calling @code{diff} and do all the
  506. X-work internally, being more polished and speedy.  However, I loathe
  507. X-replicating @code{diff} algorithm and effort elsewhere, instead of
  508. X-improving @code{diff} itself.  It would be more sensible to integrate
  509. X-@code{wdiff} in @code{diff} than the other way around.  I did it this
  510. X-way only because I had a sudden and urgent need for it, and it would
  511. X-have taken more time to do it correctly into GNU @code{diff}.  Your
  512. X-advices or opinions about this are welcome.
  513. X+work internally, allowing it to be faster and more polished.  However, I
  514. X+loathe replicating the @code{diff} algorithm and development effort,
  515. X+instead of improving @code{diff} itself.  It would be more sensible to
  516. X+integrate @code{wdiff} into @code{diff} than the other way around.  I
  517. X+did it this way only because I had a sudden and urgent need for it, and
  518. X+it would have taken too much time to integrate it correctly into GNU
  519. X+@code{diff}.  Your advice or opinions about this are welcome.
  520. X @code{wdiff} was written by Francois Pinard.
  521. X @c *** Comment placer la ce'dille?
  522. X+Please report bugs to @w{@file{bug-gnu-utils@@prep.ai.mit.edu}}.
  523. X+Include the version number, which you can find by running @w{@samp{wdiff
  524. X+--version}}.  Include in your message sufficient input to reproduce the
  525. X+problem and also, the output you expected.
  526. X @node Invoking wdiff, Examples, Overview, Top
  527. X @chapter Invoking @code{wdiff}
  528. X@@ -109,21 +115,20 @@
  529. X The format for running the @code{wdiff} program is:
  530. X @example
  531. X-wdiff @var{option} @dots{} @var{file_1} @var{file_2}
  532. X+wdiff @var{option} @dots{} @var{old_file} @var{new_file}
  533. X @end example
  534. X-@code{wdiff} will compare files @var{file_1} and @var{file_2},
  535. X-considering @var{file_1} as the old version of the text and @var{file_2}
  536. X-as the new version of the same text, and produce an annotated copy of
  537. X-@var{file_2} on standard output.
  538. X-
  539. X-@code{wdiff} will exit with a status of 0 if no difference were found,
  540. X-with a status of 1 if any difference was found or with a status of 2 for
  541. X-any other kind of reason of error.
  542. X-
  543. X-Usually, underlining is used to mark deleted words, while bolding or
  544. X-reverse video is used to makr added words; this is adjustable in many
  545. X-ways.  @code{wdiff} supports the following options:
  546. X+@code{wdiff} compares files @var{old_file} and @var{new_file} and
  547. X+produces an annotated copy of @var{new_file} on standard output.
  548. X+@code{wdiff} will exit with a status of 0 if no differences were found,
  549. X+a status of 1 if any differences were found, or a status of 2 for any
  550. X+error.
  551. X+
  552. X+In this documentation, @dfn{deleted text} refers to text in
  553. X+@var{old_file} which is not in @var{new_file}, while @dfn{inserted text}
  554. X+refers to text on @var{new_file} which is not in @var{old_file}.
  555. X+
  556. X+@code{wdiff} supports the following command line options:
  557. X @table @samp
  558. X @item --help
  559. X@@ -136,135 +141,229 @@
  560. X @item --no-deleted
  561. X @itemx -1
  562. X-Avoid producing deleted words on the output.  If none of @samp{-1} and
  563. X-@samp{-2} is selected, it might happen that the right margin will be
  564. X-exceeded for some lines, respective to the original formatting.
  565. X+Avoid producing deleted words on the output.  If neither @samp{-1} or
  566. X+@samp{-2} is selected, the original right margin may be exceeded for
  567. X+some lines.
  568. X @item --no-inserted
  569. X @itemx -2
  570. X-Avoid producing inserted words on the output.  If none of @samp{-1} and
  571. X-@samp{-2} is selected, it might happen that the right margin will be
  572. X-exceeded for some lines, respective to the original formatting.
  573. X+Avoid producing inserted words on the output.  When this flag is given,
  574. X+the whitespace in the output is taken from @var{old_file} instead of
  575. X+@var{new_file}.  If neither @samp{-1} or @samp{-2} is selected, the
  576. X+original right margin may be exceeded for some lines.
  577. X @item --no-common
  578. X @itemx -3
  579. X Avoid producing common words on the output.  When this option is not
  580. X-selected, common words and whitespace are taken from @var{file_2}.  When
  581. X-selected, differences are segregated from one other by lines containing
  582. X-only a few dashes.  Moreover, if this option is selected at the same
  583. X-time @samp{-1} or @samp{-2} is, then all of the output, if any, would
  584. X-have the same kind of emphasis; @code{wdiff} rather selects to do no
  585. X-emphasis at all.  Finally, if this option is not selected, but both
  586. X-@samp{-1} and @samp{-2} are, sections of common words between
  587. X-differences are segregated from one other by lines containing only a few
  588. X-dashes.
  589. X+selected, common words and whitespace are taken from @var{new_file},
  590. X+unless option @samp{-2} is given, in which case common words and
  591. X+whitespace are rather taken from @var{old_file}.  When selected,
  592. X+differences are separated from one another by lines of dashes.
  593. X+Moreover, if this option is selected at the same time as @samp{-1} or
  594. X+@samp{-2}, then none of the output will have any emphasis, i.e. no bold
  595. X+or underlining.  Finally, if this option is not selected, but both
  596. X+@samp{-1} and @samp{-2} are, then sections of common words between
  597. X+differences are segregated by lines of dashes.
  598. X+
  599. X+@item --statistics
  600. X+@itemx -s
  601. X+On completion, for each file, the total number of words, the number of
  602. X+common words between the files, the number of words deleted or inserted
  603. X+and the number of words that have changed is output.  (A changed word is
  604. X+one that has been replaced or is part of a replacement.)  Except for the
  605. X+total number of words, all of the numbers are followed by a percentage
  606. X+relative to the total number of words in the file.
  607. X+
  608. X+@item --auto-pager
  609. X+@itemx -a
  610. X+Some initiatives which were previously automatically taken in previous
  611. X+versions of @code{wdiff} are now put under the control of this option.
  612. X+By using it, a pager is interposed whenever the @code{wdiff} output is
  613. X+directed to the user's terminal.  Without this option, no pager will be
  614. X+called, the user is then responsible for explicitly piping @code{wdiff}
  615. X+output into a pager, if required.
  616. X+
  617. X+The pager is selected by the value of the @code{PAGER} environment
  618. X+variable when @code{wdiff} is run.  If @code{PAGER} is not defined at
  619. X+run time, then a default pager, selected at installation time, will be
  620. X+used instead.  A defined but empty value of @code{PAGER} means no pager
  621. X+at all.
  622. X+
  623. X+When a pager is interposed through the use of this option,
  624. X+one of the options @samp{-l} or @samp{-t} is also selected, depending on
  625. X+whether the string @samp{less} appears in the pager's name or not.
  626. X+
  627. X+It is often useful to define @samp{wdiff} as an alias for @samp{wdiff
  628. X+-a}.  However, this @emph{hides} the normal @code{wdiff} behaviour.  The
  629. X+default behaviour may be restored simply by piping the output from
  630. X+@code{wdiff} through @code{cat}.  This dissociates the output from the
  631. X+user's terminal.
  632. X @item --printer
  633. X @itemx -p
  634. X-Use overstriking to emphasize parts of output.  Each character of the
  635. X-deleted words is underlined by writing an underscore @samp{_} first,
  636. X-than a backspace and the letter to be underlined.  Each character of the
  637. X-added words are bolded by writing them twice, with a backspace in
  638. X+Use over-striking to emphasize parts of the output.  Each character of the
  639. X+deleted text is underlined by writing an underscore @samp{_} first,
  640. X+then a backspace and then the letter to be underlined.  Each character of the
  641. X+inserted text is emboldened by writing it twice, with a backspace in
  642. X between.  This option is not selected by default.
  643. X-@item --statistics
  644. X-@item -s
  645. X-At end of program, tell for each file the total number of words, how
  646. X-many words were common between files, how many were deleted or inserted
  647. X-and, finally, how many have changed (a changed word has been replaced or
  648. X-is part of a replacement).  Save for the total number of words itself,
  649. X-numbers are followed by a percentage relative to the total number of
  650. X-words for the file.
  651. X+@item --less-mode
  652. X+@itemx -l
  653. X+Use over-striking to emphasize parts of output.  This option works as
  654. X+option @code{-p}, but also over-strikes whitespace associated with
  655. X+inserted text.  @code{less} shows such whitespace using reverse video.
  656. X+This option is not selected by default.  However, it is automatically
  657. X+turned on whenever @code{wdiff} launches the pager @code{less}.  See
  658. X+option @samp{-a}.
  659. X+
  660. X+This option is commonly used in conjunction with @code{less}:
  661. X+
  662. X+@example
  663. X+wdiff -l @var{old_file} @var{new_file} | less
  664. X+@end example
  665. X @item --terminal
  666. X @itemx -t
  667. X-Force the production of @code{termcap} strings for emphasizing parts of
  668. X+Force the production of @code{termcap} strings for emphasising parts of
  669. X output, even if the standard output is not associated with a terminal.
  670. X-The @samp{TERM} environment variable should still contain the name of a
  671. X-valid @code{termcap} entry, however.  This option is automatically
  672. X-selected whenever the standard output is associated with a terminal.  If
  673. X-you ever need to deselect this option while still getting the output to
  674. X-the terminal, simply pipe the output of @code{wdiff} through @code{cat}
  675. X+The @samp{TERM} environment variable must contain the name of a valid
  676. X+@code{termcap} entry.  If the terminal description permits, underlining
  677. X+is used for marking deleted text, while bold or reverse video is used
  678. X+for marking inserted text.  This option is not selected by default.
  679. X+However, it is automatically turned on whenever @code{wdiff} launches a
  680. X+pager, and it is known that the pager is @emph{not} @code{less}.  See
  681. X+option @samp{-a}.
  682. X+
  683. X+This option is commonly used when @code{wdiff} output is not redirected,
  684. X+but sent directly to the user terminal, as in:
  685. X+
  686. X+@example
  687. X+wdiff -t @var{old_file} @var{new_file}
  688. X+@end example
  689. X+
  690. X+A common kludge uses @code{wdiff} together with the pager @code{more},
  691. X as in:
  692. X @example
  693. X-wdiff @var{file_1} @var{file_2} | cat
  694. X+wdiff -t @var{old_file} @var{new_file} | more
  695. X @end example
  696. X-@item --start-delete
  697. X-@item -w
  698. X-Use the following argument as the @dfn{start delete} string.  This
  699. X-string would be output prior to any sequence of deleted text, to mark
  700. X-where it starts.  By default, there is no start delete string unless
  701. X-there is no other means of distinguishing where such text starts; in
  702. X-which case the start delete string is @samp{[-}.
  703. X-
  704. X-@item --end-delete
  705. X-@item -x
  706. X-Use the following argument as the @dfn{end delete} string.  This string
  707. X-would be output after any sequence of deleted text, to mark where it
  708. X-ends.  By default, there is no end delete string unless there is no
  709. X-other means of distinguishing where such text ends; in which case the
  710. X-end delete string is @samp{-]}.
  711. X-
  712. X-@item --start-insert
  713. X-@item -y
  714. X-Use the following argument as the @dfn{start insert} string.  This
  715. X-string would be output prior to any sequence of inserted text, to mark
  716. X-where it starts.  By default, there is no start insert string unless
  717. X-there is no other means of distinguishing where such text starts; in
  718. X-which case the start insert string is @samp{@{+}.
  719. X-
  720. X-@item --end-insert
  721. X-@item -z
  722. X-Use the following argument as the @dfn{end insert} string.  This string
  723. X-would be output after any sequence of inserted text, to mark where it
  724. X-ends.  By default, there is no end insert string unless there is no
  725. X-other means of distinguishing where such text ends; in which case the
  726. X-end insert string is @samp{+@}}.
  727. X+However, some versions of @code{more} use @code{termcap} emphasis for
  728. X+their own purposes, so strange interactions are possible.
  729. X+
  730. X+@item --start-delete @var{argument}
  731. X+@itemx -w @var{argument}
  732. X+Use @var{argument} as the @dfn{start delete} string.  This string will
  733. X+be output prior to any sequence of deleted text, to mark where it
  734. X+starts.  By default, no start delete string is used unless there is no
  735. X+other means of distinguishing where such text starts; in this case the
  736. X+default start delete string is @samp{[-}.
  737. X+
  738. X+@item --end-delete @var{argument}
  739. X+@itemx -x @var{argument}
  740. X+Use @var{argument} as the @dfn{end delete} string.  This string will be
  741. X+output after any sequence of deleted text, to mark where it ends.  By
  742. X+default, no end delete string is used unless there is no other means of
  743. X+distinguishing where such text ends; in this case the default end delete
  744. X+string is @samp{-]}.
  745. X+
  746. X+@item --start-insert @var{argument}
  747. X+@itemx -y @var{argument}
  748. X+Use @var{argument} as the @dfn{start insert} string.  This string will
  749. X+be output prior to any sequence of inserted text, to mark where it
  750. X+starts.  By default, no start insert string is used unless there is no
  751. X+other means of distinguishing where such text starts; in this case the
  752. X+default start insert string is @samp{@{+}.
  753. X+
  754. X+@item --end-insert @var{argument}
  755. X+@itemx -z @var{argument}
  756. X+Use @var{argument} as the @dfn{end insert} string.  This string will be
  757. X+output after any sequence of inserted text, to mark where it ends.  By
  758. X+default, no end insert string is used unless there is no other means of
  759. X+distinguishing where such text ends; in this case the default end insert
  760. X+string is @samp{+@}}.
  761. X+
  762. X+@item --avoid-wraps
  763. X+@itemx -n
  764. X+Avoid spanning the end of line while showing deleted or inserted text.
  765. X+Any single fragment of deleted or inserted text spanning many lines will
  766. X+be considered as being made up of many smaller fragments not containing
  767. X+a newline.  So deleted text, for example, will have an end delete string
  768. X+at the end of each line, just before the new line, and a start delete
  769. X+string at the beginning of the next line.  A long paragraph of inserted
  770. X+text will have each line bracketed between start insert and end insert
  771. X+strings.  This behaviour is not selected by default.
  772. X @end table
  773. X-If your system has the program @code{less} or else, the program
  774. X-@code{more}, and if the output of @code{wdiff} is directly associated to
  775. X-a terminal, the program will then automatically pipe its output through
  776. X-one of these pagers.  The @samp{PAGER} environment variable, if set,
  777. X-overrides the built-in selection of a pager.  When a pager is selected,
  778. X-the @samp{-t} option is forced so the pager will still display the
  779. X-emphasized parts of the text.  However, in the special case @code{wdiff}
  780. X-is paging to the @code{less} program, the @samp{-p} option is forced
  781. X-instead of the @samp{-t} option, taking advantage of the fact that
  782. X-@code{less} recognizes overstrike sequences and renders them
  783. X-appropriately on the user screen.
  784. X-
  785. X-On a final note, options @samp{-p}, @samp{-t}, @samp{-[1234]} are not
  786. X-mutually exclusive.  If you use many of them, you will merely accumulate
  787. X-the effect of each.
  788. X+Note that options @samp{-p}, @samp{-t}, and @samp{-[wxyz]} are not
  789. X+mutually exclusive.  If you use a combination of them, you will merely
  790. X+accumulate the effect of each.  Option @samp{-l} is a variant of option
  791. X+@samp{-p}.
  792. X-@node Examples, Problems, Invoking wdiff, Top
  793. X-@chapter How some people used @code{wdiff}
  794. X+@node Examples,  , Invoking wdiff, Top
  795. X+@chapter Actual examples of @code{wdiff} usage
  796. X-This section will contain user-contributed examples.
  797. X+This section presents a few examples of usage, most of them have been
  798. X+contributed by @code{wdiff} users.
  799. X @itemize @bullet
  800. X+@item Change bars example.
  801. X+
  802. X+This example comes from a discussion with Joe Wells,
  803. X+@samp{jbw@@cs.bu.edu}.
  804. X+
  805. X+The following command produces a copy of @var{new_file}, shifted right
  806. X+one space to accommodate change bars since the last revision, ignoring
  807. X+those changes coming only from paragraph refilling.  Any line with new
  808. X+or changed text will get a @samp{|} in column 1.  However, deleted text
  809. X+is not shown nor marked.
  810. X+
  811. X+@example
  812. X+wdiff -1n @var{old_file} @var{new_file} |
  813. X+  sed -e 's/^/  /;/@{+/s/^ /|/;s/@{+//g;s/+@}//g'
  814. X+@end example
  815. X+
  816. X+Here is how it works.  Word differences are found, paying attention only
  817. X+to additions, as requested by option @samp{-1}.  For bigger changes
  818. X+which span line boundaries, the insert bracket strings are repeated on
  819. X+each output line, as requested by option @samp{-n}.  This output is then
  820. X+reformatted with a @code{sed} script which shifts the text right two
  821. X+columns, turns the initial space into a bar only if there is some new
  822. X+text on that line, then removes all insert bracket strings.
  823. X+
  824. X+@item @code{La@TeX{}} example.
  825. X+
  826. X+This example has been provided by Steve Fisk,
  827. X+@samp{fisk@@polar.bowdoin.edu}.
  828. X+
  829. X+The following uses La@TeX{} to put deleted text in boxes, and new text
  830. X+in double boxes:
  831. X+
  832. X+@example
  833. X+wdiff -w "\fbox@{" -x "@}" -y "\fbox@{\fbox@{" -z "@}@}" @dots{}
  834. X+@end example
  835. X+
  836. X+@noindent
  837. X+works nicely.
  838. X+
  839. X @item @code{troff} example.
  840. X-By Paul Fox, @samp{pgf@@cayman.com}.
  841. X+This example comes from Paul Fox, @samp{pgf@@cayman.com}.
  842. X Using @code{wdiff}, with some @code{troff}-specific delimiters gives
  843. X-@emph{much} better output.  The delimeters I used (extra shell-quoting
  844. X-removed for clarity) :
  845. X+@emph{much} better output.  The delimiters I used:
  846. X @example
  847. X-wdiff -d -1\s-5 -2\s0 -3\fB -4\fP
  848. X+wdiff -w'\s-5' -x'\s0' -y'\fB' -z'\fP' @dots{}
  849. X @end example
  850. X This makes the pointsize of deletions 5 points smaller than normal, and
  851. X emboldens insertions.  Fantastic!
  852. X-I experimented with
  853. X+I experimented with:
  854. X @example
  855. X-wdiff -d -1\fI -2\fP -3\fB -4\fP
  856. X+wdiff -w'\fI' -x'\fP' -y'\fB' -z'\fP'
  857. X @end example
  858. X since that's more like the defaults you use for terminals/printers, but
  859. X@@ -273,30 +372,6 @@
  860. X I tried it on code, and it works surprisingly well there, too...
  861. X-@end itemize
  862. X-
  863. X-@node Problems,  , Examples, Top
  864. X-@chapter Reporting Bugs
  865. X-
  866. X-If you find a bug in @code{wdiff}, please send electronic mail to
  867. X-@w{@samp{pinard@@iro.umontreal.ca}}.  Include the version number, which
  868. X-you can find by running @w{@samp{wdiff --version}}.  Include in your
  869. X-message sufficient input to reproduce the problem and also, the output
  870. X-you expected.
  871. X-
  872. X-Here are some received, unprocessed suggestions.
  873. X-
  874. X-@itemize @bullet
  875. X-@item
  876. X-Make an MSDOS port.
  877. X-
  878. X-@item
  879. X-Select by options exactly what is whitespace.
  880. X-
  881. X-@item
  882. X-Have a @code{wpatch} program.  I do not see good ways of doing this.
  883. X-Any ideas?  Suggested by Zhuo Zang <zzang@@stat.ufl.edu>, August 13'th,
  884. X-1992.
  885. X @end itemize
  886. X @bye
  887. X--- wdiff-0.03/writepipe.c    Mon Aug 17 14:19:38 1992
  888. X+++ wdiff-0.04/writepipe.c    Sat Dec  5 18:47:48 1992
  889. X@@ -20,6 +20,10 @@
  890. X #include <stdio.h>
  891. X #include <varargs.h>
  892. X+#if defined (HAVE_UNISTD_H)
  893. X+#include <unistd.h>
  894. X+#endif
  895. X+
  896. X /* Open a pipe to write to a program without intermediary sh.
  897. X    Checks PATH.
  898. X    Sample use:
  899. X@@ -38,7 +42,7 @@
  900. X   /* Copy arguments into `args'. */
  901. X   va_start (ap);
  902. X-  while (args[argno++] = va_arg (ap, char *))
  903. X+  while ((args[argno++] = va_arg (ap, char *)) != NULL)
  904. X     /* Do nothing. */ ;
  905. X   va_end (ap);
  906. X@@ -49,9 +53,12 @@
  907. X     {
  908. X     case 0:            /* Child.  Read from pipe. */
  909. X       close (fds[1]);        /* Not needed. */
  910. X-      close (0);        /* We don't want the old stdin. */
  911. X-      dup (fds[0]);        /* Guaranteed to dup to 0 (stdin). */
  912. X-      close (fds[0]);        /* No longer needed. */
  913. X+      if (fds[0] != 0)        /* Redirect 0 (stdin) only if needed.  */
  914. X+    {
  915. X+      close (0);        /* We don't want the old stdin. */
  916. X+      dup (fds[0]);        /* Guaranteed to dup to 0 (stdin). */
  917. X+      close (fds[0]);    /* No longer needed. */
  918. X+    }
  919. X       execvp (args[0], args);
  920. X       _exit (2);        /* 2 for `cmp'. */
  921. X     case -1:            /* Error. */
  922. SHAR_EOF
  923. echo 'File Patch4 is complete' &&
  924. chmod 0640 Patch4 ||
  925. echo 'restore of Patch4 failed'
  926. Wc_c="`wc -c < 'Patch4'`"
  927. test 137819 -eq "$Wc_c" ||
  928.     echo 'Patch4: original size 137819, current size' "$Wc_c"
  929. rm -f _shar_wnt_.tmp
  930. fi
  931. rm -f _shar_seq_.tmp
  932. echo You have unpacked the last part
  933. exit 0
  934. --
  935. Franc,ois Pinard       ``Happy GNU Year!''      pinard@iro.umontreal.ca
  936. (514) 588-4656                                   ...!uunet!iros1!pinard
  937. About the League for Programming Freedom?  Email me or lpf@uunet.uu.net
  938.