home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / txtutl / dif-ssed.doc < prev    next >
Encoding:
Text File  |  1994-07-13  |  4.0 KB  |  104 lines

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