[ruby-oci8-commit] [416] trunk/ruby-oci8: * ext/oci8/win32.c: undefine boolean to pass compilation on

nobody at rubyforge.org nobody at rubyforge.org
Sat Sep 18 09:33:11 EDT 2010


Revision: 416
Author:   kubo
Date:     2010-09-18 09:33:11 -0400 (Sat, 18 Sep 2010)

Log Message:
-----------
* ext/oci8/win32.c: undefine boolean to pass compilation on
    Cygwin. (reported by Don Hill).
* lib/oci8/encoding-init.rb, lib/oci8/encoding.yml: add a
    mapping from ZHT16HKSCS to Big5-HKSCS when the latter
    is available in ruby.

Modified Paths:
--------------
    branches/ruby-oci8-2.0/ChangeLog
    branches/ruby-oci8-2.0/ext/oci8/win32.c
    branches/ruby-oci8-2.0/lib/oci8/encoding-init.rb
    branches/ruby-oci8-2.0/lib/oci8/encoding.yml
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/win32.c
    trunk/ruby-oci8/lib/oci8/encoding-init.rb
    trunk/ruby-oci8/lib/oci8/encoding.yml

Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog	2010-09-12 12:50:44 UTC (rev 415)
+++ branches/ruby-oci8-2.0/ChangeLog	2010-09-18 13:33:11 UTC (rev 416)
@@ -1,3 +1,10 @@
+2010-09-18  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/win32.c: undefine boolean to pass compilation on
+	    Cygwin. (reported by Don Hill).
+	* lib/oci8/encoding-init.rb, lib/oci8/encoding.yml: add a
+	    mapping from ZHT16HKSCS to Big5-HKSCS when the latter
+	    is available in ruby.
+
 2010-09-12  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/env.c, ext/oci8/extconf.rb: suppress warning
 	    'use "ruby/util.h" instead of bare "util.h".'

Modified: branches/ruby-oci8-2.0/ext/oci8/win32.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/win32.c	2010-09-12 12:50:44 UTC (rev 415)
+++ branches/ruby-oci8-2.0/ext/oci8/win32.c	2010-09-18 13:33:11 UTC (rev 416)
@@ -2,9 +2,15 @@
 /*
   win32.c - part of ruby-oci8
 
-  Copyright (C) 2009 KUBO Takehiro <kubo at jiubao.org>
+  Copyright (C) 2009-2010 KUBO Takehiro <kubo at jiubao.org>
 */
 #include "oci8.h"
+#ifdef __CYGWIN__
+/* boolean is defined as a macro in oratypes.h.
+ * It conflicts with the definition in windows.h.
+ */
+#undef boolean
+#endif
 #include <windows.h>
 
 NORETURN(static void raise_error(void));
@@ -84,14 +90,14 @@
         }
         /* Get ORACLE_HOME */
         name_len = sizeof(name);
-        rv = RegQueryValueEx(arg->hSubKey, "ORACLE_HOME", NULL, &type, name, &name_len);
+        rv = RegQueryValueEx(arg->hSubKey, "ORACLE_HOME", NULL, &type, TO_ORATEXT(name), &name_len);
         if (rv != ERROR_SUCCESS || type != REG_SZ) {
             continue;
         }
         oracle_home = rb_locale_str_new_cstr(name);
         /* Get NLS_LANG */
         name_len = sizeof(name);
-        rv = RegQueryValueEx(arg->hSubKey, "NLS_LANG", NULL, &type, name, &name_len);
+        rv = RegQueryValueEx(arg->hSubKey, "NLS_LANG", NULL, &type, TO_ORATEXT(name), &name_len);
         if (rv != ERROR_SUCCESS || type != REG_SZ) {
             continue;
         }

Modified: branches/ruby-oci8-2.0/lib/oci8/encoding-init.rb
===================================================================
--- branches/ruby-oci8-2.0/lib/oci8/encoding-init.rb	2010-09-12 12:50:44 UTC (rev 415)
+++ branches/ruby-oci8-2.0/lib/oci8/encoding-init.rb	2010-09-18 13:33:11 UTC (rev 416)
@@ -5,7 +5,8 @@
 # try to get NLS_LANG.
 nls_lang = ENV['NLS_LANG']
 
