File w3m-tempdir-override.patch of Package w3m.2791

---
 rc.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

Index: w3m-0.5.3/rc.c
===================================================================
--- w3m-0.5.3.orig/rc.c
+++ w3m-0.5.3/rc.c
@@ -1225,7 +1225,16 @@ sync_with_option(void)
 #endif				/* MENU */
     }
 }
-
+static char *get_tmp_dir(void)
+{
+    char *_tmp_dir;
+    if (((_tmp_dir = getenv("TMPDIR")) == NULL || *_tmp_dir == '\0') &&
+	((_tmp_dir = getenv("TMP")) == NULL || *_tmp_dir == '\0') &&
+	((_tmp_dir = getenv("TEMP")) == NULL || *_tmp_dir == '\0'))
+	    _tmp_dir = NULL;
+    _tmp_dir = expandPath(_tmp_dir);
+    return _tmp_dir;
+}
 void
 init_rc(void)
 {
@@ -1233,9 +1242,11 @@ init_rc(void)
     struct stat st;
     FILE *f;
 
+    tmp_dir = get_tmp_dir();
     if (rc_dir != NULL)
 	goto open_rc;
 
+    no_rc_dir = TRUE;
     rc_dir = expandPath(RC_DIR);
     i = strlen(rc_dir);
     if (i > 1 && rc_dir[i - 1] == '/')
@@ -1272,7 +1283,6 @@ init_rc(void)
 	goto rc_dir_err;
     }
     no_rc_dir = FALSE;
-    tmp_dir = rc_dir;
 
     if (config_file == NULL)
 	config_file = rcFile(CONFIG_FILE);
@@ -1293,13 +1303,12 @@ init_rc(void)
 	interpret_rc(f);
 	fclose(f);
     }
+    if (!tmp_dir)
+	tmp_dir = rc_dir;
     return;
 
   rc_dir_err:
-    no_rc_dir = TRUE;
-    if (((tmp_dir = getenv("TMPDIR")) == NULL || *tmp_dir == '\0') &&
-	((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') &&
-	((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0'))
+    if (!tmp_dir)
 	tmp_dir = "/tmp";
     create_option_search_table();
     goto open_rc;
openSUSE Build Service is sponsored by