debase-ruby_core_source 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/debase/ruby_core_source.rb +1 -0
  4. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/addr2line.h +21 -0
  5. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ccan/list/list.h +635 -0
  9. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ccan/str/str.h +16 -0
  10. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/constant.h +43 -0
  11. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/dln.h +51 -0
  12. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/eval_intern.h +275 -0
  13. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/gc.h +107 -0
  14. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/id.h +210 -0
  15. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/insns.inc +107 -0
  16. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/insns_info.inc +752 -0
  17. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/internal.h +1197 -0
  18. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/iseq.h +158 -0
  19. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/known_errors.inc +746 -0
  20. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/method.h +144 -0
  21. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/node.h +544 -0
  22. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/node_name.inc +212 -0
  23. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/opt_sc.inc +734 -0
  24. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/optinsn.inc +83 -0
  25. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/optunifs.inc +124 -0
  26. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/parse.h +184 -0
  27. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/probes_helper.h +67 -0
  28. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/regenc.h +234 -0
  29. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/regint.h +972 -0
  30. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/regparse.h +363 -0
  31. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/revision.h +1 -0
  32. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/ruby_atomic.h +170 -0
  33. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/siphash.h +48 -0
  34. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/symbol.h +88 -0
  35. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/thread_pthread.h +54 -0
  36. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/thread_win32.h +36 -0
  37. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/timev.h +42 -0
  38. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/transcode_data.h +123 -0
  39. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/version.h +52 -0
  40. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm.inc +3369 -0
  41. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm_core.h +1163 -0
  42. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm_debug.h +37 -0
  43. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm_exec.h +182 -0
  44. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm_insnhelper.h +233 -0
  45. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vm_opts.h +56 -0
  46. data/lib/debase/ruby_core_source/ruby-2.2.6-p396/vmtc.inc +105 -0
  47. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/addr2line.h +21 -0
  48. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ccan/build_assert/build_assert.h +40 -0
  49. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ccan/check_type/check_type.h +63 -0
  50. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ccan/container_of/container_of.h +142 -0
  51. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ccan/list/list.h +773 -0
  52. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ccan/str/str.h +16 -0
  53. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/constant.h +50 -0
  54. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/dln.h +51 -0
  55. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/encindex.h +67 -0
  56. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/eval_intern.h +304 -0
  57. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/gc.h +114 -0
  58. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/id.h +211 -0
  59. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/id_table.h +30 -0
  60. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/insns.inc +110 -0
  61. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/insns_info.inc +776 -0
  62. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/internal.h +1406 -0
  63. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/iseq.h +249 -0
  64. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/known_errors.inc +746 -0
  65. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/method.h +213 -0
  66. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/node.h +520 -0
  67. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/node_name.inc +208 -0
  68. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/opt_sc.inc +758 -0
  69. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/optinsn.inc +83 -0
  70. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/optunifs.inc +127 -0
  71. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/parse.h +185 -0
  72. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/probes_helper.h +43 -0
  73. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/regenc.h +234 -0
  74. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/regint.h +987 -0
  75. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/regparse.h +367 -0
  76. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/revision.h +1 -0
  77. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/ruby_atomic.h +233 -0
  78. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/siphash.h +48 -0
  79. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/symbol.h +108 -0
  80. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/thread_pthread.h +54 -0
  81. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/thread_win32.h +36 -0
  82. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/timev.h +42 -0
  83. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/transcode_data.h +139 -0
  84. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/version.h +55 -0
  85. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm.inc +3411 -0
  86. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_call_iseq_optimized.inc +212 -0
  87. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_core.h +1240 -0
  88. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_debug.h +37 -0
  89. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_exec.h +182 -0
  90. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_insnhelper.h +227 -0
  91. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vm_opts.h +57 -0
  92. data/lib/debase/ruby_core_source/ruby-2.3.2-p217/vmtc.inc +108 -0
  93. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/addr2line.h +21 -0
  94. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ccan/build_assert/build_assert.h +40 -0
  95. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ccan/check_type/check_type.h +63 -0
  96. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ccan/container_of/container_of.h +142 -0
  97. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ccan/list/list.h +773 -0
  98. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ccan/str/str.h +16 -0
  99. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/constant.h +50 -0
  100. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/dln.h +51 -0
  101. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/encindex.h +67 -0
  102. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/eval_intern.h +315 -0
  103. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/gc.h +114 -0
  104. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/id.h +220 -0
  105. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/id_table.h +31 -0
  106. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/insns.inc +112 -0
  107. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/insns_info.inc +796 -0
  108. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/internal.h +1725 -0
  109. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/iseq.h +252 -0
  110. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/known_errors.inc +746 -0
  111. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/method.h +213 -0
  112. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/node.h +520 -0
  113. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/node_name.inc +208 -0
  114. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/opt_sc.inc +774 -0
  115. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/optinsn.inc +83 -0
  116. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/optunifs.inc +129 -0
  117. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/parse.h +204 -0
  118. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/probes_helper.h +43 -0
  119. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/regenc.h +237 -0
  120. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/regint.h +995 -0
  121. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/regparse.h +367 -0
  122. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/revision.h +1 -0
  123. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ruby_assert.h +54 -0
  124. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/ruby_atomic.h +233 -0
  125. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/siphash.h +48 -0
  126. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/symbol.h +108 -0
  127. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/thread_pthread.h +54 -0
  128. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/thread_win32.h +36 -0
  129. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/timev.h +42 -0
  130. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/transcode_data.h +139 -0
  131. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/version.h +73 -0
  132. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm.inc +3412 -0
  133. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_call_iseq_optimized.inc +212 -0
  134. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_core.h +1644 -0
  135. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_debug.h +37 -0
  136. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_exec.h +182 -0
  137. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_insnhelper.h +227 -0
  138. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vm_opts.h +57 -0
  139. data/lib/debase/ruby_core_source/ruby-2.4.0-preview3/vmtc.inc +110 -0
  140. data/lib/debase/ruby_core_source/version.rb +1 -1
  141. metadata +139 -3