-if defined? OCI8::Win32Util
+# if NLS_LANG is not set, get it from the Windows registry.
+if nls_lang.nil? and defined? OCI8::Win32Util
   dll_path = OCI8::Win32Util.dll_path.upcase
   if dll_path =~ %r{\\BIN\\OCI.DLL}
     oracle_home = $`
@@ -33,6 +34,10 @@
   if enc.nil?
     raise "Ruby encoding name is not found in encoding.yml for NLS_LANG #{nls_lang}."
   end
+  if enc.is_a? Array
+    # Use the first available encoding in the array.
+    enc = enc.find do |e| Encoding.find(e) rescue false; end
+  end
 else
   warn "Warning: NLS_LANG is not set. fallback to US-ASCII."
   enc = 'US-ASCII'

Modified: branches/ruby-oci8-2.0/lib/oci8/encoding.yml
===================================================================
--- branches/ruby-oci8-2.0/lib/oci8/encoding.yml	2010-09-12 12:50:44 UTC (rev 415)
+++ branches/ruby-oci8-2.0/lib/oci8/encoding.yml	2010-09-18 13:33:11 UTC (rev 416)
@@ -40,7 +40,7 @@
 # MS Windows Code Page 950 with Hong Kong Supplementary Character
 # Set HKSCS-2001 (character set conversion to and from Unicode is
 # based on Unicode 3.0)
-ZHT16HKSCS:        Big5         # Does the Big5 include HKSCS?
+ZHT16HKSCS:        [Big5-HKSCS, Big5]
 
 # MS Windows Code Page 950 Traditional Chinese
 ZHT16MSWIN950:     Big5
@@ -166,7 +166,7 @@
 # MS Windows Code Page 950 with Hong Kong Supplementary Character
 # Set HKSCS-2001 (character set conversion to and from Unicode is
 # based on Unicode 3.1)
-ZHT16HKSCS31:      Big5         # Does the Big5 include HKSCS?
+ZHT16HKSCS31:      [Big5-HKSCS, Big5]
 
 # SOPS 32-bit Traditional Chinese
 ZHT32SOPS:         nil          # FIXME

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2010-09-12 12:50:44 UTC (rev 415)
+++ trunk/ruby-oci8/ChangeLog	2010-09-18 13:33:11 UTC (rev 416)
@@ -1,3 +1,10 @@
+2010-09-18  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/win32.c: undefine boolean to pass compilation on
+	    Cygwin. (reported by Don Hill).
+	* lib/oci8/encoding-init.rb, lib/oci8/encoding.yml: add a
+	    mapping from ZHT16HKSCS to Big5-HKSCS when the latter
+	    is available in ruby.
+
 2010-09-12  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/env.c, ext/oci8/extconf.rb: suppress warning
 	    'use "ruby/util.h" instead of bare "util.h".'

Modified: trunk/ruby-oci8/ext/oci8/win32.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/win32.c	2010-09-12 12:50:44 UTC (rev 415)
+++ trunk/ruby-oci8/ext/oci8/win32.c	2010-09-18 13:33:11 UTC (rev 416)
@@ -2,9 +2,15 @@
 /*
   win32.c - part of ruby-oci8
 
-  Copyright (C) 2009 KUBO Takehiro <kubo at jiubao.org>
+  Copyright (C) 2009-2010 KUBO Takehiro <kubo at jiubao.org>
 */
 #include "oci8.h"
+#ifdef __CYGWIN__
+/* boolean is defined as a macro in oratypes.h.
+ * It conflicts with the definition in windows.h.
+ */
+#undef boolean
+#endif
 #include <windows.h>
 
 NORETURN(static void raise_error(void));
@@ -84,14 +90,14 @@
         }
         /* Get ORACLE_HOME */
         name_len = sizeof(name);
-        rv = RegQueryValueEx(arg->hSubKey, "ORACLE_HOME", NULL, &type, name, &name_len);
+        rv = RegQueryValueEx(arg->hSubKey, "ORACLE_HOME", NULL, &type, TO_ORATEXT(name), &name_len);
         if (rv != ERROR_SUCCESS || type != REG_SZ) {
             continue;
         }
         oracle_home = rb_locale_str_new_cstr(name);
         /* Get NLS_LANG */
         name_len = sizeof(name);
-        rv = RegQueryValueEx(arg->hSubKey, "NLS_LANG", NULL, &type, name, &name_len);
+        rv = RegQueryValueEx(arg->hSubKey, "NLS_LANG", NULL, &type, TO_ORATEXT(name), &name_len);
         if (rv != ERROR_SUCCESS || type != REG_SZ) {
             continue;
         }

Modified: trunk/ruby-oci8/lib/oci8/encoding-init.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/encoding-init.rb	2010-09-12 12:50:44 UTC (rev 415)
+++ trunk/ruby-oci8/lib/oci8/encoding-init.rb	2010-09-18 13:33:11 UTC (rev 416)
@@ -65,6 +65,10 @@
     if enc.nil?
       raise "Ruby encoding name is not found in encoding.yml for NLS_LANG #{nls_lang}."
     end
+    if enc.is_a? Array
+      # Use the first available encoding in the array.
+      enc = enc.find do |e| Encoding.find(e) rescue false; end
+    end
   end
   OCI8.encoding = enc
 end

Modified: trunk/ruby-oci8/lib/oci8/encoding.yml
===================================================================
--- trunk/ruby-oci8/lib/oci8/encoding.yml	2010-09-12 12:50:44 UTC (rev 415)
+++ trunk/ruby-oci8/lib/oci8/encoding.yml	2010-09-18 13:33:11 UTC (rev 416)
@@ -40,7 +40,7 @@
 # MS Windows Code Page 950 with Hong Kong Supplementary Character
 # Set HKSCS-2001 (character set conversion to and from Unicode is
 # based on Unicode 3.0)
-ZHT16HKSCS:        Big5         # Does the Big5 include HKSCS?
+ZHT16HKSCS:        [Big5-HKSCS, Big5]
 
 # MS Windows Code Page 950 Traditional Chinese
 ZHT16MSWIN950:     Big5
@@ -166,7 +166,7 @@
 # MS Windows Code Page 950 with Hong Kong Supplementary Character
 # Set HKSCS-2001 (character set conversion to and from Unicode is
 # based on Unicode 3.1)
-ZHT16HKSCS31:      Big5         # Does the Big5 include HKSCS?
+ZHT16HKSCS31:      [Big5-HKSCS, Big5]
 
 # SOPS 32-bit Traditional Chinese
 ZHT32SOPS:         nil          # FIXME




More information about the ruby-oci8-commit mailing list