Commit 398008da authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist

glib/gmessages.c (g_log_default_handler) Move the Win32 code that asks the

2005-03-20  Tor Lillqvist  <tml@novell.com>

	* glib/gmessages.c (g_log_default_handler)
	* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
	program name from the system to g_get_prgname(). Do output the pid
	also on Win32 (useful in case there are several instances of the
	same program running).
parent 20378332
2005-03-20 Tor Lillqvist <tml@novell.com>
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
also on Win32 (useful in case there are several instances of the
same program running).
* tests/testglib.c (main): Print more detailled output from the
timer tests. Don't print home directory twice. Test
g_win32_error_message().
......
2005-03-20 Tor Lillqvist <tml@novell.com>
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
also on Win32 (useful in case there are several instances of the
same program running).
* tests/testglib.c (main): Print more detailled output from the
timer tests. Don't print home directory twice. Test
g_win32_error_message().
......
2005-03-20 Tor Lillqvist <tml@novell.com>
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
also on Win32 (useful in case there are several instances of the
same program running).
* tests/testglib.c (main): Print more detailled output from the
timer tests. Don't print home directory twice. Test
g_win32_error_message().
......
2005-03-20 Tor Lillqvist <tml@novell.com>
* glib/gmessages.c (g_log_default_handler)
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
program name from the system to g_get_prgname(). Do output the pid
also on Win32 (useful in case there are several instances of the
same program running).
* tests/testglib.c (main): Print more detailled output from the
timer tests. Don't print home directory twice. Test
g_win32_error_message().
......
......@@ -883,53 +883,10 @@ g_log_default_handler (const gchar *log_domain,
{
const gchar *prg_name = g_get_prgname ();
#ifdef G_OS_WIN32
if (prg_name)
prg_name = g_strdup (prg_name);
else
{
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t buf[MAX_PATH+1];
if (GetModuleFileNameW (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
{
gchar *utf8_buf = g_utf16_to_utf8 (buf, -1,
NULL, NULL, NULL);
if (utf8_buf)
{
prg_name = g_path_get_basename (utf8_buf);
g_free (utf8_buf);
}
}
}
else
{
gchar buf[MAX_PATH+1];
if (GetModuleFileNameA (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
{
gchar *locale_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
if (locale_buf)
{
prg_name = g_path_get_basename (locale_buf);
g_free (locale_buf);
}
}
}
}
if (prg_name)
{
g_string_append_printf (gstring, "(%s): ", prg_name);
g_free ((gchar *) prg_name);
}
#else
if (!prg_name)
g_string_append_printf (gstring, "(process:%lu): ", (gulong)getpid ());
else
g_string_append_printf (gstring, "(%s:%lu): ", prg_name, (gulong)getpid ());
#endif
}
if (log_domain)
......
......@@ -1756,6 +1756,38 @@ g_get_prgname (void)
gchar* retval;
G_LOCK (g_prgname);
#ifdef G_OS_WIN32
if (g_prgname == NULL)
{
static gboolean beenhere = FALSE;
if (!beenhere)
{
gchar *utf8_buf = NULL;
beenhere = TRUE;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t buf[MAX_PATH+1];
if (GetModuleFileNameW (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
}
else
{
gchar buf[MAX_PATH+1];
if (GetModuleFileNameA (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
utf8_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
}
if (utf8_buf)
{
g_prgname = g_path_get_basename (utf8_buf);
g_free (utf8_buf);
}
}
}
#endif
retval = g_prgname;
G_UNLOCK (g_prgname);
......
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