home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol068 / dif2.rno < prev    next >
Text File  |  1984-04-29  |  4KB  |  106 lines

  1. .in 8
  2. .rm 72
  3. .ce 99
  4. Reducing the Swelling of the Phone Bill with DIF and SSED
  5. November 17, 1981
  6. Chuck Forsberg
  7. Computer Development Inc
  8. Beaverton OR
  9. .ce 0
  10.  
  11.     Lately (if not sooner) it has become obvious that there must be
  12. a better and cheaper way to distribute software updates to changing
  13. programs than to transmit all of the new files in their totality,
  14. even though only a few lines in each have been changed.
  15.  
  16.     For some years the Unix differential file print program diff(1)
  17. (the (1) refers to the section of the Unix Programmers Manual in which
  18. it is described) has had a -e flag which provides a set of ed
  19. commands suitable for transforming the first file to the second.
  20.  
  21.     With these tools, only an update file need be transmitted,
  22. provided, of course, that both the sender and the receiver had
  23. copies of the same antecdent file.
  24.  
  25.     I have written a "new" diff called dif.c which manages to operate
  26. in the primitive CP/M environment.
  27. The editing commands output in response to the -e option refrence sequential
  28. lines in the source files, so they (the commands) can be executed by a
  29. stream editor.
  30. (The Unix diff(1) creates difference files with non-forward-sequential
  31. commands.)
  32.  
  33.     To generate a difference file, the command is
  34.  
  35.     dif -e oldfile newfile >file.dif
  36.  
  37.     The >file.dif redirects the standard output to the file.
  38. A + may be susbtituted for > if simultaneous console output is
  39. desired.
  40.  
  41.     The receiver then invokes:
  42.  
  43.     ssed oldfile <file.dif >newfile
  44.  
  45.     Which will result in newfile being created identical to the
  46. oroginal newfile.
  47. Well, not precisely identical, but identical up to and including the
  48. EOF (^Z) character.
  49. The dribble after that may change, so CRCK may say they are different.
  50. To check, compare the two files with dif.
  51.  
  52.     Unix folks with 14 character file names and modification times
  53. stored by the filesystem have little trouble keeping the files
  54. synchronized.
  55. (If the antecedent files are different, there's no telling what the
  56. output file will look like!)
  57. For us poor CP/M folks (verrry) patiently awaiting something like
  58. Unix to appear magically on out desktops, I propose that the revision
  59. or revision date of the antecedent file be placed in the new file
  60. adjacent to the new revision or date, preferably on the same line.
  61. This way the user may easily verify that he has the correct
  62. antecedent.
  63.  
  64.     Dif Versions 1.10 and later place hash indices of the RETAINED lines
  65. of the antecedent file in the difference output. This allows ssed
  66. 1.10 or later to verify correctness of the antecedent file.
  67. the new .dif files are compatible with the old ssed, but, alas, not
  68. with Unix ed or sed.
  69.  
  70.     The array sizes in dif.c may have to be shrunk somewhat to run
  71. on a 48k system.
  72.  
  73.     For testing, give
  74.  
  75.     dif -e filea fileb |ssed filea >filec
  76.     dif fileb filec
  77.  
  78.     (fileb and filec should be identical)
  79.  
  80.     It ought to work if you said
  81.     dif -e filea fileb |ssed filea |dif fileb
  82.     and it does, with version 2.0.
  83.  
  84.     Version 2.0 of dif.c adds a -u flag which will unsqueeze filea before
  85. comparing it to fileb.
  86.  
  87.     Thus you can say
  88.     sq filea
  89.     dif -eu filea.qqq fileb |ssed filea |dif fileb
  90.  
  91.     Or you can say
  92.     dif -eu filea.qqq fileb |ssed -u filea.qqq |dif fileb
  93.     to test dif and ssed.
  94. (Be sure dif and ssed are exactly where you say
  95. they are, or else pipes will be broken.)
  96.  
  97.     Restriction:  Since the BDS Standard I/O library and the Directed
  98. I/O package are somewhat confused about translation between CP/M's cr/lf
  99. terminated lines and **nixs' \n terminated lines, dif was written to strip
  100. cr's from the input in order that only one cr appear on the output.
  101. As a result, lines terminated by cr/lf, lf, and lf/cr all come out the same!
  102. This would munge files where lf/cr has a special meaning (MBASIC continuation
  103. lines) or where embedded cr's are used (RTTY art).
  104.  
  105.     Unix is a trademark of WECO, CP/M of Digital Research.
  106.