mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
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.
This commit is contained in:
parent
9f42b39ddb
commit
1852bc0da7
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2004-09-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2004-09-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2004-09-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2004-09-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
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>
|
2004-09-15 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
@ -62,33 +62,7 @@ gint
|
|||||||
g_win32_ftruncate (gint fd,
|
g_win32_ftruncate (gint fd,
|
||||||
guint size)
|
guint size)
|
||||||
{
|
{
|
||||||
HANDLE hfile;
|
return _chsize (fd, size);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1068,15 +1042,16 @@ g_win32_getlocale (void)
|
|||||||
* Translate a Win32 error code (as returned by GetLastError()) into
|
* Translate a Win32 error code (as returned by GetLastError()) into
|
||||||
* the corresponding message. The message is either language neutral,
|
* the corresponding message. The message is either language neutral,
|
||||||
* or in the thread's language, or the user's language, the system's
|
* or in the thread's language, or the user's language, the system's
|
||||||
* language, or US English (see docs for FormatMessage()). *
|
* language, or US English (see docs for FormatMessage()). The
|
||||||
* The returned string should be deallocated with g_free().
|
* returned string is in UTF-8. It should be deallocated with
|
||||||
|
* g_free().
|
||||||
*
|
*
|
||||||
* Returns: newly-allocated error message
|
* Returns: newly-allocated error message
|
||||||
**/
|
**/
|
||||||
gchar *
|
gchar *
|
||||||
g_win32_error_message (gint error)
|
g_win32_error_message (gint error)
|
||||||
{
|
{
|
||||||
gchar *msg;
|
gchar *msg = NULL;
|
||||||
gchar *retval;
|
gchar *retval;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
@ -1085,15 +1060,19 @@ g_win32_error_message (gint error)
|
|||||||
|FORMAT_MESSAGE_FROM_SYSTEM,
|
|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, error, 0,
|
NULL, error, 0,
|
||||||
(LPTSTR) &msg, 0, NULL);
|
(LPTSTR) &msg, 0, NULL);
|
||||||
|
if (msg != NULL)
|
||||||
|
{
|
||||||
nbytes = strlen (msg);
|
nbytes = strlen (msg);
|
||||||
|
|
||||||
if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
|
if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
|
||||||
msg[nbytes-2] = '\0';
|
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;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -64,10 +64,10 @@ typedef int pid_t;
|
|||||||
#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
|
#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
|
||||||
|
|
||||||
/* For some POSIX functions that are not provided by the MS runtime,
|
/* 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,
|
gint g_win32_ftruncate (gint f,
|
||||||
guint size);
|
guint size);
|
||||||
#endif /* G_OS_WIN32 */
|
#endif /* G_OS_WIN32 */
|
||||||
|
Loading…
Reference in New Issue
Block a user