[Bug:1.9] compile error on win32ole with Mingw of MacPorts


#1

e$B$J$+$@$G$9!#e(B

MacPortse$B$Ke(Bmingw-gcce$B$^$G$"$k$H$$$&$N$K6C$$$F;n$7$F$_$?$N$G$9$,!“e(B
win32olee$B$G%3%s%Q%$%k%(%i!<$K$J$j$^$7$?!#BP1~$,8E$$$N$+!“e(B
IMultiLanguage2e$B$I$3$m$+e(Bmlang.he$B$b$J$$$h$&$G$9!#e(Bwin32ole.ce$B$G$O0l8+e(B
e$BBP1~$7$F$$$k$h$&$K8+$($^$9$,!”<B:]$K$Oe(Bvoid*e$B$r;H$&%3!<%I$K$J$C$Fe(B
e$B$7$^$&$?$a%3%s%Q%$%k$G$-$^$;$s!#e(BIMultiLanguagee$B$b$J$$$H$-$O0J2<$Ne(B
e$B$I$A$i$+$”$?$j$K$9$k$N$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#e(B

(1) win32olee$B$O%3%s%Q%$%k$5$;$J$$e(B
(2) e$B<B9T;~$K>o$K%(%i!<$K$9$ke(B

extconf.rbe$B$Ge(Bexite$B$9$k$@$1$J$N$Ge(B(1)e$B$O>JN,$7$^$9!#e(B(2)e$B$N%Q%C%A$r$D$1e(B
e$B$^$9!#e(B

Index: ext/win32ole/win32ole.c

— ext/win32ole/win32ole.c (revision 22130)
+++ ext/win32ole/win32ole.c (working copy)
@@ -24,5 +24,7 @@
#include <olectl.h>
#include <ole2.h>
+#if defined(HAVE_TYPE_IMULTILANGUAGE2) ||
defined(HAVE_TYPE_IMULTILANGUAGE)
#include <mlang.h>
+#endif
#include <stdlib.h>
#include <math.h>
@@ -224,5 +226,5 @@ static IMultiLanguage2 *pIMultiLanguage
static IMultiLanguage *pIMultiLanguage = NULL;
#else
-static void pIMultiLanguage = NULL; / dummy /
+#define pIMultiLanguage NULL /
dummy */
#endif

@@ -286,6 +288,9 @@ static VALUE date2time_str(double date);
static rb_encoding *ole_cp2encoding(UINT cp);
static UINT ole_encoding2cp(rb_encoding *enc);
-static void load_conv_function51932();
-static UINT ole_init_cp();
+NORETURN(static void failed_load_conv51932(void));
+#ifndef pIMultiLanguage
+static void load_conv_function51932(void);
+#endif
+static UINT ole_init_cp(void);
static char *ole_wc2mb(LPWSTR pw);
static VALUE ole_hresult2msg(HRESULT hr);
@@ -977,5 +982,12 @@ static UINT ole_encoding2cp(rb_encoding

static void
-load_conv_function51932()
+failed_load_conv51932(void)
+{

  • rb_raise(eWIN32OLERuntimeError, “fail to load convert function for
    CP51932”);
    +}

+#ifndef pIMultiLanguage
+static void
+load_conv_function51932(void)
{
HRESULT hr = E_NOINTERFACE;
@@ -988,14 +1000,16 @@ load_conv_function51932()
hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL,
CLSCTX_INPROC_SERVER,
&IID_IMultiLanguage, &p);
-#else

  • hr = E_NOINTERFACE;
  • p = NULL;
    #endif
    if (FAILED(hr)) {
  •  rb_raise(eWIN32OLERuntimeError, "fail to load convert function 
    

for CP51932");

  •  failed_load_conv51932();
    
    }
    pIMultiLanguage = p;
    }
    }
    +#else
    +#define load_conv_function51932() failed_load_conv51932()
    +#endif

+#define conv_51932(cp) ((cp) == 51932 && (load_conv_function51932(),
1))

static void
@@ -1013,9 +1027,9 @@ set_ole_codepage(UINT cp)
case CP_UTF7:
case CP_UTF8:

  •        cWIN32OLE_cp = cp;
    
  •        break;
       case 51932:
           cWIN32OLE_cp = cp;
    
  •        if (cp == 51932) {
    
  •            load_conv_function51932();
    
  •        }
    
  •        load_conv_function51932();
           break;
       default:
    

@@ -1029,5 +1043,5 @@ set_ole_codepage(UINT cp)

static UINT
-ole_init_cp()
+ole_init_cp(void)
{
UINT cp;
@@ -1109,10 +1123,9 @@ ole_wc2mb(LPWSTR pw)
{
LPSTR pm;

  • HRESULT hr;
    int size = 0;
  • DWORD dw = 0;
  • if (cWIN32OLE_cp == 51932) {
  • load_conv_function51932();
  • hr =
    pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
  • if (conv_51932(cWIN32OLE_cp)) {
    +#ifndef pIMultiLanguage
  • DWORD dw = 0;
  • HRESULT hr =
    pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
    &dw, cWIN32OLE_cp, pw, NULL, NULL, &size);
    if (FAILED(hr)) {
    @@ -1126,4 +1139,5 @@ ole_wc2mb(LPWSTR pw)
    }
    pm[size] = ‘\0’;
    +#endif
    return pm;
    }
    @@ -1328,7 +1342,4 @@ ole_vstr2wc(VALUE vstr)
    int size = 0;
    LPWSTR pw;
  • int len = 0;
  • DWORD dw = 0;
  • HRESULT hr;
    st_data_t data;
    enc = rb_enc_get(vstr);
    @@ -1352,9 +1363,9 @@ ole_vstr2wc(VALUE vstr)
    }
    }
  • if (cp == 51932) {
  • load_conv_function51932();
  • len = RSTRING_LEN(vstr);
  • size = 0;
  • hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
  • if (conv_51932(cp)) {
    +#ifndef pIMultiLanguage
  • DWORD dw = 0;
  • int len = RSTRING_LEN(vstr);
  • HRESULT hr =
    pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
    &dw, cp, RSTRING_PTR(vstr), &len, NULL, &size);
    if (FAILED(hr)) {
    @@ -1368,4 +1379,5 @@ ole_vstr2wc(VALUE vstr)
    ole_raise(hr, eWIN32OLERuntimeError, “fail to convert CP%d
    to Unicode”, cp);
    }
    +#endif
    return pw;
    }
    @@ -1381,12 +1393,10 @@ ole_mb2wc(char *pm, int len)
    int size = 0;
    LPWSTR pw;
  • HRESULT hr;

  • DWORD dw = 0;

  • int n = len;

  • if (cWIN32OLE_cp == 51932) {

  • load_conv_function51932();

  • size = 0;

  • hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,

  • if (conv_51932(cWIN32OLE_cp)) {
    +#ifndef pIMultiLanguage
  • DWORD dw = 0;
  • int n = len;
  • HRESULT hr =
    pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
    &dw, cWIN32OLE_cp, pm, &n, NULL, &size);
    if (FAILED(hr)) {
    @@ -1399,4 +1409,5 @@ ole_mb2wc(char *pm, int len)
    ole_raise(hr, eWIN32OLERuntimeError, “fail to convert CP%d
    to Unicode”, cWIN32OLE_cp);
    }
    +#endif
    return pw;
    }

#2

e$BCfEDe(B e$B?-1Ye(B wrote:

extconf.rbe$B$Ge(Bexite$B$9$k$@$1$J$N$Ge(B(1)e$B$O>JN,$7$^$9!#e(B(2)e$B$N%Q%C%A$r$D$1e(B
e$B$^$9!#e(B

e$B%3%_%C%H$7$F$$$?$@$1$^$9$+!)e(B

e$B$H$3$m$G!"$h$/$o$+$C$F$J$$$N$G$9$,!"e(BMacPorts(e$B!)e(B)e$B$N4D6-$Ge(B
win32olee$B$C$FF0:n$9$k$b$N$J$s$G$7$g$&$+!)e(B

e$B85!9!"e(BIMultiLanguagee$B$,$J$/$Fe(Bwin32olee$B$,F0$/4D6-$H$$$&$N$re(B
e$B$A$c$s$HA[Dj$7$F$J$+$C$?$N$G!"CfESH>C<$JBP1~$K$J$C$F$$$?$H;W$$$^$9!#e(B

e$B=uEDe(B e$B2m5*e(B


#3

e$B%A%1%C%He(B #1132 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r22180.

http://redmine.ruby-lang.org/issues/show/1132


#4

e$B$J$+$@$G$9!#e(B

At Mon, 9 Feb 2009 08:19:01 +0900,
Masaki S. wrote in [ruby-dev:37953]:

e$B$H$3$m$G!"$h$/$o$+$C$F$J$$$N$G$9$,!"e(BMacPorts(e$B!)e(B)e$B$N4D6-$Ge(B
win32olee$B$C$FF0:n$9$k$b$N$J$s$G$7$g$&$+!)e(B

e$B85!9!"e(BIMultiLanguagee$B$,$J$/$Fe(Bwin32olee$B$,F0$/4D6-$H$$$&$N$re(B
e$B$A$c$s$HA[Dj$7$F$J$+$C$?$N$G!"CfESH>C<$JBP1~$K$J$C$F$$$?$H;W$$$^$9!#e(B

winee$B$b$"$k$N$G$9$,!"e(B
$ wine …/i386-mingw32/ruby -v
err:ntdll:RtlpWaitForCriticalSection section 0x6034c698 “?” wait timed
out in thread 0009, blocked by 0000, retrying (60 sec)

e$B$H%k!<%W$7$F$7$^$$$^$9!#$H$$$&$o$1$G!"8=>u$G$O%/%m%9%3%s%Q%$%k$@e(B
e$B$1$G$9!#e(B