pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/ruby-ferret Add patches to use modern Ruby's ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/80640b9c89e0
branches:  trunk
changeset: 589947:80640b9c89e0
user:      taca <taca%pkgsrc.org@localhost>
date:      Sun Jun 19 16:01:52 2011 +0000

description:
Add patches to use modern Ruby's API.  Most of them are based on
patches of http://cvs.pld-linux.org/.

Bump PKGREVISION.

diffstat:

 textproc/ruby-ferret/Makefile                        |    6 +-
 textproc/ruby-ferret/distinfo                        |    8 +-
 textproc/ruby-ferret/patches/patch-ext_ferret.c      |   32 ++
 textproc/ruby-ferret/patches/patch-ext_lang.h        |   17 +
 textproc/ruby-ferret/patches/patch-ext_r__analysis.c |  195 +++++++++++++++
 textproc/ruby-ferret/patches/patch-ext_r__index.c    |  244 +++++++++++++++++++
 textproc/ruby-ferret/patches/patch-ext_r__qparser.c  |   17 +
 textproc/ruby-ferret/patches/patch-ext_r__search.c   |  214 ++++++++++++++++
 8 files changed, 728 insertions(+), 5 deletions(-)

diffs (truncated from 780 to 300 lines):

diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/Makefile
--- a/textproc/ruby-ferret/Makefile     Sun Jun 19 15:57:50 2011 +0000
+++ b/textproc/ruby-ferret/Makefile     Sun Jun 19 16:01:52 2011 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.6 2011/02/21 16:01:20 taca Exp $
+# $NetBSD: Makefile,v 1.7 2011/06/19 16:01:52 taca Exp $
 
 DISTNAME=      ferret-0.11.6
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    textproc
 
 MAINTAINER=    minskim%NetBSD.org@localhost
@@ -9,7 +9,5 @@
 COMMENT=       Text search engine library written for Ruby
 LICENSE=       mit
 
-RUBY_VERSION_SUPPORTED= 18
-
 .include "../../lang/ruby/gem.mk"
 .include "../../mk/bsd.pkg.mk"
diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/distinfo
--- a/textproc/ruby-ferret/distinfo     Sun Jun 19 15:57:50 2011 +0000
+++ b/textproc/ruby-ferret/distinfo     Sun Jun 19 16:01:52 2011 +0000
@@ -1,5 +1,11 @@
-$NetBSD: distinfo,v 1.2 2008/04/04 15:21:28 jlam Exp $
+$NetBSD: distinfo,v 1.3 2011/06/19 16:01:52 taca Exp $
 
 SHA1 (ferret-0.11.6.gem) = 83e0fada54e20445fe4ed7cd1dcdf9ffe74bb953
 RMD160 (ferret-0.11.6.gem) = 8f3fb148dafea297468fdc277c94f13fd4c4e164
 Size (ferret-0.11.6.gem) = 473600 bytes
+SHA1 (patch-ext_ferret.c) = 97e5ee20b63f9940a897cb7e98775e39798fd67b
+SHA1 (patch-ext_lang.h) = 1c1b04b8420a9d0e610e725ca9237d9924076c4e
+SHA1 (patch-ext_r__analysis.c) = 9e072327eddedb7f97a9f0b112246c97ac76c3ad
+SHA1 (patch-ext_r__index.c) = 9f695ab78e3e7fdb0f0c29f72e11632ab77ad69d
+SHA1 (patch-ext_r__qparser.c) = 1dfd71b0e690af23d31f6e8d2d0d77622e85200a
+SHA1 (patch-ext_r__search.c) = 88bb96400a8c9fce888c8caddb7ae07741c47c38
diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/patches/patch-ext_ferret.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/ruby-ferret/patches/patch-ext_ferret.c   Sun Jun 19 16:01:52 2011 +0000
@@ -0,0 +1,32 @@
+$NetBSD: patch-ext_ferret.c,v 1.1 2011/06/19 16:01:52 taca Exp $
+
+* Switch to modern Ruby's API: http://cvs.pld-linux.org/
+
+--- ext/ferret.c.orig  2011-06-10 06:23:08.000000000 +0000
++++ ext/ferret.c
+@@ -162,14 +162,14 @@ void *frt_rb_data_ptr(VALUE val)
+ char *
+ rs2s(VALUE rstr)
+ {
+-    return (char *)(RSTRING(rstr)->ptr ? RSTRING(rstr)->ptr : EMPTY_STRING);
++    return (char *)(RSTRING_PTR(rstr) ? RSTRING_PTR(rstr) : EMPTY_STRING);
+ }
+ 
+ char *
+ nstrdup(VALUE rstr)
+ {
+     char *old = rs2s(rstr);
+-    int len = RSTRING(rstr)->len;
++    int len = RSTRING_LEN(rstr);
+     char *new = ALLOC_N(char, len + 1);
+     memcpy(new, old, len + 1);
+     return new;
+@@ -295,7 +295,7 @@ static VALUE frt_term_to_s(VALUE self)
+     char *field = StringValuePtr(rfield);
+     char *text = StringValuePtr(rtext);
+     char *term_str = ALLOC_N(char,
+-                             5 + RSTRING(rfield)->len + RSTRING(rtext)->len);
++                             5 + RSTRING_LEN(rfield) + RSTRING_LEN(rtext));
+     sprintf(term_str, "%s:%s", field, text);
+     rstr = rb_str_new2(term_str);
+     free(term_str);
diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/patches/patch-ext_lang.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/ruby-ferret/patches/patch-ext_lang.h     Sun Jun 19 16:01:52 2011 +0000
@@ -0,0 +1,17 @@
+$NetBSD: patch-ext_lang.h,v 1.1 2011/06/19 16:01:52 taca Exp $
+
+* Switch to modern Ruby's API: http://cvs.pld-linux.org/
+
+--- ext/lang.h.orig    2011-06-10 06:23:08.000000000 +0000
++++ ext/lang.h
+@@ -6,6 +6,10 @@
+ #include <stdarg.h>
+ #include <ruby.h>
+ 
++#ifndef RUBY_RUBY_H
++#define RUBY18
++#endif
++
+ #undef close
+ #undef rename
+ #undef read
diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/patches/patch-ext_r__analysis.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/ruby-ferret/patches/patch-ext_r__analysis.c      Sun Jun 19 16:01:52 2011 +0000
@@ -0,0 +1,195 @@
+$NetBSD: patch-ext_r__analysis.c,v 1.1 2011/06/19 16:01:52 taca Exp $
+
+* Switch to modern Ruby's API: http://cvs.pld-linux.org/
+
+--- ext/r_analysis.c.orig      2011-06-10 06:23:08.000000000 +0000
++++ ext/r_analysis.c
+@@ -1,6 +1,11 @@
++#include "lang.h"
++#ifdef RUBY18
+ #include <regex.h>
++#else
++#include <ruby/regex.h>
++#endif
+ #include <locale.h>
+-#include <st.h>
++#include <ruby/st.h>
+ #include "ferret.h"
+ #include "analysis.h"
+ 
+@@ -47,13 +52,15 @@ static ID id_token_stream;
+ 
+ static VALUE object_space;
+ 
++#ifdef RUBY18
+ extern int ruby_re_search(struct re_pattern_buffer *, const char *, int, int,
+                           int, struct re_registers *);
++#endif
+ 
+ int
+ frt_rb_hash_size(VALUE hash)
+ {
+-    return RHASH(hash)->tbl->num_entries;
++    return RHASH_SIZE(hash);
+ }
+ 
+ /****************************************************************************
+@@ -69,11 +76,11 @@ get_stopwords(VALUE rstop_words)
+     int i, len;
+     VALUE rstr;
+     Check_Type(rstop_words, T_ARRAY);
+-    len = RARRAY(rstop_words)->len;
+-    stop_words = ALLOC_N(char *, RARRAY(rstop_words)->len + 1);
++    len = RARRAY_LEN(rstop_words);
++    stop_words = ALLOC_N(char *, RARRAY_LEN(rstop_words) + 1);
+     stop_words[len] = NULL;
+     for (i = 0; i < len; i++) {
+-        rstr = rb_obj_as_string(RARRAY(rstop_words)->ptr[i]);
++        rstr = rb_obj_as_string(RARRAY_PTR(rstop_words)[i]);
+         stop_words[i] = rs2s(rstr);
+     }
+     return stop_words;
+@@ -132,7 +139,7 @@ frt_set_token(Token *tk, VALUE rt)
+     if (rt == Qnil) return NULL;
+ 
+     Data_Get_Struct(rt, RToken, rtk);
+-    tk_set(tk, rs2s(rtk->text), RSTRING(rtk->text)->len,
++    tk_set(tk, rs2s(rtk->text), RSTRING_LEN(rtk->text),
+            rtk->start, rtk->end, rtk->pos_inc);
+     return tk;
+ }
+@@ -372,7 +379,7 @@ frt_token_to_s(VALUE self)
+     RToken *token;
+     char *buf;
+     GET_TK(token, self);
+-    buf = alloca(RSTRING(token->text)->len + 80);
++    buf = alloca(RSTRING_LEN(token->text) + 80);
+     sprintf(buf, "token[\"%s\":%d:%d:%d]", rs2s(token->text),
+             token->start, token->end, token->pos_inc);
+     return rb_str_new2(buf);
+@@ -621,7 +628,7 @@ typedef struct RegExpTokenStream {
+     VALUE rtext;
+     VALUE regex;
+     VALUE proc;
+-    int   curr_ind;  
++    long   curr_ind;  
+ } RegExpTokenStream;
+ 
+ static void
+@@ -689,16 +696,20 @@ frt_rets_get_text(VALUE self)
+     return RETS(ts)->rtext;
+ }
+ 
++#ifdef RUBY18
++
+ static Token *
+ rets_next(TokenStream *ts)
+ {
+     static struct re_registers regs;
+     int ret, beg, end;
+-    struct RString *rtext = RSTRING(RETS(ts)->rtext);
++    struct RString *rtext = RSTRING_PTR(RETS(ts));
++    long rtext_len = RSTRING_LEN(RETS(ts)->rtext);
++    char *rtext_ptr = RSTRING_PTR(RETS(ts)->rtext);
+     Check_Type(RETS(ts)->regex, T_REGEXP);
+     ret = ruby_re_search(RREGEXP(RETS(ts)->regex)->ptr,
+-                         rtext->ptr, rtext->len,
+-                         RETS(ts)->curr_ind, rtext->len - RETS(ts)->curr_ind,
++                       rtext_ptr, rtext_len,
++                       RETS(ts)->curr_ind, rtext_len - RETS(ts)->curr_ind,
+                          &regs);
+ 
+     if (ret == -2) rb_raise(rb_eStandardError, "regexp buffer overflow");
+@@ -707,15 +718,78 @@ rets_next(TokenStream *ts)
+     beg = regs.beg[0];
+     RETS(ts)->curr_ind = end = regs.end[0];
+     if (NIL_P(RETS(ts)->proc)) {
+-        return tk_set(&(CachedTS(ts)->token), rtext->ptr + beg, end - beg,
++        return tk_set(&(CachedTS(ts)->token), rtext_ptr + beg, end - beg,
+                       beg, end, 1);
+     } else {
+-        VALUE rtok = rb_str_new(rtext->ptr + beg, end - beg);
++        VALUE rtok = rb_str_new(rtext_ptr + beg, end - beg);
+         rtok = rb_funcall(RETS(ts)->proc, id_call, 1, rtok);
+         return tk_set(&(CachedTS(ts)->token), rs2s(rtok),
+-                      RSTRING(rtok)->len, beg, end, 1);
++                      RSTRING_LEN(rtok), beg, end, 1);
++    }
++}
++#else
++
++// partly lifted from ruby 1.9 string.c
++#include <ruby/encoding.h>
++#define BEG(no) regs->beg[no]
++#define END(no) regs->end[no]
++#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
++static VALUE
++  scan_once(VALUE str, VALUE pat, long *start)
++{
++  VALUE match;
++  struct re_registers *regs;
++
++  if (rb_reg_search(pat, str, *start, 0) >= 0) {
++    match = rb_backref_get();
++    regs = RMATCH_REGS(match);
++    if (BEG(0) == END(0)) {
++      rb_encoding *enc = STR_ENC_GET(str);
++      /*
++      * Always consume at least one character of the input string
++       */
++        if (RSTRING_LEN(str) > END(0))
++        *start = END(0)+rb_enc_mbclen(RSTRING_PTR(str)+END(0),
++        RSTRING_END(str), enc);
++      else
++        *start = END(0)+1;
++    }
++    else {
++      *start = END(0);
+     }
++    return rb_reg_nth_match(0, match);
++  }
++  return Qnil;
+ }
++//
++
++static Token *
++  rets_next(TokenStream *ts)
++{
++  VALUE ret;
++  long rtok_len;
++  int beg, end;
++  Check_Type(RETS(ts)->regex, T_REGEXP);
++  ret = scan_once(RETS(ts)->rtext, RETS(ts)->regex, &(RETS(ts)->curr_ind));
++  if (NIL_P(ret)) return NULL;
++
++  Check_Type(ret, T_STRING);
++  rtok_len = RSTRING_LEN(ret);
++  beg = RETS(ts)->curr_ind - rtok_len;
++  end = RETS(ts)->curr_ind;
++
++  if (NIL_P(RETS(ts)->proc)) {
++    return tk_set(&(CachedTS(ts)->token), rs2s(ret), rtok_len,
++      beg, end, 1);
++  } else {
++    VALUE rtok;
++    rtok = rb_funcall(RETS(ts)->proc, id_call, 1, ret);
++    return tk_set(&(CachedTS(ts)->token), rs2s(rtok),
++      RSTRING_LEN(rtok), beg, end, 1);
++  }
++}
++
++#endif
+ 
+ static TokenStream *
+ rets_reset(TokenStream *ts, char *text)
+@@ -1029,8 +1103,8 @@ static int frt_add_mappings_i(VALUE key,
+         }
+         if (TYPE(key) == T_ARRAY) {
+             int i;
+-            for (i = RARRAY(key)->len - 1; i >= 0; i--) {
+-                frt_add_mapping_i(mf, RARRAY(key)->ptr[i], to);
++            for (i = RARRAY_LEN(key) - 1; i >= 0; i--) {
++                frt_add_mapping_i(mf, RARRAY_PTR(key)[i], to);
+             }
+         }
+         else {
diff -r 4abbefab8423 -r 80640b9c89e0 textproc/ruby-ferret/patches/patch-ext_r__index.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/ruby-ferret/patches/patch-ext_r__index.c Sun Jun 19 16:01:52 2011 +0000
@@ -0,0 +1,244 @@
+$NetBSD: patch-ext_r__index.c,v 1.1 2011/06/19 16:01:52 taca Exp $
+
+* Switch to modern Ruby's API: http://cvs.pld-linux.org/



Home | Main Index | Thread Index | Old Index