home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / turbo_c / bugs.zip / PATCH.DOC < prev    next >
Text File  |  1987-06-23  |  3KB  |  72 lines

  1. PATCH.COM
  2.  
  3. Syntax: patch [-u] dif_file prog_file [out_file]
  4.  
  5. PATCH.COM reads the text from dif_file and applies the patch to prog_file.
  6. The diff file is relatively free format. Any number of spaces or tabs can
  7. appear between two values, and any number of spaces, tabs, and blank lines
  8. can appear between lines.  The file consists of zero or more pairs of lines
  9. in the following format:
  10.  
  11.    offset: newbyte [newbyte ...]
  12.            oldbyte [oldbyte ...]
  13.  
  14. All values are represented in the file using hexidecimal digits.  The value
  15. of offset can range from 0 to 7FFFFFFF hex.  The values of new and old bytes
  16. can range from 0 to FF hex.
  17.  
  18. Comments can be inserted in the file by starting a new line with
  19. a semicolon (;).
  20.  
  21. ----------------------------------- Example --------------------------------
  22. ; Example patch file
  23.     6:  88
  24.         85
  25.  1DEE:  74 1A 52 7F FF 77 00
  26.         73 00 1A 52 7F ff 77
  27. ; notice the free format
  28. 03636: 053 08  5B     19 71 8  5B    19
  29.  
  30. 00 00   00 00 00 00  00 0
  31. ----------------------------------------------------------------------------
  32.  
  33. As you can see from the first two pairs, the diff file is more readable when
  34. formatted nicely.  But, you can be pretty flexible as shown in the third
  35. pair of lines.  Note: The first line of each pair contains the new byte values
  36. while the second line contains the old byte values.
  37.  
  38. When applying a patch, PATCH.COM makes a first pass to check that all bytes
  39. in the file which will be changed, currently match the old values which are
  40. defined in dif_file.  If they don't, an error message is printed and the
  41. patch is not applied.  If they do match, all the corresponding bytes are
  42. changed to their new values.  If any error occurs during this second step,
  43. it is most likely an out of disk space error.  During the update, a backup
  44. copy of your original file (.BAK) is kept.  This means you need twice as
  45. much disk space if your input and output files are on the same disk drive.
  46. In case of an error, the temporary file is usually deleted and the .BAK file
  47. is renamed back to the original name.  If something else goes wrong, like a
  48. power outage, you should still have your original file on the disk with a
  49. .BAK extension.
  50.  
  51. After the patch is completed:
  52.   If the output file is the same as the input file, the .BAK file is deleted.
  53.   If the output file is different than the input file, the .BAK file is
  54.   renamed back to its original name.
  55.  
  56. The -u option cause PATCH.COM to undo the patch defined in dif_file.  In this
  57. case, it checks that all the bytes to be modified match the new byte values
  58. on the first line of each pair.  It then changes the corresponding bytes to
  59. the old byte values defined on the second line of each pair.
  60.  
  61. The last parameter (out_file) is optional.  If defined, the patched version
  62. of the original file will be saved under the name specified by out_file, and
  63. the original file will be left intact.  If it is not specified, the patched
  64. version of the file will have the same name as the original version of the
  65. file, and the original version of the file will be lost.
  66.  
  67. Note:  Because PATCH.COM checks the old values of each byte to be patched,
  68. two or more patches which affect the same byte must be applied in order.
  69. Also, because of the fixed offsets defined in dif_file, the same dif_file will
  70. probably not be usable with multiple versions of the program file being
  71. patched.
  72.