* grub-core/osdep/windows/hostdisk.c (grub_util_fd_strerror):
Cut tailing newline. Remove arbitrary limitation. Always use grub_util_tchar_to_utf8.
This commit is contained in:
parent
148f100768
commit
8f53bb3fd2
2 changed files with 32 additions and 17 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/osdep/windows/hostdisk.c (grub_util_fd_strerror):
|
||||||
|
Cut tailing newline. Remove arbitrary limitation. Always use
|
||||||
|
grub_util_tchar_to_utf8.
|
||||||
|
|
||||||
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-10-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/misc.c (grub_vsnprintf_real): Handle %% properly.
|
* grub-core/kern/misc.c (grub_vsnprintf_real): Handle %% properly.
|
||||||
|
|
|
@ -255,24 +255,33 @@ grub_util_fd_close (grub_util_fd_t fd)
|
||||||
const char *
|
const char *
|
||||||
grub_util_fd_strerror (void)
|
grub_util_fd_strerror (void)
|
||||||
{
|
{
|
||||||
DWORD err;
|
DWORD err = GetLastError ();
|
||||||
static TCHAR tbuf[1024];
|
LPTSTR tstr = NULL;
|
||||||
err = GetLastError ();
|
static char *last;
|
||||||
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
|
char *ret, *ptr;
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
NULL, err,
|
|
||||||
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
tbuf, ARRAY_SIZE (tbuf), NULL);
|
|
||||||
|
|
||||||
#if SIZEOF_TCHAR == 1
|
free (last);
|
||||||
return (char *) tbuf;
|
last = 0;
|
||||||
#elif SIZEOF_TCHAR == 2
|
|
||||||
static grub_uint8_t buf[ARRAY_SIZE (tbuf) * GRUB_MAX_UTF8_PER_UTF16 + 1];
|
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
*grub_utf16_to_utf8 (buf, tbuf, ARRAY_SIZE (tbuf)) = '\0';
|
| FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
return (char *) buf;
|
NULL, err, 0, (LPTSTR) &tstr, 0, NULL);
|
||||||
#else
|
|
||||||
#error "Unsupported TCHAR size"
|
if (!tstr)
|
||||||
#endif
|
return "unknown error";
|
||||||
|
|
||||||
|
ret = grub_util_tchar_to_utf8 (tstr);
|
||||||
|
|
||||||
|
LocalFree (tstr);
|
||||||
|
|
||||||
|
last = ret;
|
||||||
|
|
||||||
|
for (ptr = ret + strlen (ret) - 1;
|
||||||
|
ptr >= ret && (*ptr == '\n' || *ptr == '\r');
|
||||||
|
ptr--);
|
||||||
|
ptr[1] = '\0';
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
Loading…
Reference in a new issue