[前][次][番号順一覧][スレッド一覧]

ruby-changes:44230

From: usa <ko1@a...>
Date: Sat, 1 Oct 2016 00:50:36 +0900 (JST)
Subject: [ruby-changes:44230] usa:r56303 (ruby_2_2): merge revision(s) 49495: [Backport #12183]

usa	2016-10-01 00:50:14 +0900 (Sat, 01 Oct 2016)

  New Revision: 56303

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56303

  Log:
    merge revision(s) 49495: [Backport #12183]
    
    * ext/win32ole/win32ole.c (Init_win32ole): should not use atexit to
      free allocated hash table to avoid error on Cygwin.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ext/win32ole/win32ole.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/ext/win32ole/win32ole.c
===================================================================
--- ruby_2_2/ext/win32ole/win32ole.c	(revision 56302)
+++ ruby_2_2/ext/win32ole/win32ole.c	(revision 56303)
@@ -26,7 +26,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L26
 const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A}};
 #endif
 
-#define WIN32OLE_VERSION "1.8.3"
+#define WIN32OLE_VERSION "1.8.4"
 
 typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
     (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -54,13 +54,13 @@ static HINSTANCE ghhctrl = NULL; https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L54
 static HINSTANCE gole32 = NULL;
 static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL;
 static VALUE com_hash;
+static VALUE enc2cp_hash;
 static IDispatchVtbl com_vtbl;
 static UINT cWIN32OLE_cp = CP_ACP;
 static rb_encoding *cWIN32OLE_enc;
 static UINT g_cp_to_check = CP_ACP;
 static char g_lcid_to_check[8 + 1];
 static VARTYPE g_nil_to = VT_ERROR;
-static st_table *enc2cp_table;
 static IMessageFilterVtbl message_filter;
 static IMessageFilter imessage_filter = { &message_filter };
 static IMessageFilter* previous_filter;
@@ -166,9 +166,6 @@ static VALUE ole_ptrtype2val(ITypeInfo * https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L166
 static VALUE fole_method_help(VALUE self, VALUE cmdname);
 static VALUE fole_activex_initialize(VALUE self);
 
-static void init_enc2cp(void);
-static void free_enc2cp(void);
-
 static void com_hash_free(void *ptr);
 static void com_hash_mark(void *ptr);
 static size_t com_hash_size(const void *ptr);
@@ -179,8 +176,8 @@ static const rb_data_type_t ole_datatype https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L176
     0, 0, RUBY_TYPED_FREE_IMMEDIATELY
 };
 
-static const rb_data_type_t com_hash_datatype = {
-    "com_hash",
+static const rb_data_type_t win32ole_hash_datatype = {
+    "win32ole_hash",
     {com_hash_mark, com_hash_free, com_hash_size,},
     0, 0, RUBY_TYPED_FREE_IMMEDIATELY
 };
@@ -857,10 +854,11 @@ ole_vstr2wc(VALUE vstr) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L854
     UINT size = 0;
     LPWSTR pw;
     st_data_t data;
+    struct st_table *tbl = DATA_PTR(enc2cp_hash);
     enc = rb_enc_get(vstr);
 
-    if (st_lookup(enc2cp_table, (st_data_t)enc, &data)) {
-        cp = (int)data;
+    if (st_lookup(tbl, (VALUE)enc | FIXNUM_FLAG, &data)) {
+        cp = FIX2INT((VALUE)data);
     } else {
         cp = ole_encoding2cp(enc);
         if (code_page_installed(cp) ||
@@ -872,7 +870,7 @@ ole_vstr2wc(VALUE vstr) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L870
             cp == CP_UTF7 ||
             cp == CP_UTF8 ||
             cp == 51932) {
-            st_insert(enc2cp_table, (st_data_t)enc, (st_data_t)cp);
+            st_insert(tbl, (VALUE)enc | FIXNUM_FLAG, INT2FIX(cp));
         } else {
             rb_raise(eWIN32OLERuntimeError, "not installed Windows codepage(%d) according to `%s'", cp, rb_enc_name(enc));
         }
@@ -3868,18 +3866,6 @@ typelib_from_val(VALUE obj, ITypeLib **p https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L3866
 }
 
 static void
-init_enc2cp(void)
-{
-    enc2cp_table = st_init_numtable();
-}
-
-static void
-free_enc2cp(void)
-{
-    st_free_table(enc2cp_table);
-}
-
-static void
 com_hash_free(void *ptr)
 {
     st_table *tbl = ptr;
@@ -3921,7 +3907,10 @@ Init_win32ole(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L3907
     message_filter.RetryRejectedCall = mf_RetryRejectedCall;
     message_filter.MessagePending = mf_MessagePending;
 
-    com_hash = TypedData_Wrap_Struct(rb_cData, &com_hash_datatype, st_init_numtable());
+    enc2cp_hash = TypedData_Wrap_Struct(rb_cData, &win32ole_hash_datatype, st_init_numtable());
+    rb_gc_register_mark_object(enc2cp_hash);
+
+    com_hash = TypedData_Wrap_Struct(rb_cData, &win32ole_hash_datatype, st_init_numtable());
     rb_gc_register_mark_object(com_hash);
 
     cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject);
@@ -4067,7 +4056,5 @@ Init_win32ole(void) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/win32ole/win32ole.c#L4056
     Init_win32ole_record();
     Init_win32ole_error();
 
-    init_enc2cp();
-    atexit((void (*)(void))free_enc2cp);
     ole_init_cp();
 }
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 56302)
+++ ruby_2_2/version.h	(revision 56303)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-10-01"
-#define RUBY_PATCHLEVEL 372
+#define RUBY_PATCHLEVEL 373
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 56302)
+++ ruby_2_2/ChangeLog	(revision 56303)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sat Oct  1 00:49:40 2016  Masaki Suketa <masaki.suketa@n...>
+
+	* ext/win32ole/win32ole.c (Init_win32ole): should not use atexit to
+	  free allocated hash table to avoid error on Cygwin.
+
 Sat Oct  1 00:43:11 2016  Naohisa Goto  <ngotogenome@g...>
 
 	* test/fiddle/test_pointer.rb (test_to_str, test_to_s, test_aref_aset):

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r49495


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]