@@ -0,0 +1,237 @@
1
+ #ifndef ONIGURUMA_REGENC_H
2
+ #define ONIGURUMA_REGENC_H
3
+ /**********************************************************************
4
+ regenc.h - Onigmo (Oniguruma-mod) (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * Copyright (c) 2011 K.Takata <kentkt AT csc DOT jp>
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ #ifndef REGINT_H
34
+ #ifndef RUBY_EXTERN
35
+ #include "ruby/config.h"
36
+ #include "ruby/defines.h"
37
+ #endif
38
+ #endif
39
+
40
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
41
+ #undef ONIG_ESCAPE_UCHAR_COLLISION
42
+ #endif
43
+
44
+ #include "ruby/oniguruma.h"
45
+
46
+ RUBY_SYMBOL_EXPORT_BEGIN
47
+
48
+ typedef struct {
49
+ OnigCodePoint from;
50
+ OnigCodePoint to;
51
+ } OnigPairCaseFoldCodes;
52
+
53
+
54
+ #ifndef NULL
55
+ #define NULL ((void* )0)
56
+ #endif
57
+
58
+ #ifndef TRUE
59
+ #define TRUE 1
60
+ #endif
61
+
62
+ #ifndef FALSE
63
+ #define FALSE 0
64
+ #endif
65
+
66
+ #ifndef ARG_UNUSED
67
+ #if defined(__GNUC__)
68
+ # define ARG_UNUSED __attribute__ ((unused))
69
+ #else
70
+ # define ARG_UNUSED
71
+ #endif
72
+ #endif
73
+
74
+ #define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
75
+ #define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
76
+ #define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
77
+ #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
78
+
79
+ #define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? enc->min_enc_len : ONIGENC_MBC_ENC_LEN(enc,p,e))
80
+
81
+ /* character types bit flag */
82
+ #define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
83
+ #define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
84
+ #define BIT_CTYPE_BLANK (1<< ONIGENC_CTYPE_BLANK)
85
+ #define BIT_CTYPE_CNTRL (1<< ONIGENC_CTYPE_CNTRL)
86
+ #define BIT_CTYPE_DIGIT (1<< ONIGENC_CTYPE_DIGIT)
87
+ #define BIT_CTYPE_GRAPH (1<< ONIGENC_CTYPE_GRAPH)
88
+ #define BIT_CTYPE_LOWER (1<< ONIGENC_CTYPE_LOWER)
89
+ #define BIT_CTYPE_PRINT (1<< ONIGENC_CTYPE_PRINT)
90
+ #define BIT_CTYPE_PUNCT (1<< ONIGENC_CTYPE_PUNCT)
91
+ #define BIT_CTYPE_SPACE (1<< ONIGENC_CTYPE_SPACE)
92
+ #define BIT_CTYPE_UPPER (1<< ONIGENC_CTYPE_UPPER)
93
+ #define BIT_CTYPE_XDIGIT (1<< ONIGENC_CTYPE_XDIGIT)
94
+ #define BIT_CTYPE_WORD (1<< ONIGENC_CTYPE_WORD)
95
+ #define BIT_CTYPE_ALNUM (1<< ONIGENC_CTYPE_ALNUM)
96
+ #define BIT_CTYPE_ASCII (1<< ONIGENC_CTYPE_ASCII)
97
+
98
+ #define CTYPE_TO_BIT(ctype) (1<<(ctype))
99
+ #define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \
100
+ ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\
101
+ (ctype) == ONIGENC_CTYPE_PRINT)
102
+
103
+
104
+ typedef struct {
105
+ short int len;
106
+ const UChar name[6];
107
+ int ctype;
108
+ } PosixBracketEntryType;
109
+
110
+ #define POSIX_BRACKET_ENTRY_INIT(name, ctype) \
111
+ {(short int )(sizeof(name) - 1), (name), (ctype)}
112
+
113
+ #ifndef numberof
114
+ #define numberof(array) (int )(sizeof(array) / sizeof((array)[0]))
115
+ #endif
116
+
117
+
118
+ #define USE_CRNL_AS_LINE_TERMINATOR
119
+ #define USE_UNICODE_PROPERTIES
120
+ #define USE_UNICODE_AGE_PROPERTIES
121
+ /* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */
122
+ /* #define USE_UNICODE_ALL_LINE_TERMINATORS */ /* see Unicode.org UTS #18 */
123
+
124
+
125
+ #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII
126
+
127
+ /* for encoding system implementation (internal) */
128
+ ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
129
+ ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
130
+ ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
131
+ ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
132
+ CONSTFUNC(ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc)));
133
+ PUREFUNC(ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc)));
134
+ ONIG_EXTERN int onigenc_single_byte_ascii_only_case_map P_((OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc));
135
+
136
+
137
+ /* methods for single byte encoding */
138
+ ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower, OnigEncoding enc));
139
+ CONSTFUNC(ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p, const UChar* e, OnigEncoding enc)));
140
+ PUREFUNC(ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end, OnigEncoding enc)));
141
+ CONSTFUNC(ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc)));
142
+ ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf, OnigEncoding enc));
143
+ CONSTFUNC(ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s, const OnigUChar* end, OnigEncoding enc)));
144
+ CONSTFUNC(ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc)));
145
+ CONSTFUNC(ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc)));
146
+ CONSTFUNC(ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc)));
147
+
148
+ /* methods for multi byte encoding */
149
+ ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
150
+ ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
151
+ CONSTFUNC(ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc)));
152
+ ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
153
+ ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, const UChar* p, const UChar* end));
154
+ ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, const UChar* p, const UChar* end));
155
+ ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
156
+ CONSTFUNC(ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc)));
157
+ ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
158
+ ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
159
+
160
+ ONIG_EXTERN int onigenc_unicode_case_map P_((OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc));
161
+
162
+
163
+ /* in enc/unicode.c */
164
+ ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
165
+ ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
166
+ ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
167
+ ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
168
+ ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
169
+ ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
170
+
171
+
172
+ #define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8)
173
+ #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc)
174
+ #define UTF16_IS_SURROGATE(c) (((c) & 0xf8) == 0xd8)
175
+
176
+ #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
177
+ OnigEncISO_8859_1_ToLowerCaseTable[c]
178
+ #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
179
+ OnigEncISO_8859_1_ToUpperCaseTable[c]
180
+
181
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
182
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
183
+
184
+ ONIG_EXTERN int
185
+ onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
186
+ ONIG_EXTERN int
187
+ onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
188
+ ONIG_EXTERN UChar*
189
+ onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
190
+
191
+ /* defined in regexec.c, but used in enc/xxx.c */
192
+ extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
193
+
194
+ ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
195
+ ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[];
196
+ ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[];
197
+ ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
198
+
199
+ #define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80)
200
+ #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
201
+ #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
202
+ #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
203
+ ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
204
+ #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
205
+ (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
206
+ ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
207
+
208
+ /* Check if the code is in the range. (from <= code && code <= to) */
209
+ #define ONIGENC_IS_IN_RANGE(code, from, to) \
210
+ ((OnigCodePoint )((code) - (from)) <= (OnigCodePoint )((to) - (from)))
211
+
212
+
213
+ #ifdef ONIG_ENC_REGISTER
214
+ extern int ONIG_ENC_REGISTER(const char *, OnigEncoding);
215
+ #define OnigEncodingName(n) encoding_##n
216
+ #define OnigEncodingDeclare(n) static const OnigEncodingType OnigEncodingName(n)
217
+ #define OnigEncodingDefine(f,n) \
218
+ OnigEncodingDeclare(n); \
219
+ void Init_##f(void) { \
220
+ ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
221
+ &OnigEncodingName(n)); \
222
+ } \
223
+ OnigEncodingDeclare(n)
224
+ #else
225
+ #define OnigEncodingName(n) OnigEncoding##n
226
+ #define OnigEncodingDeclare(n) const OnigEncodingType OnigEncodingName(n)
227
+ #define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
228
+ #endif
229
+
230
+ /* macros for define replica encoding and encoding alias */
231
+ #define ENC_REPLICATE(name, orig)
232
+ #define ENC_ALIAS(name, orig)
233
+ #define ENC_DUMMY(name)
234
+
235
+ RUBY_SYMBOL_EXPORT_END
236
+
237
+ #endif /* ONIGURUMA_REGENC_H */
@@ -0,0 +1,995 @@
1
+ #ifndef ONIGURUMA_REGINT_H
2
+ #define ONIGURUMA_REGINT_H
3
+ /**********************************************************************
4
+ regint.h - Onigmo (Oniguruma-mod) (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2013 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * Copyright (c) 2011-2014 K.Takata <kentkt AT csc DOT jp>
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /* for debug */
34
+ /* #define ONIG_DEBUG_PARSE_TREE */
35
+ /* #define ONIG_DEBUG_COMPILE */
36
+ /* #define ONIG_DEBUG_SEARCH */
37
+ /* #define ONIG_DEBUG_MATCH */
38
+ /* #define ONIG_DONT_OPTIMIZE */
39
+
40
+ /* for byte-code statistical data. */
41
+ /* #define ONIG_DEBUG_STATISTICS */
42
+
43
+ #if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
44
+ defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
45
+ defined(ONIG_DEBUG_STATISTICS)
46
+ #ifndef ONIG_DEBUG
47
+ #define ONIG_DEBUG
48
+ #endif
49
+ #endif
50
+
51
+ #ifndef UNALIGNED_WORD_ACCESS
52
+ #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
53
+ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
54
+ defined(__powerpc64__) || \
55
+ defined(__mc68020__)
56
+ #define UNALIGNED_WORD_ACCESS 1
57
+ #else
58
+ #define UNALIGNED_WORD_ACCESS 0
59
+ #endif
60
+ #endif
61
+
62
+ #if UNALIGNED_WORD_ACCESS
63
+ #define PLATFORM_UNALIGNED_WORD_ACCESS
64
+ #endif
65
+
66
+ /* config */
67
+ /* spec. config */
68
+ #define USE_NAMED_GROUP
69
+ #define USE_SUBEXP_CALL
70
+ #define USE_PERL_SUBEXP_CALL
71
+ #define USE_CAPITAL_P_NAMED_GROUP
72
+ #define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
73
+ #define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
74
+ #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
75
+ #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
76
+ /* #define USE_RECOMPILE_API */
77
+ /* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
78
+ #define USE_NO_INVALID_QUANTIFIER
79
+
80
+ /* internal config */
81
+ #define USE_PARSE_TREE_NODE_RECYCLE
82
+ #define USE_OP_PUSH_OR_JUMP_EXACT
83
+ #define USE_QTFR_PEEK_NEXT
84
+ #define USE_ST_LIBRARY
85
+ #define USE_SHARED_CCLASS_TABLE
86
+ #define USE_SUNDAY_QUICK_SEARCH
87
+
88
+ #define INIT_MATCH_STACK_SIZE 160
89
+ #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
90
+
91
+ /* check config */
92
+ #if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
93
+ #if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
94
+ #error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
95
+ #endif
96
+ #endif
97
+
98
+ #if defined(__GNUC__)
99
+ # define ARG_UNUSED __attribute__ ((unused))
100
+ #else
101
+ # define ARG_UNUSED
102
+ #endif
103
+
104
+ #ifndef RUBY_DEFINES_H
105
+ #include "ruby/ruby.h"
106
+ #undef xmalloc
107
+ #undef xrealloc
108
+ #undef xcalloc
109
+ #undef xfree
110
+ #endif
111
+
112
+ /* */
113
+ /* escape other system UChar definition */
114
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
115
+ #undef ONIG_ESCAPE_UCHAR_COLLISION
116
+ #endif
117
+
118
+ #define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
119
+ #undef USE_CAPTURE_HISTORY
120
+ #define USE_VARIABLE_META_CHARS
121
+ #define USE_POSIX_API_REGION_OPTION /* needed for POSIX API support */
122
+ #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
123
+ /* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
124
+
125
+ /* multithread config */
126
+ /* #define USE_MULTI_THREAD_SYSTEM */
127
+ /* #define USE_DEFAULT_MULTI_THREAD_SYSTEM */
128
+
129
+ #if defined(USE_MULTI_THREAD_SYSTEM) \
130
+ && defined(USE_DEFAULT_MULTI_THREAD_SYSTEM)
131
+
132
+ #ifdef _WIN32
133
+ #define WIN32_LEAN_AND_MEAN
134
+ #include <windows.h>
135
+ extern CRITICAL_SECTION gOnigMutex;
136
+ #define THREAD_SYSTEM_INIT InitializeCriticalSection(&gOnigMutex)
137
+ #define THREAD_SYSTEM_END DeleteCriticalSection(&gOnigMutex)
138
+ #define THREAD_ATOMIC_START EnterCriticalSection(&gOnigMutex)
139
+ #define THREAD_ATOMIC_END LeaveCriticalSection(&gOnigMutex)
140
+ #define THREAD_PASS Sleep(0)
141
+ #else /* _WIN32 */
142
+ #include <pthread.h>
143
+ #include <sched.h>
144
+ extern pthread_mutex_t gOnigMutex;
145
+ #define THREAD_SYSTEM_INIT pthread_mutex_init(&gOnigMutex, NULL)
146
+ #define THREAD_SYSTEM_END pthread_mutex_destroy(&gOnigMutex)
147
+ #define THREAD_ATOMIC_START pthread_mutex_lock(&gOnigMutex)
148
+ #define THREAD_ATOMIC_END pthread_mutex_unlock(&gOnigMutex)
149
+ #define THREAD_PASS sched_yield()
150
+ #endif /* _WIN32 */
151
+
152
+ #else /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
153
+
154
+ #ifndef THREAD_SYSTEM_INIT
155
+ #define THREAD_SYSTEM_INIT /* depend on thread system */
156
+ #endif
157
+ #ifndef THREAD_SYSTEM_END
158
+ #define THREAD_SYSTEM_END /* depend on thread system */
159
+ #endif
160
+ #ifndef THREAD_ATOMIC_START
161
+ #define THREAD_ATOMIC_START /* depend on thread system */
162
+ #endif
163
+ #ifndef THREAD_ATOMIC_END
164
+ #define THREAD_ATOMIC_END /* depend on thread system */
165
+ #endif
166
+ #ifndef THREAD_PASS
167
+ #define THREAD_PASS /* depend on thread system */
168
+ #endif
169
+
170
+ #endif /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
171
+
172
+ #ifndef xmalloc
173
+ #define xmalloc malloc
174
+ #define xrealloc realloc
175
+ #define xcalloc calloc
176
+ #define xfree free
177
+ #endif
178
+
179
+ #ifdef RUBY
180
+
181
+ #define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
182
+ #define onig_st_init_table st_init_table
183
+ #define onig_st_init_table_with_size st_init_table_with_size
184
+ #define onig_st_init_numtable st_init_numtable
185
+ #define onig_st_init_numtable_with_size st_init_numtable_with_size
186
+ #define onig_st_init_strtable st_init_strtable
187
+ #define onig_st_init_strtable_with_size st_init_strtable_with_size
188
+ #define onig_st_delete st_delete
189
+ #define onig_st_delete_safe st_delete_safe
190
+ #define onig_st_insert st_insert
191
+ #define onig_st_lookup st_lookup
192
+ #define onig_st_foreach st_foreach
193
+ #define onig_st_add_direct st_add_direct
194
+ #define onig_st_free_table st_free_table
195
+ #define onig_st_cleanup_safe st_cleanup_safe
196
+ #define onig_st_copy st_copy
197
+ #define onig_st_nothing_key_clone st_nothing_key_clone
198
+ #define onig_st_nothing_key_free st_nothing_key_free
199
+ #define onig_st_is_member st_is_member
200
+
201
+ #define USE_UPPER_CASE_TABLE
202
+ #else
203
+
204
+ #define CHECK_INTERRUPT_IN_MATCH_AT
205
+
206
+ #define st_init_table onig_st_init_table
207
+ #define st_init_table_with_size onig_st_init_table_with_size
208
+ #define st_init_numtable onig_st_init_numtable
209
+ #define st_init_numtable_with_size onig_st_init_numtable_with_size
210
+ #define st_init_strtable onig_st_init_strtable
211
+ #define st_init_strtable_with_size onig_st_init_strtable_with_size
212
+ #define st_delete onig_st_delete
213
+ #define st_delete_safe onig_st_delete_safe
214
+ #define st_insert onig_st_insert
215
+ #define st_lookup onig_st_lookup
216
+ #define st_foreach onig_st_foreach
217
+ #define st_add_direct onig_st_add_direct
218
+ #define st_free_table onig_st_free_table
219
+ #define st_cleanup_safe onig_st_cleanup_safe
220
+ #define st_copy onig_st_copy
221
+ #define st_nothing_key_clone onig_st_nothing_key_clone
222
+ #define st_nothing_key_free onig_st_nothing_key_free
223
+ /* */
224
+ #define onig_st_is_member st_is_member
225
+
226
+ #endif
227
+
228
+ #define STATE_CHECK_STRING_THRESHOLD_LEN 7
229
+ #define STATE_CHECK_BUFF_MAX_SIZE 0x4000
230
+
231
+ #define THREAD_PASS_LIMIT_COUNT 8
232
+ #define xmemset memset
233
+ #define xmemcpy memcpy
234
+ #define xmemmove memmove
235
+
236
+ #if defined(_WIN32) && !defined(__GNUC__)
237
+ #define xalloca _alloca
238
+ #define xvsnprintf _vsnprintf
239
+ #else
240
+ #define xalloca alloca
241
+ #define xvsnprintf vsnprintf
242
+ #endif
243
+
244
+
245
+ #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
246
+ #define ONIG_STATE_INC(reg) (reg)->state++
247
+ #define ONIG_STATE_DEC(reg) (reg)->state--
248
+
249
+ #define ONIG_STATE_INC_THREAD(reg) do {\
250
+ THREAD_ATOMIC_START;\
251
+ (reg)->state++;\
252
+ THREAD_ATOMIC_END;\
253
+ } while(0)
254
+ #define ONIG_STATE_DEC_THREAD(reg) do {\
255
+ THREAD_ATOMIC_START;\
256
+ (reg)->state--;\
257
+ THREAD_ATOMIC_END;\
258
+ } while(0)
259
+ #else
260
+ #define ONIG_STATE_INC(reg) /* Nothing */
261
+ #define ONIG_STATE_DEC(reg) /* Nothing */
262
+ #define ONIG_STATE_INC_THREAD(reg) /* Nothing */
263
+ #define ONIG_STATE_DEC_THREAD(reg) /* Nothing */
264
+ #endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
265
+
266
+ #ifdef HAVE_STDLIB_H
267
+ #include <stdlib.h>
268
+ #endif
269
+
270
+ #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
271
+ #include <alloca.h>
272
+ #endif
273
+
274
+ #ifdef HAVE_STRING_H
275
+ # include <string.h>
276
+ #else
277
+ # include <strings.h>
278
+ #endif
279
+
280
+ #include <ctype.h>
281
+ #ifdef HAVE_SYS_TYPES_H
282
+ #include <sys/types.h>
283
+ #endif
284
+
285
+ #ifdef HAVE_STDINT_H
286
+ # include <stdint.h>
287
+ #endif
288
+
289
+ #ifdef HAVE_INTTYPES_H
290
+ # include <inttypes.h>
291
+ #endif
292
+
293
+ #ifdef STDC_HEADERS
294
+ # include <stddef.h>
295
+ #endif
296
+
297
+ #ifdef _WIN32
298
+ #include <malloc.h> /* for alloca() */
299
+ #endif
300
+
301
+ #ifdef ONIG_DEBUG
302
+ # include <stdio.h>
303
+ #endif
304
+
305
+ #ifdef _WIN32
306
+ #if defined(_MSC_VER) && (_MSC_VER < 1300)
307
+ #ifndef _INTPTR_T_DEFINED
308
+ #define _INTPTR_T_DEFINED
309
+ typedef int intptr_t;
310
+ #endif
311
+ #ifndef _UINTPTR_T_DEFINED
312
+ #define _UINTPTR_T_DEFINED
313
+ typedef unsigned int uintptr_t;
314
+ #endif
315
+ #endif
316
+ #endif /* _WIN32 */
317
+
318
+ #ifndef PRIdPTR
319
+ #ifdef _WIN64
320
+ #define PRIdPTR "I64d"
321
+ #define PRIuPTR "I64u"
322
+ #define PRIxPTR "I64x"
323
+ #else
324
+ #define PRIdPTR "ld"
325
+ #define PRIuPTR "lu"
326
+ #define PRIxPTR "lx"
327
+ #endif
328
+ #endif
329
+
330
+ #include "regenc.h"
331
+
332
+ RUBY_SYMBOL_EXPORT_BEGIN
333
+
334
+ #ifdef MIN
335
+ #undef MIN
336
+ #endif
337
+ #ifdef MAX
338
+ #undef MAX
339
+ #endif
340
+ #define MIN(a,b) (((a)>(b))?(b):(a))
341
+ #define MAX(a,b) (((a)<(b))?(b):(a))
342
+
343
+ #define IS_NULL(p) (((void*)(p)) == (void*)0)
344
+ #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
345
+ #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
346
+ #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
347
+ #define NULL_UCHARP ((UChar* )0)
348
+
349
+ #define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
350
+
351
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
352
+
353
+ #define PLATFORM_GET_INC(val,p,type) do{\
354
+ val = *(type* )p;\
355
+ (p) += sizeof(type);\
356
+ } while(0)
357
+
358
+ #else
359
+
360
+ #define PLATFORM_GET_INC(val,p,type) do{\
361
+ xmemcpy(&val, (p), sizeof(type));\
362
+ (p) += sizeof(type);\
363
+ } while(0)
364
+
365
+ /* sizeof(OnigCodePoint) */
366
+ #define WORD_ALIGNMENT_SIZE SIZEOF_LONG
367
+
368
+ #define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
369
+ (pad_size) = WORD_ALIGNMENT_SIZE \
370
+ - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
371
+ if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
372
+ } while (0)
373
+
374
+ #define ALIGNMENT_RIGHT(addr) do {\
375
+ (addr) += (WORD_ALIGNMENT_SIZE - 1);\
376
+ (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
377
+ } while (0)
378
+
379
+ #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
380
+
381
+ /* stack pop level */
382
+ #define STACK_POP_LEVEL_FREE 0
383
+ #define STACK_POP_LEVEL_MEM_START 1
384
+ #define STACK_POP_LEVEL_ALL 2
385
+
386
+ /* optimize flags */
387
+ #define ONIG_OPTIMIZE_NONE 0
388
+ #define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
389
+ #define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
390
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (applied to a multibyte string) */
391
+ #define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
392
+ #define ONIG_OPTIMIZE_MAP 5 /* char map */
393
+ #define ONIG_OPTIMIZE_EXACT_BM_IC 6 /* BM (ignore case) */
394
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
395
+
396
+ /* bit status */
397
+ typedef unsigned int BitStatusType;
398
+
399
+ #define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
400
+ #define BIT_STATUS_CLEAR(stats) (stats) = 0
401
+ #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
402
+ #define BIT_STATUS_AT(stats,n) \
403
+ ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType )1 << n)) : ((stats) & 1))
404
+
405
+ #define BIT_STATUS_ON_AT(stats,n) do {\
406
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
407
+ (stats) |= (1 << (n));\
408
+ else\
409
+ (stats) |= 1;\
410
+ } while (0)
411
+
412
+ #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
413
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
414
+ (stats) |= (1 << (n));\
415
+ } while (0)
416
+
417
+
418
+ #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
419
+
420
+ #define DIGITVAL(code) ((code) - '0')
421
+ #define ODIGITVAL(code) DIGITVAL(code)
422
+ #define XDIGITVAL(enc,code) \
423
+ (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
424
+ : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
425
+
426
+ #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
427
+ #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
428
+ #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
429
+ #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
430
+ #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
431
+ #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
432
+ #define IS_FIND_CONDITION(option) ((option) & \
433
+ (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
434
+ #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
435
+ #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
436
+ #define IS_NOTBOS(option) ((option) & ONIG_OPTION_NOTBOS)
437
+ #define IS_NOTEOS(option) ((option) & ONIG_OPTION_NOTEOS)
438
+ #define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
439
+ #define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
440
+ #define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
441
+ #define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
442
+ #define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
443
+
444
+ /* OP_SET_OPTION is required for these options.
445
+ #define IS_DYNAMIC_OPTION(option) \
446
+ (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
447
+ */
448
+ /* ignore-case and multibyte status are included in compiled code. */
449
+ #define IS_DYNAMIC_OPTION(option) 0
450
+
451
+ #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
452
+ ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
453
+
454
+ #define REPEAT_INFINITE -1
455
+ #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
456
+
457
+ /* bitset */
458
+ #define BITS_PER_BYTE 8
459
+ #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
460
+ #define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
461
+ #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
462
+
463
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
464
+ typedef unsigned int Bits;
465
+ #else
466
+ typedef unsigned char Bits;
467
+ #endif
468
+ typedef Bits BitSet[BITSET_SIZE];
469
+ typedef Bits* BitSetRef;
470
+
471
+ #define SIZE_BITSET (int )sizeof(BitSet)
472
+
473
+ #define BITSET_CLEAR(bs) do {\
474
+ int i;\
475
+ for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
476
+ } while (0)
477
+
478
+ #define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
479
+ #define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
480
+
481
+ #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
482
+ #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
483
+ #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
484
+ #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
485
+
486
+ /* bytes buffer */
487
+ typedef struct _BBuf {
488
+ UChar* p;
489
+ unsigned int used;
490
+ unsigned int alloc;
491
+ } BBuf;
492
+
493
+ #define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
494
+
495
+ #define BBUF_SIZE_INC(buf,inc) do{\
496
+ UChar *tmp;\
497
+ (buf)->alloc += (inc);\
498
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
499
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
500
+ (buf)->p = tmp;\
501
+ } while (0)
502
+
503
+ #define BBUF_EXPAND(buf,low) do{\
504
+ UChar *tmp;\
505
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
506
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
507
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
508
+ (buf)->p = tmp;\
509
+ } while (0)
510
+
511
+ #define BBUF_ENSURE_SIZE(buf,size) do{\
512
+ unsigned int new_alloc = (buf)->alloc;\
513
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
514
+ if ((buf)->alloc != new_alloc) {\
515
+ UChar *tmp;\
516
+ tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
517
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
518
+ (buf)->p = tmp;\
519
+ (buf)->alloc = new_alloc;\
520
+ }\
521
+ } while (0)
522
+
523
+ #define BBUF_WRITE(buf,pos,bytes,n) do{\
524
+ int used = (pos) + (int )(n);\
525
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
526
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
527
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
528
+ } while (0)
529
+
530
+ #define BBUF_WRITE1(buf,pos,byte) do{\
531
+ int used = (pos) + 1;\
532
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
533
+ (buf)->p[(pos)] = (UChar )(byte);\
534
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
535
+ } while (0)
536
+
537
+ #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
538
+ #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
539
+ #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
540
+ #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
541
+
542
+ /* from < to */
543
+ #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
544
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
545
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
546
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
547
+ } while (0)
548
+
549
+ /* from > to */
550
+ #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
551
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
552
+ } while (0)
553
+
554
+ /* from > to */
555
+ #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
556
+ xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
557
+ (buf)->used -= (from - to);\
558
+ } while (0)
559
+
560
+ #define BBUF_INSERT(buf,pos,bytes,n) do {\
561
+ if (pos >= (buf)->used) {\
562
+ BBUF_WRITE(buf,pos,bytes,n);\
563
+ }\
564
+ else {\
565
+ BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
566
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
567
+ }\
568
+ } while (0)
569
+
570
+ #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
571
+
572
+
573
+ #define ANCHOR_BEGIN_BUF (1<<0)
574
+ #define ANCHOR_BEGIN_LINE (1<<1)
575
+ #define ANCHOR_BEGIN_POSITION (1<<2)
576
+ #define ANCHOR_END_BUF (1<<3)
577
+ #define ANCHOR_SEMI_END_BUF (1<<4)
578
+ #define ANCHOR_END_LINE (1<<5)
579
+
580
+ #define ANCHOR_WORD_BOUND (1<<6)
581
+ #define ANCHOR_NOT_WORD_BOUND (1<<7)
582
+ #define ANCHOR_WORD_BEGIN (1<<8)
583
+ #define ANCHOR_WORD_END (1<<9)
584
+ #define ANCHOR_PREC_READ (1<<10)
585
+ #define ANCHOR_PREC_READ_NOT (1<<11)
586
+ #define ANCHOR_LOOK_BEHIND (1<<12)
587
+ #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
588
+
589
+ #define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
590
+ #define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
591
+
592
+ #define ANCHOR_KEEP (1<<16)
593
+
594
+ /* operation code */
595
+ enum OpCode {
596
+ OP_FINISH = 0, /* matching process terminator (no more alternative) */
597
+ OP_END = 1, /* pattern code terminator (success end) */
598
+
599
+ OP_EXACT1 = 2, /* single byte, N = 1 */
600
+ OP_EXACT2, /* single byte, N = 2 */
601
+ OP_EXACT3, /* single byte, N = 3 */
602
+ OP_EXACT4, /* single byte, N = 4 */
603
+ OP_EXACT5, /* single byte, N = 5 */
604
+ OP_EXACTN, /* single byte */
605
+ OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
606
+ OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
607
+ OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
608
+ OP_EXACTMB2N, /* mb-length = 2 */
609
+ OP_EXACTMB3N, /* mb-length = 3 */
610
+ OP_EXACTMBN, /* other length */
611
+
612
+ OP_EXACT1_IC, /* single byte, N = 1, ignore case */
613
+ OP_EXACTN_IC, /* single byte, ignore case */
614
+
615
+ OP_CCLASS,
616
+ OP_CCLASS_MB,
617
+ OP_CCLASS_MIX,
618
+ OP_CCLASS_NOT,
619
+ OP_CCLASS_MB_NOT,
620
+ OP_CCLASS_MIX_NOT,
621
+ OP_CCLASS_NODE, /* pointer to CClassNode node */
622
+
623
+ OP_ANYCHAR, /* "." */
624
+ OP_ANYCHAR_ML, /* "." multi-line */
625
+ OP_ANYCHAR_STAR, /* ".*" */
626
+ OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
627
+ OP_ANYCHAR_STAR_PEEK_NEXT,
628
+ OP_ANYCHAR_ML_STAR_PEEK_NEXT,
629
+
630
+ OP_WORD,
631
+ OP_NOT_WORD,
632
+ OP_WORD_BOUND,
633
+ OP_NOT_WORD_BOUND,
634
+ OP_WORD_BEGIN,
635
+ OP_WORD_END,
636
+
637
+ OP_ASCII_WORD,
638
+ OP_NOT_ASCII_WORD,
639
+ OP_ASCII_WORD_BOUND,
640
+ OP_NOT_ASCII_WORD_BOUND,
641
+ OP_ASCII_WORD_BEGIN,
642
+ OP_ASCII_WORD_END,
643
+
644
+ OP_BEGIN_BUF,
645
+ OP_END_BUF,
646
+ OP_BEGIN_LINE,
647
+ OP_END_LINE,
648
+ OP_SEMI_END_BUF,
649
+ OP_BEGIN_POSITION,
650
+ OP_BEGIN_POS_OR_LINE, /* used for implicit anchor optimization */
651
+
652
+ OP_BACKREF1,
653
+ OP_BACKREF2,
654
+ OP_BACKREFN,
655
+ OP_BACKREFN_IC,
656
+ OP_BACKREF_MULTI,
657
+ OP_BACKREF_MULTI_IC,
658
+ OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
659
+
660
+ OP_MEMORY_START,
661
+ OP_MEMORY_START_PUSH, /* push back-tracker to stack */
662
+ OP_MEMORY_END_PUSH, /* push back-tracker to stack */
663
+ OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
664
+ OP_MEMORY_END,
665
+ OP_MEMORY_END_REC, /* push marker to stack */
666
+
667
+ OP_KEEP,
668
+
669
+ OP_FAIL, /* pop stack and move */
670
+ OP_JUMP,
671
+ OP_PUSH,
672
+ OP_POP,
673
+ OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
674
+ OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
675
+ OP_REPEAT, /* {n,m} */
676
+ OP_REPEAT_NG, /* {n,m}? (non greedy) */
677
+ OP_REPEAT_INC,
678
+ OP_REPEAT_INC_NG, /* non greedy */
679
+ OP_REPEAT_INC_SG, /* search and get in stack */
680
+ OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
681
+ OP_NULL_CHECK_START, /* null loop checker start */
682
+ OP_NULL_CHECK_END, /* null loop checker end */
683
+ OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
684
+ OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
685
+
686
+ OP_PUSH_POS, /* (?=...) start */
687
+ OP_POP_POS, /* (?=...) end */
688
+ OP_PUSH_POS_NOT, /* (?!...) start */
689
+ OP_FAIL_POS, /* (?!...) end */
690
+ OP_PUSH_STOP_BT, /* (?>...) start */
691
+ OP_POP_STOP_BT, /* (?>...) end */
692
+ OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
693
+ OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
694
+ OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
695
+
696
+ OP_CALL, /* \g<name> */
697
+ OP_RETURN,
698
+
699
+ OP_CONDITION,
700
+
701
+ OP_STATE_CHECK_PUSH, /* combination explosion check and push */
702
+ OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
703
+ OP_STATE_CHECK, /* check only */
704
+ OP_STATE_CHECK_ANYCHAR_STAR,
705
+ OP_STATE_CHECK_ANYCHAR_ML_STAR,
706
+
707
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
708
+ OP_SET_OPTION_PUSH, /* set option and push recover option */
709
+ OP_SET_OPTION /* set option */
710
+ };
711
+
712
+ typedef int RelAddrType;
713
+ typedef int AbsAddrType;
714
+ typedef int LengthType;
715
+ typedef int RepeatNumType;
716
+ typedef short int MemNumType;
717
+ typedef short int StateCheckNumType;
718
+ typedef void* PointerType;
719
+
720
+ #define SIZE_OPCODE 1
721
+ #define SIZE_RELADDR (int )sizeof(RelAddrType)
722
+ #define SIZE_ABSADDR (int )sizeof(AbsAddrType)
723
+ #define SIZE_LENGTH (int )sizeof(LengthType)
724
+ #define SIZE_MEMNUM (int )sizeof(MemNumType)
725
+ #define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
726
+ #define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
727
+ #define SIZE_OPTION (int )sizeof(OnigOptionType)
728
+ #define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
729
+ #define SIZE_POINTER (int )sizeof(PointerType)
730
+
731
+
732
+ #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
733
+ #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
734
+ #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
735
+ #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
736
+ #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
737
+ #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
738
+ #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
739
+ #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
740
+
741
+ /* code point's address must be aligned address. */
742
+ #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
743
+ #define GET_BYTE_INC(byte,p) do{\
744
+ byte = *(p);\
745
+ (p)++;\
746
+ } while(0)
747
+
748
+
749
+ /* op-code + arg size */
750
+ #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
751
+ #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
752
+ #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
753
+ #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
754
+ #define SIZE_OP_POP SIZE_OPCODE
755
+ #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
756
+ #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
757
+ #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
758
+ #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
759
+ #define SIZE_OP_PUSH_POS SIZE_OPCODE
760
+ #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
761
+ #define SIZE_OP_POP_POS SIZE_OPCODE
762
+ #define SIZE_OP_FAIL_POS SIZE_OPCODE
763
+ #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
764
+ #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
765
+ #define SIZE_OP_FAIL SIZE_OPCODE
766
+ #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
767
+ #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
768
+ #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
769
+ #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
770
+ #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
771
+ #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
772
+ #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
773
+ #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
774
+ #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
775
+ #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
776
+ #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
777
+ #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
778
+ #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
779
+ #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
780
+ #define SIZE_OP_RETURN SIZE_OPCODE
781
+ #define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
782
+
783
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
784
+ #define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
785
+ #define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
786
+ #define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
787
+ #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
788
+ #endif
789
+
790
+ #define MC_ESC(syn) (syn)->meta_char_table.esc
791
+ #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
792
+ #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
793
+ #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
794
+ #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
795
+ #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
796
+
797
+ #define IS_MC_ESC_CODE(code, syn) \
798
+ ((code) == MC_ESC(syn) && \
799
+ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
800
+
801
+
802
+ #define SYN_POSIX_COMMON_OP \
803
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
804
+ ONIG_SYN_OP_DECIMAL_BACKREF | \
805
+ ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
806
+ ONIG_SYN_OP_LINE_ANCHOR | \
807
+ ONIG_SYN_OP_ESC_CONTROL_CHARS )
808
+
809
+ #define SYN_GNU_REGEX_OP \
810
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
811
+ ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
812
+ ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
813
+ ONIG_SYN_OP_VBAR_ALT | \
814
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
815
+ ONIG_SYN_OP_QMARK_ZERO_ONE | \
816
+ ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
817
+ ONIG_SYN_OP_ESC_W_WORD | \
818
+ ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
819
+ ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
820
+ ONIG_SYN_OP_LINE_ANCHOR )
821
+
822
+ #define SYN_GNU_REGEX_BV \
823
+ ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
824
+ ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
825
+ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
826
+
827
+
828
+ #define NCCLASS_FLAGS(cc) ((cc)->flags)
829
+ #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
830
+ #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
831
+ #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
832
+
833
+ /* cclass node */
834
+ #define FLAG_NCCLASS_NOT (1<<0)
835
+ #define FLAG_NCCLASS_SHARE (1<<1)
836
+
837
+ #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
838
+ #define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
839
+ #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
840
+ #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
841
+ #define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
842
+
843
+ typedef struct {
844
+ int type;
845
+ /* struct _Node* next; */
846
+ /* unsigned int flags; */
847
+ } NodeBase;
848
+
849
+ typedef struct {
850
+ NodeBase base;
851
+ unsigned int flags;
852
+ BitSet bs;
853
+ BBuf* mbuf; /* multi-byte info or NULL */
854
+ } CClassNode;
855
+
856
+ typedef intptr_t OnigStackIndex;
857
+
858
+ typedef struct _OnigStackType {
859
+ unsigned int type;
860
+ union {
861
+ struct {
862
+ UChar *pcode; /* byte code position */
863
+ UChar *pstr; /* string position */
864
+ UChar *pstr_prev; /* previous char position of pstr */
865
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
866
+ unsigned int state_check;
867
+ #endif
868
+ UChar *pkeep; /* keep pattern position */
869
+ } state;
870
+ struct {
871
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
872
+ UChar *pcode; /* byte code position (head of repeated target) */
873
+ int num; /* repeat id */
874
+ } repeat;
875
+ struct {
876
+ OnigStackIndex si; /* index of stack */
877
+ } repeat_inc;
878
+ struct {
879
+ int num; /* memory num */
880
+ UChar *pstr; /* start/end position */
881
+ /* Following information is set, if this stack type is MEM-START */
882
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
883
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
884
+ } mem;
885
+ struct {
886
+ int num; /* null check id */
887
+ UChar *pstr; /* start position */
888
+ } null_check;
889
+ #ifdef USE_SUBEXP_CALL
890
+ struct {
891
+ UChar *ret_addr; /* byte code position */
892
+ int num; /* null check id */
893
+ UChar *pstr; /* string position */
894
+ } call_frame;
895
+ #endif
896
+ } u;
897
+ } OnigStackType;
898
+
899
+ typedef struct {
900
+ void* stack_p;
901
+ size_t stack_n;
902
+ OnigOptionType options;
903
+ OnigRegion* region;
904
+ const UChar* start; /* search start position */
905
+ const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
906
+ #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
907
+ OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
908
+ UChar* best_s;
909
+ #endif
910
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
911
+ void* state_check_buff;
912
+ int state_check_buff_size;
913
+ #endif
914
+ } OnigMatchArg;
915
+
916
+
917
+ #define IS_CODE_SB_WORD(enc,code) \
918
+ (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
919
+
920
+ typedef struct OnigEndCallListItem {
921
+ struct OnigEndCallListItem* next;
922
+ void (*func)(void);
923
+ } OnigEndCallListItemType;
924
+
925
+ extern void onig_add_end_call(void (*func)(void));
926
+
927
+
928
+ #ifdef ONIG_DEBUG
929
+
930
+ typedef struct {
931
+ short int opcode;
932
+ const char* name;
933
+ short int arg_type;
934
+ } OnigOpInfoType;
935
+
936
+ extern OnigOpInfoType OnigOpInfo[];
937
+
938
+
939
+ extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc));
940
+
941
+ #ifdef ONIG_DEBUG_STATISTICS
942
+ extern void onig_statistics_init P_((void));
943
+ extern void onig_print_statistics P_((FILE* f));
944
+ #endif
945
+ #endif
946
+
947
+ extern UChar* onig_error_code_to_format P_((OnigPosition code));
948
+ extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
949
+ extern int onig_bbuf_init P_((BBuf* buf, OnigDistance size));
950
+ extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
951
+ extern void onig_chain_reduce P_((regex_t* reg));
952
+ extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
953
+ extern void onig_transfer P_((regex_t* to, regex_t* from));
954
+ extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
955
+ extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
956
+
957
+ /* strend hash */
958
+ typedef void hash_table_type;
959
+ #ifdef RUBY
960
+ #include "ruby/st.h"
961
+ typedef st_data_t hash_data_type;
962
+ #else
963
+ #include "st.h"
964
+ typedef uintptr_t hash_data_type;
965
+ #endif
966
+
967
+ extern hash_table_type* onig_st_init_strend_table_with_size P_((st_index_t size));
968
+ extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
969
+ extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
970
+
971
+ /* encoding property management */
972
+ #define PROPERTY_LIST_ADD_PROP(Name, CR) \
973
+ r = onigenc_property_list_add_property((UChar* )Name, CR,\
974
+ &PropertyNameTable, &PropertyList, &PropertyListNum,\
975
+ &PropertyListSize);\
976
+ if (r != 0) goto end
977
+
978
+ #define PROPERTY_LIST_INIT_CHECK \
979
+ if (PropertyInited == 0) {\
980
+ int r = onigenc_property_list_init(init_property_list);\
981
+ if (r != 0) return r;\
982
+ }
983
+
984
+ extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
985
+
986
+ typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
987
+
988
+ extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
989
+
990
+ extern size_t onig_memsize P_((const regex_t *reg));
991
+ extern size_t onig_region_memsize P_((const struct re_registers *regs));
992
+
993
+ RUBY_SYMBOL_EXPORT_END
994
+
995
+ #endif /* ONIGURUMA_REGINT_H */