153 lines
4.1 KiB
Diff
153 lines
4.1 KiB
Diff
diff -Naur sary-ruby-1.2.0.orig//builder.c sary-ruby-1.2.0//builder.c
|
|
--- sary-ruby-1.2.0.orig//builder.c 2005-03-30 07:48:09.000000000 +0900
|
|
+++ sary-ruby-1.2.0//builder.c 2010-05-27 20:08:33.000000000 +0900
|
|
@@ -26,7 +26,6 @@
|
|
#include <errno.h>
|
|
#include "sary.h"
|
|
#include "ruby.h"
|
|
-#include "version.h"
|
|
|
|
#define GET_Builder(obj, dat) Data_Get_Struct(obj, SaryBuilder, dat)
|
|
|
|
@@ -63,21 +62,13 @@
|
|
rb_scan_args(argc, argv, "11", &file_name, &array_name);
|
|
|
|
Check_SafeStr(file_name);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
file_name_ptr = StringValuePtr(file_name);
|
|
-#else
|
|
- file_name_ptr = STR2CSTR(file_name);
|
|
-#endif
|
|
|
|
if (array_name == Qnil)
|
|
builder = sary_builder_new(file_name_ptr);
|
|
else {
|
|
Check_SafeStr(array_name);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
array_name_ptr = StringValuePtr(array_name);
|
|
-#else
|
|
- array_name_ptr = STR2CSTR(array_name);
|
|
-#endif
|
|
builder = sary_builder_new2(file_name_ptr, array_name_ptr);
|
|
}
|
|
if (builder == NULL)
|
|
diff -Naur sary-ruby-1.2.0.orig//searcher.c sary-ruby-1.2.0//searcher.c
|
|
--- sary-ruby-1.2.0.orig//searcher.c 2005-03-30 07:48:09.000000000 +0900
|
|
+++ sary-ruby-1.2.0//searcher.c 2010-05-27 20:13:17.000000000 +0900
|
|
@@ -27,7 +27,13 @@
|
|
#include <errno.h>
|
|
#include "sary.h"
|
|
#include "ruby.h"
|
|
-#include "version.h"
|
|
+
|
|
+#ifndef RARRAY_LEN
|
|
+#define RARRAY_LEN(a) RARRAY(a)->len
|
|
+#endif
|
|
+#ifndef RSTRING_LEN
|
|
+#define RSTRING_LEN(str) RSTRING(str)->len
|
|
+#endif
|
|
|
|
#define GET_Searcher(obj, dat) Data_Get_Struct(obj, SarySearcher, dat)
|
|
|
|
@@ -82,21 +88,13 @@
|
|
rb_scan_args(argc, argv, "11", &file_name, &array_name);
|
|
|
|
Check_SafeStr(file_name);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
file_name_ptr = StringValuePtr(file_name);
|
|
-#else
|
|
- file_name_ptr = STR2CSTR(file_name);
|
|
-#endif
|
|
|
|
if (array_name == Qnil)
|
|
searcher = sary_searcher_new(file_name_ptr);
|
|
else {
|
|
Check_SafeStr(array_name);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
array_name_ptr = StringValuePtr(array_name);
|
|
-#else
|
|
- array_name_ptr = STR2CSTR(array_name);
|
|
-#endif
|
|
searcher = sary_searcher_new2(file_name_ptr, array_name_ptr);
|
|
}
|
|
if (searcher == NULL)
|
|
@@ -133,12 +131,8 @@
|
|
GET_Searcher(klass, searcher);
|
|
|
|
Check_SafeStr(pattern);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
pat = StringValuePtr(pattern);
|
|
- len = RSTRING(pattern)->len;
|
|
-#else
|
|
- pat = str2cstr(pattern, &len);
|
|
-#endif
|
|
+ len = RSTRING_LEN(pattern);
|
|
|
|
if (sary_searcher_search2(searcher, pat, len))
|
|
return Qtrue;
|
|
@@ -157,7 +151,7 @@
|
|
|
|
GET_Searcher(klass, searcher);
|
|
|
|
- len = RARRAY(pattern_array)->len;
|
|
+ len = RARRAY_LEN(pattern_array);
|
|
if (len == 0) {
|
|
return Qfalse;
|
|
}
|
|
@@ -166,11 +160,7 @@
|
|
for (i = 0; i < len; i++) {
|
|
pattern = rb_ary_entry(pattern_array, (long)i);
|
|
Check_SafeStr(pattern);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
pat[i] = StringValuePtr(pattern);
|
|
-#else
|
|
- pat[i] = STR2CSTR(pattern);
|
|
-#endif
|
|
}
|
|
|
|
if (sary_searcher_multi_search(searcher, pat, len))
|
|
@@ -189,11 +179,7 @@
|
|
GET_Searcher(klass, searcher);
|
|
|
|
Check_SafeStr(pattern);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
pat = StringValuePtr(pattern);
|
|
-#else
|
|
- pat = STR2CSTR(pattern);
|
|
-#endif
|
|
|
|
if (sary_searcher_isearch(searcher, pat, NUM2INT(len)))
|
|
return Qtrue;
|
|
@@ -224,12 +210,8 @@
|
|
GET_Searcher(klass, searcher);
|
|
|
|
Check_SafeStr(pattern);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
pat = StringValuePtr(pattern);
|
|
- len = RSTRING(pattern)->len;
|
|
-#else
|
|
- pat = str2cstr(pattern, &len);
|
|
-#endif
|
|
+ len = RSTRING_LEN(pattern);
|
|
|
|
if (sary_searcher_icase_search2(searcher, pat, len))
|
|
return Qtrue;
|
|
@@ -275,15 +257,10 @@
|
|
|
|
Check_SafeStr(start_tag);
|
|
Check_SafeStr(end_tag);
|
|
-#if RUBY_VERSION_CODE >= 180
|
|
stag = StringValuePtr(start_tag);
|
|
etag = StringValuePtr(end_tag);
|
|
- slen = RSTRING(stag)->len;
|
|
- elen = RSTRING(etag)->len;
|
|
-#else
|
|
- stag = rb_str2cstr(start_tag, &slen);
|
|
- etag = rb_str2cstr(end_tag, &elen);
|
|
-#endif
|
|
+ slen = RSTRING_LEN(stag);
|
|
+ elen = RSTRING_LEN(etag);
|
|
|
|
region = sary_searcher_get_next_tagged_region2(searcher, stag, slen,
|
|
etag, elen, &rlen);
|