From 2f0f254bd90d36e4eece5285596d240b930f1d77 Mon Sep 17 00:00:00 2001 From: swills Date: Wed, 4 May 2011 01:26:03 +0000 Subject: - Fix build with Ruby 1.9 PR: ports/156325 Submitted by: me Approved by: maintainer timeout (clsung) --- textproc/ruby-sary/Makefile | 2 +- textproc/ruby-sary/files/patch-ruby19 | 152 ++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 textproc/ruby-sary/files/patch-ruby19 (limited to 'textproc') diff --git a/textproc/ruby-sary/Makefile b/textproc/ruby-sary/Makefile index f38b7bf43bab..6b6c24ee5276 100644 --- a/textproc/ruby-sary/Makefile +++ b/textproc/ruby-sary/Makefile @@ -7,7 +7,7 @@ PORTNAME= sary PORTVERSION= 1.2.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= textproc ruby MASTER_SITES= http://sary.sourceforge.net/ PKGNAMEPREFIX= ${RUBY_PKGNAMEPREFIX} diff --git a/textproc/ruby-sary/files/patch-ruby19 b/textproc/ruby-sary/files/patch-ruby19 new file mode 100644 index 000000000000..8884ad832a98 --- /dev/null +++ b/textproc/ruby-sary/files/patch-ruby19 @@ -0,0 +1,152 @@ +diff -Naur builder.c builder.c +--- builder.c 2005-03-30 07:48:09.000000000 +0900 ++++ builder.c 2010-05-27 20:08:33.000000000 +0900 +@@ -26,7 +26,6 @@ + #include + #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 searcher.c searcher.c +--- searcher.c 2005-03-30 07:48:09.000000000 +0900 ++++ searcher.c 2010-05-27 20:13:17.000000000 +0900 +@@ -27,7 +27,13 @@ + #include + #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); -- cgit