[Mingw-w64-public] [PATCH 1/5] gai_strerrorA: reimplement without FormatMessageA (forbidden in Windows Store)
--- mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c index 8f7f679..956f84f 100644 --- a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c +++ b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c @@ -5,13 +5,16 @@ #define __CRT__NO_INLINE #include #include +#include -char *gai_strerrorA(int ecode) +WINAPI char *gai_strerrorA(int ecode) { - DWORD dwMsgLen __attribute__((unused)); static char buff[GAI_STRERROR_BUFFER_SIZE + 1]; - dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK, - NULL, ecode, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPSTR)buff, - GAI_STRERROR_BUFFER_SIZE, NULL); +wchar_t *u = gai_strerrorW(ecode); +if (!u) +return NULL; + +wcstombs(buff, u, GAI_STRERROR_BUFFER_SIZE + 1); + return buff; } -- 1.8.3.2 -- DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH 1/5] gai_strerrorA: reimplement without FormatMessageA (forbidden in Windows Store)
2013/11/16 Rafaël Carré : > --- > mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c | 13 - > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c > b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c > index 8f7f679..956f84f 100644 > --- a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c > +++ b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c > @@ -5,13 +5,16 @@ > #define __CRT__NO_INLINE > #include > #include > +#include > > -char *gai_strerrorA(int ecode) > +WINAPI char *gai_strerrorA(int ecode) For what is this WINAPI? I doubt that it is required. AFAI read documentation is gai_strerrorA not stdcall. > { > - DWORD dwMsgLen __attribute__((unused)); > static char buff[GAI_STRERROR_BUFFER_SIZE + 1]; > - dwMsgLen = > FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK, > - NULL, ecode, > MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPSTR)buff, > - GAI_STRERROR_BUFFER_SIZE, NULL); > +wchar_t *u = gai_strerrorW(ecode); > +if (!u) > +return NULL; Is it actual possible that gai_strerrorW returns NULL?!? > +wcstombs(buff, u, GAI_STRERROR_BUFFER_SIZE + 1); > + > return buff; > } > -- > 1.8.3.2 Rest of the patch is ok. Regards, Kai -- DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
Re: [Mingw-w64-public] [PATCH 1/5] gai_strerrorA: reimplement without FormatMessageA (forbidden in Windows Store)
Le 16/11/2013 22:40, Kai Tietz a écrit : > 2013/11/16 Rafaël Carré : >> --- >> mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c | 13 - >> 1 file changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c >> b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c >> index 8f7f679..956f84f 100644 >> --- a/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c >> +++ b/mingw-w64-crt/libsrc/ws2tcpip/gai_strerrorA.c >> @@ -5,13 +5,16 @@ >> #define __CRT__NO_INLINE >> #include >> #include >> +#include >> >> -char *gai_strerrorA(int ecode) >> +WINAPI char *gai_strerrorA(int ecode) > For what is this WINAPI? I doubt that it is required. AFAI read > documentation is gai_strerrorA not stdcall. I have no clue ... I will remove it and retest. >> { >> - DWORD dwMsgLen __attribute__((unused)); >> static char buff[GAI_STRERROR_BUFFER_SIZE + 1]; >> - dwMsgLen = >> FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_MAX_WIDTH_MASK, >> - NULL, ecode, >> MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPSTR)buff, >> - GAI_STRERROR_BUFFER_SIZE, NULL); >> +wchar_t *u = gai_strerrorW(ecode); >> +if (!u) >> +return NULL; > Is it actual possible that gai_strerrorW returns NULL?!? > >> +wcstombs(buff, u, GAI_STRERROR_BUFFER_SIZE + 1); >> + >> return buff; >> } >> -- >> 1.8.3.2 > > Rest of the patch is ok. > > Regards, > Kai Thanks, -- DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk ___ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public