about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/HTAlert.c4
-rw-r--r--src/HTFWriter.c1
-rw-r--r--src/LYCharUtils.c7
-rw-r--r--src/LYGlobalDefs.h1
-rw-r--r--src/LYHistory.c31
-rw-r--r--src/LYMain.c12
-rw-r--r--src/LYUtils.c49
-rw-r--r--src/LYUtils.h4
8 files changed, 70 insertions, 39 deletions
diff --git a/src/HTAlert.c b/src/HTAlert.c
index 40d3c3d5..a3a902c2 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -261,11 +261,11 @@ PUBLIC char * HTPrompt ARGS2(
     char Tmp[200];
 
     Tmp[0] = '\0';
-    Tmp[199] = '\0';
+    Tmp[sizeof(Tmp)-1] = '\0';
 
     _statusline(Msg);
     if (deflt)
-	strncpy(Tmp, deflt, 199);
+	strncpy(Tmp, deflt, sizeof(Tmp)-1);
 
     if (!dump_output_immediately)
 	LYgetstr(Tmp, VISIBLE, sizeof(Tmp), NORECALL);
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 28a4d1b5..7211c3ef 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -234,6 +234,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
 #endif /* FNAMES_8_3 */
 		    LYLocalFileToURL (&addr, path);
 		    if (!use_gzread) {
+			LYRenamedTemp(me->anchor->FileCache, path);
 			StrAllocCopy(me->anchor->FileCache, path);
 			StrAllocCopy(me->anchor->content_encoding, "binary");
 		    }
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index bd3110af..717409ce 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -365,12 +365,7 @@ PUBLIC void LYFillLocalFileURL ARGS2(
 	temp2 = HTVMS_wwwName(getenv("PATH"));
 #else
 	char curdir[LY_MAXPATH];
-#if HAVE_GETCWD
-	getcwd (curdir, sizeof(curdir));
-#else
-	getwd (curdir);
-#endif /* NO_GETCWD */
-	temp2 = wwwName(curdir);
+	temp2 = wwwName(Current_Dir(curdir));
 #endif /* VMS */
 	LYAddHtmlSep(href);
 	/*
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index adf37ba6..8e8d49ba 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -134,6 +134,7 @@ extern char *checked_radio;  /* form radio buttons */
 extern char *unchecked_radio;  /* form radio buttons */
 extern char *empty_string;
 extern char *LynxHome;
+extern char *original_dir;
 extern char *startfile;
 extern char *helpfile;
 extern char *helpfilepath;
diff --git a/src/LYHistory.c b/src/LYHistory.c
index ae60493f..65c3874c 100644
--- a/src/LYHistory.c
+++ b/src/LYHistory.c
@@ -746,29 +746,20 @@ PUBLIC void LYstore_message2 ARGS2(
 	CONST char *,	message,
 	CONST char *,	argument)
 {
-    char *temp = NULL;
 
-    if (message == NULL)
-	return;
-
-    HTSprintf(&temp, message, (argument == 0) ? "" : argument);
-
-    to_stack(temp);
-
-    return;
+    if (message != NULL) {
+	char *temp = NULL;
+	HTSprintf(&temp, message, (argument == 0) ? "" : argument);
+	to_stack(temp);
+    }
 }
+
 PUBLIC void LYstore_message ARGS1(
 	CONST char *,	message)
 {
-    char *temp = NULL;
-
-    if (message == NULL)
-	return;
-
-    HTSprintf(&temp, message);
-
-    to_stack(temp);
-
-    return;
+    if (message != NULL) {
+	char *temp = NULL;
+	StrAllocCopy(temp, message);
+	to_stack(temp);
+    }
 }
-
diff --git a/src/LYMain.c b/src/LYMain.c
index 9d9d7e03..851b93ae 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -268,6 +268,7 @@ PUBLIC char *bookmark_page = NULL; /* the name of the default bookmark page */
 PUBLIC char *BookmarkPage = NULL;  /* the name of the current bookmark page */
 PUBLIC char *LynxHome = NULL;	/* the default Home HREF. */
 PUBLIC char *homepage = NULL;  /* home page or main screen */
+PUBLIC char *original_dir = NULL; /* the original directory */
 PUBLIC char *startfile = NULL;	/* the first file */
 PUBLIC char *helpfile = NULL;	/* the main help file */
 PUBLIC char *helpfilepath = NULL;   /* the path to the help file set */
@@ -479,6 +480,7 @@ PRIVATE void free_lynx_globals NOARGS
 
     FREE(LynxHome);
     FREE(homepage);
+    FREE(original_dir);
     FREE(startfile);
     FREE(helpfile);
     FREE(helpfilepath);
@@ -1327,6 +1329,16 @@ PUBLIC int main ARGS2(
 #endif /* USE_COLOR_TABLE */
 
     /*
+     *  Set the original directory, used for default download
+     */
+    if (!strcmp(Current_Dir(filename), ".")) {
+	if ((cp = getenv("PWD")) != 0)
+	    StrAllocCopy(original_dir, cp);
+    } else {
+	StrAllocCopy(original_dir, filename);
+    }
+
+    /*
      *	Set the compilation default signature file. - FM
      */
     strcpy(filename, LYNX_SIG_FILE);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 7b397219..3ede56ab 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -3865,7 +3865,7 @@ PUBLIC void LYConvertToURL ARGS2(
 	 *  Not a SHELL pathspec.  Get the full VMS spec and convert it.
 	 */
 	char *cur_dir = NULL;
-	static char url_file[256], file_name[256], dir_name[256];
+	static char url_file[LY_MAXPATH], file_name[LY_MAXPATH], dir_name[LY_MAXPATH];
 	unsigned long context = 0;
 	$DESCRIPTOR(url_file_dsc, url_file);
 	$DESCRIPTOR(file_name_dsc, file_name);
@@ -4017,8 +4017,7 @@ have_VMS_URL:
 	     *	They want .
 	     */
 	    char curdir[LY_MAXPATH];
-	    getcwd (curdir, sizeof(curdir));
-	    StrAllocCopy(temp, wwwName(curdir));
+	    StrAllocCopy(temp, wwwName(Current_Dir(curdir)));
 	    StrAllocCat(*AllocatedString, temp);
 	    FREE(temp);
 	    CTRACE(tfp, "Converted '%s' to '%s'\n",
@@ -4050,11 +4049,7 @@ have_VMS_URL:
 	    char curdir[LY_MAXPATH];
 	    char *temp2 = NULL;
 	    BOOL is_local = FALSE;
-#if HAVE_GETCWD
-	    getcwd (curdir, sizeof(curdir));
-#else
-	    getwd (curdir);
-#endif /* NO_GETCWD */
+	    Current_Dir (curdir);
 	    /*
 	     *	Concatenate and simplify, trimming any
 	     *	residual relative elements. - FM
@@ -4845,6 +4840,20 @@ PRIVATE void LYHomeDir_free NOARGS
 }
 #endif /* LY_FIND_LEAKS */
 
+PUBLIC char * Current_Dir ARGS1(
+	char *,	pathname)
+{
+    char *result;
+#if HAVE_GETCWD
+    result = getcwd (pathname, LY_MAXPATH);
+#else
+    result = getwd (pathname);
+#endif /* NO_GETCWD */
+    if (result == 0)
+	strcpy(pathname, ".");
+    return pathname;
+}
+
 PUBLIC CONST char * Home_Dir NOARGS
 {
     static CONST char *homedir = NULL;
@@ -5954,6 +5963,7 @@ PUBLIC void LYCloseTempFP ARGS1(
 	if (p->file == fp) {
 	    fclose(p->file);
 	    p->file = 0;
+	    CTRACE(tfp, "...LYCloseTempFP(%s)\n", p->name);
 	    break;
 	}
     }
@@ -6003,6 +6013,24 @@ PUBLIC void LYCleanupTemp NOARGS
 }
 
 /*
+ * We renamed a temporary file.  Keep track so we can remove it on exit.
+ */
+PUBLIC void LYRenamedTemp ARGS2(
+	char *,		oldname,
+	char *,		newname)
+{
+    LY_TEMP *p;
+
+    CTRACE(tfp, "LYRenamedTemp(old=%s, new=%s)\n", oldname, newname);
+    for (p = ly_temp; p != 0; p = p->next) {
+	if (!strcmp(oldname, p->name)) {
+	    StrAllocCopy((p->name), newname);
+	    break;
+	}
+    }
+}
+
+/*
  *  Convert local pathname to www name
  *  (do not bother about file://localhost prefix at this point).
  */
@@ -6089,7 +6117,7 @@ PUBLIC BOOLEAN LYValidateFilename ARGS2(
 	cp = NULL;
     else
 #endif /*  __DJGPP__ || _WINDOWS */
-	cp = getenv("PWD");
+	cp = original_dir;
     }
     else
 #endif /* __EMX__*/
@@ -6179,7 +6207,7 @@ PUBLIC int LYOpenInternalPage ARGS2(
 	FILE **,  fp0,
 	char **, newfile)
 {
-    static char tempfile[256];
+    static char tempfile[LY_MAXPATH];
 
     LYRemoveTemp(tempfile);
     if ((*fp0 = LYOpenTemp(tempfile, HTML_SUFFIX, "w")) == NULL) {
@@ -6376,6 +6404,7 @@ PUBLIC int LYSystem ARGS1(
 
     fflush(stdout);
     fflush(stderr);
+    CTRACE(tfp, "LYSystem(%s)\n", command);
     CTRACE_FLUSH(tfp);
 
 #ifdef __DJGPP__
diff --git a/src/LYUtils.h b/src/LYUtils.h
index f205eec1..6a507b94 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -69,14 +69,15 @@ extern FILE *LYNewTxtFile PARAMS((char * name));
 extern FILE *LYOpenScratch PARAMS((char *result, CONST char *prefix));
 extern FILE *LYOpenTemp PARAMS((char *result, CONST char *suffix, CONST char *mode));
 extern FILE *LYReopenTemp PARAMS((char *name));
+extern char *Current_Dir PARAMS((char * pathname));
 extern char *LYPathLeaf PARAMS((char * pathname));
 extern char *LYSysShell NOPARAMS;
 extern char *LYgetXDisplay NOPARAMS;
 extern char *strip_trailing_slash PARAMS((char * my_dirname));
 extern char *wwwName PARAMS((CONST char *pathname));
-extern int LYConsoleInputFD PARAMS((BOOLEAN need_selectable));
 extern int HTCheckForInterrupt NOPARAMS;
 extern int LYCheckForProxyURL PARAMS((char *filename));
+extern int LYConsoleInputFD PARAMS((BOOLEAN need_selectable));
 extern int LYCopyFile PARAMS((char *src, char *dst));
 extern int LYOpenInternalPage PARAMS((FILE **fp0, char **newfile));
 extern int LYSystem PARAMS((char *command));
@@ -105,6 +106,7 @@ extern void LYFakeZap PARAMS((BOOL set));
 extern void LYLocalFileToURL PARAMS((char **target, CONST char *source));
 extern void LYLocalhostAliases_free NOPARAMS;
 extern void LYRemoveTemp PARAMS((char *name));
+extern void LYRenamedTemp PARAMS((char * oldname, char * newname));
 extern void LYTrimHtmlSep PARAMS((char *path));
 extern void LYTrimPathSep PARAMS((char *path));
 extern void LYTrimRelFromAbsPath PARAMS((char *path));