[#23717] error at TestDRbMServer (test/drb) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。どうしても原因がわからないので、報告だけ・・・

18 messages 2004/06/19
[#23718] Re: error at TestDRbMServer (test/drb) — nobu.nakada@... 2004/06/19

なかだです。

[#23719] Re: error at TestDRbMServer (test/drb) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/06/19

山本です。

[#23720] Re: error at TestDRbMServer (test/drb) — nobu.nakada@... 2004/06/19

なかだです。

[#23724] Re: error at TestDRbMServer (test/drb) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2004/06/19

山本です。

[#23762] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

40 messages 2004/06/23

[#23784] URI() — Tanaka Akira <akr@...17n.org>

前から思っていたのですが、URI.parse("http://...") を URI("http://...")

19 messages 2004/06/25

[ruby-dev:23749] Re: WIN32OLEの日本語エラーメッセージが切り詰められる

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2004-06-22 10:52:13 UTC
List: ruby-dev #23749
山本です。

[ruby-dev:23693] のスレッドのパッチと、本スレッドのパッチをまとめました。
改行文字が CR + LF であることに依存しない方向で、少し変えました。
コミットしてもいいでしょうか?(二通り用意しました)

  * win32ole.c(OLE_FREE, ole_event_free) avoid possible SEGV caused by
    CoFreeUnusedLibraries between FolderItemVerb#Release() and
    FolderItemVerbs#Release(). (Microsoft Shell.Application objects)

  * win32ole.c(ole_hresult2msg): should not truncate the message in
    multibyte characters.

  * win32ole.c(ole_hresult2msg): free allocated message heap.

// 改行だけ削除するバージョン

Index: win32ole.c
===================================================================
RCS file: /var/cvs/src/ruby/ext/win32ole/win32ole.c,v
retrieving revision 1.22
diff -u -w -b -p -r1.22 win32ole.c
--- win32ole.c	8 May 2004 03:54:51 -0000	1.22
+++ win32ole.c	22 Jun 2004 09:40:39 -0000
@@ -67,7 +67,6 @@
             (x) = 0;\
         }\
     }\
-    CoFreeUnusedLibraries();\
 }
 
 #define OLEData_Get_Struct(obj, pole) {\
@@ -488,7 +487,7 @@ ole_hresult2msg(hr)
     HRESULT hr;
 {
     VALUE msg = Qnil;
-    char *p_msg;
+    char *p_msg = NULL;
     DWORD dwCount;
 
     char strhr[100];
@@ -501,15 +500,16 @@ ole_hresult2msg(hr)
                             NULL, hr, LOCALE_SYSTEM_DEFAULT,
                             (LPTSTR)&p_msg, 0, NULL);
     if (dwCount > 0) {
-        /* remove dots and CRs/LFs */
+        /* remove CRs/LFs */
         while (dwCount > 0 &&
-               (p_msg[dwCount-1] < ' ' || p_msg[dwCount-1] == '.')) {
+               (p_msg[dwCount-1] == '\r' || p_msg[dwCount-1] == '\n')) {
             p_msg[--dwCount] = '\0';
         }
         if (p_msg[0] != '\0') {
             rb_str_cat2(msg, p_msg);
         }
     }
+    LocalFree(p_msg);
     return msg;
 }
 
@@ -5341,7 +5341,6 @@ ole_event_free(poleev)
             pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie);
             OLE_RELEASE(pcp);
         }
-        CoFreeUnusedLibraries();
     }
 }
 
// '.' も削除するバージョン(オリジナルの挙動)

Index: win32ole.c
===================================================================
RCS file: /var/cvs/src/ruby/ext/win32ole/win32ole.c,v
retrieving revision 1.22
diff -u -w -b -p -r1.22 win32ole.c
--- win32ole.c	8 May 2004 03:54:51 -0000	1.22
+++ win32ole.c	22 Jun 2004 10:15:14 -0000
@@ -67,7 +67,6 @@
             (x) = 0;\
         }\
     }\
-    CoFreeUnusedLibraries();\
 }
 
 #define OLEData_Get_Struct(obj, pole) {\
@@ -488,7 +487,7 @@ ole_hresult2msg(hr)
     HRESULT hr;
 {
     VALUE msg = Qnil;
-    char *p_msg;
+    char *p_msg = NULL;
     DWORD dwCount;
 
     char strhr[100];
@@ -502,14 +501,18 @@ ole_hresult2msg(hr)
                             (LPTSTR)&p_msg, 0, NULL);
     if (dwCount > 0) {
         /* remove dots and CRs/LFs */
-        while (dwCount > 0 &&
-               (p_msg[dwCount-1] < ' ' || p_msg[dwCount-1] == '.')) {
-            p_msg[--dwCount] = '\0';
+        char *term = p_msg + strlen(p_msg);
+        while (p_msg < term) {
+            term = CharPrev(p_msg, term);
+            if (*term == '.' || *term == '\r' || *term == '\n')
+                *term = '\0';
+            else break;
         }
         if (p_msg[0] != '\0') {
             rb_str_cat2(msg, p_msg);
         }
     }
+    LocalFree(p_msg);
     return msg;
 }
 
@@ -5341,7 +5344,6 @@ ole_event_free(poleev)
             pcp->lpVtbl->Unadvise(pcp, poleev->pEvent->m_dwCookie);
             OLE_RELEASE(pcp);
         }
-        CoFreeUnusedLibraries();
     }
 }
 



In This Thread