Commit 1852bc0d authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

Convert message to UTF-8. Technically this breaks API, but the actual use

2004-09-15  Tor Lillqvist  <tml@iki.fi>

	* glib/gwin32.c (g_win32_error_message): Convert message to
	UTF-8. Technically this breaks API, but the actual use cases in
	gdk/win32 have assumed it is UTF-8 anyway. Fix
	documentation. (#152618, Kazuki Iwamoto)

	* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
	good idea, and it clashes with newest mingw headers, which have a
	ftruncate implementation as an inline function. Thanks to Dominik R.

	* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
	call _chsize() in the C library.
parent 9f42b39d
2004-09-15 Tor Lillqvist <tml@iki.fi>
* glib/gwin32.c (g_win32_error_message): Convert message to
UTF-8. Technically this breaks API, but the actual use cases in
gdk/win32 have assumed it is UTF-8 anyway. Fix
documentation. (#152618, Kazuki Iwamoto)
* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
good idea, and it clashes with newest mingw headers, which have a
ftruncate implementation as an inline function. Thanks to Dominik R.
* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
call _chsize() in the C library.
2004-09-15 Matthias Clasen <mclasen@redhat.com>
* NEWS: Update.
......
2004-09-15 Tor Lillqvist <tml@iki.fi>
* glib/gwin32.c (g_win32_error_message): Convert message to
UTF-8. Technically this breaks API, but the actual use cases in
gdk/win32 have assumed it is UTF-8 anyway. Fix
documentation. (#152618, Kazuki Iwamoto)
* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
good idea, and it clashes with newest mingw headers, which have a
ftruncate implementation as an inline function. Thanks to Dominik R.
* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
call _chsize() in the C library.
2004-09-15 Matthias Clasen <mclasen@redhat.com>
* NEWS: Update.
......
2004-09-15 Tor Lillqvist <tml@iki.fi>
* glib/gwin32.c (g_win32_error_message): Convert message to
UTF-8. Technically this breaks API, but the actual use cases in
gdk/win32 have assumed it is UTF-8 anyway. Fix
documentation. (#152618, Kazuki Iwamoto)
* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
good idea, and it clashes with newest mingw headers, which have a
ftruncate implementation as an inline function. Thanks to Dominik R.
* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
call _chsize() in the C library.
2004-09-15 Matthias Clasen <mclasen@redhat.com>
* NEWS: Update.
......
2004-09-15 Tor Lillqvist <tml@iki.fi>
* glib/gwin32.c (g_win32_error_message): Convert message to
UTF-8. Technically this breaks API, but the actual use cases in
gdk/win32 have assumed it is UTF-8 anyway. Fix
documentation. (#152618, Kazuki Iwamoto)
* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
good idea, and it clashes with newest mingw headers, which have a
ftruncate implementation as an inline function. Thanks to Dominik R.
* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
call _chsize() in the C library.
2004-09-15 Matthias Clasen <mclasen@redhat.com>
* NEWS: Update.
......
2004-09-15 Tor Lillqvist <tml@iki.fi>
* glib/gwin32.c (g_win32_error_message): Convert message to
UTF-8. Technically this breaks API, but the actual use cases in
gdk/win32 have assumed it is UTF-8 anyway. Fix
documentation. (#152618, Kazuki Iwamoto)
* glib/gwin32.h: Don't define ftruncate as a macro. Was never a
good idea, and it clashes with newest mingw headers, which have a
ftruncate implementation as an inline function. Thanks to Dominik R.
* glib/gwin32.c (g_win32_ftruncate): Simplify implementation, just
call _chsize() in the C library.
2004-09-15 Matthias Clasen <mclasen@redhat.com>
* NEWS: Update.
......
......@@ -62,33 +62,7 @@ gint
g_win32_ftruncate (gint fd,
guint size)
{
HANDLE hfile;
guint curpos;
g_return_val_if_fail (fd >= 0, -1);
hfile = (HANDLE) _get_osfhandle (fd);
curpos = SetFilePointer (hfile, 0, NULL, FILE_CURRENT);
if (curpos == 0xFFFFFFFF
|| SetFilePointer (hfile, size, NULL, FILE_BEGIN) == 0xFFFFFFFF
|| !SetEndOfFile (hfile))
{
gint error = GetLastError ();
switch (error)
{
case ERROR_INVALID_HANDLE:
errno = EBADF;
break;
default:
errno = EIO;
break;
}
return -1;
}
return 0;
return _chsize (fd, size);
}
#endif
......@@ -1068,15 +1042,16 @@ g_win32_getlocale (void)
* Translate a Win32 error code (as returned by GetLastError()) into
* the corresponding message. The message is either language neutral,
* or in the thread's language, or the user's language, the system's
* language, or US English (see docs for FormatMessage()). *
* The returned string should be deallocated with g_free().
* language, or US English (see docs for FormatMessage()). The
* returned string is in UTF-8. It should be deallocated with
* g_free().
*
* Returns: newly-allocated error message
**/
gchar *
g_win32_error_message (gint error)
{
gchar *msg;
gchar *msg = NULL;
gchar *retval;
int nbytes;
......@@ -1085,15 +1060,19 @@ g_win32_error_message (gint error)
|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0,
(LPTSTR) &msg, 0, NULL);
nbytes = strlen (msg);
if (msg != NULL)
{
nbytes = strlen (msg);
if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
msg[nbytes-2] = '\0';
if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
msg[nbytes-2] = '\0';
retval = g_strdup (msg);
retval = g_locale_to_utf8 (msg, -1, NULL, NULL, NULL);
if (msg != NULL)
LocalFree (msg);
LocalFree (msg);
}
else
retval = g_strdup ("");
return retval;
}
......
......@@ -64,10 +64,10 @@ typedef int pid_t;
#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
/* For some POSIX functions that are not provided by the MS runtime,
* we provide emulators in glib, which are prefixed with g_win32_.
* we provide emulation functions in glib, which are prefixed with
* g_win32_. Or that was the idea at some time, but there is just one
* of those:
*/
# define ftruncate(fd, size) g_win32_ftruncate (fd, size)
gint g_win32_ftruncate (gint f,
guint size);
#endif /* G_OS_WIN32 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment