home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug056.arc / DIF-SSED.DOC < prev    next >
Text File  |  1979-12-31  |  4KB  |  104 lines

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