[Groonga-commit] ranguba/rroonga at 7c0e5ed [master] Encoding is always available on Ruby 2.1 or later

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Mar 6 00:12:16 JST 2016


Kouhei Sutou	2016-03-06 00:12:16 +0900 (Sun, 06 Mar 2016)

  New Revision: 7c0e5ed7a18470cc81328fdfbe28521b3c23a78e
  https://github.com/ranguba/rroonga/commit/7c0e5ed7a18470cc81328fdfbe28521b3c23a78e

  Message:
    Encoding is always available on Ruby 2.1 or later

  Modified files:
    ext/groonga/rb-grn-context.c
    ext/groonga/rb-grn-encoding.c
    ext/groonga/rb-grn.h

  Modified: ext/groonga/rb-grn-context.c (+0 -10)
===================================================================
--- ext/groonga/rb-grn-context.c    2016-03-06 00:10:38 +0900 (447215d)
+++ ext/groonga/rb-grn-context.c    2016-03-06 00:12:16 +0900 (f42a9a7)
@@ -302,18 +302,13 @@ rb_grn_context_rb_string_new (grn_ctx *context, const char *string, long length)
 {
     if (length < 0)
         length = strlen(string);
-#ifdef HAVE_RUBY_ENCODING_H
     return rb_enc_str_new(string, length,
                           rb_grn_encoding_to_ruby_encoding(context->encoding));
-#else
-    return rb_str_new(string, length);
-#endif
 }
 
 VALUE
 rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
 {
-#ifdef HAVE_RUBY_ENCODING_H
     int index, to_index;
     rb_encoding *encoding, *to_encoding;
     grn_encoding context_encoding;
@@ -339,7 +334,6 @@ rb_grn_context_rb_string_encode (grn_ctx *context, VALUE rb_string)
 
     rb_string = rb_str_encode(rb_string, rb_enc_from_encoding(to_encoding),
                               0, Qnil);
-#endif
     return rb_string;
 }
 
@@ -601,14 +595,10 @@ rb_grn_context_set_encoding (VALUE self, VALUE rb_encoding)
 static VALUE
 rb_grn_context_get_ruby_encoding (VALUE self)
 {
-#ifdef HAVE_RUBY_ENCODING_H
     grn_encoding encoding;
 
     encoding = GRN_CTX_GET_ENCODING(SELF(self));
     return rb_grn_encoding_to_ruby_encoding_object(encoding);
-#else
-    return Qnil;
-#endif
 }
 
 /*

  Modified: ext/groonga/rb-grn-encoding.c (+0 -2)
===================================================================
--- ext/groonga/rb-grn-encoding.c    2016-03-06 00:10:38 +0900 (31d5d68)
+++ ext/groonga/rb-grn-encoding.c    2016-03-06 00:12:16 +0900 (cc394cf)
@@ -148,7 +148,6 @@ rb_grn_encoding_to_ruby_object (grn_encoding encoding)
     return rb_encoding;
 }
 
-#ifdef HAVE_RUBY_ENCODING_H
 rb_encoding *
 rb_grn_encoding_to_ruby_encoding (grn_encoding encoding)
 {
@@ -190,7 +189,6 @@ rb_grn_encoding_to_ruby_encoding_object (grn_encoding encoding)
     rb_encoding *rb_encoding = rb_grn_encoding_to_ruby_encoding(encoding);
     return rb_enc_from_encoding(rb_encoding);
 }
-#endif
 
 /*
  * デフォルトのエンコーディングを返す。

  Modified: ext/groonga/rb-grn.h (+1 -5)
===================================================================
--- ext/groonga/rb-grn.h    2016-03-06 00:10:38 +0900 (b8c6e44)
+++ ext/groonga/rb-grn.h    2016-03-06 00:12:16 +0900 (740cd56)
@@ -21,10 +21,8 @@
 #define __RB_GRN_H__
 
 #include <ruby.h>
+#include <ruby/encoding.h>
 
-#ifdef HAVE_RUBY_ENCODING_H
-#  include <ruby/encoding.h>
-#endif
 #ifdef HAVE_RUBY_INTERN_H
 #  include <ruby/intern.h>
 #endif
@@ -745,11 +743,9 @@ VALUE          rb_grn_index_new                     (VALUE rb_index_column,
 grn_encoding   rb_grn_encoding_from_ruby_object     (VALUE object,
                                                      grn_ctx *context);
 VALUE          rb_grn_encoding_to_ruby_object       (grn_encoding encoding);
-#ifdef HAVE_RUBY_ENCODING_H
 rb_encoding   *rb_grn_encoding_to_ruby_encoding     (grn_encoding encoding);
 VALUE          rb_grn_encoding_to_ruby_encoding_object
                                                     (grn_encoding encoding);
-#endif
 
 grn_ctx       *rb_grn_context_from_ruby_object      (VALUE object);
 VALUE          rb_grn_context_to_ruby_object        (grn_ctx *context);
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index