Added
Link Here
|
1 |
diff -Naur builder.c builder.c |
2 |
--- builder.c 2005-03-30 07:48:09.000000000 +0900 |
3 |
+++ builder.c 2010-05-27 20:08:33.000000000 +0900 |
4 |
@@ -26,7 +26,6 @@ |
5 |
#include <errno.h> |
6 |
#include "sary.h" |
7 |
#include "ruby.h" |
8 |
-#include "version.h" |
9 |
|
10 |
#define GET_Builder(obj, dat) Data_Get_Struct(obj, SaryBuilder, dat) |
11 |
|
12 |
@@ -63,21 +62,13 @@ |
13 |
rb_scan_args(argc, argv, "11", &file_name, &array_name); |
14 |
|
15 |
Check_SafeStr(file_name); |
16 |
-#if RUBY_VERSION_CODE >= 180 |
17 |
file_name_ptr = StringValuePtr(file_name); |
18 |
-#else |
19 |
- file_name_ptr = STR2CSTR(file_name); |
20 |
-#endif |
21 |
|
22 |
if (array_name == Qnil) |
23 |
builder = sary_builder_new(file_name_ptr); |
24 |
else { |
25 |
Check_SafeStr(array_name); |
26 |
-#if RUBY_VERSION_CODE >= 180 |
27 |
array_name_ptr = StringValuePtr(array_name); |
28 |
-#else |
29 |
- array_name_ptr = STR2CSTR(array_name); |
30 |
-#endif |
31 |
builder = sary_builder_new2(file_name_ptr, array_name_ptr); |
32 |
} |
33 |
if (builder == NULL) |
34 |
diff -Naur searcher.c searcher.c |
35 |
--- searcher.c 2005-03-30 07:48:09.000000000 +0900 |
36 |
+++ searcher.c 2010-05-27 20:13:17.000000000 +0900 |
37 |
@@ -27,7 +27,13 @@ |
38 |
#include <errno.h> |
39 |
#include "sary.h" |
40 |
#include "ruby.h" |
41 |
-#include "version.h" |
42 |
+ |
43 |
+#ifndef RARRAY_LEN |
44 |
+#define RARRAY_LEN(a) RARRAY(a)->len |
45 |
+#endif |
46 |
+#ifndef RSTRING_LEN |
47 |
+#define RSTRING_LEN(str) RSTRING(str)->len |
48 |
+#endif |
49 |
|
50 |
#define GET_Searcher(obj, dat) Data_Get_Struct(obj, SarySearcher, dat) |
51 |
|
52 |
@@ -82,21 +88,13 @@ |
53 |
rb_scan_args(argc, argv, "11", &file_name, &array_name); |
54 |
|
55 |
Check_SafeStr(file_name); |
56 |
-#if RUBY_VERSION_CODE >= 180 |
57 |
file_name_ptr = StringValuePtr(file_name); |
58 |
-#else |
59 |
- file_name_ptr = STR2CSTR(file_name); |
60 |
-#endif |
61 |
|
62 |
if (array_name == Qnil) |
63 |
searcher = sary_searcher_new(file_name_ptr); |
64 |
else { |
65 |
Check_SafeStr(array_name); |
66 |
-#if RUBY_VERSION_CODE >= 180 |
67 |
array_name_ptr = StringValuePtr(array_name); |
68 |
-#else |
69 |
- array_name_ptr = STR2CSTR(array_name); |
70 |
-#endif |
71 |
searcher = sary_searcher_new2(file_name_ptr, array_name_ptr); |
72 |
} |
73 |
if (searcher == NULL) |
74 |
@@ -133,12 +131,8 @@ |
75 |
GET_Searcher(klass, searcher); |
76 |
|
77 |
Check_SafeStr(pattern); |
78 |
-#if RUBY_VERSION_CODE >= 180 |
79 |
pat = StringValuePtr(pattern); |
80 |
- len = RSTRING(pattern)->len; |
81 |
-#else |
82 |
- pat = str2cstr(pattern, &len); |
83 |
-#endif |
84 |
+ len = RSTRING_LEN(pattern); |
85 |
|
86 |
if (sary_searcher_search2(searcher, pat, len)) |
87 |
return Qtrue; |
88 |
@@ -157,7 +151,7 @@ |
89 |
|
90 |
GET_Searcher(klass, searcher); |
91 |
|
92 |
- len = RARRAY(pattern_array)->len; |
93 |
+ len = RARRAY_LEN(pattern_array); |
94 |
if (len == 0) { |
95 |
return Qfalse; |
96 |
} |
97 |
@@ -166,11 +160,7 @@ |
98 |
for (i = 0; i < len; i++) { |
99 |
pattern = rb_ary_entry(pattern_array, (long)i); |
100 |
Check_SafeStr(pattern); |
101 |
-#if RUBY_VERSION_CODE >= 180 |
102 |
pat[i] = StringValuePtr(pattern); |
103 |
-#else |
104 |
- pat[i] = STR2CSTR(pattern); |
105 |
-#endif |
106 |
} |
107 |
|
108 |
if (sary_searcher_multi_search(searcher, pat, len)) |
109 |
@@ -189,11 +179,7 @@ |
110 |
GET_Searcher(klass, searcher); |
111 |
|
112 |
Check_SafeStr(pattern); |
113 |
-#if RUBY_VERSION_CODE >= 180 |
114 |
pat = StringValuePtr(pattern); |
115 |
-#else |
116 |
- pat = STR2CSTR(pattern); |
117 |
-#endif |
118 |
|
119 |
if (sary_searcher_isearch(searcher, pat, NUM2INT(len))) |
120 |
return Qtrue; |
121 |
@@ -224,12 +210,8 @@ |
122 |
GET_Searcher(klass, searcher); |
123 |
|
124 |
Check_SafeStr(pattern); |
125 |
-#if RUBY_VERSION_CODE >= 180 |
126 |
pat = StringValuePtr(pattern); |
127 |
- len = RSTRING(pattern)->len; |
128 |
-#else |
129 |
- pat = str2cstr(pattern, &len); |
130 |
-#endif |
131 |
+ len = RSTRING_LEN(pattern); |
132 |
|
133 |
if (sary_searcher_icase_search2(searcher, pat, len)) |
134 |
return Qtrue; |
135 |
@@ -275,15 +257,10 @@ |
136 |
|
137 |
Check_SafeStr(start_tag); |
138 |
Check_SafeStr(end_tag); |
139 |
-#if RUBY_VERSION_CODE >= 180 |
140 |
stag = StringValuePtr(start_tag); |
141 |
etag = StringValuePtr(end_tag); |
142 |
- slen = RSTRING(stag)->len; |
143 |
- elen = RSTRING(etag)->len; |
144 |
-#else |
145 |
- stag = rb_str2cstr(start_tag, &slen); |
146 |
- etag = rb_str2cstr(end_tag, &elen); |
147 |
-#endif |
148 |
+ slen = RSTRING_LEN(stag); |
149 |
+ elen = RSTRING_LEN(etag); |
150 |
|
151 |
region = sary_searcher_get_next_tagged_region2(searcher, stag, slen, |
152 |
etag, elen, &rlen); |