[ruby-oci8-commit] [298] trunk/ruby-oci8: * ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId()

nobody at rubyforge.org nobody at rubyforge.org
Sun Dec 21 07:49:05 EST 2008


Revision: 298
Author:   kubo
Date:     2008-12-21 07:49:05 -0500 (Sun, 21 Dec 2008)

Log Message:
-----------
* ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId()
* ext/oci8/encoding.c: add OCI8#charset_name2id and
    OCI8#charset_id2name.
* ext/oci8/env.c: include <util.h> only when ruby 1.8.
* ext/oci8/oci8.h: don't include <rubyio.h> which is not used
    anywhere.
* ext/oci8/ocinumber.c: include <errno.h> to compile
    ruby-oci8 for ruby 1.9.
* lib/oci8/metadata.rb: comment duplicated typecode.
* test/test_all.rb: use AutoRunner when it is found.
    Ruby 1.9's test unit does't has AutoRunner.
* test/test_oranumber.rb: explicity convert actual_val, which is
    passed to before assert_in_delta(), to a Float to prevent
    SEGV in OCINumberSub().

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/apiwrap.yml
    trunk/ruby-oci8/ext/oci8/encoding.c
    trunk/ruby-oci8/ext/oci8/env.c
    trunk/ruby-oci8/ext/oci8/oci8.h
    trunk/ruby-oci8/ext/oci8/ocinumber.c
    trunk/ruby-oci8/lib/oci8/metadata.rb
    trunk/ruby-oci8/test/test_all.rb
    trunk/ruby-oci8/test/test_oranumber.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ChangeLog	2008-12-21 12:49:05 UTC (rev 298)
@@ -1,3 +1,19 @@
+2008-12-21  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/apiwrap.yml: add OCINlsCharSetNameToId()
+	* ext/oci8/encoding.c: add OCI8#charset_name2id and
+	    OCI8#charset_id2name.
+	* ext/oci8/env.c: include <util.h> only when ruby 1.8.
+	* ext/oci8/oci8.h: don't include <rubyio.h> which is not used
+	    anywhere.
+	* ext/oci8/ocinumber.c: include <errno.h> to compile
+	    ruby-oci8 for ruby 1.9.
+	* lib/oci8/metadata.rb: comment duplicated typecode.
+	* test/test_all.rb: use AutoRunner when it is found.
+	    Ruby 1.9's test unit does't has AutoRunner.
+	* test/test_oranumber.rb: explicity convert actual_val, which is
+	    passed to before assert_in_delta(), to a Float to prevent
+	    SEGV in OCINumberSub().
+
 2008-12-14  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/stmt.c: fix comment.
 	* test/test_rowid.rb: add one assertion as ruby-oci8 1.0 branch does.

Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.yml	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.yml	2008-12-21 12:49:05 UTC (rev 298)
@@ -1126,6 +1126,12 @@
             - size_t buflen
             - ub2 id
 
+OCINlsCharSetNameToId:
+  :version: 920
+  :ret:     ub2
+  :args:    - dvoid *envhp
+            - const oratext *name
+
 #
 # Oracle 10.1
 #

Modified: trunk/ruby-oci8/ext/oci8/encoding.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/encoding.c	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ext/oci8/encoding.c	2008-12-21 12:49:05 UTC (rev 298)
@@ -23,14 +23,11 @@
 
 /* Oracle charset id -> Oracle charset name */
 static VALUE csid2name;
-VALUE oci8_charset_id2name(VALUE svc, VALUE csid);
 
-#ifdef HAVE_TYPE_RB_ENCODING
 /* Oracle charset name -> Oracle charset id */
 static ID id_upcase;
 static VALUE csname2id;
 static VALUE oci8_charset_name2id(VALUE svc, VALUE name);
-#endif /* HAVE_TYPE_RB_ENCODING */
 
 VALUE oci8_charset_id2name(VALUE svc, VALUE csid)
 {
@@ -79,22 +76,19 @@
     }
     OBJ_FREEZE(name);
     rb_hash_aset(csid2name, csid, name);
-#ifdef HAVE_TYPE_RB_ENCODING
     rb_hash_aset(csname2id, name, csid);
-#endif /* HAVE_TYPE_RB_ENCODING */
     return name;
 }
 
