diff 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #------------------------------------------------------------------------------
  2. # $File: diff,v 1.21 2024/07/13 14:47:09 christos Exp $
  3. # diff: file(1) magic for diff(1) output
  4. #
  5. # Update: Joerg Jenderek
  6. # URL: https://en.wikipedia.org/wiki/Diff
  7. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff.trid.xml
  8. # Note: called "diff output text" by TrID and
  9. # "Differences between files" by shared MIME-info database from freedesktop.org
  10. # According to shared MIME-info database also tabulator character instead of space character and
  11. # by TrID minus character after space character
  12. 0 search/1 diff\040 diff output text
  13. # diff output text (strength=40=40+0) after unified diff output (strength=131=38+93)
  14. #!:strength +0
  15. !:mime text/x-diff
  16. #!:mime text/x-patch
  17. !:ext diff/patch
  18. # no short named pch dif examples found
  19. #!:ext diff/patch/dif/pch
  20. # URL: https://en.wikipedia.org/wiki/Diff_utility#Context_format
  21. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff-context.trid.xml
  22. # Note: called "context diff output" by TrID
  23. # and "Differences between files" by shared MIME-info database from freedesktop.org
  24. 0 search/1 ***\040
  25. # context diff output text (strength=42=38+4) before
  26. # C source (strength=41,39,37) exported SGML document (strength=39,28)
  27. !:strength +4
  28. >&0 search/1024 \n---\040 context diff output text
  29. !:mime text/x-diff
  30. #!:mime text/x-patch
  31. !:ext diff/patch
  32. # no short named pch dif examples found
  33. #!:ext diff/patch/dif/pch
  34. 0 search/1 Only\040in\040 diff output text
  35. # diff output text output text (strength=38=38+0) after unified diff output (strength=131=38+93)
  36. #!:strength +0
  37. !:mime text/x-diff
  38. #!:mime text/x-patch
  39. !:ext diff
  40. 0 search/1 Common\040subdirectories:\040 diff output text
  41. !:mime text/x-diff
  42. # URL: https://en.wikipedia.org/wiki/Diff#Extensions
  43. # Reference: http://mark0.net/download/triddefs_xml.7z/defs/d/diff-rcs.trid.xml
  44. # Note: called "RCS/CVS diff output" by TrID
  45. # and "Differences between files" by shared MIME-info database from freedesktop.org
  46. 0 search/1 Index: RCS/CVS diff output text
  47. # RCS/CVS diff output text (strength=36=36+0) after unified diff output (strength=131=38+93)
  48. #!:strength +0
  49. !:mime text/x-diff
  50. #!:mime text/x-patch
  51. !:ext diff/patch
  52. # bsdiff: file(1) magic for bsdiff(1) output
  53. # Update: Joerg Jenderek
  54. # URL: http://www.daemonology.net/bsdiff/
  55. # Reference: https://github.com/cperciva/bsdiff/blob/master/bsdiff-ra/FORMAT
  56. # http://mark0.net/download/triddefs_xml.7z/defs/b/bsdiff.trid.xml
  57. # Note: called "bsdiff patch" by TrID and and "BSDIFF" version 4.0 by DROID via PUID fmt/439 and
  58. # "Binary differences between files" by shared MIME-info database from freedesktop.org
  59. 0 string/b BSDIFF40
  60. # skip DROID fmt-439-signature-id-672.bsdiff with invalid new file segment length 0
  61. >16 long !0 bsdiff(1) patch file
  62. #!:mime application/octet-stream
  63. !:mime application/x-bsdiff
  64. !:ext bsdiff
  65. # new file length
  66. #>>8 lequad x \b, new length %lld
  67. # new file segment length
  68. #>>16 lelong x \b, new segment length %d
  69. # compressed header block length
  70. #>>20 lelong !0 \b, compressed header length %d
  71. # patch data block length
  72. #>>24 lequad x \b, data length %lld
  73. # look for bzip data by ./compress after message with 1 space at end
  74. >>0x20 indirect x \b, at 0x20
  75. # From: Joerg Jenderek
  76. # URL: https://www.chromium.org/developers/design-documents/software-updates-courgette/
  77. # Reference: https://github.com/adobe/chromium/blob/master/courgette/third_party/bsdiff.h
  78. # http://mark0.net/download/triddefs_xml.7z/defs/b/bsdiff-chrome.trid.xml
  79. # Note: called "Courgette Binary Diff output" by TrID
  80. # the Courgette bsdiff tool use a total different file format compared with BSD variant from Colin Percival
  81. 0 string/b GBSDIF42 Courgette binary diff output
  82. #!:mime application/octet-stream
  83. !:mime application/x-patch
  84. !:ext patch/bsdiff
  85. # slen; length of the file to be patched
  86. #>8 ubelong x \b, source length %u
  87. # scrc32; CRC32 of the file to be patched
  88. >12 ubelong x \b, crc %#8.8x
  89. # dlen; length of the result file
  90. #>16 ubelong x \b, result length %u
  91. # cblen; length of the control block
  92. #>20 ubelong x \b, control length %u
  93. # difflen; length of the diff block
  94. #>24 ubelong x \b, patch length %u
  95. # extralen; length of the extra block
  96. #>28 ubelong x \b, extra length %u
  97. # unified diff
  98. # URL: http://fileformats.archiveteam.org/wiki/Unified_diff
  99. # https://en.wikipedia.org/wiki/Diff_utility#Unified_format
  100. # Reference: https://www.artima.com/weblogs/viewpost.jsp?thread=164293
  101. # http://mark0.net/download/triddefs_xml.7z/defs/d/diff-unified.trid.xml
  102. # Note: called "unified diff output" by TrID and
  103. # "Differences between files" by shared MIME-info database from freedesktop.org
  104. # use b flag to forces the test to be done for binary files (non ASCII text like with Ctrl-D Ctrl-V Ctrl-Z)
  105. 0 search/4096/b ---\040
  106. !:strength + 93
  107. >0 use diff-unified
  108. # most samples are just pure ASCII text like: ShellR64.patch
  109. 0 search/11054 ---\040
  110. # unified diff (strength=131=38+93) before
  111. # HTML document text (strength=170,90,71,53,52,51,49) POSIX shell script (fix-qt5.6-build.patch strength=130 ./commands)
  112. # JavaScript source (strength=112,84,81,80,79,78,72,69) C++ source (strength=71,70,69,68,67,54),
  113. # Python script (strength=69,67,63,60,58,57,56,54,52,37)LaTeX document text (strength=62,56,55,51,43)
  114. # TeX document (strength=51,38) C source (strength=41,39,37)
  115. # exported SGML document (strength=39,28) diff output text (strength=38=38+0)
  116. # Pascal source (strength=37) RCS/CVS diff (strength=36=36+0),
  117. # Algol 68 source (strength=?) CSV ASCII text (strength=?)
  118. !:strength + 93
  119. >0 use diff-unified
  120. # check for 3 characteristic lines of unified diff
  121. 0 name diff-unified
  122. >0 search/11084 +++\040
  123. >>&0 search/1024 \n
  124. # at signs line sometimes other (with 2 space chars before) like: indent-header.patch
  125. >>>&0 search/2 @@\040- unified diff output text
  126. !:mime text/x-diff
  127. #!:mime text/x-patch
  128. # https://file-extension.net/seeker/file_extension_dif file_extension_pch file_extension_rej
  129. !:ext diff/patch/dif/pch/rej
  130. # GRR: mainly for debugging purpose for variants with text before real diff output
  131. >>>>0 string !---\040
  132. >>>>>0 string x \b, 1st line "%s"
  133. >>>>>>&1 string x \b, 2nd line "%s"
  134. >>>>>>>&1 string x \b, 3rd line "%s"
  135. # librsync -- the library for network deltas
  136. #
  137. # Copyright (C) 2001 by Martin Pool. You may do whatever you want with
  138. # this file.
  139. #
  140. 0 belong 0x72730236 rdiff network-delta data
  141. 0 belong 0x72730136 rdiff network-delta signature data
  142. >4 belong x (block length=%d,
  143. >8 belong x signature strength=%d)