1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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;

参考:

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?