-#ifdef HAVE_TYPE_RB_ENCODING
-
 static VALUE oci8_charset_name2id(VALUE svc, VALUE name)
 {
-    VALUE csid = rb_hash_aref(csname2id, StringValue(name));
+    VALUE csid;
 
+    name = rb_funcall(name, id_upcase, 0);
+    csid = rb_hash_aref(csname2id, StringValue(name));
     if (!NIL_P(csid)) {
         return csid;
     }
-    name = rb_funcall(name, id_upcase, 0);
     if (have_OCINlsCharSetNameToId) {
         /* Oracle 9iR2 or upper */
         ub2 rv;
@@ -124,32 +118,27 @@
         bind_vars[1].alenp = NULL;
 
         /* convert chaset name to charset id by querying Oracle server. */
-        oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars);
+        oci8_exec_sql(oci8_get_svcctx(svc), "BEGIN :csid := nls_charset_id(:name); END;", 0, NULL, 2, bind_vars, 1);
         if (ind) {
             return Qnil;
         }
-        csid = INT2FIX(id);
+        csid = INT2FIX(ival);
     }
     rb_hash_aset(csid2name, csid, name);
     rb_hash_aset(csname2id, name, csid);
     return csid;
 }
 
-#endif /* HAVE_TYPE_RB_ENCODING */
 
 void Init_oci8_encoding(VALUE cOCI8)
 {
     csid2name = rb_hash_new();
     rb_global_variable(&csid2name);
 
-#ifdef HAVE_TYPE_RB_ENCODING
     id_upcase = rb_intern("upcase");
     csname2id = rb_hash_new();
     rb_global_variable(&csname2id);
-#endif /* HAVE_TYPE_RB_ENCODING */
 
-#if 0
     rb_define_method(cOCI8, "charset_name2id", oci8_charset_name2id, 1);
     rb_define_method(cOCI8, "charset_id2name", oci8_charset_id2name, 1);
-#endif
 }

Modified: trunk/ruby-oci8/ext/oci8/env.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/env.c	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ext/oci8/env.c	2008-12-21 12:49:05 UTC (rev 298)
@@ -7,11 +7,8 @@
 */
 #include "oci8.h"
 
-/* ruby_setenv */
-#ifdef HAVE_RUBY_UTIL_H
-#include <ruby/util.h>
-#endif
-#ifdef HAVE_UTIL_H
+#if !defined(RUBY_VM)
+/* ruby_setenv for workaround ruby 1.8.4 */
 #include <util.h>
 #endif
 

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2008-12-21 12:49:05 UTC (rev 298)
@@ -8,7 +8,6 @@
 #define _RUBY_OCI_H_ 1
 
 #include "ruby.h"
-#include "rubyio.h"
 #ifdef HAVE_INTERN_H
 #include "intern.h"
 #endif

Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-12-21 12:49:05 UTC (rev 298)
@@ -10,6 +10,7 @@
  */
 #include "oci8.h"
 #include <orl.h>
+#include <errno.h>
 
 #ifndef RUBY_VM
 /* ruby 1.8 */

Modified: trunk/ruby-oci8/lib/oci8/metadata.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/metadata.rb	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/lib/oci8/metadata.rb	2008-12-21 12:49:05 UTC (rev 298)
@@ -501,10 +501,10 @@
         when 189; :interval_ym # OCI_TYPECODE_INTERVAL_YM
         when 190; :interval_ds # OCI_TYPECODE_INTERVAL_DS
         when 104; :urowid      # OCI_TYPECODE_UROWID
-        when 228; :otmfirst    # OCI_TYPECODE_OTMFIRST
-        when 320; :otmlast     # OCI_TYPECODE_OTMLAST
-        when 228; :sysfirst    # OCI_TYPECODE_SYSFIRST
-        when 235; :syslast     # OCI_TYPECODE_SYSLAST
+        #when 228; :otmfirst   # OCI_TYPECODE_OTMFIRST
+        #when 320; :otmlast    # OCI_TYPECODE_OTMLAST
+        #when 228; :sysfirst   # OCI_TYPECODE_SYSFIRST
+        #when 235; :syslast    # OCI_TYPECODE_SYSLAST
         when 266; :pls_integer # OCI_TYPECODE_PLS_INTEGER
         end
       end

Modified: trunk/ruby-oci8/test/test_all.rb
===================================================================
--- trunk/ruby-oci8/test/test_all.rb	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/test/test_all.rb	2008-12-21 12:49:05 UTC (rev 298)
@@ -35,5 +35,6 @@
 end
 
 #Test::Unit::AutoRunner.run(true, true)
-Test::Unit::AutoRunner.run()
-
+if defined? Test::Unit::AutoRunner
+  Test::Unit::AutoRunner.run()
+end

Modified: trunk/ruby-oci8/test/test_oranumber.rb
===================================================================
--- trunk/ruby-oci8/test/test_oranumber.rb	2008-12-14 13:26:05 UTC (rev 297)
+++ trunk/ruby-oci8/test/test_oranumber.rb	2008-12-21 12:49:05 UTC (rev 298)
@@ -98,6 +98,9 @@
           puts '-----------'
           raise $!
         end
+        # explicity convert actual_val to a Float to prevent SEGV
+        # in OCINumberSub().
+        actual_val = actual_val.to_f if defined? ::MiniTest
         assert_in_delta(expected_val, actual_val, delta, x)
       end
     end




More information about the ruby-oci8-commit mailing list