[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: work3 -loadlib bug
- From: David Burgess <dburgess@...>
- Date: Wed, 22 Dec 2004 10:45:25 +1000
Included is a patch that fixes a typo bug in loadlib.c
In addition the patch trims the trailing control characters
from the error messages returned from FormatMessage().
Win32 only.
--- orig-lua-5.1-work3/src/lib/loadlib.c Sat Nov 20 01:52:12 2004
+++ lua-5.1-work3/src/lib/loadlib.c Wed Dec 22 11:43:11 2004
@@ -94,9 +94,14 @@
{
int error=GetLastError();
char buffer[128];
- if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
- 0, error, 0, buffer, sizeof(buffer), 0))
+ int l;
+ if ((l=FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
+ 0, error, 0, buffer, sizeof(buffer), 0)) != 0) {
+ /* remove trailing junk */
+ while (l > 0 && iscntrl(buffer[l-1]) || isspace(buffer[l-1])) l--;
+ if (l>=0) buffer[l] = '\0';
lua_pushstring(L,buffer);
+ }
else
lua_pushfstring(L,"system error %d\n",error);
}
@@ -111,7 +116,7 @@
{
registerlib(L, lib);
lua_pushcfunction(L,f);
- return 1;
+ return 0;
}
}
pusherror(L);
@@ -123,7 +128,6 @@
}
-
/* Native Mac OS X / Darwin Implementation */
#elif defined(USE_DYLD)