gchar hostname[100];
g_tmp_dir = g_strdup (g_getenv ("TMPDIR"));
- if (!g_tmp_dir)
+ if (g_tmp_dir == NULL || *g_tmp_dir == '\0')
g_tmp_dir = g_strdup (g_getenv ("TMP"));
- if (!g_tmp_dir)
+ if (g_tmp_dir == NULL || *g_tmp_dir == '\0')
g_tmp_dir = g_strdup (g_getenv ("TEMP"));
#ifdef G_OS_WIN32
- if (!g_tmp_dir)
+ if (g_tmp_dir == NULL || *g_tmp_dir == '\0')
g_tmp_dir = get_windows_directory_root ();
#else
#ifdef P_tmpdir
- if (!g_tmp_dir)
+ if (g_tmp_dir == NULL || *g_tmp_dir == '\0')
{
gsize k;
g_tmp_dir = g_strdup (P_tmpdir);
}
#endif
- if (!g_tmp_dir)
+ if (g_tmp_dir == NULL || *g_tmp_dir == '\0')
{
g_tmp_dir = g_strdup ("/tmp");
}
* <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
* of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
* The encoding of the returned string is system-defined. On Windows,
- * it is always UTF-8. The return value is never %NULL.
+ * it is always UTF-8. The return value is never %NULL or the empty string.
*
* Returns: the directory to use for temporary files.
*/
g_assert_cmpstr (appname, ==, "appname");
}
+static void
+test_tmpdir (void)
+{
+ g_test_bug ("627969");
+ g_assert_cmpstr (g_get_tmp_dir (), !=, "");
+}
+
int
main (int argc,
char *argv[])
{
argv0 = argv[0];
+ /* for tmpdir test, need to do this early before g_get_any_init */
+ g_setenv ("TMPDIR", "", TRUE);
+ g_unsetenv ("TMP");
+ g_unsetenv ("TEMP");
+
g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/");
g_test_add_func ("/utils/language-names", test_language_names);
g_test_add_func ("/utils/version", test_version);
g_test_add_func ("/utils/appname", test_appname);
+ g_test_add_func ("/utils/tmpdir", test_tmpdir);
return g_test_run();
}