rugged 0.28.4 → 0.28.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (350) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rugged/version.rb +1 -1
  3. data/vendor/libgit2/AUTHORS +0 -1
  4. data/vendor/libgit2/CMakeLists.txt +16 -36
  5. data/vendor/libgit2/COPYING +0 -28
  6. data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +1 -5
  7. data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +2 -2
  8. data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +1 -1
  9. data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +2 -2
  10. data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +0 -6
  11. data/vendor/libgit2/deps/http-parser/http_parser.c +6 -11
  12. data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
  13. data/vendor/libgit2/deps/regex/COPYING +502 -0
  14. data/vendor/libgit2/deps/regex/config.h +7 -0
  15. data/vendor/libgit2/deps/regex/regcomp.c +3857 -0
  16. data/vendor/libgit2/deps/regex/regex.c +92 -0
  17. data/vendor/libgit2/deps/regex/regex.h +582 -0
  18. data/vendor/libgit2/deps/regex/regex_internal.c +1744 -0
  19. data/vendor/libgit2/deps/regex/regex_internal.h +819 -0
  20. data/vendor/libgit2/deps/regex/regexec.c +4369 -0
  21. data/vendor/libgit2/deps/zlib/adler32.c +7 -0
  22. data/vendor/libgit2/deps/zlib/crc32.c +7 -0
  23. data/vendor/libgit2/include/git2.h +0 -2
  24. data/vendor/libgit2/include/git2/apply.h +2 -22
  25. data/vendor/libgit2/include/git2/attr.h +12 -19
  26. data/vendor/libgit2/include/git2/blame.h +2 -2
  27. data/vendor/libgit2/include/git2/blob.h +12 -44
  28. data/vendor/libgit2/include/git2/buffer.h +14 -20
  29. data/vendor/libgit2/include/git2/checkout.h +14 -46
  30. data/vendor/libgit2/include/git2/cherrypick.h +3 -3
  31. data/vendor/libgit2/include/git2/clone.h +2 -2
  32. data/vendor/libgit2/include/git2/commit.h +1 -23
  33. data/vendor/libgit2/include/git2/common.h +5 -7
  34. data/vendor/libgit2/include/git2/config.h +12 -12
  35. data/vendor/libgit2/include/git2/deprecated.h +3 -243
  36. data/vendor/libgit2/include/git2/describe.h +4 -4
  37. data/vendor/libgit2/include/git2/diff.h +14 -16
  38. data/vendor/libgit2/include/git2/filter.h +0 -8
  39. data/vendor/libgit2/include/git2/index.h +1 -2
  40. data/vendor/libgit2/include/git2/indexer.h +4 -48
  41. data/vendor/libgit2/include/git2/inttypes.h +309 -0
  42. data/vendor/libgit2/include/git2/merge.h +10 -6
  43. data/vendor/libgit2/include/git2/net.h +5 -0
  44. data/vendor/libgit2/include/git2/object.h +14 -2
  45. data/vendor/libgit2/include/git2/odb.h +2 -3
  46. data/vendor/libgit2/include/git2/odb_backend.h +4 -5
  47. data/vendor/libgit2/include/git2/oid.h +1 -1
  48. data/vendor/libgit2/include/git2/pack.h +1 -12
  49. data/vendor/libgit2/include/git2/proxy.h +3 -5
  50. data/vendor/libgit2/include/git2/rebase.h +2 -46
  51. data/vendor/libgit2/include/git2/refs.h +0 -19
  52. data/vendor/libgit2/include/git2/remote.h +12 -35
  53. data/vendor/libgit2/include/git2/repository.h +2 -24
  54. data/vendor/libgit2/include/git2/revert.h +1 -1
  55. data/vendor/libgit2/include/git2/stash.h +3 -3
  56. data/vendor/libgit2/include/git2/status.h +16 -25
  57. data/vendor/libgit2/include/git2/submodule.h +3 -20
  58. data/vendor/libgit2/include/git2/sys/alloc.h +9 -9
  59. data/vendor/libgit2/include/git2/sys/odb_backend.h +4 -48
  60. data/vendor/libgit2/include/git2/sys/refdb_backend.h +21 -57
  61. data/vendor/libgit2/include/git2/sys/repository.h +1 -5
  62. data/vendor/libgit2/include/git2/sys/time.h +31 -0
  63. data/vendor/libgit2/include/git2/sys/transport.h +2 -2
  64. data/vendor/libgit2/include/git2/tag.h +2 -11
  65. data/vendor/libgit2/include/git2/trace.h +2 -2
  66. data/vendor/libgit2/include/git2/transport.h +340 -11
  67. data/vendor/libgit2/include/git2/tree.h +1 -1
  68. data/vendor/libgit2/include/git2/types.h +89 -4
  69. data/vendor/libgit2/include/git2/version.h +2 -2
  70. data/vendor/libgit2/include/git2/worktree.h +5 -5
  71. data/vendor/libgit2/libgit2.pc.in +13 -0
  72. data/vendor/libgit2/src/CMakeLists.txt +222 -88
  73. data/vendor/libgit2/src/alloc.c +14 -2
  74. data/vendor/libgit2/src/apply.c +30 -60
  75. data/vendor/libgit2/src/attr.c +64 -70
  76. data/vendor/libgit2/src/attr_file.c +96 -189
  77. data/vendor/libgit2/src/attr_file.h +9 -9
  78. data/vendor/libgit2/src/attrcache.c +46 -44
  79. data/vendor/libgit2/src/attrcache.h +1 -2
  80. data/vendor/libgit2/src/blame.c +5 -17
  81. data/vendor/libgit2/src/blame.h +1 -1
  82. data/vendor/libgit2/src/blame_git.c +7 -21
  83. data/vendor/libgit2/src/blob.c +17 -81
  84. data/vendor/libgit2/src/blob.h +2 -2
  85. data/vendor/libgit2/src/branch.c +5 -29
  86. data/vendor/libgit2/src/buffer.c +7 -14
  87. data/vendor/libgit2/src/cache.c +33 -26
  88. data/vendor/libgit2/src/cache.h +1 -1
  89. data/vendor/libgit2/src/cc-compat.h +0 -5
  90. data/vendor/libgit2/src/checkout.c +16 -26
  91. data/vendor/libgit2/src/cherrypick.c +3 -9
  92. data/vendor/libgit2/src/clone.c +7 -29
  93. data/vendor/libgit2/src/clone.h +0 -4
  94. data/vendor/libgit2/src/commit.c +21 -69
  95. data/vendor/libgit2/src/commit.h +0 -6
  96. data/vendor/libgit2/src/commit_list.c +76 -28
  97. data/vendor/libgit2/src/commit_list.h +2 -2
  98. data/vendor/libgit2/src/common.h +75 -3
  99. data/vendor/libgit2/src/config.c +40 -31
  100. data/vendor/libgit2/src/config.h +6 -7
  101. data/vendor/libgit2/src/config_backend.h +0 -12
  102. data/vendor/libgit2/src/config_cache.c +39 -39
  103. data/vendor/libgit2/src/config_entries.c +99 -69
  104. data/vendor/libgit2/src/config_entries.h +0 -1
  105. data/vendor/libgit2/src/config_file.c +380 -337
  106. data/vendor/libgit2/src/config_mem.c +16 -12
  107. data/vendor/libgit2/src/config_parse.c +29 -49
  108. data/vendor/libgit2/src/config_parse.h +12 -13
  109. data/vendor/libgit2/src/crlf.c +14 -14
  110. data/vendor/libgit2/src/describe.c +20 -21
  111. data/vendor/libgit2/src/diff.c +58 -43
  112. data/vendor/libgit2/src/diff.h +1 -2
  113. data/vendor/libgit2/src/diff_driver.c +38 -37
  114. data/vendor/libgit2/src/diff_file.c +7 -9
  115. data/vendor/libgit2/src/diff_file.h +1 -1
  116. data/vendor/libgit2/src/diff_generate.c +85 -135
  117. data/vendor/libgit2/src/diff_generate.h +2 -2
  118. data/vendor/libgit2/src/diff_parse.c +1 -1
  119. data/vendor/libgit2/src/diff_print.c +13 -25
  120. data/vendor/libgit2/src/diff_stats.c +1 -1
  121. data/vendor/libgit2/src/diff_tform.c +4 -4
  122. data/vendor/libgit2/src/errors.c +22 -12
  123. data/vendor/libgit2/src/features.h.in +2 -9
  124. data/vendor/libgit2/src/fetch.c +2 -7
  125. data/vendor/libgit2/src/fetchhead.c +1 -1
  126. data/vendor/libgit2/src/filebuf.c +10 -6
  127. data/vendor/libgit2/src/filebuf.h +2 -2
  128. data/vendor/libgit2/src/{futils.c → fileops.c} +17 -21
  129. data/vendor/libgit2/src/{futils.h → fileops.h} +5 -5
  130. data/vendor/libgit2/src/filter.c +8 -16
  131. data/vendor/libgit2/src/fnmatch.c +248 -0
  132. data/vendor/libgit2/src/fnmatch.h +48 -0
  133. data/vendor/libgit2/src/global.c +40 -12
  134. data/vendor/libgit2/src/global.h +2 -0
  135. data/vendor/libgit2/src/hash.c +0 -61
  136. data/vendor/libgit2/src/hash.h +21 -19
  137. data/vendor/libgit2/src/hash/{sha1/collisiondetect.c → hash_collisiondetect.h} +17 -14
  138. data/vendor/libgit2/src/hash/{sha1/common_crypto.c → hash_common_crypto.h} +19 -15
  139. data/vendor/libgit2/src/hash/{sha1/generic.c → hash_generic.c} +10 -22
  140. data/vendor/libgit2/src/hash/{sha1/generic.h → hash_generic.h} +14 -4
  141. data/vendor/libgit2/src/hash/{sha1/mbedtls.c → hash_mbedtls.c} +7 -15
  142. data/vendor/libgit2/src/hash/{sha1/mbedtls.h → hash_mbedtls.h} +11 -6
  143. data/vendor/libgit2/src/hash/{sha1/openssl.c → hash_openssl.h} +18 -14
  144. data/vendor/libgit2/src/hash/{sha1/win32.c → hash_win32.c} +24 -34
  145. data/vendor/libgit2/src/hash/{sha1/win32.h → hash_win32.h} +19 -6
  146. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.c +3 -14
  147. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/sha1.h +0 -0
  148. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.c +0 -0
  149. data/vendor/libgit2/src/hash/{sha1/sha1dc → sha1dc}/ubc_check.h +0 -0
  150. data/vendor/libgit2/src/hashsig.c +1 -1
  151. data/vendor/libgit2/src/idxmap.c +65 -91
  152. data/vendor/libgit2/src/idxmap.h +15 -151
  153. data/vendor/libgit2/src/ignore.c +38 -32
  154. data/vendor/libgit2/src/index.c +43 -66
  155. data/vendor/libgit2/src/index.h +1 -1
  156. data/vendor/libgit2/src/indexer.c +70 -69
  157. data/vendor/libgit2/src/integer.h +4 -39
  158. data/vendor/libgit2/src/iterator.c +22 -27
  159. data/vendor/libgit2/src/map.h +1 -1
  160. data/vendor/libgit2/src/merge.c +44 -58
  161. data/vendor/libgit2/src/merge_driver.c +4 -4
  162. data/vendor/libgit2/src/merge_file.c +1 -1
  163. data/vendor/libgit2/src/mwindow.c +23 -18
  164. data/vendor/libgit2/src/mwindow.h +4 -4
  165. data/vendor/libgit2/src/netops.c +165 -55
  166. data/vendor/libgit2/src/netops.h +25 -3
  167. data/vendor/libgit2/src/notes.c +2 -2
  168. data/vendor/libgit2/src/object.c +2 -2
  169. data/vendor/libgit2/src/object.h +0 -2
  170. data/vendor/libgit2/src/odb.c +23 -41
  171. data/vendor/libgit2/src/odb.h +2 -3
  172. data/vendor/libgit2/src/odb_loose.c +10 -17
  173. data/vendor/libgit2/src/odb_mempack.c +23 -10
  174. data/vendor/libgit2/src/odb_pack.c +4 -4
  175. data/vendor/libgit2/src/offmap.c +55 -43
  176. data/vendor/libgit2/src/offmap.h +24 -102
  177. data/vendor/libgit2/src/oid.c +1 -6
  178. data/vendor/libgit2/src/oidmap.c +57 -39
  179. data/vendor/libgit2/src/oidmap.h +19 -99
  180. data/vendor/libgit2/src/pack-objects.c +32 -25
  181. data/vendor/libgit2/src/pack-objects.h +1 -1
  182. data/vendor/libgit2/src/pack.c +47 -45
  183. data/vendor/libgit2/src/pack.h +14 -12
  184. data/vendor/libgit2/src/parse.c +0 -10
  185. data/vendor/libgit2/src/parse.h +3 -3
  186. data/vendor/libgit2/src/patch.c +1 -1
  187. data/vendor/libgit2/src/patch_generate.c +2 -2
  188. data/vendor/libgit2/src/patch_parse.c +31 -124
  189. data/vendor/libgit2/src/path.c +6 -43
  190. data/vendor/libgit2/src/path.h +0 -2
  191. data/vendor/libgit2/src/pathspec.c +13 -13
  192. data/vendor/libgit2/src/pool.c +22 -26
  193. data/vendor/libgit2/src/pool.h +7 -7
  194. data/vendor/libgit2/src/posix.c +7 -7
  195. data/vendor/libgit2/src/posix.h +1 -12
  196. data/vendor/libgit2/src/proxy.c +2 -7
  197. data/vendor/libgit2/src/push.c +5 -10
  198. data/vendor/libgit2/src/reader.c +2 -2
  199. data/vendor/libgit2/src/rebase.c +7 -66
  200. data/vendor/libgit2/src/refdb.c +0 -12
  201. data/vendor/libgit2/src/refdb_fs.c +165 -214
  202. data/vendor/libgit2/src/reflog.c +13 -11
  203. data/vendor/libgit2/src/refs.c +18 -24
  204. data/vendor/libgit2/src/refspec.c +16 -9
  205. data/vendor/libgit2/src/remote.c +52 -50
  206. data/vendor/libgit2/src/remote.h +2 -2
  207. data/vendor/libgit2/src/repository.c +100 -115
  208. data/vendor/libgit2/src/repository.h +40 -49
  209. data/vendor/libgit2/src/revert.c +3 -8
  210. data/vendor/libgit2/src/revparse.c +19 -18
  211. data/vendor/libgit2/src/revwalk.c +30 -63
  212. data/vendor/libgit2/src/revwalk.h +0 -20
  213. data/vendor/libgit2/src/settings.c +0 -5
  214. data/vendor/libgit2/src/sortedcache.c +26 -12
  215. data/vendor/libgit2/src/sortedcache.h +1 -1
  216. data/vendor/libgit2/src/stash.c +65 -45
  217. data/vendor/libgit2/src/status.c +9 -15
  218. data/vendor/libgit2/src/{allocators/stdalloc.c → stdalloc.c} +4 -3
  219. data/vendor/libgit2/src/{allocators/stdalloc.h → stdalloc.h} +4 -4
  220. data/vendor/libgit2/src/streams/openssl.c +0 -20
  221. data/vendor/libgit2/src/streams/socket.c +2 -2
  222. data/vendor/libgit2/src/strmap.c +84 -37
  223. data/vendor/libgit2/src/strmap.h +33 -105
  224. data/vendor/libgit2/src/submodule.c +70 -102
  225. data/vendor/libgit2/src/submodule.h +1 -1
  226. data/vendor/libgit2/src/sysdir.c +1 -11
  227. data/vendor/libgit2/src/tag.c +2 -10
  228. data/vendor/libgit2/src/trace.c +1 -1
  229. data/vendor/libgit2/src/trace.h +2 -2
  230. data/vendor/libgit2/src/trailer.c +32 -46
  231. data/vendor/libgit2/src/transaction.c +9 -10
  232. data/vendor/libgit2/src/transports/auth.c +9 -10
  233. data/vendor/libgit2/src/transports/auth.h +4 -11
  234. data/vendor/libgit2/src/transports/auth_negotiate.c +9 -23
  235. data/vendor/libgit2/src/transports/auth_negotiate.h +2 -2
  236. data/vendor/libgit2/src/transports/cred.c +6 -6
  237. data/vendor/libgit2/src/{allocators/win32_crtdbg.h → transports/cred.h} +4 -5
  238. data/vendor/libgit2/src/transports/git.c +16 -11
  239. data/vendor/libgit2/src/transports/http.c +276 -419
  240. data/vendor/libgit2/src/transports/http.h +1 -1
  241. data/vendor/libgit2/src/transports/local.c +9 -9
  242. data/vendor/libgit2/src/transports/smart.c +17 -17
  243. data/vendor/libgit2/src/transports/smart.h +2 -2
  244. data/vendor/libgit2/src/transports/smart_protocol.c +60 -36
  245. data/vendor/libgit2/src/transports/ssh.c +36 -46
  246. data/vendor/libgit2/src/transports/winhttp.c +207 -231
  247. data/vendor/libgit2/src/tree-cache.c +7 -14
  248. data/vendor/libgit2/src/tree.c +24 -10
  249. data/vendor/libgit2/src/unix/map.c +1 -1
  250. data/vendor/libgit2/src/unix/posix.h +11 -1
  251. data/vendor/libgit2/src/userdiff.h +1 -3
  252. data/vendor/libgit2/src/util.c +53 -51
  253. data/vendor/libgit2/src/util.h +21 -16
  254. data/vendor/libgit2/src/win32/map.c +5 -3
  255. data/vendor/libgit2/src/win32/path_w32.c +2 -12
  256. data/vendor/libgit2/src/win32/path_w32.h +29 -0
  257. data/vendor/libgit2/src/win32/posix.h +4 -1
  258. data/vendor/libgit2/src/win32/posix_w32.c +5 -40
  259. data/vendor/libgit2/src/win32/precompiled.h +2 -0
  260. data/vendor/libgit2/src/win32/thread.c +10 -5
  261. data/vendor/libgit2/src/win32/w32_buffer.c +3 -7
  262. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +93 -0
  263. data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +2 -0
  264. data/vendor/libgit2/src/win32/w32_stack.c +9 -4
  265. data/vendor/libgit2/src/win32/w32_stack.h +3 -3
  266. data/vendor/libgit2/src/win32/w32_util.c +0 -31
  267. data/vendor/libgit2/src/win32/w32_util.h +32 -6
  268. data/vendor/libgit2/src/worktree.c +22 -36
  269. data/vendor/libgit2/src/xdiff/xdiffi.c +1 -1
  270. data/vendor/libgit2/src/xdiff/xmerge.c +0 -12
  271. data/vendor/libgit2/src/xdiff/xpatience.c +0 -3
  272. metadata +34 -98
  273. data/vendor/libgit2/cmake/Modules/FindGSSFramework.cmake +0 -28
  274. data/vendor/libgit2/cmake/Modules/FindPCRE.cmake +0 -38
  275. data/vendor/libgit2/cmake/Modules/FindPCRE2.cmake +0 -37
  276. data/vendor/libgit2/cmake/Modules/PkgBuildConfig.cmake +0 -110
  277. data/vendor/libgit2/cmake/Modules/SelectGSSAPI.cmake +0 -53
  278. data/vendor/libgit2/cmake/Modules/SelectHTTPSBackend.cmake +0 -124
  279. data/vendor/libgit2/cmake/Modules/SelectHashes.cmake +0 -66
  280. data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +0 -21
  281. data/vendor/libgit2/deps/ntlmclient/compat.h +0 -33
  282. data/vendor/libgit2/deps/ntlmclient/crypt.h +0 -64
  283. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +0 -120
  284. data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +0 -18
  285. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -145
  286. data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +0 -18
  287. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +0 -130
  288. data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +0 -21
  289. data/vendor/libgit2/deps/ntlmclient/ntlm.c +0 -1420
  290. data/vendor/libgit2/deps/ntlmclient/ntlm.h +0 -174
  291. data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +0 -320
  292. data/vendor/libgit2/deps/ntlmclient/unicode.h +0 -36
  293. data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +0 -445
  294. data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +0 -201
  295. data/vendor/libgit2/deps/ntlmclient/utf8.h +0 -1257
  296. data/vendor/libgit2/deps/ntlmclient/util.c +0 -21
  297. data/vendor/libgit2/deps/ntlmclient/util.h +0 -14
  298. data/vendor/libgit2/deps/pcre/CMakeLists.txt +0 -140
  299. data/vendor/libgit2/deps/pcre/COPYING +0 -5
  300. data/vendor/libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS +0 -22
  301. data/vendor/libgit2/deps/pcre/cmake/FindEditline.cmake +0 -17
  302. data/vendor/libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake +0 -58
  303. data/vendor/libgit2/deps/pcre/cmake/FindReadline.cmake +0 -29
  304. data/vendor/libgit2/deps/pcre/config.h.in +0 -57
  305. data/vendor/libgit2/deps/pcre/pcre.h +0 -641
  306. data/vendor/libgit2/deps/pcre/pcre_byte_order.c +0 -319
  307. data/vendor/libgit2/deps/pcre/pcre_chartables.c +0 -198
  308. data/vendor/libgit2/deps/pcre/pcre_compile.c +0 -9800
  309. data/vendor/libgit2/deps/pcre/pcre_config.c +0 -190
  310. data/vendor/libgit2/deps/pcre/pcre_dfa_exec.c +0 -3676
  311. data/vendor/libgit2/deps/pcre/pcre_exec.c +0 -7173
  312. data/vendor/libgit2/deps/pcre/pcre_fullinfo.c +0 -245
  313. data/vendor/libgit2/deps/pcre/pcre_get.c +0 -669
  314. data/vendor/libgit2/deps/pcre/pcre_globals.c +0 -86
  315. data/vendor/libgit2/deps/pcre/pcre_internal.h +0 -2787
  316. data/vendor/libgit2/deps/pcre/pcre_jit_compile.c +0 -11913
  317. data/vendor/libgit2/deps/pcre/pcre_maketables.c +0 -156
  318. data/vendor/libgit2/deps/pcre/pcre_newline.c +0 -210
  319. data/vendor/libgit2/deps/pcre/pcre_ord2utf8.c +0 -94
  320. data/vendor/libgit2/deps/pcre/pcre_printint.c +0 -834
  321. data/vendor/libgit2/deps/pcre/pcre_refcount.c +0 -92
  322. data/vendor/libgit2/deps/pcre/pcre_string_utils.c +0 -211
  323. data/vendor/libgit2/deps/pcre/pcre_study.c +0 -1686
  324. data/vendor/libgit2/deps/pcre/pcre_tables.c +0 -727
  325. data/vendor/libgit2/deps/pcre/pcre_ucd.c +0 -3644
  326. data/vendor/libgit2/deps/pcre/pcre_valid_utf8.c +0 -301
  327. data/vendor/libgit2/deps/pcre/pcre_version.c +0 -98
  328. data/vendor/libgit2/deps/pcre/pcre_xclass.c +0 -268
  329. data/vendor/libgit2/deps/pcre/pcreposix.c +0 -421
  330. data/vendor/libgit2/deps/pcre/pcreposix.h +0 -117
  331. data/vendor/libgit2/deps/pcre/ucp.h +0 -224
  332. data/vendor/libgit2/include/git2/cert.h +0 -135
  333. data/vendor/libgit2/include/git2/cred.h +0 -308
  334. data/vendor/libgit2/include/git2/sys/cred.h +0 -90
  335. data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
  336. data/vendor/libgit2/src/config_snapshot.c +0 -206
  337. data/vendor/libgit2/src/errors.h +0 -81
  338. data/vendor/libgit2/src/hash/sha1.h +0 -38
  339. data/vendor/libgit2/src/hash/sha1/collisiondetect.h +0 -19
  340. data/vendor/libgit2/src/hash/sha1/common_crypto.h +0 -19
  341. data/vendor/libgit2/src/hash/sha1/openssl.h +0 -19
  342. data/vendor/libgit2/src/net.c +0 -184
  343. data/vendor/libgit2/src/net.h +0 -36
  344. data/vendor/libgit2/src/regexp.c +0 -221
  345. data/vendor/libgit2/src/regexp.h +0 -97
  346. data/vendor/libgit2/src/transports/auth_ntlm.c +0 -223
  347. data/vendor/libgit2/src/transports/auth_ntlm.h +0 -35
  348. data/vendor/libgit2/src/wildmatch.c +0 -320
  349. data/vendor/libgit2/src/wildmatch.h +0 -23
  350. data/vendor/libgit2/src/win32/w32_common.h +0 -39
@@ -1,92 +0,0 @@
1
- /*************************************************
2
- * Perl-Compatible Regular Expressions *
3
- *************************************************/
4
-
5
- /* PCRE is a library of functions to support regular expressions whose syntax
6
- and semantics are as close as possible to those of the Perl 5 language.
7
-
8
- Written by Philip Hazel
9
- Copyright (c) 1997-2012 University of Cambridge
10
-
11
- -----------------------------------------------------------------------------
12
- Redistribution and use in source and binary forms, with or without
13
- modification, are permitted provided that the following conditions are met:
14
-
15
- * Redistributions of source code must retain the above copyright notice,
16
- this list of conditions and the following disclaimer.
17
-
18
- * Redistributions in binary form must reproduce the above copyright
19
- notice, this list of conditions and the following disclaimer in the
20
- documentation and/or other materials provided with the distribution.
21
-
22
- * Neither the name of the University of Cambridge nor the names of its
23
- contributors may be used to endorse or promote products derived from
24
- this software without specific prior written permission.
25
-
26
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
- POSSIBILITY OF SUCH DAMAGE.
37
- -----------------------------------------------------------------------------
38
- */
39
-
40
-
41
- /* This module contains the external function pcre_refcount(), which is an
42
- auxiliary function that can be used to maintain a reference count in a compiled
43
- pattern data block. This might be helpful in applications where the block is
44
- shared by different users. */
45
-
46
-
47
- #ifdef HAVE_CONFIG_H
48
- #include "config.h"
49
- #endif
50
-
51
- #include "pcre_internal.h"
52
-
53
-
54
- /*************************************************
55
- * Maintain reference count *
56
- *************************************************/
57
-
58
- /* The reference count is a 16-bit field, initialized to zero. It is not
59
- possible to transfer a non-zero count from one host to a different host that
60
- has a different byte order - though I can't see why anyone in their right mind
61
- would ever want to do that!
62
-
63
- Arguments:
64
- argument_re points to compiled code
65
- adjust value to add to the count
66
-
67
- Returns: the (possibly updated) count value (a non-negative number), or
68
- a negative error number
69
- */
70
-
71
- #if defined COMPILE_PCRE8
72
- PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
73
- pcre_refcount(pcre *argument_re, int adjust)
74
- #elif defined COMPILE_PCRE16
75
- PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
76
- pcre16_refcount(pcre16 *argument_re, int adjust)
77
- #elif defined COMPILE_PCRE32
78
- PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
79
- pcre32_refcount(pcre32 *argument_re, int adjust)
80
- #endif
81
- {
82
- REAL_PCRE *re = (REAL_PCRE *)argument_re;
83
- if (re == NULL) return PCRE_ERROR_NULL;
84
- if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
85
- if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
86
- re->ref_count = (-adjust > re->ref_count)? 0 :
87
- (adjust + re->ref_count > 65535)? 65535 :
88
- re->ref_count + adjust;
89
- return re->ref_count;
90
- }
91
-
92
- /* End of pcre_refcount.c */
@@ -1,211 +0,0 @@
1
- /*************************************************
2
- * Perl-Compatible Regular Expressions *
3
- *************************************************/
4
-
5
- /* PCRE is a library of functions to support regular expressions whose syntax
6
- and semantics are as close as possible to those of the Perl 5 language.
7
-
8
- Written by Philip Hazel
9
- Copyright (c) 1997-2014 University of Cambridge
10
-
11
- -----------------------------------------------------------------------------
12
- Redistribution and use in source and binary forms, with or without
13
- modification, are permitted provided that the following conditions are met:
14
-
15
- * Redistributions of source code must retain the above copyright notice,
16
- this list of conditions and the following disclaimer.
17
-
18
- * Redistributions in binary form must reproduce the above copyright
19
- notice, this list of conditions and the following disclaimer in the
20
- documentation and/or other materials provided with the distribution.
21
-
22
- * Neither the name of the University of Cambridge nor the names of its
23
- contributors may be used to endorse or promote products derived from
24
- this software without specific prior written permission.
25
-
26
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
- POSSIBILITY OF SUCH DAMAGE.
37
- -----------------------------------------------------------------------------
38
- */
39
-
40
-
41
- /* This module contains internal functions for comparing and finding the length
42
- of strings for different data item sizes. */
43
-
44
-
45
- #ifdef HAVE_CONFIG_H
46
- #include "config.h"
47
- #endif
48
-
49
- #include "pcre_internal.h"
50
-
51
- #ifndef COMPILE_PCRE8
52
-
53
- /*************************************************
54
- * Compare string utilities *
55
- *************************************************/
56
-
57
- /* The following two functions compares two strings. Basically a strcmp
58
- for non 8 bit characters.
59
-
60
- Arguments:
61
- str1 first string
62
- str2 second string
63
-
64
- Returns: 0 if both string are equal (like strcmp), 1 otherwise
65
- */
66
-
67
- int
68
- PRIV(strcmp_uc_uc)(const pcre_uchar *str1, const pcre_uchar *str2)
69
- {
70
- pcre_uchar c1;
71
- pcre_uchar c2;
72
-
73
- while (*str1 != '\0' || *str2 != '\0')
74
- {
75
- c1 = *str1++;
76
- c2 = *str2++;
77
- if (c1 != c2)
78
- return ((c1 > c2) << 1) - 1;
79
- }
80
- /* Both length and characters must be equal. */
81
- return 0;
82
- }
83
-
84
- #ifdef COMPILE_PCRE32
85
-
86
- int
87
- PRIV(strcmp_uc_uc_utf)(const pcre_uchar *str1, const pcre_uchar *str2)
88
- {
89
- pcre_uchar c1;
90
- pcre_uchar c2;
91
-
92
- while (*str1 != '\0' || *str2 != '\0')
93
- {
94
- c1 = UCHAR21INC(str1);
95
- c2 = UCHAR21INC(str2);
96
- if (c1 != c2)
97
- return ((c1 > c2) << 1) - 1;
98
- }
99
- /* Both length and characters must be equal. */
100
- return 0;
101
- }
102
-
103
- #endif /* COMPILE_PCRE32 */
104
-
105
- int
106
- PRIV(strcmp_uc_c8)(const pcre_uchar *str1, const char *str2)
107
- {
108
- const pcre_uint8 *ustr2 = (pcre_uint8 *)str2;
109
- pcre_uchar c1;
110
- pcre_uchar c2;
111
-
112
- while (*str1 != '\0' || *ustr2 != '\0')
113
- {
114
- c1 = *str1++;
115
- c2 = (pcre_uchar)*ustr2++;
116
- if (c1 != c2)
117
- return ((c1 > c2) << 1) - 1;
118
- }
119
- /* Both length and characters must be equal. */
120
- return 0;
121
- }
122
-
123
- #ifdef COMPILE_PCRE32
124
-
125
- int
126
- PRIV(strcmp_uc_c8_utf)(const pcre_uchar *str1, const char *str2)
127
- {
128
- const pcre_uint8 *ustr2 = (pcre_uint8 *)str2;
129
- pcre_uchar c1;
130
- pcre_uchar c2;
131
-
132
- while (*str1 != '\0' || *ustr2 != '\0')
133
- {
134
- c1 = UCHAR21INC(str1);
135
- c2 = (pcre_uchar)*ustr2++;
136
- if (c1 != c2)
137
- return ((c1 > c2) << 1) - 1;
138
- }
139
- /* Both length and characters must be equal. */
140
- return 0;
141
- }
142
-
143
- #endif /* COMPILE_PCRE32 */
144
-
145
- /* The following two functions compares two, fixed length
146
- strings. Basically an strncmp for non 8 bit characters.
147
-
148
- Arguments:
149
- str1 first string
150
- str2 second string
151
- num size of the string
152
-
153
- Returns: 0 if both string are equal (like strcmp), 1 otherwise
154
- */
155
-
156
- int
157
- PRIV(strncmp_uc_uc)(const pcre_uchar *str1, const pcre_uchar *str2, unsigned int num)
158
- {
159
- pcre_uchar c1;
160
- pcre_uchar c2;
161
-
162
- while (num-- > 0)
163
- {
164
- c1 = *str1++;
165
- c2 = *str2++;
166
- if (c1 != c2)
167
- return ((c1 > c2) << 1) - 1;
168
- }
169
- /* Both length and characters must be equal. */
170
- return 0;
171
- }
172
-
173
- int
174
- PRIV(strncmp_uc_c8)(const pcre_uchar *str1, const char *str2, unsigned int num)
175
- {
176
- const pcre_uint8 *ustr2 = (pcre_uint8 *)str2;
177
- pcre_uchar c1;
178
- pcre_uchar c2;
179
-
180
- while (num-- > 0)
181
- {
182
- c1 = *str1++;
183
- c2 = (pcre_uchar)*ustr2++;
184
- if (c1 != c2)
185
- return ((c1 > c2) << 1) - 1;
186
- }
187
- /* Both length and characters must be equal. */
188
- return 0;
189
- }
190
-
191
- /* The following function returns with the length of
192
- a zero terminated string. Basically an strlen for non 8 bit characters.
193
-
194
- Arguments:
195
- str string
196
-
197
- Returns: length of the string
198
- */
199
-
200
- unsigned int
201
- PRIV(strlen_uc)(const pcre_uchar *str)
202
- {
203
- unsigned int len = 0;
204
- while (*str++ != 0)
205
- len++;
206
- return len;
207
- }
208
-
209
- #endif /* !COMPILE_PCRE8 */
210
-
211
- /* End of pcre_string_utils.c */
@@ -1,1686 +0,0 @@
1
- /*************************************************
2
- * Perl-Compatible Regular Expressions *
3
- *************************************************/
4
-
5
- /* PCRE is a library of functions to support regular expressions whose syntax
6
- and semantics are as close as possible to those of the Perl 5 language.
7
-
8
- Written by Philip Hazel
9
- Copyright (c) 1997-2012 University of Cambridge
10
-
11
- -----------------------------------------------------------------------------
12
- Redistribution and use in source and binary forms, with or without
13
- modification, are permitted provided that the following conditions are met:
14
-
15
- * Redistributions of source code must retain the above copyright notice,
16
- this list of conditions and the following disclaimer.
17
-
18
- * Redistributions in binary form must reproduce the above copyright
19
- notice, this list of conditions and the following disclaimer in the
20
- documentation and/or other materials provided with the distribution.
21
-
22
- * Neither the name of the University of Cambridge nor the names of its
23
- contributors may be used to endorse or promote products derived from
24
- this software without specific prior written permission.
25
-
26
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
- POSSIBILITY OF SUCH DAMAGE.
37
- -----------------------------------------------------------------------------
38
- */
39
-
40
-
41
- /* This module contains the external function pcre_study(), along with local
42
- supporting functions. */
43
-
44
-
45
- #ifdef HAVE_CONFIG_H
46
- #include "config.h"
47
- #endif
48
-
49
- #include "pcre_internal.h"
50
-
51
- #define SET_BIT(c) start_bits[c/8] |= (1 << (c&7))
52
-
53
- /* Returns from set_start_bits() */
54
-
55
- enum { SSB_FAIL, SSB_DONE, SSB_CONTINUE, SSB_UNKNOWN };
56
-
57
-
58
-
59
- /*************************************************
60
- * Find the minimum subject length for a group *
61
- *************************************************/
62
-
63
- /* Scan a parenthesized group and compute the minimum length of subject that
64
- is needed to match it. This is a lower bound; it does not mean there is a
65
- string of that length that matches. In UTF8 mode, the result is in characters
66
- rather than bytes.
67
-
68
- Arguments:
69
- re compiled pattern block
70
- code pointer to start of group (the bracket)
71
- startcode pointer to start of the whole pattern's code
72
- options the compiling options
73
- recurses chain of recurse_check to catch mutual recursion
74
- countptr pointer to call count (to catch over complexity)
75
-
76
- Returns: the minimum length
77
- -1 if \C in UTF-8 mode or (*ACCEPT) was encountered
78
- -2 internal error (missing capturing bracket)
79
- -3 internal error (opcode not listed)
80
- */
81
-
82
- static int
83
- find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
84
- const pcre_uchar *startcode, int options, recurse_check *recurses,
85
- int *countptr)
86
- {
87
- int length = -1;
88
- /* PCRE_UTF16 has the same value as PCRE_UTF8. */
89
- BOOL utf = (options & PCRE_UTF8) != 0;
90
- BOOL had_recurse = FALSE;
91
- recurse_check this_recurse;
92
- register int branchlength = 0;
93
- register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
94
-
95
- if ((*countptr)++ > 1000) return -1; /* too complex */
96
-
97
- if (*code == OP_CBRA || *code == OP_SCBRA ||
98
- *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;
99
-
100
- /* Scan along the opcodes for this branch. If we get to the end of the
101
- branch, check the length against that of the other branches. */
102
-
103
- for (;;)
104
- {
105
- int d, min;
106
- pcre_uchar *cs, *ce;
107
- register pcre_uchar op = *cc;
108
-
109
- switch (op)
110
- {
111
- case OP_COND:
112
- case OP_SCOND:
113
-
114
- /* If there is only one branch in a condition, the implied branch has zero
115
- length, so we don't add anything. This covers the DEFINE "condition"
116
- automatically. */
117
-
118
- cs = cc + GET(cc, 1);
119
- if (*cs != OP_ALT)
120
- {
121
- cc = cs + 1 + LINK_SIZE;
122
- break;
123
- }
124
-
125
- /* Otherwise we can fall through and treat it the same as any other
126
- subpattern. */
127
-
128
- case OP_CBRA:
129
- case OP_SCBRA:
130
- case OP_BRA:
131
- case OP_SBRA:
132
- case OP_CBRAPOS:
133
- case OP_SCBRAPOS:
134
- case OP_BRAPOS:
135
- case OP_SBRAPOS:
136
- case OP_ONCE:
137
- case OP_ONCE_NC:
138
- d = find_minlength(re, cc, startcode, options, recurses, countptr);
139
- if (d < 0) return d;
140
- branchlength += d;
141
- do cc += GET(cc, 1); while (*cc == OP_ALT);
142
- cc += 1 + LINK_SIZE;
143
- break;
144
-
145
- /* ACCEPT makes things far too complicated; we have to give up. */
146
-
147
- case OP_ACCEPT:
148
- case OP_ASSERT_ACCEPT:
149
- return -1;
150
-
151
- /* Reached end of a branch; if it's a ket it is the end of a nested
152
- call. If it's ALT it is an alternation in a nested call. If it is END it's
153
- the end of the outer call. All can be handled by the same code. If an
154
- ACCEPT was previously encountered, use the length that was in force at that
155
- time, and pass back the shortest ACCEPT length. */
156
-
157
- case OP_ALT:
158
- case OP_KET:
159
- case OP_KETRMAX:
160
- case OP_KETRMIN:
161
- case OP_KETRPOS:
162
- case OP_END:
163
- if (length < 0 || (!had_recurse && branchlength < length))
164
- length = branchlength;
165
- if (op != OP_ALT) return length;
166
- cc += 1 + LINK_SIZE;
167
- branchlength = 0;
168
- had_recurse = FALSE;
169
- break;
170
-
171
- /* Skip over assertive subpatterns */
172
-
173
- case OP_ASSERT:
174
- case OP_ASSERT_NOT:
175
- case OP_ASSERTBACK:
176
- case OP_ASSERTBACK_NOT:
177
- do cc += GET(cc, 1); while (*cc == OP_ALT);
178
- /* Fall through */
179
-
180
- /* Skip over things that don't match chars */
181
-
182
- case OP_REVERSE:
183
- case OP_CREF:
184
- case OP_DNCREF:
185
- case OP_RREF:
186
- case OP_DNRREF:
187
- case OP_DEF:
188
- case OP_CALLOUT:
189
- case OP_SOD:
190
- case OP_SOM:
191
- case OP_EOD:
192
- case OP_EODN:
193
- case OP_CIRC:
194
- case OP_CIRCM:
195
- case OP_DOLL:
196
- case OP_DOLLM:
197
- case OP_NOT_WORD_BOUNDARY:
198
- case OP_WORD_BOUNDARY:
199
- cc += PRIV(OP_lengths)[*cc];
200
- break;
201
-
202
- /* Skip over a subpattern that has a {0} or {0,x} quantifier */
203
-
204
- case OP_BRAZERO:
205
- case OP_BRAMINZERO:
206
- case OP_BRAPOSZERO:
207
- case OP_SKIPZERO:
208
- cc += PRIV(OP_lengths)[*cc];
209
- do cc += GET(cc, 1); while (*cc == OP_ALT);
210
- cc += 1 + LINK_SIZE;
211
- break;
212
-
213
- /* Handle literal characters and + repetitions */
214
-
215
- case OP_CHAR:
216
- case OP_CHARI:
217
- case OP_NOT:
218
- case OP_NOTI:
219
- case OP_PLUS:
220
- case OP_PLUSI:
221
- case OP_MINPLUS:
222
- case OP_MINPLUSI:
223
- case OP_POSPLUS:
224
- case OP_POSPLUSI:
225
- case OP_NOTPLUS:
226
- case OP_NOTPLUSI:
227
- case OP_NOTMINPLUS:
228
- case OP_NOTMINPLUSI:
229
- case OP_NOTPOSPLUS:
230
- case OP_NOTPOSPLUSI:
231
- branchlength++;
232
- cc += 2;
233
- #ifdef SUPPORT_UTF
234
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
235
- #endif
236
- break;
237
-
238
- case OP_TYPEPLUS:
239
- case OP_TYPEMINPLUS:
240
- case OP_TYPEPOSPLUS:
241
- branchlength++;
242
- cc += (cc[1] == OP_PROP || cc[1] == OP_NOTPROP)? 4 : 2;
243
- break;
244
-
245
- /* Handle exact repetitions. The count is already in characters, but we
246
- need to skip over a multibyte character in UTF8 mode. */
247
-
248
- case OP_EXACT:
249
- case OP_EXACTI:
250
- case OP_NOTEXACT:
251
- case OP_NOTEXACTI:
252
- branchlength += GET2(cc,1);
253
- cc += 2 + IMM2_SIZE;
254
- #ifdef SUPPORT_UTF
255
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
256
- #endif
257
- break;
258
-
259
- case OP_TYPEEXACT:
260
- branchlength += GET2(cc,1);
261
- cc += 2 + IMM2_SIZE + ((cc[1 + IMM2_SIZE] == OP_PROP
262
- || cc[1 + IMM2_SIZE] == OP_NOTPROP)? 2 : 0);
263
- break;
264
-
265
- /* Handle single-char non-literal matchers */
266
-
267
- case OP_PROP:
268
- case OP_NOTPROP:
269
- cc += 2;
270
- /* Fall through */
271
-
272
- case OP_NOT_DIGIT:
273
- case OP_DIGIT:
274
- case OP_NOT_WHITESPACE:
275
- case OP_WHITESPACE:
276
- case OP_NOT_WORDCHAR:
277
- case OP_WORDCHAR:
278
- case OP_ANY:
279
- case OP_ALLANY:
280
- case OP_EXTUNI:
281
- case OP_HSPACE:
282
- case OP_NOT_HSPACE:
283
- case OP_VSPACE:
284
- case OP_NOT_VSPACE:
285
- branchlength++;
286
- cc++;
287
- break;
288
-
289
- /* "Any newline" might match two characters, but it also might match just
290
- one. */
291
-
292
- case OP_ANYNL:
293
- branchlength += 1;
294
- cc++;
295
- break;
296
-
297
- /* The single-byte matcher means we can't proceed in UTF-8 mode. (In
298
- non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever
299
- appear, but leave the code, just in case.) */
300
-
301
- case OP_ANYBYTE:
302
- #ifdef SUPPORT_UTF
303
- if (utf) return -1;
304
- #endif
305
- branchlength++;
306
- cc++;
307
- break;
308
-
309
- /* For repeated character types, we have to test for \p and \P, which have
310
- an extra two bytes of parameters. */
311
-
312
- case OP_TYPESTAR:
313
- case OP_TYPEMINSTAR:
314
- case OP_TYPEQUERY:
315
- case OP_TYPEMINQUERY:
316
- case OP_TYPEPOSSTAR:
317
- case OP_TYPEPOSQUERY:
318
- if (cc[1] == OP_PROP || cc[1] == OP_NOTPROP) cc += 2;
319
- cc += PRIV(OP_lengths)[op];
320
- break;
321
-
322
- case OP_TYPEUPTO:
323
- case OP_TYPEMINUPTO:
324
- case OP_TYPEPOSUPTO:
325
- if (cc[1 + IMM2_SIZE] == OP_PROP
326
- || cc[1 + IMM2_SIZE] == OP_NOTPROP) cc += 2;
327
- cc += PRIV(OP_lengths)[op];
328
- break;
329
-
330
- /* Check a class for variable quantification */
331
-
332
- case OP_CLASS:
333
- case OP_NCLASS:
334
- #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
335
- case OP_XCLASS:
336
- /* The original code caused an unsigned overflow in 64 bit systems,
337
- so now we use a conditional statement. */
338
- if (op == OP_XCLASS)
339
- cc += GET(cc, 1);
340
- else
341
- cc += PRIV(OP_lengths)[OP_CLASS];
342
- #else
343
- cc += PRIV(OP_lengths)[OP_CLASS];
344
- #endif
345
-
346
- switch (*cc)
347
- {
348
- case OP_CRPLUS:
349
- case OP_CRMINPLUS:
350
- case OP_CRPOSPLUS:
351
- branchlength++;
352
- /* Fall through */
353
-
354
- case OP_CRSTAR:
355
- case OP_CRMINSTAR:
356
- case OP_CRQUERY:
357
- case OP_CRMINQUERY:
358
- case OP_CRPOSSTAR:
359
- case OP_CRPOSQUERY:
360
- cc++;
361
- break;
362
-
363
- case OP_CRRANGE:
364
- case OP_CRMINRANGE:
365
- case OP_CRPOSRANGE:
366
- branchlength += GET2(cc,1);
367
- cc += 1 + 2 * IMM2_SIZE;
368
- break;
369
-
370
- default:
371
- branchlength++;
372
- break;
373
- }
374
- break;
375
-
376
- /* Backreferences and subroutine calls are treated in the same way: we find
377
- the minimum length for the subpattern. A recursion, however, causes an
378
- a flag to be set that causes the length of this branch to be ignored. The
379
- logic is that a recursion can only make sense if there is another
380
- alternation that stops the recursing. That will provide the minimum length
381
- (when no recursion happens). A backreference within the group that it is
382
- referencing behaves in the same way.
383
-
384
- If PCRE_JAVASCRIPT_COMPAT is set, a backreference to an unset bracket
385
- matches an empty string (by default it causes a matching failure), so in
386
- that case we must set the minimum length to zero. */
387
-
388
- case OP_DNREF: /* Duplicate named pattern back reference */
389
- case OP_DNREFI:
390
- if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
391
- {
392
- int count = GET2(cc, 1+IMM2_SIZE);
393
- pcre_uchar *slot = (pcre_uchar *)re +
394
- re->name_table_offset + GET2(cc, 1) * re->name_entry_size;
395
- d = INT_MAX;
396
- while (count-- > 0)
397
- {
398
- ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(slot, 0));
399
- if (cs == NULL) return -2;
400
- do ce += GET(ce, 1); while (*ce == OP_ALT);
401
- if (cc > cs && cc < ce) /* Simple recursion */
402
- {
403
- d = 0;
404
- had_recurse = TRUE;
405
- break;
406
- }
407
- else
408
- {
409
- recurse_check *r = recurses;
410
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
411
- if (r != NULL) /* Mutual recursion */
412
- {
413
- d = 0;
414
- had_recurse = TRUE;
415
- break;
416
- }
417
- else
418
- {
419
- int dd;
420
- this_recurse.prev = recurses;
421
- this_recurse.group = cs;
422
- dd = find_minlength(re, cs, startcode, options, &this_recurse,
423
- countptr);
424
- if (dd < d) d = dd;
425
- }
426
- }
427
- slot += re->name_entry_size;
428
- }
429
- }
430
- else d = 0;
431
- cc += 1 + 2*IMM2_SIZE;
432
- goto REPEAT_BACK_REFERENCE;
433
-
434
- case OP_REF: /* Single back reference */
435
- case OP_REFI:
436
- if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
437
- {
438
- ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(cc, 1));
439
- if (cs == NULL) return -2;
440
- do ce += GET(ce, 1); while (*ce == OP_ALT);
441
- if (cc > cs && cc < ce) /* Simple recursion */
442
- {
443
- d = 0;
444
- had_recurse = TRUE;
445
- }
446
- else
447
- {
448
- recurse_check *r = recurses;
449
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
450
- if (r != NULL) /* Mutual recursion */
451
- {
452
- d = 0;
453
- had_recurse = TRUE;
454
- }
455
- else
456
- {
457
- this_recurse.prev = recurses;
458
- this_recurse.group = cs;
459
- d = find_minlength(re, cs, startcode, options, &this_recurse,
460
- countptr);
461
- }
462
- }
463
- }
464
- else d = 0;
465
- cc += 1 + IMM2_SIZE;
466
-
467
- /* Handle repeated back references */
468
-
469
- REPEAT_BACK_REFERENCE:
470
- switch (*cc)
471
- {
472
- case OP_CRSTAR:
473
- case OP_CRMINSTAR:
474
- case OP_CRQUERY:
475
- case OP_CRMINQUERY:
476
- case OP_CRPOSSTAR:
477
- case OP_CRPOSQUERY:
478
- min = 0;
479
- cc++;
480
- break;
481
-
482
- case OP_CRPLUS:
483
- case OP_CRMINPLUS:
484
- case OP_CRPOSPLUS:
485
- min = 1;
486
- cc++;
487
- break;
488
-
489
- case OP_CRRANGE:
490
- case OP_CRMINRANGE:
491
- case OP_CRPOSRANGE:
492
- min = GET2(cc, 1);
493
- cc += 1 + 2 * IMM2_SIZE;
494
- break;
495
-
496
- default:
497
- min = 1;
498
- break;
499
- }
500
-
501
- branchlength += min * d;
502
- break;
503
-
504
- /* We can easily detect direct recursion, but not mutual recursion. This is
505
- caught by a recursion depth count. */
506
-
507
- case OP_RECURSE:
508
- cs = ce = (pcre_uchar *)startcode + GET(cc, 1);
509
- do ce += GET(ce, 1); while (*ce == OP_ALT);
510
- if (cc > cs && cc < ce) /* Simple recursion */
511
- had_recurse = TRUE;
512
- else
513
- {
514
- recurse_check *r = recurses;
515
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
516
- if (r != NULL) /* Mutual recursion */
517
- had_recurse = TRUE;
518
- else
519
- {
520
- this_recurse.prev = recurses;
521
- this_recurse.group = cs;
522
- branchlength += find_minlength(re, cs, startcode, options,
523
- &this_recurse, countptr);
524
- }
525
- }
526
- cc += 1 + LINK_SIZE;
527
- break;
528
-
529
- /* Anything else does not or need not match a character. We can get the
530
- item's length from the table, but for those that can match zero occurrences
531
- of a character, we must take special action for UTF-8 characters. As it
532
- happens, the "NOT" versions of these opcodes are used at present only for
533
- ASCII characters, so they could be omitted from this list. However, in
534
- future that may change, so we include them here so as not to leave a
535
- gotcha for a future maintainer. */
536
-
537
- case OP_UPTO:
538
- case OP_UPTOI:
539
- case OP_NOTUPTO:
540
- case OP_NOTUPTOI:
541
- case OP_MINUPTO:
542
- case OP_MINUPTOI:
543
- case OP_NOTMINUPTO:
544
- case OP_NOTMINUPTOI:
545
- case OP_POSUPTO:
546
- case OP_POSUPTOI:
547
- case OP_NOTPOSUPTO:
548
- case OP_NOTPOSUPTOI:
549
-
550
- case OP_STAR:
551
- case OP_STARI:
552
- case OP_NOTSTAR:
553
- case OP_NOTSTARI:
554
- case OP_MINSTAR:
555
- case OP_MINSTARI:
556
- case OP_NOTMINSTAR:
557
- case OP_NOTMINSTARI:
558
- case OP_POSSTAR:
559
- case OP_POSSTARI:
560
- case OP_NOTPOSSTAR:
561
- case OP_NOTPOSSTARI:
562
-
563
- case OP_QUERY:
564
- case OP_QUERYI:
565
- case OP_NOTQUERY:
566
- case OP_NOTQUERYI:
567
- case OP_MINQUERY:
568
- case OP_MINQUERYI:
569
- case OP_NOTMINQUERY:
570
- case OP_NOTMINQUERYI:
571
- case OP_POSQUERY:
572
- case OP_POSQUERYI:
573
- case OP_NOTPOSQUERY:
574
- case OP_NOTPOSQUERYI:
575
-
576
- cc += PRIV(OP_lengths)[op];
577
- #ifdef SUPPORT_UTF
578
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
579
- #endif
580
- break;
581
-
582
- /* Skip these, but we need to add in the name length. */
583
-
584
- case OP_MARK:
585
- case OP_PRUNE_ARG:
586
- case OP_SKIP_ARG:
587
- case OP_THEN_ARG:
588
- cc += PRIV(OP_lengths)[op] + cc[1];
589
- break;
590
-
591
- /* The remaining opcodes are just skipped over. */
592
-
593
- case OP_CLOSE:
594
- case OP_COMMIT:
595
- case OP_FAIL:
596
- case OP_PRUNE:
597
- case OP_SET_SOM:
598
- case OP_SKIP:
599
- case OP_THEN:
600
- cc += PRIV(OP_lengths)[op];
601
- break;
602
-
603
- /* This should not occur: we list all opcodes explicitly so that when
604
- new ones get added they are properly considered. */
605
-
606
- default:
607
- return -3;
608
- }
609
- }
610
- /* Control never gets here */
611
- }
612
-
613
-
614
-
615
- /*************************************************
616
- * Set a bit and maybe its alternate case *
617
- *************************************************/
618
-
619
- /* Given a character, set its first byte's bit in the table, and also the
620
- corresponding bit for the other version of a letter if we are caseless. In
621
- UTF-8 mode, for characters greater than 127, we can only do the caseless thing
622
- when Unicode property support is available.
623
-
624
- Arguments:
625
- start_bits points to the bit map
626
- p points to the character
627
- caseless the caseless flag
628
- cd the block with char table pointers
629
- utf TRUE for UTF-8 / UTF-16 / UTF-32 mode
630
-
631
- Returns: pointer after the character
632
- */
633
-
634
- static const pcre_uchar *
635
- set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,
636
- compile_data *cd, BOOL utf)
637
- {
638
- pcre_uint32 c = *p;
639
-
640
- #ifdef COMPILE_PCRE8
641
- SET_BIT(c);
642
-
643
- #ifdef SUPPORT_UTF
644
- if (utf && c > 127)
645
- {
646
- GETCHARINC(c, p);
647
- #ifdef SUPPORT_UCP
648
- if (caseless)
649
- {
650
- pcre_uchar buff[6];
651
- c = UCD_OTHERCASE(c);
652
- (void)PRIV(ord2utf)(c, buff);
653
- SET_BIT(buff[0]);
654
- }
655
- #endif /* Not SUPPORT_UCP */
656
- return p;
657
- }
658
- #else /* Not SUPPORT_UTF */
659
- (void)(utf); /* Stops warning for unused parameter */
660
- #endif /* SUPPORT_UTF */
661
-
662
- /* Not UTF-8 mode, or character is less than 127. */
663
-
664
- if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
665
- return p + 1;
666
- #endif /* COMPILE_PCRE8 */
667
-
668
- #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
669
- if (c > 0xff)
670
- {
671
- c = 0xff;
672
- caseless = FALSE;
673
- }
674
- SET_BIT(c);
675
-
676
- #ifdef SUPPORT_UTF
677
- if (utf && c > 127)
678
- {
679
- GETCHARINC(c, p);
680
- #ifdef SUPPORT_UCP
681
- if (caseless)
682
- {
683
- c = UCD_OTHERCASE(c);
684
- if (c > 0xff)
685
- c = 0xff;
686
- SET_BIT(c);
687
- }
688
- #endif /* SUPPORT_UCP */
689
- return p;
690
- }
691
- #else /* Not SUPPORT_UTF */
692
- (void)(utf); /* Stops warning for unused parameter */
693
- #endif /* SUPPORT_UTF */
694
-
695
- if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
696
- return p + 1;
697
- #endif
698
- }
699
-
700
-
701
-
702
- /*************************************************
703
- * Set bits for a positive character type *
704
- *************************************************/
705
-
706
- /* This function sets starting bits for a character type. In UTF-8 mode, we can
707
- only do a direct setting for bytes less than 128, as otherwise there can be
708
- confusion with bytes in the middle of UTF-8 characters. In a "traditional"
709
- environment, the tables will only recognize ASCII characters anyway, but in at
710
- least one Windows environment, some higher bytes bits were set in the tables.
711
- So we deal with that case by considering the UTF-8 encoding.
712
-
713
- Arguments:
714
- start_bits the starting bitmap
715
- cbit type the type of character wanted
716
- table_limit 32 for non-UTF-8; 16 for UTF-8
717
- cd the block with char table pointers
718
-
719
- Returns: nothing
720
- */
721
-
722
- static void
723
- set_type_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
724
- compile_data *cd)
725
- {
726
- register pcre_uint32 c;
727
- for (c = 0; c < table_limit; c++) start_bits[c] |= cd->cbits[c+cbit_type];
728
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
729
- if (table_limit == 32) return;
730
- for (c = 128; c < 256; c++)
731
- {
732
- if ((cd->cbits[c/8] & (1 << (c&7))) != 0)
733
- {
734
- pcre_uchar buff[6];
735
- (void)PRIV(ord2utf)(c, buff);
736
- SET_BIT(buff[0]);
737
- }
738
- }
739
- #endif
740
- }
741
-
742
-
743
- /*************************************************
744
- * Set bits for a negative character type *
745
- *************************************************/
746
-
747
- /* This function sets starting bits for a negative character type such as \D.
748
- In UTF-8 mode, we can only do a direct setting for bytes less than 128, as
749
- otherwise there can be confusion with bytes in the middle of UTF-8 characters.
750
- Unlike in the positive case, where we can set appropriate starting bits for
751
- specific high-valued UTF-8 characters, in this case we have to set the bits for
752
- all high-valued characters. The lowest is 0xc2, but we overkill by starting at
753
- 0xc0 (192) for simplicity.
754
-
755
- Arguments:
756
- start_bits the starting bitmap
757
- cbit type the type of character wanted
758
- table_limit 32 for non-UTF-8; 16 for UTF-8
759
- cd the block with char table pointers
760
-
761
- Returns: nothing
762
- */
763
-
764
- static void
765
- set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
766
- compile_data *cd)
767
- {
768
- register pcre_uint32 c;
769
- for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->cbits[c+cbit_type];
770
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
771
- if (table_limit != 32) for (c = 24; c < 32; c++) start_bits[c] = 0xff;
772
- #endif
773
- }
774
-
775
-
776
-
777
- /*************************************************
778
- * Create bitmap of starting bytes *
779
- *************************************************/
780
-
781
- /* This function scans a compiled unanchored expression recursively and
782
- attempts to build a bitmap of the set of possible starting bytes. As time goes
783
- by, we may be able to get more clever at doing this. The SSB_CONTINUE return is
784
- useful for parenthesized groups in patterns such as (a*)b where the group
785
- provides some optional starting bytes but scanning must continue at the outer
786
- level to find at least one mandatory byte. At the outermost level, this
787
- function fails unless the result is SSB_DONE.
788
-
789
- Arguments:
790
- code points to an expression
791
- start_bits points to a 32-byte table, initialized to 0
792
- utf TRUE if in UTF-8 / UTF-16 / UTF-32 mode
793
- cd the block with char table pointers
794
-
795
- Returns: SSB_FAIL => Failed to find any starting bytes
796
- SSB_DONE => Found mandatory starting bytes
797
- SSB_CONTINUE => Found optional starting bytes
798
- SSB_UNKNOWN => Hit an unrecognized opcode
799
- */
800
-
801
- static int
802
- set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf,
803
- compile_data *cd)
804
- {
805
- register pcre_uint32 c;
806
- int yield = SSB_DONE;
807
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
808
- int table_limit = utf? 16:32;
809
- #else
810
- int table_limit = 32;
811
- #endif
812
-
813
- #if 0
814
- /* ========================================================================= */
815
- /* The following comment and code was inserted in January 1999. In May 2006,
816
- when it was observed to cause compiler warnings about unused values, I took it
817
- out again. If anybody is still using OS/2, they will have to put it back
818
- manually. */
819
-
820
- /* This next statement and the later reference to dummy are here in order to
821
- trick the optimizer of the IBM C compiler for OS/2 into generating correct
822
- code. Apparently IBM isn't going to fix the problem, and we would rather not
823
- disable optimization (in this module it actually makes a big difference, and
824
- the pcre module can use all the optimization it can get). */
825
-
826
- volatile int dummy;
827
- /* ========================================================================= */
828
- #endif
829
-
830
- do
831
- {
832
- BOOL try_next = TRUE;
833
- const pcre_uchar *tcode = code + 1 + LINK_SIZE;
834
-
835
- if (*code == OP_CBRA || *code == OP_SCBRA ||
836
- *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += IMM2_SIZE;
837
-
838
- while (try_next) /* Loop for items in this branch */
839
- {
840
- int rc;
841
-
842
- switch(*tcode)
843
- {
844
- /* If we reach something we don't understand, it means a new opcode has
845
- been created that hasn't been added to this code. Hopefully this problem
846
- will be discovered during testing. */
847
-
848
- default:
849
- return SSB_UNKNOWN;
850
-
851
- /* Fail for a valid opcode that implies no starting bits. */
852
-
853
- case OP_ACCEPT:
854
- case OP_ASSERT_ACCEPT:
855
- case OP_ALLANY:
856
- case OP_ANY:
857
- case OP_ANYBYTE:
858
- case OP_CIRC:
859
- case OP_CIRCM:
860
- case OP_CLOSE:
861
- case OP_COMMIT:
862
- case OP_COND:
863
- case OP_CREF:
864
- case OP_DEF:
865
- case OP_DNCREF:
866
- case OP_DNREF:
867
- case OP_DNREFI:
868
- case OP_DNRREF:
869
- case OP_DOLL:
870
- case OP_DOLLM:
871
- case OP_END:
872
- case OP_EOD:
873
- case OP_EODN:
874
- case OP_EXTUNI:
875
- case OP_FAIL:
876
- case OP_MARK:
877
- case OP_NOT:
878
- case OP_NOTEXACT:
879
- case OP_NOTEXACTI:
880
- case OP_NOTI:
881
- case OP_NOTMINPLUS:
882
- case OP_NOTMINPLUSI:
883
- case OP_NOTMINQUERY:
884
- case OP_NOTMINQUERYI:
885
- case OP_NOTMINSTAR:
886
- case OP_NOTMINSTARI:
887
- case OP_NOTMINUPTO:
888
- case OP_NOTMINUPTOI:
889
- case OP_NOTPLUS:
890
- case OP_NOTPLUSI:
891
- case OP_NOTPOSPLUS:
892
- case OP_NOTPOSPLUSI:
893
- case OP_NOTPOSQUERY:
894
- case OP_NOTPOSQUERYI:
895
- case OP_NOTPOSSTAR:
896
- case OP_NOTPOSSTARI:
897
- case OP_NOTPOSUPTO:
898
- case OP_NOTPOSUPTOI:
899
- case OP_NOTPROP:
900
- case OP_NOTQUERY:
901
- case OP_NOTQUERYI:
902
- case OP_NOTSTAR:
903
- case OP_NOTSTARI:
904
- case OP_NOTUPTO:
905
- case OP_NOTUPTOI:
906
- case OP_NOT_HSPACE:
907
- case OP_NOT_VSPACE:
908
- case OP_PRUNE:
909
- case OP_PRUNE_ARG:
910
- case OP_RECURSE:
911
- case OP_REF:
912
- case OP_REFI:
913
- case OP_REVERSE:
914
- case OP_RREF:
915
- case OP_SCOND:
916
- case OP_SET_SOM:
917
- case OP_SKIP:
918
- case OP_SKIP_ARG:
919
- case OP_SOD:
920
- case OP_SOM:
921
- case OP_THEN:
922
- case OP_THEN_ARG:
923
- return SSB_FAIL;
924
-
925
- /* A "real" property test implies no starting bits, but the fake property
926
- PT_CLIST identifies a list of characters. These lists are short, as they
927
- are used for characters with more than one "other case", so there is no
928
- point in recognizing them for OP_NOTPROP. */
929
-
930
- case OP_PROP:
931
- if (tcode[1] != PT_CLIST) return SSB_FAIL;
932
- {
933
- const pcre_uint32 *p = PRIV(ucd_caseless_sets) + tcode[2];
934
- while ((c = *p++) < NOTACHAR)
935
- {
936
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
937
- if (utf)
938
- {
939
- pcre_uchar buff[6];
940
- (void)PRIV(ord2utf)(c, buff);
941
- c = buff[0];
942
- }
943
- #endif
944
- if (c > 0xff) SET_BIT(0xff); else SET_BIT(c);
945
- }
946
- }
947
- try_next = FALSE;
948
- break;
949
-
950
- /* We can ignore word boundary tests. */
951
-
952
- case OP_WORD_BOUNDARY:
953
- case OP_NOT_WORD_BOUNDARY:
954
- tcode++;
955
- break;
956
-
957
- /* If we hit a bracket or a positive lookahead assertion, recurse to set
958
- bits from within the subpattern. If it can't find anything, we have to
959
- give up. If it finds some mandatory character(s), we are done for this
960
- branch. Otherwise, carry on scanning after the subpattern. */
961
-
962
- case OP_BRA:
963
- case OP_SBRA:
964
- case OP_CBRA:
965
- case OP_SCBRA:
966
- case OP_BRAPOS:
967
- case OP_SBRAPOS:
968
- case OP_CBRAPOS:
969
- case OP_SCBRAPOS:
970
- case OP_ONCE:
971
- case OP_ONCE_NC:
972
- case OP_ASSERT:
973
- rc = set_start_bits(tcode, start_bits, utf, cd);
974
- if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
975
- if (rc == SSB_DONE) try_next = FALSE; else
976
- {
977
- do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
978
- tcode += 1 + LINK_SIZE;
979
- }
980
- break;
981
-
982
- /* If we hit ALT or KET, it means we haven't found anything mandatory in
983
- this branch, though we might have found something optional. For ALT, we
984
- continue with the next alternative, but we have to arrange that the final
985
- result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET,
986
- return SSB_CONTINUE: if this is the top level, that indicates failure,
987
- but after a nested subpattern, it causes scanning to continue. */
988
-
989
- case OP_ALT:
990
- yield = SSB_CONTINUE;
991
- try_next = FALSE;
992
- break;
993
-
994
- case OP_KET:
995
- case OP_KETRMAX:
996
- case OP_KETRMIN:
997
- case OP_KETRPOS:
998
- return SSB_CONTINUE;
999
-
1000
- /* Skip over callout */
1001
-
1002
- case OP_CALLOUT:
1003
- tcode += 2 + 2*LINK_SIZE;
1004
- break;
1005
-
1006
- /* Skip over lookbehind and negative lookahead assertions */
1007
-
1008
- case OP_ASSERT_NOT:
1009
- case OP_ASSERTBACK:
1010
- case OP_ASSERTBACK_NOT:
1011
- do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
1012
- tcode += 1 + LINK_SIZE;
1013
- break;
1014
-
1015
- /* BRAZERO does the bracket, but carries on. */
1016
-
1017
- case OP_BRAZERO:
1018
- case OP_BRAMINZERO:
1019
- case OP_BRAPOSZERO:
1020
- rc = set_start_bits(++tcode, start_bits, utf, cd);
1021
- if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
1022
- /* =========================================================================
1023
- See the comment at the head of this function concerning the next line,
1024
- which was an old fudge for the benefit of OS/2.
1025
- dummy = 1;
1026
- ========================================================================= */
1027
- do tcode += GET(tcode,1); while (*tcode == OP_ALT);
1028
- tcode += 1 + LINK_SIZE;
1029
- break;
1030
-
1031
- /* SKIPZERO skips the bracket. */
1032
-
1033
- case OP_SKIPZERO:
1034
- tcode++;
1035
- do tcode += GET(tcode,1); while (*tcode == OP_ALT);
1036
- tcode += 1 + LINK_SIZE;
1037
- break;
1038
-
1039
- /* Single-char * or ? sets the bit and tries the next item */
1040
-
1041
- case OP_STAR:
1042
- case OP_MINSTAR:
1043
- case OP_POSSTAR:
1044
- case OP_QUERY:
1045
- case OP_MINQUERY:
1046
- case OP_POSQUERY:
1047
- tcode = set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
1048
- break;
1049
-
1050
- case OP_STARI:
1051
- case OP_MINSTARI:
1052
- case OP_POSSTARI:
1053
- case OP_QUERYI:
1054
- case OP_MINQUERYI:
1055
- case OP_POSQUERYI:
1056
- tcode = set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
1057
- break;
1058
-
1059
- /* Single-char upto sets the bit and tries the next */
1060
-
1061
- case OP_UPTO:
1062
- case OP_MINUPTO:
1063
- case OP_POSUPTO:
1064
- tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, FALSE, cd, utf);
1065
- break;
1066
-
1067
- case OP_UPTOI:
1068
- case OP_MINUPTOI:
1069
- case OP_POSUPTOI:
1070
- tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, TRUE, cd, utf);
1071
- break;
1072
-
1073
- /* At least one single char sets the bit and stops */
1074
-
1075
- case OP_EXACT:
1076
- tcode += IMM2_SIZE;
1077
- /* Fall through */
1078
- case OP_CHAR:
1079
- case OP_PLUS:
1080
- case OP_MINPLUS:
1081
- case OP_POSPLUS:
1082
- (void)set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
1083
- try_next = FALSE;
1084
- break;
1085
-
1086
- case OP_EXACTI:
1087
- tcode += IMM2_SIZE;
1088
- /* Fall through */
1089
- case OP_CHARI:
1090
- case OP_PLUSI:
1091
- case OP_MINPLUSI:
1092
- case OP_POSPLUSI:
1093
- (void)set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
1094
- try_next = FALSE;
1095
- break;
1096
-
1097
- /* Special spacing and line-terminating items. These recognize specific
1098
- lists of characters. The difference between VSPACE and ANYNL is that the
1099
- latter can match the two-character CRLF sequence, but that is not
1100
- relevant for finding the first character, so their code here is
1101
- identical. */
1102
-
1103
- case OP_HSPACE:
1104
- SET_BIT(CHAR_HT);
1105
- SET_BIT(CHAR_SPACE);
1106
- #ifdef SUPPORT_UTF
1107
- if (utf)
1108
- {
1109
- #ifdef COMPILE_PCRE8
1110
- SET_BIT(0xC2); /* For U+00A0 */
1111
- SET_BIT(0xE1); /* For U+1680, U+180E */
1112
- SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */
1113
- SET_BIT(0xE3); /* For U+3000 */
1114
- #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1115
- SET_BIT(0xA0);
1116
- SET_BIT(0xFF); /* For characters > 255 */
1117
- #endif /* COMPILE_PCRE[8|16|32] */
1118
- }
1119
- else
1120
- #endif /* SUPPORT_UTF */
1121
- {
1122
- #ifndef EBCDIC
1123
- SET_BIT(0xA0);
1124
- #endif /* Not EBCDIC */
1125
- #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1126
- SET_BIT(0xFF); /* For characters > 255 */
1127
- #endif /* COMPILE_PCRE[16|32] */
1128
- }
1129
- try_next = FALSE;
1130
- break;
1131
-
1132
- case OP_ANYNL:
1133
- case OP_VSPACE:
1134
- SET_BIT(CHAR_LF);
1135
- SET_BIT(CHAR_VT);
1136
- SET_BIT(CHAR_FF);
1137
- SET_BIT(CHAR_CR);
1138
- #ifdef SUPPORT_UTF
1139
- if (utf)
1140
- {
1141
- #ifdef COMPILE_PCRE8
1142
- SET_BIT(0xC2); /* For U+0085 */
1143
- SET_BIT(0xE2); /* For U+2028, U+2029 */
1144
- #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1145
- SET_BIT(CHAR_NEL);
1146
- SET_BIT(0xFF); /* For characters > 255 */
1147
- #endif /* COMPILE_PCRE[8|16|32] */
1148
- }
1149
- else
1150
- #endif /* SUPPORT_UTF */
1151
- {
1152
- SET_BIT(CHAR_NEL);
1153
- #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1154
- SET_BIT(0xFF); /* For characters > 255 */
1155
- #endif
1156
- }
1157
- try_next = FALSE;
1158
- break;
1159
-
1160
- /* Single character types set the bits and stop. Note that if PCRE_UCP
1161
- is set, we do not see these op codes because \d etc are converted to
1162
- properties. Therefore, these apply in the case when only characters less
1163
- than 256 are recognized to match the types. */
1164
-
1165
- case OP_NOT_DIGIT:
1166
- set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
1167
- try_next = FALSE;
1168
- break;
1169
-
1170
- case OP_DIGIT:
1171
- set_type_bits(start_bits, cbit_digit, table_limit, cd);
1172
- try_next = FALSE;
1173
- break;
1174
-
1175
- /* The cbit_space table has vertical tab as whitespace; we no longer
1176
- have to play fancy tricks because Perl added VT to its whitespace at
1177
- release 5.18. PCRE added it at release 8.34. */
1178
-
1179
- case OP_NOT_WHITESPACE:
1180
- set_nottype_bits(start_bits, cbit_space, table_limit, cd);
1181
- try_next = FALSE;
1182
- break;
1183
-
1184
- case OP_WHITESPACE:
1185
- set_type_bits(start_bits, cbit_space, table_limit, cd);
1186
- try_next = FALSE;
1187
- break;
1188
-
1189
- case OP_NOT_WORDCHAR:
1190
- set_nottype_bits(start_bits, cbit_word, table_limit, cd);
1191
- try_next = FALSE;
1192
- break;
1193
-
1194
- case OP_WORDCHAR:
1195
- set_type_bits(start_bits, cbit_word, table_limit, cd);
1196
- try_next = FALSE;
1197
- break;
1198
-
1199
- /* One or more character type fudges the pointer and restarts, knowing
1200
- it will hit a single character type and stop there. */
1201
-
1202
- case OP_TYPEPLUS:
1203
- case OP_TYPEMINPLUS:
1204
- case OP_TYPEPOSPLUS:
1205
- tcode++;
1206
- break;
1207
-
1208
- case OP_TYPEEXACT:
1209
- tcode += 1 + IMM2_SIZE;
1210
- break;
1211
-
1212
- /* Zero or more repeats of character types set the bits and then
1213
- try again. */
1214
-
1215
- case OP_TYPEUPTO:
1216
- case OP_TYPEMINUPTO:
1217
- case OP_TYPEPOSUPTO:
1218
- tcode += IMM2_SIZE; /* Fall through */
1219
-
1220
- case OP_TYPESTAR:
1221
- case OP_TYPEMINSTAR:
1222
- case OP_TYPEPOSSTAR:
1223
- case OP_TYPEQUERY:
1224
- case OP_TYPEMINQUERY:
1225
- case OP_TYPEPOSQUERY:
1226
- switch(tcode[1])
1227
- {
1228
- default:
1229
- case OP_ANY:
1230
- case OP_ALLANY:
1231
- return SSB_FAIL;
1232
-
1233
- case OP_HSPACE:
1234
- SET_BIT(CHAR_HT);
1235
- SET_BIT(CHAR_SPACE);
1236
- #ifdef SUPPORT_UTF
1237
- if (utf)
1238
- {
1239
- #ifdef COMPILE_PCRE8
1240
- SET_BIT(0xC2); /* For U+00A0 */
1241
- SET_BIT(0xE1); /* For U+1680, U+180E */
1242
- SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */
1243
- SET_BIT(0xE3); /* For U+3000 */
1244
- #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1245
- SET_BIT(0xA0);
1246
- SET_BIT(0xFF); /* For characters > 255 */
1247
- #endif /* COMPILE_PCRE[8|16|32] */
1248
- }
1249
- else
1250
- #endif /* SUPPORT_UTF */
1251
- #ifndef EBCDIC
1252
- SET_BIT(0xA0);
1253
- #endif /* Not EBCDIC */
1254
- break;
1255
-
1256
- case OP_ANYNL:
1257
- case OP_VSPACE:
1258
- SET_BIT(CHAR_LF);
1259
- SET_BIT(CHAR_VT);
1260
- SET_BIT(CHAR_FF);
1261
- SET_BIT(CHAR_CR);
1262
- #ifdef SUPPORT_UTF
1263
- if (utf)
1264
- {
1265
- #ifdef COMPILE_PCRE8
1266
- SET_BIT(0xC2); /* For U+0085 */
1267
- SET_BIT(0xE2); /* For U+2028, U+2029 */
1268
- #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1269
- SET_BIT(CHAR_NEL);
1270
- SET_BIT(0xFF); /* For characters > 255 */
1271
- #endif /* COMPILE_PCRE16 */
1272
- }
1273
- else
1274
- #endif /* SUPPORT_UTF */
1275
- SET_BIT(CHAR_NEL);
1276
- break;
1277
-
1278
- case OP_NOT_DIGIT:
1279
- set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
1280
- break;
1281
-
1282
- case OP_DIGIT:
1283
- set_type_bits(start_bits, cbit_digit, table_limit, cd);
1284
- break;
1285
-
1286
- /* The cbit_space table has vertical tab as whitespace; we no longer
1287
- have to play fancy tricks because Perl added VT to its whitespace at
1288
- release 5.18. PCRE added it at release 8.34. */
1289
-
1290
- case OP_NOT_WHITESPACE:
1291
- set_nottype_bits(start_bits, cbit_space, table_limit, cd);
1292
- break;
1293
-
1294
- case OP_WHITESPACE:
1295
- set_type_bits(start_bits, cbit_space, table_limit, cd);
1296
- break;
1297
-
1298
- case OP_NOT_WORDCHAR:
1299
- set_nottype_bits(start_bits, cbit_word, table_limit, cd);
1300
- break;
1301
-
1302
- case OP_WORDCHAR:
1303
- set_type_bits(start_bits, cbit_word, table_limit, cd);
1304
- break;
1305
- }
1306
-
1307
- tcode += 2;
1308
- break;
1309
-
1310
- /* Character class where all the information is in a bit map: set the
1311
- bits and either carry on or not, according to the repeat count. If it was
1312
- a negative class, and we are operating with UTF-8 characters, any byte
1313
- with a value >= 0xc4 is a potentially valid starter because it starts a
1314
- character with a value > 255. */
1315
-
1316
- #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
1317
- case OP_XCLASS:
1318
- if ((tcode[1 + LINK_SIZE] & XCL_HASPROP) != 0)
1319
- return SSB_FAIL;
1320
- /* All bits are set. */
1321
- if ((tcode[1 + LINK_SIZE] & XCL_MAP) == 0 && (tcode[1 + LINK_SIZE] & XCL_NOT) != 0)
1322
- return SSB_FAIL;
1323
- #endif
1324
- /* Fall through */
1325
-
1326
- case OP_NCLASS:
1327
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1328
- if (utf)
1329
- {
1330
- start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
1331
- memset(start_bits+25, 0xff, 7); /* Bits for 0xc9 - 0xff */
1332
- }
1333
- #endif
1334
- #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1335
- SET_BIT(0xFF); /* For characters > 255 */
1336
- #endif
1337
- /* Fall through */
1338
-
1339
- case OP_CLASS:
1340
- {
1341
- pcre_uint8 *map;
1342
- #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
1343
- map = NULL;
1344
- if (*tcode == OP_XCLASS)
1345
- {
1346
- if ((tcode[1 + LINK_SIZE] & XCL_MAP) != 0)
1347
- map = (pcre_uint8 *)(tcode + 1 + LINK_SIZE + 1);
1348
- tcode += GET(tcode, 1);
1349
- }
1350
- else
1351
- #endif
1352
- {
1353
- tcode++;
1354
- map = (pcre_uint8 *)tcode;
1355
- tcode += 32 / sizeof(pcre_uchar);
1356
- }
1357
-
1358
- /* In UTF-8 mode, the bits in a bit map correspond to character
1359
- values, not to byte values. However, the bit map we are constructing is
1360
- for byte values. So we have to do a conversion for characters whose
1361
- value is > 127. In fact, there are only two possible starting bytes for
1362
- characters in the range 128 - 255. */
1363
-
1364
- #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
1365
- if (map != NULL)
1366
- #endif
1367
- {
1368
- #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1369
- if (utf)
1370
- {
1371
- for (c = 0; c < 16; c++) start_bits[c] |= map[c];
1372
- for (c = 128; c < 256; c++)
1373
- {
1374
- if ((map[c/8] & (1 << (c&7))) != 0)
1375
- {
1376
- int d = (c >> 6) | 0xc0; /* Set bit for this starter */
1377
- start_bits[d/8] |= (1 << (d&7)); /* and then skip on to the */
1378
- c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */
1379
- }
1380
- }
1381
- }
1382
- else
1383
- #endif
1384
- {
1385
- /* In non-UTF-8 mode, the two bit maps are completely compatible. */
1386
- for (c = 0; c < 32; c++) start_bits[c] |= map[c];
1387
- }
1388
- }
1389
-
1390
- /* Advance past the bit map, and act on what follows. For a zero
1391
- minimum repeat, continue; otherwise stop processing. */
1392
-
1393
- switch (*tcode)
1394
- {
1395
- case OP_CRSTAR:
1396
- case OP_CRMINSTAR:
1397
- case OP_CRQUERY:
1398
- case OP_CRMINQUERY:
1399
- case OP_CRPOSSTAR:
1400
- case OP_CRPOSQUERY:
1401
- tcode++;
1402
- break;
1403
-
1404
- case OP_CRRANGE:
1405
- case OP_CRMINRANGE:
1406
- case OP_CRPOSRANGE:
1407
- if (GET2(tcode, 1) == 0) tcode += 1 + 2 * IMM2_SIZE;
1408
- else try_next = FALSE;
1409
- break;
1410
-
1411
- default:
1412
- try_next = FALSE;
1413
- break;
1414
- }
1415
- }
1416
- break; /* End of bitmap class handling */
1417
-
1418
- } /* End of switch */
1419
- } /* End of try_next loop */
1420
-
1421
- code += GET(code, 1); /* Advance to next branch */
1422
- }
1423
- while (*code == OP_ALT);
1424
- return yield;
1425
- }
1426
-
1427
-
1428
-
1429
-
1430
-
1431
- /*************************************************
1432
- * Study a compiled expression *
1433
- *************************************************/
1434
-
1435
- /* This function is handed a compiled expression that it must study to produce
1436
- information that will speed up the matching. It returns a pcre[16]_extra block
1437
- which then gets handed back to pcre_exec().
1438
-
1439
- Arguments:
1440
- re points to the compiled expression
1441
- options contains option bits
1442
- errorptr points to where to place error messages;
1443
- set NULL unless error
1444
-
1445
- Returns: pointer to a pcre[16]_extra block, with study_data filled in and
1446
- the appropriate flags set;
1447
- NULL on error or if no optimization possible
1448
- */
1449
-
1450
- #if defined COMPILE_PCRE8
1451
- PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
1452
- pcre_study(const pcre *external_re, int options, const char **errorptr)
1453
- #elif defined COMPILE_PCRE16
1454
- PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION
1455
- pcre16_study(const pcre16 *external_re, int options, const char **errorptr)
1456
- #elif defined COMPILE_PCRE32
1457
- PCRE_EXP_DEFN pcre32_extra * PCRE_CALL_CONVENTION
1458
- pcre32_study(const pcre32 *external_re, int options, const char **errorptr)
1459
- #endif
1460
- {
1461
- int min;
1462
- int count = 0;
1463
- BOOL bits_set = FALSE;
1464
- pcre_uint8 start_bits[32];
1465
- PUBL(extra) *extra = NULL;
1466
- pcre_study_data *study;
1467
- const pcre_uint8 *tables;
1468
- pcre_uchar *code;
1469
- compile_data compile_block;
1470
- const REAL_PCRE *re = (const REAL_PCRE *)external_re;
1471
-
1472
-
1473
- *errorptr = NULL;
1474
-
1475
- if (re == NULL || re->magic_number != MAGIC_NUMBER)
1476
- {
1477
- *errorptr = "argument is not a compiled regular expression";
1478
- return NULL;
1479
- }
1480
-
1481
- if ((re->flags & PCRE_MODE) == 0)
1482
- {
1483
- #if defined COMPILE_PCRE8
1484
- *errorptr = "argument not compiled in 8 bit mode";
1485
- #elif defined COMPILE_PCRE16
1486
- *errorptr = "argument not compiled in 16 bit mode";
1487
- #elif defined COMPILE_PCRE32
1488
- *errorptr = "argument not compiled in 32 bit mode";
1489
- #endif
1490
- return NULL;
1491
- }
1492
-
1493
- if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
1494
- {
1495
- *errorptr = "unknown or incorrect option bit(s) set";
1496
- return NULL;
1497
- }
1498
-
1499
- code = (pcre_uchar *)re + re->name_table_offset +
1500
- (re->name_count * re->name_entry_size);
1501
-
1502
- /* For an anchored pattern, or an unanchored pattern that has a first char, or
1503
- a multiline pattern that matches only at "line starts", there is no point in
1504
- seeking a list of starting bytes. */
1505
-
1506
- if ((re->options & PCRE_ANCHORED) == 0 &&
1507
- (re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) == 0)
1508
- {
1509
- int rc;
1510
-
1511
- /* Set the character tables in the block that is passed around */
1512
-
1513
- tables = re->tables;
1514
-
1515
- #if defined COMPILE_PCRE8
1516
- if (tables == NULL)
1517
- (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1518
- (void *)(&tables));
1519
- #elif defined COMPILE_PCRE16
1520
- if (tables == NULL)
1521
- (void)pcre16_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1522
- (void *)(&tables));
1523
- #elif defined COMPILE_PCRE32
1524
- if (tables == NULL)
1525
- (void)pcre32_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1526
- (void *)(&tables));
1527
- #endif
1528
-
1529
- compile_block.lcc = tables + lcc_offset;
1530
- compile_block.fcc = tables + fcc_offset;
1531
- compile_block.cbits = tables + cbits_offset;
1532
- compile_block.ctypes = tables + ctypes_offset;
1533
-
1534
- /* See if we can find a fixed set of initial characters for the pattern. */
1535
-
1536
- memset(start_bits, 0, 32 * sizeof(pcre_uint8));
1537
- rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,
1538
- &compile_block);
1539
- bits_set = rc == SSB_DONE;
1540
- if (rc == SSB_UNKNOWN)
1541
- {
1542
- *errorptr = "internal error: opcode not recognized";
1543
- return NULL;
1544
- }
1545
- }
1546
-
1547
- /* Find the minimum length of subject string. */
1548
-
1549
- switch(min = find_minlength(re, code, code, re->options, NULL, &count))
1550
- {
1551
- case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
1552
- case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
1553
- default: break;
1554
- }
1555
-
1556
- /* If a set of starting bytes has been identified, or if the minimum length is
1557
- greater than zero, or if JIT optimization has been requested, or if
1558
- PCRE_STUDY_EXTRA_NEEDED is set, get a pcre[16]_extra block and a
1559
- pcre_study_data block. The study data is put in the latter, which is pointed to
1560
- by the former, which may also get additional data set later by the calling
1561
- program. At the moment, the size of pcre_study_data is fixed. We nevertheless
1562
- save it in a field for returning via the pcre_fullinfo() function so that if it
1563
- becomes variable in the future, we don't have to change that code. */
1564
-
1565
- if (bits_set || min > 0 || (options & (
1566
- #ifdef SUPPORT_JIT
1567
- PCRE_STUDY_JIT_COMPILE | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE |
1568
- PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
1569
- #endif
1570
- PCRE_STUDY_EXTRA_NEEDED)) != 0)
1571
- {
1572
- extra = (PUBL(extra) *)(PUBL(malloc))
1573
- (sizeof(PUBL(extra)) + sizeof(pcre_study_data));
1574
- if (extra == NULL)
1575
- {
1576
- *errorptr = "failed to get memory";
1577
- return NULL;
1578
- }
1579
-
1580
- study = (pcre_study_data *)((char *)extra + sizeof(PUBL(extra)));
1581
- extra->flags = PCRE_EXTRA_STUDY_DATA;
1582
- extra->study_data = study;
1583
-
1584
- study->size = sizeof(pcre_study_data);
1585
- study->flags = 0;
1586
-
1587
- /* Set the start bits always, to avoid unset memory errors if the
1588
- study data is written to a file, but set the flag only if any of the bits
1589
- are set, to save time looking when none are. */
1590
-
1591
- if (bits_set)
1592
- {
1593
- study->flags |= PCRE_STUDY_MAPPED;
1594
- memcpy(study->start_bits, start_bits, sizeof(start_bits));
1595
- }
1596
- else memset(study->start_bits, 0, 32 * sizeof(pcre_uint8));
1597
-
1598
- #ifdef PCRE_DEBUG
1599
- if (bits_set)
1600
- {
1601
- pcre_uint8 *ptr = start_bits;
1602
- int i;
1603
-
1604
- printf("Start bits:\n");
1605
- for (i = 0; i < 32; i++)
1606
- printf("%3d: %02x%s", i * 8, *ptr++, ((i + 1) & 0x7) != 0? " " : "\n");
1607
- }
1608
- #endif
1609
-
1610
- /* Always set the minlength value in the block, because the JIT compiler
1611
- makes use of it. However, don't set the bit unless the length is greater than
1612
- zero - the interpretive pcre_exec() and pcre_dfa_exec() needn't waste time
1613
- checking the zero case. */
1614
-
1615
- if (min > 0)
1616
- {
1617
- study->flags |= PCRE_STUDY_MINLEN;
1618
- study->minlength = min;
1619
- }
1620
- else study->minlength = 0;
1621
-
1622
- /* If JIT support was compiled and requested, attempt the JIT compilation.
1623
- If no starting bytes were found, and the minimum length is zero, and JIT
1624
- compilation fails, abandon the extra block and return NULL, unless
1625
- PCRE_STUDY_EXTRA_NEEDED is set. */
1626
-
1627
- #ifdef SUPPORT_JIT
1628
- extra->executable_jit = NULL;
1629
- if ((options & PCRE_STUDY_JIT_COMPILE) != 0)
1630
- PRIV(jit_compile)(re, extra, JIT_COMPILE);
1631
- if ((options & PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE) != 0)
1632
- PRIV(jit_compile)(re, extra, JIT_PARTIAL_SOFT_COMPILE);
1633
- if ((options & PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE) != 0)
1634
- PRIV(jit_compile)(re, extra, JIT_PARTIAL_HARD_COMPILE);
1635
-
1636
- if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0 &&
1637
- (options & PCRE_STUDY_EXTRA_NEEDED) == 0)
1638
- {
1639
- #if defined COMPILE_PCRE8
1640
- pcre_free_study(extra);
1641
- #elif defined COMPILE_PCRE16
1642
- pcre16_free_study(extra);
1643
- #elif defined COMPILE_PCRE32
1644
- pcre32_free_study(extra);
1645
- #endif
1646
- extra = NULL;
1647
- }
1648
- #endif
1649
- }
1650
-
1651
- return extra;
1652
- }
1653
-
1654
-
1655
- /*************************************************
1656
- * Free the study data *
1657
- *************************************************/
1658
-
1659
- /* This function frees the memory that was obtained by pcre_study().
1660
-
1661
- Argument: a pointer to the pcre[16]_extra block
1662
- Returns: nothing
1663
- */
1664
-
1665
- #if defined COMPILE_PCRE8
1666
- PCRE_EXP_DEFN void
1667
- pcre_free_study(pcre_extra *extra)
1668
- #elif defined COMPILE_PCRE16
1669
- PCRE_EXP_DEFN void
1670
- pcre16_free_study(pcre16_extra *extra)
1671
- #elif defined COMPILE_PCRE32
1672
- PCRE_EXP_DEFN void
1673
- pcre32_free_study(pcre32_extra *extra)
1674
- #endif
1675
- {
1676
- if (extra == NULL)
1677
- return;
1678
- #ifdef SUPPORT_JIT
1679
- if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
1680
- extra->executable_jit != NULL)
1681
- PRIV(jit_free)(extra->executable_jit);
1682
- #endif
1683
- PUBL(free)(extra);
1684
- }
1685
-
1686
- /* End of pcre_study.c */