Skip to content

Instantly share code, notes, and snippets.

@Hamayama
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hamayama/d86b1c66040c23e7bb35 to your computer and use it in GitHub Desktop.
Save Hamayama/d86b1c66040c23e7bb35 to your computer and use it in GitHub Desktop.
GaucheのWindows版のシステムエラー表示のパッチ(2015-2-27)(2015-5-6修正)(2015-7-3修正)
--- error_orig.c 2015-07-02 18:12:26 +0900
+++ error.c 2015-07-03 00:14:02 +0900
@@ -650,17 +650,23 @@
syserr = SCM_MAKE_STR_COPYING(strerror(en));
#else /*GAUCHE_WINDOWS*/
if (en < 0) {
- LPTSTR msgbuf;
+ ScmObj ostr = Scm_MakeOutputStringPort(TRUE);
+ LPTSTR msgbuf = NULL;
const char *xmsgbuf;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- -en,
- 0,
- (LPTSTR)&msgbuf,
- 0, NULL);
- xmsgbuf = SCM_WCS2MBS(msgbuf);
- syserr = SCM_MAKE_STR_COPYING(xmsgbuf);
+ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ -en,
+ MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
+ (LPTSTR)&msgbuf,
+ 0, NULL)) {
+ xmsgbuf = SCM_WCS2MBS(msgbuf);
+ SCM_PUTZ(xmsgbuf, -1, ostr);
+ }
LocalFree(msgbuf);
+ Scm_Printf(SCM_PORT(ostr), "(error code = %d)", -en);
+ syserr = Scm_GetOutputString(SCM_PORT(ostr), 0);
} else {
syserr = SCM_MAKE_STR_COPYING(strerror(en));
}
@@ -685,9 +691,9 @@
void Scm_SysError(const char *msg, ...)
{
ScmObj e;
- va_list args;
- ScmVM *vm = Scm_VM();
int en = get_errno();
+ ScmVM *vm = Scm_VM();
+ va_list args;
ScmObj syserr = get_syserrmsg(en);
#if defined(GAUCHE_WINDOWS)
@@ -739,9 +745,9 @@
void Scm_PortError(ScmPort *port, int reason, const char *msg, ...)
{
ScmObj e;
+ int en = get_errno();
ScmVM *vm = Scm_VM();
va_list args;
- int en = get_errno();
SCM_UNWIND_PROTECT {
ScmObj ostr = Scm_MakeOutputStringPort(TRUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment