Commit 34462896 authored by Bruno Haible's avatar Bruno Haible Committed by Tor Lillqvist

When the sublangid is SUBLANG_DEFAULT, return the locale of the language's

2001-09-24  Bruno Haible  <haible@clisp.cons.org>

	* glib/gwin32.c (g_win32_getlocale): When the sublangid is
	SUBLANG_DEFAULT, return the locale of the language's main country,
	not a country-neutral locale. E.g. "en_US" instead of "en". Add
	handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
	(China == CN, CH == Switzerland). Ignore empty environment
	variable values.

2001-09-28  Tor Lillqvist  <tml@iki.fi>

	* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
	source file from libcharset and compile in this directory.

	* glib/giochannel.c: Mark rest of g_set_error strings for
	translation, too.

	* glib/giowin32.c: Add some debugging output functions, call them
	when debugging.
	(create_events, g_io_win32_msg_write): Free message fetched with
	g_win32_error_message ().
	(g_io_win32_check): Indentation fixes.
	(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
	G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
	like on Unix. This helps making the test programs run
	successfully.

	* glib/gmain.c (g_poll): Return the code ifdeffed out with
	TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
	seem to work as previously with the code in place. Especially
	spawn-test didn't work with the code ifdeffed out (Bug#61067).

	* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
	on Unix.

	* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
	accidentally left in.

gthread:

2001-09-28  Tor Lillqvist  <tml@iki.fi>

	* gthread-win32.c: Use an extra level of indirection for GMutex.
	It is now a pointer either to a pointer to a CRITICAL_SECTION
	struct, or to a mutex HANDLE. This is needed in case the user
	defines G_ERRORCHECK_MUTEXES. G_MUTEX_SIZE must correctly reflect
	the size of *GMutex, but this used to vary depending on whether we
	at run-time chose to use CRITICAL_SECTIONs or mutexes.
	(g_mutex_free_win32_cs_impl, g_cond_free_win32_impl): Call
	DeleteCriticalSection() when done with it.

	* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
	g_thread_impl_init() before accessing
	g_thread_functions_for_glib_use_default, as the
	g_thread_impl_init() function might modify it.

po:

2001-09-28  Tor Lillqvist  <tml@iki.fi>

	* POTFILES.in: Add iochannel.c and giowin32.c.

	* sv.po: Remove a bogus fuzziness indicator.
parent ad813a42
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
Thu Sep 27 14:26:57 2001 Owen Taylor <otaylor@redhat.com>
* glib/gstrfuncs.c (g_ascii_strup/down): Use gssize to
......
......@@ -1496,7 +1496,7 @@ read_again:
{
g_set_error (error, G_CONVERT_ERROR,
G_CONVERT_ERROR_PARTIAL_INPUT,
"Leftover unconverted data in read buffer");
_("Leftover unconverted data in read buffer"));
return G_IO_STATUS_ERROR;
}
else
......@@ -1576,7 +1576,7 @@ read_again:
if (channel->encoding && channel->read_buf->len > 0)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
"Channel terminates in a partial character");
_("Channel terminates in a partial character"));
return G_IO_STATUS_ERROR;
}
line_length = use_buf->len;
......@@ -1650,7 +1650,7 @@ g_io_channel_read_to_end (GIOChannel *channel,
if (channel->encoding && channel->read_buf->len > 0)
{
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
"Channel terminates in a partial character");
_("Channel terminates in a partial character"));
return G_IO_STATUS_ERROR;
}
......@@ -1750,7 +1750,7 @@ g_io_channel_read_chars (GIOChannel *channel,
{
g_set_error (error, G_CONVERT_ERROR,
G_CONVERT_ERROR_PARTIAL_INPUT,
"Leftover unconverted data in read buffer");
_("Leftover unconverted data in read buffer"));
status = G_IO_STATUS_ERROR;
}
......@@ -1836,7 +1836,7 @@ g_io_channel_read_unichar (GIOChannel *channel,
{
g_set_error (error, G_CONVERT_ERROR,
G_CONVERT_ERROR_PARTIAL_INPUT,
"Leftover unconverted data in read buffer");
_("Leftover unconverted data in read buffer"));
status = G_IO_STATUS_ERROR;
}
......
......@@ -123,16 +123,59 @@ struct _GIOWin32Watch {
};
static void
g_io_channel_win32_init (GIOWin32Channel *channel)
g_win32_print_access_mode (int flags)
{
g_print ("%s%s%s%s%s%s%s%s%s%s",
((flags & 0x3) == _O_RDWR ? "O_RDWR" :
((flags & 0x3) == _O_RDONLY ? "O_RDONLY" :
((flags & 0x3) == _O_WRONLY ? "O_WRONLY" : "0"))),
(flags & _O_APPEND ? "|O_APPEND" : ""),
(flags & _O_RANDOM ? "|O_RANDOM" : ""),
(flags & _O_SEQUENTIAL ? "|O_SEQUENTIAL" : ""),
(flags & _O_TEMPORARY ? "|O_TEMPORARY" : ""),
(flags & _O_CREAT ? "|O_CREAT" : ""),
(flags & _O_TRUNC ? "|O_TRUNC" : ""),
(flags & _O_EXCL ? "|O_EXCL" : ""),
(flags & _O_TEXT ? "|O_TEXT" : ""),
(flags & _O_BINARY ? "|O_BINARY" : ""));
}
static void
g_win32_print_gioflags (GIOFlags flags)
{
char *bar = "";
if (flags & G_IO_FLAG_APPEND)
bar = "|", g_print ("APPEND");
if (flags & G_IO_FLAG_NONBLOCK)
g_print ("%sNONBLOCK", bar), bar = "|";
if (flags & G_IO_FLAG_IS_READABLE)
g_print ("%sREADABLE", bar), bar = "|";
if (flags & G_IO_FLAG_IS_WRITEABLE)
g_print ("%sWRITEABLE", bar), bar = "|";
if (flags & G_IO_FLAG_IS_WRITEABLE)
g_print ("%sWRITEABLE", bar), bar = "|";
if (flags & G_IO_FLAG_IS_SEEKABLE)
g_print ("%sSEEKABLE", bar), bar = "|";
}
static gboolean
g_io_win32_get_debug_flag (void)
{
#ifdef G_IO_WIN32_DEBUG
channel->debug = TRUE;
return TRUE;
#else
if (getenv ("G_IO_WIN32_DEBUG") != NULL)
channel->debug = TRUE;
return TRUE;
else
channel->debug = FALSE;
return FALSE;
#endif
}
static void
g_io_channel_win32_init (GIOWin32Channel *channel)
{
channel->debug = g_io_win32_get_debug_flag ();
channel->buffer = NULL;
channel->running = FALSE;
channel->needs_close = FALSE;
......@@ -150,7 +193,7 @@ create_events (GIOWin32Channel *channel)
{
SECURITY_ATTRIBUTES sec_attrs;
sec_attrs.nLength = sizeof(SECURITY_ATTRIBUTES);
sec_attrs.nLength = sizeof (SECURITY_ATTRIBUTES);
sec_attrs.lpSecurityDescriptor = NULL;
sec_attrs.bInheritHandle = FALSE;
......@@ -161,8 +204,9 @@ create_events (GIOWin32Channel *channel)
|| !(channel->space_avail_event = CreateEvent (&sec_attrs, FALSE, FALSE, NULL))
|| !(channel->data_avail_noticed_event = CreateEvent (&sec_attrs, FALSE, FALSE, NULL)))
{
gchar *msg = g_win32_error_message (GetLastError ());
g_error ("Error creating event: %s", msg);
gchar *emsg = g_win32_error_message (GetLastError ());
g_error ("Error creating event: %s", emsg);
g_free (emsg);
}
}
......@@ -524,12 +568,11 @@ g_io_win32_prepare (GSource *source,
static gboolean
g_io_win32_check (GSource *source)
{
MSG msg;
MSG msg;
GIOWin32Watch *watch = (GIOWin32Watch *)source;
GIOWin32Channel *channel = (GIOWin32Channel *)watch->channel;
GIOCondition buffer_condition = g_io_channel_get_buffer_condition (watch->channel);
if (channel->debug)
g_print ("g_io_win32_check: for thread %#x:\n"
"\twatch->pollfd.events:%#x, watch->pollfd.revents:%#x, channel->revents:%#x\n",
......@@ -537,14 +580,14 @@ g_io_win32_check (GSource *source)
watch->pollfd.events, watch->pollfd.revents, channel->revents);
if (channel->type != G_IO_WIN32_WINDOWS_MESSAGES)
{
watch->pollfd.revents = (watch->pollfd.events & channel->revents);
}
else
{
return (PeekMessage (&msg, channel->hwnd, 0, 0, PM_NOREMOVE));
}
{
watch->pollfd.revents = (watch->pollfd.events & channel->revents);
}
else
{
return (PeekMessage (&msg, channel->hwnd, 0, 0, PM_NOREMOVE));
}
if (channel->type == G_IO_WIN32_SOCKET)
{
if (channel->debug)
......@@ -655,20 +698,20 @@ g_io_win32_msg_read (GIOChannel *channel,
if (count < sizeof (MSG))
{
g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
_("Incorrect message size")); /* Correct error message? FIXME */
_("Incorrect message size")); /* Informative enough error message? */
return G_IO_STATUS_ERROR;
}
if (win32_channel->debug)
g_print ("g_io_win32_msg_read: for %#x\n",
win32_channel->hwnd);
(guint) win32_channel->hwnd);
if (!PeekMessage (&msg, win32_channel->hwnd, 0, 0, PM_REMOVE))
return G_IO_STATUS_AGAIN;
memmove (buf, &msg, sizeof (MSG));
*bytes_read = sizeof (MSG);
return (*bytes_read > 0) ? G_IO_STATUS_NORMAL : G_IO_STATUS_EOF;
return G_IO_STATUS_NORMAL;
}
static GIOStatus
......@@ -684,7 +727,7 @@ g_io_win32_msg_write (GIOChannel *channel,
if (count != sizeof (MSG))
{
g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_INVAL,
_("Incorrect message size")); /* Correct error message? FIXME */
_("Incorrect message size")); /* Informative enough error message? */
return G_IO_STATUS_ERROR;
}
......@@ -692,8 +735,9 @@ g_io_win32_msg_write (GIOChannel *channel,
memmove (&msg, buf, sizeof (MSG));
if (!PostMessage (win32_channel->hwnd, msg.message, msg.wParam, msg.lParam))
{
g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED,
_("Unknown error")); /* Correct error message? FIXME */
gchar *emsg = g_win32_error_message (GetLastError ());
g_set_error(err, G_IO_CHANNEL_ERROR, G_IO_CHANNEL_ERROR_FAILED, emsg);
g_free (emsg);
return G_IO_STATUS_ERROR;
}
......@@ -789,6 +833,9 @@ g_io_win32_fd_read (GIOChannel *channel,
result = read (win32_channel->fd, buf, count);
if (win32_channel->debug)
g_print ("g_io_win32_fd_read: read() = %d\n", result);
if (result < 0)
{
*bytes_read = 0;
......@@ -809,7 +856,6 @@ g_io_win32_fd_read (GIOChannel *channel,
*bytes_read = result;
return G_IO_STATUS_NORMAL; /* XXX: 0 byte read an error ?? */
return (result > 0) ? G_IO_STATUS_NORMAL : G_IO_STATUS_EOF;
}
......@@ -948,7 +994,9 @@ g_io_win32_sock_read (GIOChannel *channel,
if (win32_channel->debug)
g_print ("g_io_win32_sock_read: sockfd:%d count:%d\n",
win32_channel->fd, count);
repeat:
#ifdef WE_NEED_TO_HANDLE_WSAEINTR
repeat:
#endif
result = recv (win32_channel->fd, buf, count, 0);
if (win32_channel->debug)
......@@ -981,7 +1029,6 @@ repeat:
{
*bytes_read = result;
return G_IO_STATUS_NORMAL; /* XXX: 0 byte read an error ?? */
return (result > 0) ? G_IO_STATUS_NORMAL : G_IO_STATUS_EOF;
}
}
......@@ -1000,7 +1047,9 @@ g_io_win32_sock_write (GIOChannel *channel,
if (win32_channel->debug)
g_print ("g_io_win32_sock_write: sockfd:%d count:%d\n",
win32_channel->fd, count);
#ifdef WE_NEED_TO_HANDLE_WSAEINTR
repeat:
#endif
result = send (win32_channel->fd, buf, count, 0);
if (win32_channel->debug)
......@@ -1160,9 +1209,16 @@ g_io_channel_new_file (const gchar *filename,
pmode = 0;
}
/* always open 'untranslated' */
fid = open (filename, flags | _O_BINARY, pmode);
if (g_io_win32_get_debug_flag ())
{
g_print ("g_io_channel_win32_new_file: open(\"%s\", ", filename);
g_win32_print_access_mode (flags|_O_BINARY);
g_print (",%#o)=%d\n", pmode, fid);
}
if (fid < 0)
{
g_set_error (error, G_FILE_ERROR,
......@@ -1198,9 +1254,6 @@ g_io_channel_new_file (const gchar *filename,
g_assert_not_reached ();
}
if (((GIOWin32Channel *)channel)->debug)
g_print ("g_io_channel_win32_new_file: fd = %ud\n", fid);
return channel;
}
......@@ -1211,6 +1264,13 @@ g_io_win32_set_flags (GIOChannel *channel,
{
GIOWin32Channel *win32_channel = (GIOWin32Channel *)channel;
if (win32_channel->debug)
{
g_print ("g_io_win32_set_flags: ");
g_win32_print_gioflags (flags);
g_print ("\n");
}
g_set_error (err,
G_IO_CHANNEL_ERROR,
g_file_error_from_errno (EACCES),
......@@ -1331,7 +1391,7 @@ g_io_channel_win32_new_fd (gint fd)
g_io_channel_init (channel);
g_io_channel_win32_init (win32_channel);
if (win32_channel->debug)
g_print ("g_io_channel_win32_new_fd: fd = %d\n", fd);
g_print ("g_io_channel_win32_new_fd: %u\n", fd);
channel->funcs = &win32_channel_fd_funcs;
win32_channel->type = G_IO_WIN32_FILE_DESC;
win32_channel->fd = fd;
......@@ -1350,8 +1410,8 @@ g_io_channel_win32_new_fd (gint fd)
{
channel->is_readable = !!(st.st_mode & _S_IREAD);
channel->is_writeable = !!(st.st_mode & _S_IWRITE);
/* XXX: pipes aren't seeakable, are they ? */
channel->is_seekable = !(st.st_mode & _S_IFIFO);
/* XXX What about "device files" (COM1: and the like) */
channel->is_seekable = TRUE;
}
return channel;
......@@ -1445,10 +1505,12 @@ g_io_channel_win32_make_pollfd (GIOChannel *channel,
fd->events = condition;
if (win32_channel->thread_id == 0)
if ((condition & G_IO_IN) && win32_channel->type == G_IO_WIN32_FILE_DESC)
create_thread (win32_channel, condition, read_thread);
else if (win32_channel->type == G_IO_WIN32_SOCKET)
create_thread (win32_channel, condition, select_thread);
{
if ((condition & G_IO_IN) && win32_channel->type == G_IO_WIN32_FILE_DESC)
create_thread (win32_channel, condition, read_thread);
else if (win32_channel->type == G_IO_WIN32_SOCKET)
create_thread (win32_channel, condition, select_thread);
}
}
/* Binary compatibility */
......
......@@ -403,7 +403,7 @@ g_poll (GPollFD *fds,
f->revents |= G_IO_IN;
}
}
#if TEST_WITHOUT_THIS
#if 1 /* TEST_WITHOUT_THIS */
else if (ready >= WAIT_OBJECT_0 && ready < WAIT_OBJECT_0 + nhandles)
for (f = fds; f < &fds[nfds]; ++f)
{
......
......@@ -94,8 +94,9 @@ g_rand_new (void)
{
guint32 seed;
GTimeVal now;
#if G_OS_UNIX
static gboolean dev_urandom_exists = TRUE;
if (dev_urandom_exists)
{
FILE* dev_urandom = fopen("/dev/urandom", "rb");
......@@ -108,6 +109,10 @@ g_rand_new (void)
else
dev_urandom_exists = FALSE;
}
#else
static gboolean dev_urandom_exists = FALSE;
#endif
if (!dev_urandom_exists)
{
g_get_current_time (&now);
......
......@@ -225,7 +225,6 @@ WinMain (struct HINSTANCE__ *hInstance,
}
write (child_err_report_fd, &zero, sizeof (zero));
write (child_err_report_fd, &zero, sizeof (zero));
Sleep (10000);
return 0;
}
......@@ -873,7 +873,6 @@ fork_exec_with_pipes (gboolean dont_wait,
gint stderr_pipe[2] = { -1, -1 };
gint child_err_report_pipe[2] = { -1, -1 };
gint status;
gint bytes;
gint buf[2];
gint n_ints = 0;
......
......@@ -225,7 +225,7 @@ g_win32_closedir (DIR *dir)
}
#endif
/* msvc 5.0 headers don't have latest language and sublanguage codes */
/* MSVC 5.0 headers don't have latest language and sublanguage codes */
#ifndef LANG_ARMENIAN
#define LANG_ARMENIAN 0x2b
#endif
......@@ -344,10 +344,10 @@ g_win32_closedir (DIR *dir)
*
* The setlocale in the Microsoft C library uses locale names of the
* form "English_United States.1252" etc. We want the Unixish standard
* form "en", "zh_TW" etc. This function gets the current thread
* locale from Windows and returns it as a string of the above form
* for use in forming file names etc. The returned string should be
* deallocated with g_free().
* form "en_US", "zh_TW" etc. This function gets the current thread
* locale from Windows - without any encoding info - and returns it as
* a string of the above form for use in forming file names etc. The
* returned string should be deallocated with g_free().
*
* Returns: allocated locale name
*/
......@@ -356,23 +356,32 @@ gchar *
g_win32_getlocale (void)
{
LCID lcid;
LANGID langid;
gchar *ev;