Help us understand the problem. What is going on with this article?

ruby1.9.3にruby-chasen1.7をインストール

More than 5 years have passed since last update.

rubyの1.9.3でruby-chasen1.7を使えるようにしたくて、ソースコードを修正しました。

ruby-chasen1.7-patch_for_ruby1.9.3.patch
diff --git Makefile Makefile
index 9cd4044..e668785 100644
--- Makefile
+++ Makefile
@@ -215,5 +215,5 @@ chasen.o: chasen.c $(hdrdir)/ruby/ruby.h \
  $(arch_hdrdir)/ruby/config.h \
  $(hdrdir)/ruby/defines.h \
  $(hdrdir)/ruby/intern.h \
- $(hdrdir)/ruby/rubyio.h
+ $(hdrdir)/ruby/io.h

diff --git chasen.c chasen.c
index 177a52c..e41ed48 100644
--- chasen.c
+++ chasen.c
@@ -18,7 +18,7 @@
 ************************************************/

 #include "ruby.h"
-#include "rubyio.h"
+#include "ruby/io.h"

 #include <chasen.h>

@@ -27,10 +27,10 @@ f_chasen_getopt(int argc, VALUE *argv, VALUE class){
    int i;
    char **opt = ALLOCA_N(char*, argc + 2);

-   opt[0] = "chasen.so";
+   opt[0] = RSTRING_PTR("chasen.so");
    for (i = 0; i < argc; i++){
-      Check_SafeStr(argv[i]);
-      opt[i + 1] = RSTRING(argv[i])->ptr;
+      SafeStringValue(argv[i]);
+      opt[i + 1] = RSTRING_PTR(argv[i]);
    }
    opt[argc + 1] = NULL;

@@ -41,13 +41,13 @@ f_chasen_getopt(int argc, VALUE *argv, VALUE class){

 static VALUE
 f_chasen_sparse_tostr(VALUE obj, VALUE str){
-   Check_SafeStr(str);
-   return rb_str_new2(chasen_sparse_tostr(RSTRING(str)->ptr));
+   SafeStringValue(str);
+   return rb_str_new2(chasen_sparse_tostr(RSTRING_PTR(str)));
 }

 static VALUE
 f_chasen_fparse_tostr(VALUE obj, VALUE io){
-   OpenFile *fp;
+   rb_io_t *fp;
    char *buf;
    VALUE dst = Qnil;

@@ -56,7 +56,7 @@ f_chasen_fparse_tostr(VALUE obj, VALUE io){
    rb_io_check_readable(fp);
    dst = rb_str_new(NULL, 0);

-   while ((buf = chasen_fparse_tostr(fp->f)) != NULL) {
+   while ((buf = chasen_fparse_tostr(rb_io_stdio_file(fp))) != NULL) {
       rb_str_cat(dst, buf, strlen(buf));
    }
    return dst;

参考:

quwa
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away