about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGES20
-rw-r--r--WWW/Library/Implementation/HTFTP.c6
-rw-r--r--WWW/Library/Implementation/HTFile.c8
-rw-r--r--WWW/Library/Implementation/HTFile.h4
-rw-r--r--WWW/Library/Implementation/HTParse.c4
-rw-r--r--WWW/Library/Implementation/HTString.c10
-rw-r--r--WWW/Library/Implementation/HTTCP.c8
-rw-r--r--WWW/Library/Implementation/LYLeaks.h56
-rw-r--r--src/GridText.c4
-rw-r--r--src/HTML.c4
-rw-r--r--src/LYBookmark.c4
-rw-r--r--src/LYDownload.c9
-rw-r--r--src/LYJump.c4
-rw-r--r--src/LYLeaks.c170
-rw-r--r--src/LYLocal.c4
-rw-r--r--src/LYMain.c32
-rw-r--r--src/LYMainLoop.c198
-rw-r--r--src/LYPrint.c8
-rw-r--r--src/LYReadCFG.c9
-rw-r--r--src/LYSearch.c49
-rw-r--r--src/LYSearch.h2
-rw-r--r--src/LYSession.c3
-rw-r--r--src/LYStrings.c20
-rw-r--r--src/LYStyle.c3
-rw-r--r--src/LYUpload.c6
-rw-r--r--src/LYUtils.c118
-rw-r--r--src/LYUtils.h4
-rw-r--r--src/chrtrans/def7_uni.tbl5
-rw-r--r--src/parsdate.c111
-rw-r--r--src/parsdate.y4
30 files changed, 575 insertions, 312 deletions
diff --git a/CHANGES b/CHANGES
index c90519f3..8f1413c5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,25 @@
--- $LynxId: CHANGES,v 1.573 2012/02/09 01:34:11 tom Exp $
+-- $LynxId: CHANGES,v 1.580 2012/02/10 01:52:10 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
-2012-02-08 (2.8.8dev.10)
+2012-02-09 (2.8.8dev.10)
+* use ASCII apostrophe for 7-bit approximation to U+02bd as well -TD
+* use ASCII apostrophe 0x27 for 7-bit approximation to Unicode apostrophe
+  U+02bc (suggested by Ralph Babel)
+* update LYLeaks.c / LYLeaks.h to include the bstring allocation, copy and free
+  functions -TD
+* several fixes for the -find-leaks option, e.g., include LYLeaks.h in a few
+  modules, modify the StrAllocVsprintf function to update the bookkeeping,
+  etc -TD
+* move call to LYCanWriteFile into LYValidateOutput, to make prompts for
+  download, print and upload more alike -TD
+* correct an old bug in send_file_to_file(), used when printing a page to a
+  file, which prevented its check for appending to an existing file -TD
+* modify LYValidateFilename to use LYTildeExpand -TD
+* modify LYConvertToURL to use LYTildeExpand for Unix, and further modify
+  LYTildeExpand to lookup given user's home directory, thereby making commands
+  such as "g ~root/tmp" work as expected -TD
 * replaced most LYgetStr calls with LYgetBString, except for LYMail.c and
   LYNews.c since those do use LYgetStr's limits as it was designed.  Other
   calls generally did not need those limits -TD
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 5ca71225..480eacfd 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFTP.c,v 1.100 2011/05/24 09:49:44 tom Exp $
+ * $LynxId: HTFTP.c,v 1.101 2012/02/09 12:34:48 tom Exp $
  *
  *			File Transfer Protocol (FTP) Client
  *			for a WorldWideWeb browser
@@ -1304,7 +1304,7 @@ static int get_listen_socket(void)
 	    return HTInetStatus("getsockname");
 #ifdef INET6
 	CTRACE((tfp, "HTFTP: This host is %s\n",
-		HTInetString((SockA *) soc_in)));
+		HTInetString((void *) soc_in)));
 
 	soc_in->sin_port = 0;	/* Unspecified: please allocate */
 #else
@@ -1352,7 +1352,7 @@ static int get_listen_socket(void)
 #ifdef INET6
     CTRACE((tfp, "HTFTP: bound to port %d on %s\n",
 	    (int) ntohs(soc_in->sin_port),
-	    HTInetString((SockA *) soc_in)));
+	    HTInetString((void *) soc_in)));
 #else
     CTRACE((tfp, "HTFTP: bound to port %d on %s\n",
 	    (int) ntohs(soc_in->sin_port),
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 69b537a5..be561e44 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.128 2011/06/06 09:27:35 tom Exp $
+ * $LynxId: HTFile.c,v 1.129 2012/02/10 01:10:51 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -3086,7 +3086,7 @@ void HTSetProgramPath(ProgramPaths code, const char *path)
 /*
  * Reset the list of known program paths to the ones that are compiled-in
  */
-void HTInitProgramPaths(void)
+void HTInitProgramPaths(BOOL init)
 {
     ProgramPaths code;
     int n;
@@ -3218,7 +3218,9 @@ void HTInitProgramPaths(void)
 	if (test != NULL && test != path) {
 	    free((char *) test);
 	}
-	HTSetProgramPath(code, path);
+	if (init) {
+	    HTSetProgramPath(code, path);
+	}
     }
 }
 
diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h
index 2a548060..937907d4 100644
--- a/WWW/Library/Implementation/HTFile.h
+++ b/WWW/Library/Implementation/HTFile.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.h,v 1.32 2010/09/24 00:32:16 tom Exp $
+ * $LynxId: HTFile.h,v 1.33 2012/02/10 00:59:15 tom Exp $
  *							File access in libwww
  *				FILE ACCESS
  *
@@ -347,7 +347,7 @@ extern "C" {
 /*
  * Reset the list of known program paths to the ones that are compiled-in
  */
-    extern void HTInitProgramPaths(void);
+    extern void HTInitProgramPaths(BOOL init);
 
 /*
  *  The Protocols
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index 2e74e7f7..0338dfd4 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTParse.c,v 1.69 2011/06/06 10:46:18 tom Exp $
+ * $LynxId: HTParse.c,v 1.70 2012/02/09 19:57:37 tom Exp $
  *
  *		Parse HyperText Document Address		HTParse.c
  *		================================
@@ -300,7 +300,7 @@ static void convert_to_idna(char *host)
 			buffer,
 			idna_strerror((Idna_rc) code)));
 	    }
-	    if (output)
+	    if (output)		/* "(free)" to bypass LYLeaks.c */
 		(free) (output);
 	}
 	free(buffer);
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index 9bbc3577..e22c937e 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTString.c,v 1.67 2012/02/08 00:34:44 tom Exp $
+ * $LynxId: HTString.c,v 1.69 2012/02/09 22:02:21 tom Exp $
  *
  *	Case-independent string comparison		HTString.c
  *
@@ -359,7 +359,7 @@ char *HTSACopy_extra(char **dest,
 	EXTRA_TYPE size = 0;
 
 	if (*dest != 0) {
-	    size = *(EXTRA_TYPE *) ((*dest) - EXTRA_SIZE);
+	    size = *(EXTRA_TYPE *) (void *) ((*dest) - EXTRA_SIZE);
 	}
 	if ((*dest == 0) || (size < srcsize)) {
 	    FREE_extra(*dest);
@@ -368,7 +368,7 @@ char *HTSACopy_extra(char **dest,
 	    if (*dest == NULL)
 		outofmem(__FILE__, "HTSACopy_extra");
 	    assert(*dest != NULL);
-	    *(EXTRA_TYPE *) (*dest) = size;
+	    *(EXTRA_TYPE *) (void *) (*dest) = size;
 	    *dest += EXTRA_SIZE;
 	}
 	MemCpy(*dest, src, srcsize);
@@ -649,9 +649,8 @@ PUBLIC_IF_FIND_LEAKS char *StrAllocVsprintf(char **pstr,
 	    result = HTAlloc(pstr ? *pstr : 0, new_len);
 	    if (result != 0) {
 		strcpy(result + dst_len, temp);
-		mark_malloced(temp, new_len);
 	    }
-	    free(temp);
+	    (free) (temp);
 	} else {
 	    result = temp;
 	    mark_malloced(temp, strlen(temp));
@@ -1198,6 +1197,7 @@ void HTSABAlloc(bstring **dest, int len)
 
     if ((*dest)->len != len) {
 	(*dest)->str = typeRealloc(char, (*dest)->str, len);
+
 	(*dest)->len = len;
     }
 }
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index d366d732..2723422c 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTCP.c,v 1.106 2010/11/07 21:20:58 tom Exp $
+ * $LynxId: HTTCP.c,v 1.107 2012/02/09 12:36:45 tom Exp $
  *
  *			Generic Communication Code		HTTCP.c
  *			==========================
@@ -450,7 +450,7 @@ static size_t fill_rehostent(char *rehostent,
 			     size_t rehostentsize,
 			     const LYNX_HOSTENT *phost)
 {
-    AlignedHOSTENT *data = (AlignedHOSTENT *) rehostent;
+    AlignedHOSTENT *data = (AlignedHOSTENT *) (void *) rehostent;
     int num_addrs = 0;
     int num_aliases = 0;
     char **pcnt;
@@ -513,7 +513,7 @@ static size_t fill_rehostent(char *rehostent,
 
     data->h.h_addrtype = phost->h_addrtype;
     data->h.h_length = phost->h_length;
-    p_next_charptr = (char **) (rehostent + curlen);
+    p_next_charptr = (char **) (void *) (rehostent + curlen);
     p_next_char = rehostent + curlen;
     if (phost->h_addr_list)
 	p_next_char += (size_t) (num_addrs + 1) * sizeof(phost->h_addr_list[0]);
@@ -706,7 +706,7 @@ LYNX_HOSTENT *LYGetHostByName(char *str)
      *   in the child's, otherwise the internal pointers built by the child's
      *   call to fill_rehostent would be invalid when seen by the parent).  -kw
      */
-    char *rehostent = (char *) &aligned_full_rehostent;
+    void *rehostent = (void *) &aligned_full_rehostent;
 
     /* for transfer of status from child to parent: */
     struct _statuses {
diff --git a/WWW/Library/Implementation/LYLeaks.h b/WWW/Library/Implementation/LYLeaks.h
index 69ccd4f4..b3672734 100644
--- a/WWW/Library/Implementation/LYLeaks.h
+++ b/WWW/Library/Implementation/LYLeaks.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: LYLeaks.h,v 1.14 2012/02/10 00:15:56 tom Exp $
+ */
 #ifndef __LYLEAKS_H
 /*
  *	Avoid include redundancy
@@ -44,6 +47,9 @@
  *	1999-10-17	modified to handle HTSprintf0 and HTSprintf(),
  *			and to provide mark_malloced, if
  *			LY_FIND_LEAKS_EXTENDED is defined. - kw
+ *	2003-01-22	add sequence-id for counting mallocs/frees -TD
+ *	2004-04-27	ANSIfy'd -TD
+ *	2012-02-09	add bstring interfaces -TD
  */
 
 /* Undefine this to get no improved HTSprintf0/HTSprintf tracking: */
@@ -161,6 +167,31 @@ extern "C" {
 #endif				/* StrAllocCat */
 #define StrAllocCat(dest, src)  LYLeakSACat(&(dest), src, __FILE__, __LINE__)
 
+#ifdef BStrAlloc
+#undef BStrAlloc
+#endif
+#define BStrAlloc(d,n)   LYLeakSABAlloc( &(d), n, __FILE__, __LINE__)
+
+#ifdef BStrCopy
+#undef BStrCopy
+#endif
+#define BStrCopy(d,s)  LYLeakSABCopy( &(d), BStrData(s), BStrLen(s), __FILE__, __LINE__)
+
+#ifdef BStrCopy0
+#undef BStrCopy0
+#endif
+#define BStrCopy0(d,s)  LYLeakSABCopy0( &(d), s, __FILE__, __LINE__)
+
+#ifdef BStrCat
+#undef BStrCat
+#endif
+#define BStrCat(d,s)  LYLeakSABCat( &(d), BStrData(s), BStrLen(s), __FILE__, __LINE__)
+
+#ifdef BStrCat0
+#undef BStrCat0
+#endif
+#define BStrCat0(d,s)  LYLeakSABCat0( &(d), s, __FILE__, __LINE__)
+
 #define mark_malloced(a,size) LYLeak_mark_malloced(a,size, __FILE__, __LINE__)
 
 #if defined(LY_FIND_LEAKS_EXTENDED) && !defined(NO_EXTENDED_MEMORY_TRACKING)
@@ -224,6 +255,31 @@ extern "C" {
 			     const char *src,
 			     const char *cp_File,
 			     const short ssi_Line);
+    extern void LYLeakSABAlloc(bstring **dest,
+			       int len,
+			       const char *cp_File,
+			       const short ssi_Line);
+    extern void LYLeakSABCopy(bstring **dest,
+			      const char *src,
+			      int len,
+			      const char *cp_File,
+			      const short ssi_Line);
+    extern void LYLeakSABCopy0(bstring **dest,
+			       const char *src,
+			       const char *cp_File,
+			       const short ssi_Line);
+    extern void LYLeakSABCat(bstring **dest,
+			     const char *src,
+			     int len,
+			     const char *cp_File,
+			     const short ssi_Line);
+    extern void LYLeakSABCat0(bstring **dest,
+			      const char *src,
+			      const char *cp_File,
+			      const short ssi_Line);
+    extern void LYLeakSABFree(bstring **ptr,
+			      const char *cp_File,
+			      const short ssi_Line);
 
 #ifdef LY_FIND_LEAKS_EXTENDED
 /*
diff --git a/src/GridText.c b/src/GridText.c
index 0e18511a..39d9c9ec 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.229 2012/02/09 01:55:40 tom Exp $
+ * $LynxId: GridText.c,v 1.230 2012/02/09 11:49:06 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -245,7 +245,7 @@ There are 3 functions - POOL_NEW, POOL_FREE, and ALLOC_IN_POOL.
  * Returns a pointer to the "allocated" memory or NULL if fails.
  * Updates 'poolptr' if necessary.
  */
-static pool_data *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request)
+static void *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request)
 {
     HTPool *pool = *ppoolptr;
     pool_data *ptr;
diff --git a/src/HTML.c b/src/HTML.c
index c932f4c3..74a990c5 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTML.c,v 1.153 2012/02/05 22:23:51 tom Exp $
+ * $LynxId: HTML.c,v 1.154 2012/02/10 01:26:31 tom Exp $
  *
  *		Structured stream to Rich hypertext converter
  *		============================================
@@ -4780,8 +4780,6 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		 * Use ImageSrc if no other alt or value is supplied. --LE
 		 */
 		I.value = ImageSrc;
-	    } else if (I.value == 0) {
-		StrAllocCopy(I.value, "");
 	    }
 	    if (present && present[HTML_INPUT_READONLY])
 		I.readonly = YES;
diff --git a/src/LYBookmark.c b/src/LYBookmark.c
index 174fd1e0..0a448764 100644
--- a/src/LYBookmark.c
+++ b/src/LYBookmark.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYBookmark.c,v 1.70 2012/02/08 01:37:55 tom Exp $
+ * $LynxId: LYBookmark.c,v 1.71 2012/02/09 13:01:39 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAlert.h>
@@ -292,7 +292,7 @@ void save_bookmark_link(const char *address,
 	    default:
 		break;
 	    }
-	    BStrCopy0(string_data, tmp_data->str);
+	    BStrCopy0(string_data, tmp_data ? tmp_data->str : title);
 	} else {
 	    BStrCopy0(string_data, title);
 	}
diff --git a/src/LYDownload.c b/src/LYDownload.c
index 241818c3..23ce2f66 100644
--- a/src/LYDownload.c
+++ b/src/LYDownload.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYDownload.c,v 1.64 2012/02/08 22:23:59 tom Exp $ */
+/* $LynxId: LYDownload.c,v 1.66 2012/02/09 18:55:26 tom Exp $ */
 #include <HTUtils.h>
 #include <HTParse.h>
 #include <HTList.h>
@@ -218,7 +218,7 @@ void LYDownload(char *line)
 	}
 
 	BStrCopy(command, buffer);
-	if (!LYValidateFilename(buffer, command))
+	if (!LYValidateFilename(&buffer, &command))
 	    goto cancelled;
 #ifdef HAVE_POPEN
 	else if (LYIsPipeCommand(buffer->str)) {
@@ -251,11 +251,6 @@ void LYDownload(char *line)
 	 */
 	CTRACE((tfp, "LYDownload: filename is %s\n", buffer->str));
 
-	if (!LYCanWriteFile(buffer->str)) {
-	    FirstRecall = TRUE;
-	    FnameNum = FnameTotal;
-	    goto retry;
-	}
 	SecondS = TRUE;
 
 	HTInfoMsg(SAVING);
diff --git a/src/LYJump.c b/src/LYJump.c
index 8c20145c..10cd50b6 100644
--- a/src/LYJump.c
+++ b/src/LYJump.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYJump.c,v 1.42 2012/02/09 01:56:47 tom Exp $
+ * $LynxId: LYJump.c,v 1.43 2012/02/09 13:02:30 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAlert.h>
@@ -449,7 +449,7 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp)
 	cp++;
     }
 
-    jtp->table = (JumpDatum *) malloc(nel * sizeof(JumpDatum));
+    jtp->table = (JumpDatum *) malloc((nel + 1) * sizeof(JumpDatum));
     if (jtp->table == NULL) {
 	HTAlert(OUTOF_MEM_FOR_JUMP_TABLE);
 	FREE(mp);
diff --git a/src/LYLeaks.c b/src/LYLeaks.c
index 6c251784..160bf463 100644
--- a/src/LYLeaks.c
+++ b/src/LYLeaks.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLeaks.c,v 1.34 2011/06/06 09:47:22 tom Exp $
+ * $LynxId: LYLeaks.c,v 1.36 2012/02/10 00:33:39 tom Exp $
  *
  *	Copyright (c) 1994, University of Kansas, All Rights Reserved
  *	(this file was rewritten twice - 1998/1999 and 2003/2004)
@@ -10,6 +10,8 @@
  *	05-26-94	created Lynx 2-3-1 Garrett Arch Blythe
  *	10-30-97	modified to handle StrAllocCopy() and
  *			  StrAllocCat(). - KW & FM
+ *	07-23-07	free leaks of THIS module too -TD
+ *	02-09-12	add bstring functions -TD
  */
 
 /*
@@ -57,8 +59,8 @@ static void CountFrees(size_t size)
 }
 
 #else
-#define CountMallocs() ++count_mallocs
-#define CountFrees()		/* nothing */
+#define CountMallocs(size) ++count_mallocs
+#define CountFrees(size)	/* nothing */
 #endif
 
 /*
@@ -453,6 +455,7 @@ AllocationList *LYLeak_mark_malloced(void *vp_malloced,
 		     * Add the new item to the allocation list.
 		     */
 		    AddToList(ALp_new);
+		    CountMallocs(st_bytes);
 		}
 	    }
 	}
@@ -489,7 +492,7 @@ void *LYLeakCalloc(size_t st_number, size_t st_bytes, const char *cp_File,
 	 * Allocate the requested memory.
 	 */
 	vp_calloc = (void *) calloc(st_number, st_bytes);
-	CountMallocs(st_bytes);
+	CountMallocs(st_bytes * st_number);
 
 	/*
 	 * Only if the allocation was a success do we track information.
@@ -602,8 +605,8 @@ void *LYLeakRealloc(void *vp_Alloced,
 	 * Perform the resize.  If not NULL, record the information.
 	 */
 	vp_realloc = (void *) realloc(vp_Alloced, st_newBytes);
-	CountMallocs(st_newBytes);
 	CountFrees(ALp_renew->st_Bytes);
+	CountMallocs(st_newBytes);
 
 	if (vp_realloc != NULL) {
 	    ALp_renew->st_Sequence = count_mallocs;
@@ -741,7 +744,7 @@ void LYLeakFree(void *vp_Alloced,
 /*
  *  Allocates a new copy of a string, and returns it.
  *  Tracks allocations by using other LYLeakFoo functions.
- *  Equivalent to HTSACopy in HTUtils.c - KW
+ *  Equivalent to HTSACopy in HTString.c - KW
  */
 char *LYLeakSACopy(char **dest,
 		   const char *src,
@@ -804,6 +807,159 @@ char *LYLeakSACat(char **dest,
     return *dest;
 }
 
+/******************************************************************************/
+
+/*
+ * Equivalents for bstring functions in HTString.c -TD
+ */
+/* same as HTSABAlloc */
+void LYLeakSABAlloc(bstring **dest,
+		    int len,
+		    const char *cp_File,
+		    const short ssi_Line)
+{
+    if (*dest == 0) {
+	*dest = LYLeakCalloc(1, sizeof(bstring), cp_File, ssi_Line);
+    }
+
+    if ((*dest)->len != len) {
+	(*dest)->str = (char *) LYLeakRealloc((*dest)->str,
+					      (size_t) len,
+					      cp_File,
+					      ssi_Line);
+	if ((*dest)->str == NULL)
+	    outofmem(__FILE__, "LYLeakSABalloc");
+
+	(*dest)->len = len;
+    }
+}
+
+/* same as HTSABCopy */
+void LYLeakSABCopy(bstring **dest,
+		   const char *src,
+		   int len,
+		   const char *cp_File,
+		   const short ssi_Line)
+{
+    bstring *t;
+    unsigned need = (unsigned) (len + 1);
+
+    CTRACE2(TRACE_BSTRING,
+	    (tfp, "HTSABCopy(%p, %p, %d)\n",
+	     (void *) dest, (const void *) src, len));
+    LYLeakSABFree(dest, cp_File, ssi_Line);
+    if (src) {
+	if (TRACE_BSTRING) {
+	    CTRACE((tfp, "===    %4d:", len));
+	    trace_bstring2(src, len);
+	    CTRACE((tfp, "\n"));
+	}
+	if ((t = (bstring *) LYLeakMalloc(sizeof(bstring), cp_File, ssi_Line))
+	    == NULL)
+	      outofmem(__FILE__, "HTSABCopy");
+
+	assert(t != NULL);
+
+	if ((t->str = (char *) LYLeakMalloc(need, cp_File, ssi_Line)) == NULL)
+	    outofmem(__FILE__, "HTSABCopy");
+
+	assert(t->str != NULL);
+
+	MemCpy(t->str, src, len);
+	t->len = len;
+	t->str[t->len] = '\0';
+	*dest = t;
+    }
+    if (TRACE_BSTRING) {
+	CTRACE((tfp, "=>     %4d:", BStrLen(*dest)));
+	trace_bstring(*dest);
+	CTRACE((tfp, "\n"));
+    }
+}
+
+/* same as HTSABCopy0 */
+void LYLeakSABCopy0(bstring **dest,
+		    const char *src,
+		    const char *cp_File,
+		    const short ssi_Line)
+{
+    LYLeakSABCopy(dest, src, (int) strlen(src), cp_File, ssi_Line);
+}
+
+/* same as HTSABCat */
+void LYLeakSABCat(bstring **dest,
+		  const char *src,
+		  int len,
+		  const char *cp_File,
+		  const short ssi_Line)
+{
+    bstring *t = *dest;
+
+    CTRACE2(TRACE_BSTRING,
+	    (tfp, "HTSABCat(%p, %p, %d)\n",
+	     (void *) dest, (const void *) src, len));
+    if (src) {
+	unsigned need = (unsigned) (len + 1);
+
+	if (TRACE_BSTRING) {
+	    CTRACE((tfp, "===    %4d:", len));
+	    trace_bstring2(src, len);
+	    CTRACE((tfp, "\n"));
+	}
+	if (t) {
+	    unsigned length = (unsigned) t->len + need;
+
+	    t->str = (char *) LYLeakRealloc(t->str, length, cp_File, ssi_Line);
+	} else {
+	    if ((t = (bstring *) LYLeakCalloc(1, sizeof(bstring), cp_File,
+		ssi_Line)) == NULL)
+		  outofmem(__FILE__, "HTSACat");
+
+	    assert(t != NULL);
+
+	    t->str = (char *) LYLeakMalloc(need, cp_File, ssi_Line);
+	}
+	if (t->str == NULL)
+	    outofmem(__FILE__, "HTSACat");
+
+	assert(t->str != NULL);
+
+	MemCpy(t->str + t->len, src, len);
+	t->len += len;
+	t->str[t->len] = '\0';
+	*dest = t;
+    }
+    if (TRACE_BSTRING) {
+	CTRACE((tfp, "=>     %4d:", BStrLen(*dest)));
+	trace_bstring(*dest);
+	CTRACE((tfp, "\n"));
+    }
+}
+
+/* same as HTSABCat0 */
+void LYLeakSABCat0(bstring **dest,
+		   const char *src,
+		   const char *cp_File,
+		   const short ssi_Line)
+{
+    LYLeakSABCat(dest, src, (int) strlen(src), cp_File, ssi_Line);
+}
+
+/* same as HTSABFree */
+void LYLeakSABFree(bstring **ptr,
+		   const char *cp_File,
+		   const short ssi_Line)
+{
+    if (*ptr != NULL) {
+	if ((*ptr)->str)
+	    LYLeakFree((*ptr)->str, cp_File, ssi_Line);
+	LYLeakFree(*ptr, cp_File, ssi_Line);
+	*ptr = NULL;
+    }
+}
+
+/******************************************************************************/
+
 #if defined(LY_FIND_LEAKS) && defined(LY_FIND_LEAKS_EXTENDED)
 
 const char *leak_cp_File_hack = __FILE__;
@@ -833,7 +989,7 @@ short leak_ssi_Line_hack = __LINE__;
  *  Remarks/Portability/Dependencies/Restrictions:
  *		The price for generality is severe inefficiency: several
  *		list lookups are done to be on the safe side.
- *		We don't get he real allocation size, only a minimum based
+ *		We don't get the real allocation size, only a minimum based
  *		on the string length of the result.  So the amount of memory
  *		leakage may get underestimated.
  *		If *dest is an invalid pointer value on entry (i.e. was not
diff --git a/src/LYLocal.c b/src/LYLocal.c
index f4b23208..52c57e9f 100644
--- a/src/LYLocal.c
+++ b/src/LYLocal.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLocal.c,v 1.117 2012/02/08 20:32:47 tom Exp $
+ * $LynxId: LYLocal.c,v 1.118 2012/02/09 11:45:06 tom Exp $
  *
  *  Routines to manipulate the local filesystem.
  *  Written by: Rick Mallett, Carleton University
@@ -2568,7 +2568,7 @@ void reset_dired_menu(void)
 	    FREE(mp->link);
 	    FREE(mp->rest);
 	    FREE(mp->href);
-	    mp_next = mp_next;
+	    mp_next = mp->next;
 	    FREE(mp);
 	}
 	menu_head = NULL;
diff --git a/src/LYMain.c b/src/LYMain.c
index a551d714..1fe30b8a 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMain.c,v 1.232 2011/06/06 00:01:44 tom Exp $
+ * $LynxId: LYMain.c,v 1.236 2012/02/10 01:19:45 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTP.h>
@@ -810,6 +810,7 @@ static void free_lynx_globals(void)
 #endif
     FREE(startrealm);
     FREE(personal_mail_address);
+    FREE(personal_mail_name);
     FREE(anonftp_password);
     FREE(URLDomainPrefixes);
     FREE(URLDomainSuffixes);
@@ -818,6 +819,7 @@ static void free_lynx_globals(void)
     FREE(LYTransferName);
     FREE(LYTraceLogPath);
     FREE(lynx_cfg_file);
+    FREE(SSL_cert_file);
 #if defined(USE_COLOR_STYLE)
     FREE(lynx_lss_file2);
     FREE(lynx_lss_file);
@@ -827,7 +829,7 @@ static void free_lynx_globals(void)
     LYFreeHilites(0, nlinks);
     nlinks = 0;
     LYFreeStringList(LYcommandList());
-    HTInitProgramPaths();
+    HTInitProgramPaths(FALSE);
 #if EXTENDED_STARTFILE_RECALL
     FREE(nonoption);
 #endif
@@ -1008,6 +1010,20 @@ int main(int argc,
     setuid(getuid());
 #endif
 
+#ifdef LY_FIND_LEAKS
+    /*
+     * Register the final function to be executed when being exited.  Will
+     * display memory leaks if the -find-leaks option is used.  This should
+     * be the first call to atexit() for leak-checking, which ensures that 
+     * all of the other functions will be invoked before LYLeaks().
+     */
+    atexit(LYLeaks);
+    /*
+     * Register the function which will free our allocated globals.
+     */
+    atexit(free_lynx_globals);
+#endif /* LY_FIND_LEAKS */
+
 #ifdef    NOT_ASCII
     FixCharacters();
 #endif /* NOT_ASCII */
@@ -1131,18 +1147,6 @@ int main(int argc,
     }
     LYOpenTraceLog();
 
-#ifdef LY_FIND_LEAKS
-    /*
-     * Register the final function to be executed when being exited.  Will
-     * display memory leaks if the -find-leaks option is used.
-     */
-    atexit(LYLeaks);
-    /*
-     * Register the function which will free our allocated globals.
-     */
-    atexit(free_lynx_globals);
-#endif /* LY_FIND_LEAKS */
-
     SetLocale();
 
     /*
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index e64c8830..c24c2ec3 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYMainLoop.c,v 1.187 2012/02/09 01:55:58 tom Exp $
+ * $LynxId: LYMainLoop.c,v 1.193 2012/02/10 00:26:26 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAccess.h>
@@ -591,7 +591,7 @@ static int do_change_link(void)
 			else HTuncache_current_document()
 #endif /* DIRED_SUPPORT */
 
-static void do_check_goto_URL(bstring *user_input_buffer,
+static void do_check_goto_URL(bstring **user_input,
 			      char **old_user_input,
 			      BOOLEAN *force_load)
 {
@@ -646,27 +646,27 @@ static void do_check_goto_URL(bstring *user_input_buffer,
     BOOLEAN found = FALSE;
 
     /* allow going to anchors */
-    if (user_input_buffer->str[0] == '#') {
-	if (user_input_buffer->str[1] &&
-	    HTFindPoundSelector(user_input_buffer->str + 1)) {
+    if ((*user_input)->str[0] == '#') {
+	if ((*user_input)->str[1] &&
+	    HTFindPoundSelector((*user_input)->str + 1)) {
 	    /* HTFindPoundSelector will initialize www_search_result,
 	       so we do nothing else. */
-	    HTAddGotoURL(user_input_buffer->str);
+	    HTAddGotoURL((*user_input)->str);
 	    trimPoundSelector(curdoc.address);
-	    StrAllocCat(curdoc.address, user_input_buffer->str);
+	    StrAllocCat(curdoc.address, (*user_input)->str);
 	}
     } else {
 	/*
 	 * If it's not a URL then make it one.
 	 */
-	StrAllocCopy(*old_user_input, user_input_buffer->str);
+	StrAllocCopy(*old_user_input, (*user_input)->str);
 	LYEnsureAbsoluteURL(old_user_input, "", TRUE);
-	BStrCopy0(user_input_buffer, *old_user_input);
+	BStrCopy0((*user_input), *old_user_input);
 	FREE(*old_user_input);
 
 	for (n = 0; n < TABLESIZE(table); n++) {
 	    if (*(table[n].flag)
-		&& !StrNCmp(user_input_buffer->str,
+		&& !StrNCmp((*user_input)->str,
 			    table[n].name,
 			    strlen(table[n].name))) {
 		found = TRUE;
@@ -677,12 +677,12 @@ static void do_check_goto_URL(bstring *user_input_buffer,
 	if (found) {
 	    ;
 	} else if (LYValidate &&
-		   !isHTTP_URL(user_input_buffer->str) &&
-		   !isHTTPS_URL(user_input_buffer->str)) {
+		   !isHTTP_URL((*user_input)->str) &&
+		   !isHTTPS_URL((*user_input)->str)) {
 	    HTUserMsg(GOTO_NON_HTTP_DISALLOWED);
 
 	} else {
-	    set_address(&newdoc, user_input_buffer->str);
+	    set_address(&newdoc, (*user_input)->str);
 	    newdoc.isHEAD = FALSE;
 	    /*
 	     * Might be an anchor in the same doc from a POST form.  If so,
@@ -713,7 +713,7 @@ static void do_check_goto_URL(bstring *user_input_buffer,
 
 /* returns FALSE if user cancelled input or URL was invalid, TRUE otherwise */
 static BOOL do_check_recall(int ch,
-			    bstring *user_input_buffer,
+			    bstring **user_input,
 			    char **old_user_input,
 			    int URLTotal,
 			    int *URLNum,
@@ -728,20 +728,20 @@ static BOOL do_check_recall(int ch,
 
     for (;;) {
 #ifdef WIN_EX			/* 1998/10/11 (Sun) 10:41:05 */
-	int len = strlen(user_input_buffer->str);
+	int len = strlen((*user_input)->str);
 
 	if (len >= 3) {
 	    if (len < MAX_LINE - 1
-		&& LYIsHtmlSep(user_input_buffer->str[len - 3])
-		&& LYIsDosDrive(user_input_buffer->str + len - 2))
-		LYAddPathSep0(user_input_buffer->str);
+		&& LYIsHtmlSep((*user_input)->str[len - 3])
+		&& LYIsDosDrive((*user_input)->str + len - 2))
+		LYAddPathSep0((*user_input)->str);
 
-	} else if (len == 2 && user_input_buffer->str[1] == ':') {
-	    if (LYIsDosDrive(user_input_buffer->str)) {
-		LYAddPathSep0(user_input_buffer->str);
+	} else if (len == 2 && (*user_input)->str[1] == ':') {
+	    if (LYIsDosDrive((*user_input)->str)) {
+		LYAddPathSep0((*user_input)->str);
 	    } else {
-		HTUserMsg2(WWW_ILLEGAL_URL_MESSAGE, user_input_buffer->str);
-		BStrCopy0(user_input_buffer, *old_user_input);
+		HTUserMsg2(WWW_ILLEGAL_URL_MESSAGE, (*user_input)->str);
+		BStrCopy0((*user_input), *old_user_input);
 		FREE(*old_user_input);
 		ret = FALSE;
 		break;
@@ -751,10 +751,10 @@ static BOOL do_check_recall(int ch,
 	/*
 	 * Get rid of leading spaces (and any other spaces).
 	 */
-	LYTrimAllStartfile(user_input_buffer->str);
-	if (isBEmpty(user_input_buffer) &&
+	LYTrimAllStartfile((*user_input)->str);
+	if (isBEmpty(*user_input) &&
 	    !(recall && (ch == UPARROW || ch == DNARROW))) {
-	    BStrCopy0(user_input_buffer, *old_user_input);
+	    BStrCopy0((*user_input), *old_user_input);
 	    FREE(*old_user_input);
 	    HTInfoMsg(CANCELLED);
 	    ret = FALSE;
@@ -780,10 +780,10 @@ static BOOL do_check_recall(int ch,
 		*URLNum = 0;
 	    if ((cp = (char *) HTList_objectAt(Goto_URLs,
 					       *URLNum)) != NULL) {
-		BStrCopy0(user_input_buffer, cp);
+		BStrCopy0((*user_input), cp);
 		if (goto_buffer
 		    && **old_user_input
-		    && !strcmp(*old_user_input, user_input_buffer->str)) {
+		    && !strcmp(*old_user_input, (*user_input)->str)) {
 		    _statusline(EDIT_CURRENT_GOTO);
 		} else if ((goto_buffer && URLTotal == 2) ||
 			   (!goto_buffer && URLTotal == 1)) {
@@ -791,13 +791,12 @@ static BOOL do_check_recall(int ch,
 		} else {
 		    _statusline(EDIT_A_PREV_GOTO);
 		}
-		if ((ch = LYgetBString(&user_input_buffer,
-				       VISIBLE, 0, recall)) < 0) {
+		if ((ch = LYgetBString(user_input, VISIBLE, 0, recall)) < 0) {
 		    /*
 		     * User cancelled the Goto via ^G.  Restore
-		     * user_input_buffer and break.  - FM
+		     * user_input and break.  - FM
 		     */
-		    BStrCopy0(user_input_buffer, *old_user_input);
+		    BStrCopy0((*user_input), *old_user_input);
 		    FREE(*old_user_input);
 		    HTInfoMsg(CANCELLED);
 		    ret = FALSE;
@@ -824,9 +823,9 @@ static BOOL do_check_recall(int ch,
 		 */
 		*URLNum = URLTotal - 1;
 	    if ((cp = (char *) HTList_objectAt(Goto_URLs, *URLNum)) != NULL) {
-		BStrCopy0(user_input_buffer, cp);
+		BStrCopy0((*user_input), cp);
 		if (goto_buffer && **old_user_input &&
-		    !strcmp(*old_user_input, user_input_buffer->str)) {
+		    !strcmp(*old_user_input, (*user_input)->str)) {
 		    _statusline(EDIT_CURRENT_GOTO);
 		} else if ((goto_buffer && URLTotal == 2) ||
 			   (!goto_buffer && URLTotal == 1)) {
@@ -834,13 +833,12 @@ static BOOL do_check_recall(int ch,
 		} else {
 		    _statusline(EDIT_A_PREV_GOTO);
 		}
-		if ((ch = LYgetBString(&user_input_buffer,
-				       VISIBLE, 0, recall)) < 0) {
+		if ((ch = LYgetBString(user_input, VISIBLE, 0, recall)) < 0) {
 		    /*
 		     * User cancelled the Goto via ^G.  Restore
-		     * user_input_buffer and break.  - FM
+		     * user_input and break.  - FM
 		     */
-		    BStrCopy0(user_input_buffer, *old_user_input);
+		    BStrCopy0((*user_input), *old_user_input);
 		    FREE(*old_user_input);
 		    HTInfoMsg(CANCELLED);
 		    ret = FALSE;
@@ -1702,16 +1700,16 @@ static void handle_LYK_CLEAR_AUTH(int *old_c,
     }
 }
 
-static int handle_LYK_COMMAND(bstring *user_input_buffer)
+static int handle_LYK_COMMAND(bstring **user_input)
 {
     LYKeymapCode ch;
     Kcmd *mp;
     char *src, *tmp;
 
-    BStrCopy0(user_input_buffer, "");
+    BStrCopy0((*user_input), "");
     _statusline(": ");
-    if (LYgetBString(&user_input_buffer, VISIBLE, 0, RECALL_CMD) >= 0) {
-	src = LYSkipBlanks(user_input_buffer->str);
+    if (LYgetBString(user_input, VISIBLE, 0, RECALL_CMD) >= 0) {
+	src = LYSkipBlanks((*user_input)->str);
 	tmp = LYSkipNonBlanks(src);
 	*tmp = 0;
 	ch = ((mp = LYStringToKcmd(src)) != 0) ? mp->code : LYK_UNKNOWN;
@@ -2364,7 +2362,7 @@ static int handle_LYK_DWIMEDIT(int *cmd,
 }
 
 static int handle_LYK_ECGOTO(int *ch,
-			     bstring *user_input_buffer,
+			     bstring **user_input,
 			     char **old_user_input,
 			     int *old_c,
 			     int real_c)
@@ -2395,11 +2393,11 @@ static int handle_LYK_ECGOTO(int *ch,
 #endif /* DIRED_SUPPORT */
 
     /*
-     * Save the current user_input_buffer string, and load the current
+     * Save the current user_input string, and load the current
      * document's address.
      */
-    StrAllocCopy(*old_user_input, user_input_buffer->str);
-    BStrCopy0(user_input_buffer, curdoc.address);
+    StrAllocCopy(*old_user_input, (*user_input)->str);
+    BStrCopy0((*user_input), curdoc.address);
 
     /*
      * Warn the user if the current document has POST data associated with it. 
@@ -2412,12 +2410,11 @@ static int handle_LYK_ECGOTO(int *ch,
      * Offer the current document's URL for editing.  - FM
      */
     _statusline(EDIT_CURDOC_URL);
-    if (((*ch = LYgetBString(&user_input_buffer, VISIBLE,
-			     0, RECALL_URL)) >= 0) &&
-	!isBEmpty(user_input_buffer) &&
-	strcmp(user_input_buffer->str, curdoc.address)) {
-	LYTrimAllStartfile(user_input_buffer->str);
-	if (!isBEmpty(user_input_buffer)) {
+    if (((*ch = LYgetBString(user_input, VISIBLE, 0, RECALL_URL)) >= 0) &&
+	!isBEmpty(*user_input) &&
+	strcmp((*user_input)->str, curdoc.address)) {
+	LYTrimAllStartfile((*user_input)->str);
+	if (!isBEmpty(*user_input)) {
 	    return 2;
 	}
     }
@@ -2425,7 +2422,7 @@ static int handle_LYK_ECGOTO(int *ch,
      * User cancelled via ^G, a full deletion, or not modifying the URL.  - FM
      */
     HTInfoMsg(CANCELLED);
-    BStrCopy0(user_input_buffer, *old_user_input);
+    BStrCopy0((*user_input), *old_user_input);
     FREE(*old_user_input);
     return 0;
 }
@@ -2587,7 +2584,7 @@ static void handle_LYK_EDIT_TEXTAREA(BOOLEAN *refresh_screen,
 }
 
 static int handle_LYK_ELGOTO(int *ch,
-			     bstring *user_input_buffer,
+			     bstring **user_input,
 			     char **old_user_input,
 			     int *old_c,
 			     int real_c)
@@ -2645,11 +2642,11 @@ static int handle_LYK_ELGOTO(int *ch,
 #endif /* DIRED_SUPPORT */
 
     /*
-     * Save the current user_input_buffer string, and load the current link's
+     * Save the current user_input string, and load the current link's
      * address.  - FM
      */
-    StrAllocCopy(*old_user_input, user_input_buffer->str);
-    BStrCopy0(user_input_buffer,
+    StrAllocCopy(*old_user_input, (*user_input)->str);
+    BStrCopy0((*user_input),
 	      ((links[curdoc.link].type == WWW_FORM_LINK_TYPE)
 	       ? links[curdoc.link].l_form->submit_action
 	       : links[curdoc.link].lname));
@@ -2657,15 +2654,14 @@ static int handle_LYK_ELGOTO(int *ch,
      * Offer the current link's URL for editing.  - FM
      */
     _statusline(EDIT_CURLINK_URL);
-    if (((*ch = LYgetBString(&user_input_buffer, VISIBLE,
-			     0, RECALL_URL)) >= 0) &&
-	!isBEmpty(user_input_buffer) &&
-	strcmp(user_input_buffer->str,
+    if (((*ch = LYgetBString(user_input, VISIBLE, 0, RECALL_URL)) >= 0) &&
+	!isBEmpty(*user_input) &&
+	strcmp((*user_input)->str,
 	       ((links[curdoc.link].type == WWW_FORM_LINK_TYPE)
 		? links[curdoc.link].l_form->submit_action
 		: links[curdoc.link].lname))) {
-	LYTrimAllStartfile(user_input_buffer->str);
-	if (!isBEmpty(user_input_buffer)) {
+	LYTrimAllStartfile((*user_input)->str);
+	if (!isBEmpty(*user_input)) {
 	    return 2;
 	}
     }
@@ -2673,7 +2669,7 @@ static int handle_LYK_ELGOTO(int *ch,
      * User cancelled via ^G, a full deletion, or not modifying the URL.  - FM
      */
     HTInfoMsg(CANCELLED);
-    BStrCopy0(user_input_buffer, *old_user_input);
+    BStrCopy0((*user_input), *old_user_input);
     FREE(*old_user_input);
     return 0;
 }
@@ -2874,7 +2870,7 @@ static void handle_LYK_FIRST_LINK(void)
 }
 
 static BOOLEAN handle_LYK_GOTO(int *ch,
-			       bstring *user_input_buffer,
+			       bstring **user_input,
 			       char **old_user_input,
 			       RecallType * recall,
 			       int *URLTotal,
@@ -2892,12 +2888,12 @@ static BOOLEAN handle_LYK_GOTO(int *ch,
 	return FALSE;
     }
 
-    StrAllocCopy(*old_user_input, user_input_buffer->str);
+    StrAllocCopy(*old_user_input, (*user_input)->str);
     if (!goto_buffer)
-	BStrCopy0(user_input_buffer, "");
+	BStrCopy0((*user_input), "");
 
     *URLTotal = (Goto_URLs ? HTList_count(Goto_URLs) : 0);
-    if (goto_buffer && !isBEmpty(user_input_buffer)) {
+    if (goto_buffer && !isBEmpty(*user_input)) {
 	*recall = ((*URLTotal > 1) ? RECALL_URL : NORECALL);
 	*URLNum = 0;
 	*FirstURLRecall = FALSE;
@@ -2911,12 +2907,12 @@ static BOOLEAN handle_LYK_GOTO(int *ch,
      * Ask the user.
      */
     _statusline(URL_TO_OPEN);
-    if ((*ch = LYgetBString(&user_input_buffer, VISIBLE, 0, *recall)) < 0) {
+    if ((*ch = LYgetBString(user_input, VISIBLE, 0, *recall)) < 0) {
 	/*
-	 * User cancelled the Goto via ^G.  Restore user_input_buffer and
+	 * User cancelled the Goto via ^G.  Restore user_input and
 	 * break.  - FM
 	 */
-	BStrCopy0(user_input_buffer, *old_user_input);
+	BStrCopy0((*user_input), *old_user_input);
 	FREE(*old_user_input);
 	HTInfoMsg(CANCELLED);
 	return FALSE;
@@ -3509,7 +3505,7 @@ static BOOLEAN check_JUMP_param(char **url_template)
     BStrFree(input);
     FREE(encoded);
     *url_template = result;
-    return TRUE;
+    return (BOOLEAN) code;
 }
 
 static void fill_JUMP_Params(char **addressp)
@@ -3520,7 +3516,7 @@ static void fill_JUMP_Params(char **addressp)
 }
 
 static BOOLEAN handle_LYK_JUMP(int c,
-			       bstring *user_input_buffer,
+			       bstring **user_input,
 			       char **old_user_input GCC_UNUSED,
 			       RecallType * recall GCC_UNUSED,
 			       BOOLEAN *FirstURLRecall GCC_UNUSED,
@@ -3546,7 +3542,7 @@ static BOOLEAN handle_LYK_JUMP(int c,
 #ifdef PERMIT_GOTO_FROM_JUMP
 	    if (!strncasecomp(ret, "Go ", 3)) {
 		LYJumpFileURL = FALSE;
-		StrAllocCopy(*old_user_input, user_input_buffer->str);
+		StrAllocCopy(*old_user_input, (*user_input)->str);
 		*URLTotal = (Goto_URLs ? HTList_count(Goto_URLs) : 0);
 		*recall = ((*URLTotal >= 1) ? RECALL_URL : NORECALL);
 		*URLNum = *URLTotal;
@@ -3561,14 +3557,14 @@ static BOOLEAN handle_LYK_JUMP(int c,
 		    return FALSE;
 		}
 		ret = HTParse((ret + 3), startfile, PARSE_ALL);
-		BStrCopy0(user_input_buffer, ret);
+		BStrCopy0((*user_input), ret);
 		FREE(ret);
 		return TRUE;
 	    }
 #endif /* PERMIT_GOTO_FROM_JUMP */
 	    ret = HTParse(ret, startfile, PARSE_ALL);
 	    if (!LYTrimStartfile(ret)) {
-		LYRemoveBlanks(user_input_buffer->str);
+		LYRemoveBlanks((*user_input)->str);
 	    }
 	    if (!check_JUMP_param(&ret))
 		return FALSE;
@@ -4925,7 +4921,7 @@ void handle_LYK_WHEREIS(int cmd,
 	 */
 	BStrCopy0(prev_target, "");
     }
-    found = textsearch(&curdoc, prev_target,
+    found = textsearch(&curdoc, &prev_target,
 		       (cmd == LYK_WHEREIS)
 		       ? 0
 		       : ((cmd == LYK_NEXT)
@@ -5343,6 +5339,14 @@ static BOOLEAN handle_LYK_MAXSCREEN_TOGGLE(int *cmd)
 }
 #endif
 
+#ifdef LY_FIND_LEAKS
+#define CleanupMainLoop() \
+ 	BStrFree(prev_target); \
+ 	BStrFree(user_input_buffer)
+#else
+#define CleanupMainLoop()	/* nothing */
+#endif
+
 /*
  * Here's where we do all the work.
  * mainloop is basically just a big switch dependent on the users input.  I
@@ -5351,7 +5355,6 @@ static BOOLEAN handle_LYK_MAXSCREEN_TOGGLE(int *cmd)
  * This needs some work to make it neater.  - Lou Moutilli
  *					(memoir from the original Lynx - FM)
  */
-
 int mainloop(void)
 {
 #if defined(WIN_EX)		/* 1997/10/08 (Wed) 14:52:06 */
@@ -5823,6 +5826,7 @@ int mainloop(void)
 		    /*
 		     * If nhist = 0 then it must be the first file.
 		     */
+		    CleanupMainLoop();
 		    exit_immediately_with_error_message(NOT_FOUND, first_file);
 		    return (EXIT_FAILURE);
 		}
@@ -5887,6 +5891,7 @@ int mainloop(void)
 			newdoc.internal_link = FALSE;
 			goto try_again;
 		    } else {
+			CleanupMainLoop();
 			exit_immediately_with_error_message(NULLFILE, first_file);
 			return (EXIT_FAILURE);
 		    }
@@ -6013,6 +6018,7 @@ int mainloop(void)
 			    FREE(temp);
 			    if (LYValidate) {
 				HTAlert(BOOKMARKS_DISABLED);
+				CleanupMainLoop();
 				return (EXIT_FAILURE);
 			    }
 			    if ((temp = HTParse(newdoc.address, "",
@@ -6208,6 +6214,7 @@ int mainloop(void)
 	    } else if (!dump_links_only) {
 		print_wwwfile_to_fd(stdout, FALSE, FALSE);
 	    }
+	    CleanupMainLoop();
 	    return ((dump_server_status >= 400) ? EXIT_FAILURE : EXIT_SUCCESS);
 	}
 
@@ -6671,6 +6678,7 @@ int mainloop(void)
 		    fprintf(fp,
 			    gettext("Fatal error - could not open output file %s\n"),
 			    cfile);
+		    CleanupMainLoop();
 		    if (!dump_output_immediately) {
 			exit_immediately(EXIT_FAILURE);
 		    }
@@ -6909,8 +6917,10 @@ int mainloop(void)
 	 * loop.
 	 */
 	if (traversal) {
-	    if ((c = DoTraversal(c, &crawl_ok)) < 0)
+	    if ((c = DoTraversal(c, &crawl_ok)) < 0) {
+		CleanupMainLoop();
 		return (EXIT_FAILURE);
+	    }
 	}
 	/* traversal */
 #ifdef WIN_EX
@@ -6972,7 +6982,7 @@ int mainloop(void)
 	    break;
 
 	case LYK_COMMAND:
-	    cmd = handle_LYK_COMMAND(user_input_buffer);
+	    cmd = handle_LYK_COMMAND(&user_input_buffer);
 	    goto new_cmd;
 
 	case LYK_INTERRUPT:
@@ -7032,11 +7042,14 @@ int mainloop(void)
 	    break;
 
 	case LYK_QUIT:		/* quit */
-	    if (handle_LYK_QUIT())
+	    if (handle_LYK_QUIT()) {
+		CleanupMainLoop();
 		return (EXIT_SUCCESS);
+	    }
 	    break;
 
 	case LYK_ABORT:	/* don't ask the user about quitting */
+	    CleanupMainLoop();
 	    return (EXIT_SUCCESS);
 
 	case LYK_NEXT_PAGE:	/* next page */
@@ -7152,7 +7165,7 @@ int mainloop(void)
 		*t = '\0';
 		get_clip_release();
 		BStrCopy0(user_input_buffer, buf);
-		do_check_goto_URL(user_input_buffer, &temp, &force_load);
+		do_check_goto_URL(&user_input_buffer, &temp, &force_load);
 		free(buf);
 	    }
 	    break;
@@ -7279,6 +7292,7 @@ int mainloop(void)
 	case LYK_PREV_DOC:	/* back up a level */
 	    switch (handle_PREV_DOC(&cmd, &old_c, real_c)) {
 	    case 1:
+		CleanupMainLoop();
 		return (EXIT_SUCCESS);
 	    case 2:
 		goto new_cmd;
@@ -7313,22 +7327,22 @@ int mainloop(void)
 	    break;
 
 	case LYK_ELGOTO:	/* edit URL of current link and go to it  */
-	    if (handle_LYK_ELGOTO(&ch, user_input_buffer, &temp, &old_c, real_c))
-		do_check_goto_URL(user_input_buffer, &temp, &force_load);
+	    if (handle_LYK_ELGOTO(&ch, &user_input_buffer, &temp, &old_c, real_c))
+		do_check_goto_URL(&user_input_buffer, &temp, &force_load);
 	    break;
 
 	case LYK_ECGOTO:	/* edit current URL and go to to it     */
-	    if (handle_LYK_ECGOTO(&ch, user_input_buffer, &temp, &old_c, real_c))
-		do_check_goto_URL(user_input_buffer, &temp, &force_load);
+	    if (handle_LYK_ECGOTO(&ch, &user_input_buffer, &temp, &old_c, real_c))
+		do_check_goto_URL(&user_input_buffer, &temp, &force_load);
 	    break;
 
 	case LYK_GOTO:		/* 'g' to goto a random URL  */
-	    if (handle_LYK_GOTO(&ch, user_input_buffer, &temp, &recall,
+	    if (handle_LYK_GOTO(&ch, &user_input_buffer, &temp, &recall,
 				&URLTotal, &URLNum, &FirstURLRecall, &old_c,
 				real_c)) {
-		if (do_check_recall(ch, user_input_buffer, &temp, URLTotal,
+		if (do_check_recall(ch, &user_input_buffer, &temp, URLTotal,
 				    &URLNum, recall, &FirstURLRecall))
-		    do_check_goto_URL(user_input_buffer, &temp, &force_load);
+		    do_check_goto_URL(&user_input_buffer, &temp, &force_load);
 	    }
 	    break;
 
@@ -7537,12 +7551,12 @@ int mainloop(void)
 	    break;
 
 	case LYK_JUMP:
-	    if (handle_LYK_JUMP(c, user_input_buffer, &temp, &recall,
+	    if (handle_LYK_JUMP(c, &user_input_buffer, &temp, &recall,
 				&FirstURLRecall, &URLNum, &URLTotal, &ch,
 				&old_c, real_c)) {
-		if (do_check_recall(ch, user_input_buffer, &temp, URLTotal,
+		if (do_check_recall(ch, &user_input_buffer, &temp, URLTotal,
 				    &URLNum, recall, &FirstURLRecall))
-		    do_check_goto_URL(user_input_buffer, &temp, &force_load);
+		    do_check_goto_URL(&user_input_buffer, &temp, &force_load);
 	    }
 	    break;
 
diff --git a/src/LYPrint.c b/src/LYPrint.c
index a9af8135..1cea439f 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYPrint.c,v 1.93 2012/02/08 23:40:43 tom Exp $
+ * $LynxId: LYPrint.c,v 1.95 2012/02/09 18:55:26 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAccess.h>
@@ -328,14 +328,14 @@ static void send_file_to_file(DocInfo *newdoc,
 	break;
     }
 
-    if (!LYValidateFilename(buffer, filename)) {
+    if (!LYValidateFilename(&buffer, &filename)) {
 	CancelPrint(SAVE_REQUEST_CANCELLED);
     }
 
     /*
      * See if it already exists.
      */
-    switch (LYValidateOutput(buffer->str)) {
+    switch (c = LYValidateOutput(buffer->str)) {
     case 'Y':
 	break;
     case 'N':
@@ -1411,7 +1411,7 @@ char *GetFileName(void)
      * Expand tilde's, make filename absolute, etc.
      */
     BStrCopy0(tbuf, "");
-    if (!LYValidateFilename(tbuf, fbuf))
+    if (!LYValidateFilename(&tbuf, &fbuf))
 	goto cleanup;
 
     /*
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 10e09614..26d8ebc6 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYReadCFG.c,v 1.166 2011/06/12 00:30:30 tom Exp $
+ * $LynxId: LYReadCFG.c,v 1.167 2012/02/10 01:10:22 tom Exp $
  */
 #ifndef NO_RULES
 #include <HTRules.h>
@@ -2004,8 +2004,11 @@ void LYSetConfigValue(const char *name,
 #endif
 
     case CONF_PRG:
-	if (StrAllocCopy(temp_value, value))
+	if (isEmpty(value)) {
+	    HTSetProgramPath((ProgramPaths) (q->def_value), NULL);
+	} else if (StrAllocCopy(temp_value, value)) {
 	    HTSetProgramPath((ProgramPaths) (q->def_value), temp_value);
+	}
 	break;
 
     default:
@@ -2316,7 +2319,7 @@ void read_cfg(const char *cfg_filename,
 	      int nesting_level,
 	      FILE *fp0)
 {
-    HTInitProgramPaths();
+    HTInitProgramPaths(TRUE);
     do_read_cfg(cfg_filename, parent_filename, nesting_level, fp0, NULL);
 }
 
diff --git a/src/LYSearch.c b/src/LYSearch.c
index 82c83dda..7c6d1d28 100644
--- a/src/LYSearch.c
+++ b/src/LYSearch.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYSearch.c,v 1.29 2012/02/08 15:02:45 tom Exp $
+ * $LynxId: LYSearch.c,v 1.31 2012/02/09 19:02:53 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAlert.h>
@@ -153,7 +153,7 @@ static int check_prev_target_in_links(int *cur,
  * insensitive depending on the 'LYcase_sensitive' global variable
  */
 BOOL textsearch(DocInfo *cur_doc,
-		bstring *prev_target,
+		bstring **prev_target,
 		int direction)
 {
     int offset;
@@ -179,14 +179,17 @@ BOOL textsearch(DocInfo *cur_doc,
     recall = ((QueryTotal >= 1) ? RECALL_URL : NORECALL);
     QueryNum = QueryTotal;
 
-    if (direction != 0)
+    if (direction != 0) {
 	/*
 	 * LYK_NEXT or LYK_PREV was pressed, so copy the buffer into
 	 * prev_target.
 	 */
-	BStrCopy(prev_target, my_prev_target);
+	BStrCopy(*prev_target, my_prev_target);
+    } else if (*prev_target == 0) {
+	BStrCopy0(*prev_target, "");
+    }
 
-    if (strlen(prev_target->str) == 0) {
+    if (strlen((*prev_target)->str) == 0) {
 	/*
 	 * This is a new WHEREIS search ('/'), or LYK_NEXT was pressed but
 	 * there was no previous search, so we need to get a search string from
@@ -194,20 +197,20 @@ BOOL textsearch(DocInfo *cur_doc,
 	 */
 	_statusline(ENTER_WHEREIS_QUERY);
 
-	ch = LYgetBString(&prev_target, VISIBLE, 0, recall);
+	ch = LYgetBString(prev_target, VISIBLE, 0, recall);
 	if (ch < 0) {
 	    /*
 	     * User cancelled the search via ^G.  Restore prev_target and
 	     * return.  - FM
 	     */
-	    BStrCopy(prev_target, my_prev_target);
+	    BStrCopy(*prev_target, my_prev_target);
 	    HTInfoMsg(CANCELLED);
 	    return (FALSE);
 	}
     }
 
   check_recall:
-    if (strlen(prev_target->str) == 0 &&
+    if (strlen((*prev_target)->str) == 0 &&
 	!(recall && (ch == UPARROW || ch == DNARROW))) {
 	/*
 	 * No entry.  Simply return, retaining the current buffer.  Because
@@ -249,9 +252,9 @@ BOOL textsearch(DocInfo *cur_doc,
 	    QueryNum = 0;
 	if ((cp = (char *) HTList_objectAt(search_queries,
 					   QueryNum)) != NULL) {
-	    BStrCopy0(prev_target, cp);
+	    BStrCopy0(*prev_target, cp);
 	    if (!isBEmpty(my_prev_target) &&
-		!strcmp(my_prev_target->str, prev_target->str)) {
+		!strcmp(my_prev_target->str, (*prev_target)->str)) {
 		_statusline(EDIT_CURRENT_QUERY);
 	    } else if ((!isBEmpty(my_prev_target) && QueryTotal == 2) ||
 		       (isBEmpty(my_prev_target) && QueryTotal == 1)) {
@@ -259,13 +262,13 @@ BOOL textsearch(DocInfo *cur_doc,
 	    } else {
 		_statusline(EDIT_A_PREV_QUERY);
 	    }
-	    ch = LYgetBString(&prev_target, VISIBLE, 0, recall);
+	    ch = LYgetBString(prev_target, VISIBLE, 0, recall);
 	    if (ch < 0) {
 		/*
 		 * User canceled the search via ^G.  Restore prev_target and
 		 * return.  - FM
 		 */
-		BStrCopy(prev_target, my_prev_target);
+		BStrCopy(*prev_target, my_prev_target);
 		HTInfoMsg(CANCELLED);
 		return (FALSE);
 	    }
@@ -301,9 +304,9 @@ BOOL textsearch(DocInfo *cur_doc,
 	    QueryNum = QueryTotal - 1;
 	if ((cp = (char *) HTList_objectAt(search_queries,
 					   QueryNum)) != NULL) {
-	    BStrCopy0(prev_target, cp);
+	    BStrCopy0(*prev_target, cp);
 	    if (!isBEmpty(my_prev_target) &&
-		!strcmp(my_prev_target->str, prev_target->str)) {
+		!strcmp(my_prev_target->str, (*prev_target)->str)) {
 		_statusline(EDIT_CURRENT_QUERY);
 	    } else if ((!isBEmpty(my_prev_target) && QueryTotal == 2) ||
 		       (isBEmpty(my_prev_target) && QueryTotal == 1)) {
@@ -311,13 +314,13 @@ BOOL textsearch(DocInfo *cur_doc,
 	    } else {
 		_statusline(EDIT_A_PREV_QUERY);
 	    }
-	    ch = LYgetBString(&prev_target, VISIBLE, 0, recall);
+	    ch = LYgetBString(prev_target, VISIBLE, 0, recall);
 	    if (ch < 0) {
 		/*
 		 * User cancelled the search via ^G.  Restore prev_target and
 		 * return.  - FM
 		 */
-		BStrCopy(prev_target, my_prev_target);
+		BStrCopy(*prev_target, my_prev_target);
 		HTInfoMsg(CANCELLED);
 		return (FALSE);
 	    }
@@ -327,16 +330,16 @@ BOOL textsearch(DocInfo *cur_doc,
     /*
      * Replace the search string buffer with the new target.  - FM
      */
-    BStrCopy(my_prev_target, prev_target);
+    BStrCopy(my_prev_target, *prev_target);
     HTAddSearchQuery(my_prev_target->str);
 
     if (direction < 0) {
 	offset = 0;
-	if (check_prev_target_in_links(&cur_doc->link, prev_target->str)) {
+	if (check_prev_target_in_links(&cur_doc->link, (*prev_target)->str)) {
 	    /*
 	     * Found in link, changed cur, we're done.
 	     */
-	    LYhighlight(FALSE, oldcur, prev_target->str);
+	    LYhighlight(FALSE, oldcur, (*prev_target)->str);
 	    return (TRUE);
 	}
     } else {
@@ -345,11 +348,11 @@ BOOL textsearch(DocInfo *cur_doc,
 	 * Search the links on the currently displayed page for the string,
 	 * starting after the current link.  - FM
 	 */
-	if (check_next_target_in_links(&cur_doc->link, prev_target->str)) {
+	if (check_next_target_in_links(&cur_doc->link, (*prev_target)->str)) {
 	    /*
 	     * Found in link, changed cur, we're done.
 	     */
-	    LYhighlight(FALSE, oldcur, prev_target->str);
+	    LYhighlight(FALSE, oldcur, (*prev_target)->str);
 	    return (TRUE);
 	}
 
@@ -367,9 +370,9 @@ BOOL textsearch(DocInfo *cur_doc,
      * Resume search, this time for all text.  Set www_search_result if string
      * found, and position the hit near top of screen.
      */
-    www_user_search((cur_doc->line + offset), cur_doc, prev_target->str, direction);
+    www_user_search((cur_doc->line + offset), cur_doc, (*prev_target)->str, direction);
     if (cur_doc->link != oldcur) {
-	LYhighlight(FALSE, oldcur, prev_target->str);
+	LYhighlight(FALSE, oldcur, (*prev_target)->str);
 	return (TRUE);
     }
     return (BOOL) (www_search_result > 0);
diff --git a/src/LYSearch.h b/src/LYSearch.h
index 798809a5..c95d59cd 100644
--- a/src/LYSearch.h
+++ b/src/LYSearch.h
@@ -9,7 +9,7 @@
 extern "C" {
 #endif
     extern BOOL textsearch(DocInfo *cur_doc,
-			   bstring *prev_target,
+			   bstring **prev_target,
 			   int direction);
 
 #define IN_FILE 1
diff --git a/src/LYSession.c b/src/LYSession.c
index 8c5c690d..37b47e0f 100644
--- a/src/LYSession.c
+++ b/src/LYSession.c
@@ -1,7 +1,8 @@
-/* $LynxId: LYSession.c,v 1.7 2010/10/31 18:15:33 Paul.B.Mahol Exp $ */
+/* $LynxId: LYSession.c,v 1.8 2012/02/09 20:00:59 tom Exp $ */
 
 #include <LYSession.h>
 
+#include <LYLeaks.h>
 #include <LYUtils.h>
 #include <LYStrings.h>
 #include <LYHistory.h>
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 2d25c424..0760fda8 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.200 2012/02/08 15:51:01 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.202 2012/02/09 18:48:45 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <UCAux.h>
@@ -2901,7 +2901,9 @@ static void ExtendEditor(EDREC * edit, int position)
     size_t need = (size_t) (++position);
 
     if (need >= MaxLen && (BufLimit == 0 || need < BufLimit)) {
-	CTRACE((tfp, "ExtendEditor from %d to %d\n", MaxLen, need));
+	CTRACE((tfp, "ExtendEditor from %u to %u\n",
+		(unsigned) MaxLen,
+		(unsigned) need));
 	Buf = typeRealloc(char, Buf, need);
 	Offs2Col = typeRealloc(int, Offs2Col, need + 1);
 
@@ -2920,10 +2922,10 @@ void LYFinishEdit(EDREC * edit)
 
 void LYSetupEdit(EDREC * edit, char *old_value, size_t buffer_limit, int display_limit)
 {
-    CTRACE((tfp, "LYSetupEdit buffer %d, display %d:%s\n",
-	    buffer_limit,
+    CTRACE((tfp, "LYSetupEdit buffer %u, display %d:%s\n",
+	    (unsigned) buffer_limit,
 	    display_limit,
-	    NonNull(old_value)));
+	    old_value));
 
     BufLimit = buffer_limit;
     if (buffer_limit == 0)
@@ -3682,7 +3684,9 @@ static void fill_edited_line(int prompting GCC_UNUSED, int length, int ch)
 void LYRefreshEdit(EDREC * edit)
 {
     /* bytes and characters are not the same thing */
+#if defined(DEBUG_EDIT)
     int all_bytes;
+#endif
     int pos_bytes = Pos;
     int dpy_bytes;
     int lft_bytes;		/* base of string which is displayed */
@@ -3728,12 +3732,12 @@ void LYRefreshEdit(EDREC * edit)
     IsDirty = FALSE;
 
     StrLen = strlen(&Buf[0]);
-    all_bytes = (int) StrLen;
 
     all_cells = LYstrCells(Buf);
     pos_cells = LYstrExtent2(Buf, Pos);
 
 #if defined(SUPPORT_MULTIBYTE_EDIT) && defined(DEBUG_EDIT)
+    all_bytes = (int) StrLen;
     lft_chars = mbcs_glyphs(Buf, DspStart);
     pos_chars = mbcs_glyphs(Buf, Pos);
     all_chars = mbcs_glyphs(Buf, all_bytes);
@@ -5074,6 +5078,10 @@ int LYgetBString(bstring **inputline,
     CTRACE((tfp, "called LYgetBString hidden %d, recall %d\n", hidden, recall));
 
     LYGetYX(y, x);		/* Use screen from cursor position to eol */
+
+    if (*inputline == NULL)	/* caller may not have initialized this */
+	BStrCopy0(*inputline, "");
+
     LYSetupEdit(edit, (*inputline)->str, max_cols, LYcolLimit - x);
     IsHidden = (BOOL) hidden;
 #ifdef FEPCTRL
diff --git a/src/LYStyle.c b/src/LYStyle.c
index 0b891869..5f1aa2af 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStyle.c,v 1.70 2011/06/06 09:28:29 tom Exp $
+ * $LynxId: LYStyle.c,v 1.71 2012/02/10 01:24:18 tom Exp $
  *
  * character level styles for Lynx
  * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
@@ -622,6 +622,7 @@ static void HStyle_addStyle(char *buffer)
 			      name ? name : "!?! empty !?!"));
 	if (!default_color_reset)
 	    parse_style(name);
+	FREE(name);
 	return;			/* do not need to process it again */
     }
     CTRACE2(TRACE_STYLE, (tfp, "READCSS:%s\n", name ? name : "!?! empty !?!"));
diff --git a/src/LYUpload.c b/src/LYUpload.c
index 8f405b07..f07550e2 100644
--- a/src/LYUpload.c
+++ b/src/LYUpload.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUpload.c,v 1.35 2010/09/25 11:34:51 tom Exp $
+ * $LynxId: LYUpload.c,v 1.36 2012/02/09 15:09:38 tom Exp $
  *
  *  Routines to upload files to the local filesystem.
  *  Created by: Rick Mallett, Carleton University
@@ -127,10 +127,6 @@ int LYUpload(char *line)
 	 */
 	CTRACE((tfp, "LYUpload: filename is %s", filename));
 
-	if (!LYCanWriteFile(filename)) {
-	    goto retry;
-	}
-
 	HTAddParam(&the_upload, upload_command->command, 1, filename);
 	HTEndParam(&the_upload, upload_command->command, 1);
     } else {			/* No substitution, no changes */
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 201e3d7d..93cf6c25 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.215 2012/02/08 22:31:58 tom Exp $
+ * $LynxId: LYUtils.c,v 1.218 2012/02/09 18:56:48 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -4235,21 +4235,13 @@ void LYConvertToURL(char **AllocatedString,
 	else
 #endif /* USE_DOS_DRIVES */
 	if (LYIsTilde(*old_string)) {
-	    /*
-	     * On Unix, convert '~' to Home_Dir().
-	     */
-	    StrAllocCat(*AllocatedString, wwwName(Home_Dir()));
-	    if ((cp = strchr(old_string, '/')) != NULL) {
-		/*
-		 * Append rest of path, if present, skipping "user" if "~user"
-		 * was entered, simplifying, and eliminating any residual
-		 * relative elements.  - FM
-		 */
-		StrAllocCopy(temp, cp);
-		LYTrimRelFromAbsPath(temp);
-		StrAllocCat(*AllocatedString, temp);
-		FREE(temp);
-	    }
+	    char *his_home = NULL;
+
+	    StrAllocCopy(his_home, old_string);
+	    LYTildeExpand(&his_home, FALSE);
+	    StrAllocCat(*AllocatedString, his_home);
+	    FREE(his_home);
+
 	    CTRACE((tfp, "Converted '%s' to '%s'\n",
 		    old_string, *AllocatedString));
 	} else {
@@ -5499,6 +5491,29 @@ char *LYTildeExpand(char **pathname,
 	    FREE(second);
 	} else if (temp[1] == '\0') {
 	    StrAllocCopy(*pathname, wwwName(Home_Dir()));
+#ifndef NOUSERS
+	} else {
+	    char *save;
+	    char saved = '\0';
+	    struct passwd *pw;
+
+	    for (save = temp; *save != '\0'; ++save) {
+		if (LYIsPathSep(*save)) {
+		    saved = *save;
+		    *save = '\0';
+		    break;
+		}
+	    }
+	    pw = getpwnam(temp + 1);
+	    *save = saved;
+	    if (pw != 0 && non_empty(pw->pw_dir)) {
+		temp = NULL;
+		StrAllocCopy(temp, save);
+		StrAllocCopy(*pathname, pw->pw_dir);
+		StrAllocCat(*pathname, temp);
+		FREE(temp);
+	    }
+#endif
 	}
 	CTRACE((tfp, "expanded path %s\n", *pathname));
     }
@@ -6631,67 +6646,58 @@ const char *wwwName(const char *pathname)
  * expand it.  Expand home-directory expressions in the given string.  Only
  * allow pipes if the user can spawn shell commands.
  */
-BOOLEAN LYValidateFilename(bstring *result,
-			   bstring *given)
+BOOLEAN LYValidateFilename(bstring **result,
+			   bstring **given)
 {
     BOOLEAN code = TRUE;
     char *cp = NULL;
-    const char *cp2 = NULL;
 
     /*
      * Cancel if the user entered "/dev/null" on Unix, or an "nl:" path on VMS. 
      * - FM
      */
-    if (LYIsNullDevice(given->str)) {
+    if (LYIsNullDevice((*given)->str)) {
 	/* just ignore it */
 	code = FALSE;
 #ifdef HAVE_POPEN
-    } else if (LYIsPipeCommand(given->str)) {
+    } else if (LYIsPipeCommand((*given)->str)) {
 	if (no_shell) {
 	    HTUserMsg(SPAWNING_DISABLED);
 	    code = FALSE;
 	} else {
-	    BStrCopy(result, given);
+	    BStrCopy(*result, (*given));
 	}
 #endif
     } else {
-	if ((cp = FindLeadingTilde(given->str, TRUE)) != 0
-	    && (cp2 = wwwName(Home_Dir())) != 0) {
-	    if (LYIsTilde(cp[0]) && LYIsPathSep(cp[1])) {
-		char *cp1 = NULL;
+	if ((cp = FindLeadingTilde((*given)->str, TRUE)) != 0) {
+	    char *cp1 = NULL;
 
-		*cp++ = '\0';
-		StrAllocCopy(cp1, cp);
-
-		BStrCopy(result, given);
-		LYTrimPathSep(result->str);
-		BStrCat0(result, cp2);
-		BStrCat0(result, cp1);
-		BStrCopy(given, result);
-
-		FREE(cp1);
-	    }
+	    StrAllocCopy(cp1, (*given)->str);
+	    LYTildeExpand(&cp1, TRUE);
+	    BStrCopy0(*result, cp1);
+	    BStrCopy0(*given, cp1);
+	    FREE(cp1);
 	}
 #ifdef VMS
-	if (strchr(given->str, '/') != NULL) {
-	    BStrCopy0(result, HTVMS_name("", given->str));
-	    BStrCopy(given, result);
-	}
-	if (given->str[0] != '/'
-	    && strchr(given->str, ':') == NULL) {
-	    BStrCopy0(result, "sys$disk:");
-	    if (strchr(given->str, ']') == NULL)
-		BStrCat0(result, "[]");
-	    BStrCat(result, given);
+	if (strchr((*given)->str, '/') != NULL) {
+	    BStrCopy0(*result, HTVMS_name("", (*given)->str));
+	    BStrCopy(*given, *result);
+	}
+	if ((*given)->str[0] != '/'
+	    && strchr((*given)->str, ':') == NULL) {
+	    BStrCopy0(*result, "sys$disk:");
+	    if (strchr((*given)->str, ']') == NULL)
+		BStrCat0(*result, "[]");
+	    BStrCat(*result, (*given));
 	} else {
-	    BStrCopy(result, given);
+	    BStrCopy(*result, (*given));
 	}
 #else
 
 #ifndef __EMX__
-	if (!LYisAbsPath(given->str)) {
+	if (!LYisAbsPath((*given)->str)) {
 #if defined(__DJGPP__) || defined(_WINDOWS)
-	    if (strchr(result->str, ':') != NULL)
+	    if (strchr(*result->str, ':') != NULL)
 		cp = NULL;
 	    else
 #endif /*  __DJGPP__ || _WINDOWS */
@@ -6710,14 +6716,14 @@ BOOLEAN LYValidateFilename(bstring *result,
 
 	if (cp) {
 	    LYTrimPathSep(cp);
-	    BStrCopy0(result, cp);
-	    BStrCat0(result, "/");
+	    BStrCopy0(*result, cp);
+	    BStrCat0(*result, "/");
 	} else {
-	    BStrCopy0(result, "");
+	    BStrCopy0(*result, "");
 	}
 	if (code) {
-	    cp = HTSYS_name(given->str);
-	    BStrCat0(result, cp);
+	    cp = HTSYS_name((*given)->str);
+	    BStrCat0(*result, cp);
 	}
 #endif /* VMS */
     }
@@ -6767,6 +6773,8 @@ int LYValidateOutput(char *filename)
 	} else if (c == NO) {
 	    return 'N';
 	}
+    } else if (!LYCanWriteFile(filename)) {
+	return 'N';
     }
     return 'Y';
 }
diff --git a/src/LYUtils.h b/src/LYUtils.h
index 397a76c9..ba5de817 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -1,4 +1,4 @@
-/* $LynxId: LYUtils.h,v 1.90 2012/02/08 22:12:09 tom Exp $ */
+/* $LynxId: LYUtils.h,v 1.91 2012/02/09 18:55:26 tom Exp $ */
 #ifndef LYUTILS_H
 #define LYUTILS_H
 
@@ -117,7 +117,7 @@ extern "C" {
 				      char *prefix_list, char *suffix_list);
     extern BOOLEAN LYFixCursesOnForAccess(const char *addr, const char *physical);
     extern BOOLEAN LYPathOffHomeOK(char *fbuffer, size_t fbuffer_size);
-    extern BOOLEAN LYValidateFilename(bstring *result, bstring *given);
+    extern BOOLEAN LYValidateFilename(bstring **result, bstring **given);
     extern BOOLEAN LYisAbsPath(const char *path);
     extern BOOLEAN LYisLocalAlias(const char *filename);
     extern BOOLEAN LYisLocalFile(const char *filename);
diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl
index 366aac83..ab360b11 100644
--- a/src/chrtrans/def7_uni.tbl
+++ b/src/chrtrans/def7_uni.tbl
@@ -1,4 +1,4 @@
-# $LynxId: def7_uni.tbl,v 1.28 2008/04/15 19:38:41 Tim.Larson Exp $
+# $LynxId: def7_uni.tbl,v 1.29 2012/02/10 01:45:54 tom Exp $
 # Default 7bit replacements.
 #
 # This table is very important and should not be excluded from the distribution
@@ -336,7 +336,8 @@ U+02b1:<?>
 U+02b3:<r>
 U+02b7:<w>
 U+02bb:;S
-0x60	U+02bc
+0x27	U+02bc
+0x27	U+02bd
 U+02c6:^
 U+02c7:'<
 U+02c8:|
diff --git a/src/parsdate.c b/src/parsdate.c
index 7fcd2fda..fb486698 100644
--- a/src/parsdate.c
+++ b/src/parsdate.c
@@ -5,7 +5,7 @@ static const char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
 #define YYBYACC 1
 #define YYMAJOR 1
 #define YYMINOR 9
-#define YYPATCH 20101127
+#define YYPATCH 20120114
 
 #define YYEMPTY        (-1)
 #define yyclearin      (yychar = YYEMPTY)
@@ -16,10 +16,12 @@ static const char yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93";
 
 #define YYPURE 0
 
-#line 2 "parsdate.y"
+#line 2 "./parsdate.y"
+
+#include <LYLeaks.h>
 
 /*
- *  $LynxId: parsdate.c,v 1.11 2011/05/24 08:26:35 tom Exp $
+ *  $LynxId: parsdate.c,v 1.13 2012/02/10 01:37:59 tom Exp $
  *
  *  This module is adapted and extended from tin, to use for LYmktime().
  *
@@ -147,7 +149,7 @@ static void date_error(const char GCC_UNUSED *s)
     /*NOTREACHED */
 }
 
-#line 134 "parsdate.y"
+#line 136 "./parsdate.y"
 #ifdef YYSTYPE
 #undef  YYSTYPE_IS_DECLARED
 #define YYSTYPE_IS_DECLARED 1
@@ -159,7 +161,8 @@ typedef union {
     enum _MERIDIAN	Meridian;
 } YYSTYPE;
 #endif /* !YYSTYPE_IS_DECLARED */
-#line 162 "y.tab.c"
+#line 164 "y.tab.c"
+
 /* compatibility with bison */
 #ifdef YYPARSE_PARAM
 /* compatibility with FreeBSD */
@@ -186,7 +189,6 @@ typedef union {
 #define YYERROR_CALL(msg) yyerror(msg)
 
 extern int YYPARSE_DECL();
-extern int YYLEX_DECL();
 
 #define tDAY 257
 #define tDAYZONE 258
@@ -364,6 +366,15 @@ static const char *yyrule[] = {
 
 };
 #endif
+
+int      yydebug;
+int      yynerrs;
+
+int      yyerrflag;
+int      yychar;
+YYSTYPE  yyval;
+YYSTYPE  yylval;
+
 /* define the initial stack-sizes */
 #ifdef YYSTACKSIZE
 #undef YYMAXDEPTH
@@ -379,9 +390,6 @@ static const char *yyrule[] = {
 
 #define YYINITSTACKSIZE 500
 
-int      yydebug;
-int      yynerrs;
-
 typedef struct {
     unsigned stacksize;
     short    *s_base;
@@ -390,14 +398,9 @@ typedef struct {
     YYSTYPE  *l_base;
     YYSTYPE  *l_mark;
 } YYSTACKDATA;
-int      yyerrflag;
-int      yychar;
-YYSTYPE  yyval;
-YYSTYPE  yylval;
-
 /* variables for the parser stack */
 static YYSTACKDATA yystack;
-#line 356 "parsdate.y"
+#line 358 "./parsdate.y"
 
 
 /*
@@ -981,7 +984,7 @@ time_t parsedate(char *p,
      * from the error return value.  (Alternately could set errno on error.) */
     return (Start == (time_t) -1) ? 0 : Start;
 }
-#line 984 "y.tab.c"
+#line 987 "y.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>		/* needed for printf */
@@ -1006,18 +1009,14 @@ static int yygrowstack(YYSTACKDATA *data)
         newsize = YYMAXDEPTH;
 
     i = data->s_mark - data->s_base;
-    newss = (data->s_base != 0)
-          ? (short *)realloc(data->s_base, newsize * sizeof(*newss))
-          : (short *)malloc(newsize * sizeof(*newss));
+    newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
     if (newss == 0)
         return -1;
 
     data->s_base = newss;
     data->s_mark = newss + i;
 
-    newvs = (data->l_base != 0)
-          ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))
-          : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
+    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
     if (newvs == 0)
         return -1;
 
@@ -1192,7 +1191,7 @@ yyreduce:
     switch (yyn)
     {
 case 3:
-#line 152 "parsdate.y"
+#line 154 "./parsdate.y"
 	{
 	    yyHaveTime++;
 #if	defined(lint)
@@ -1204,27 +1203,27 @@ case 3:
 	}
 break;
 case 4:
-#line 161 "parsdate.y"
+#line 163 "./parsdate.y"
 	{
 	    yyHaveTime++;
 	    yyTimezone = yystack.l_mark[0].Number;
 	}
 break;
 case 5:
-#line 165 "parsdate.y"
+#line 167 "./parsdate.y"
 	{
 	    yyHaveDate++;
 	}
 break;
 case 6:
-#line 168 "parsdate.y"
+#line 170 "./parsdate.y"
 	{
 	    yyHaveDate++;
 	    yyHaveTime++;
 	}
 break;
 case 7:
-#line 172 "parsdate.y"
+#line 174 "./parsdate.y"
 	{
 	    yyHaveDate++;
 	    yyHaveTime++;
@@ -1232,13 +1231,13 @@ case 7:
 	}
 break;
 case 8:
-#line 177 "parsdate.y"
+#line 179 "./parsdate.y"
 	{
 	    yyHaveRel = 1;
 	}
 break;
 case 9:
-#line 182 "parsdate.y"
+#line 184 "./parsdate.y"
 	{
 	    if (yystack.l_mark[-1].Number < 100) {
 		yyHour = yystack.l_mark[-1].Number;
@@ -1253,7 +1252,7 @@ case 9:
 	}
 break;
 case 10:
-#line 194 "parsdate.y"
+#line 196 "./parsdate.y"
 	{
 	    yyHour = yystack.l_mark[-3].Number;
 	    yyMinutes = yystack.l_mark[-1].Number;
@@ -1262,7 +1261,7 @@ case 10:
 	}
 break;
 case 11:
-#line 200 "parsdate.y"
+#line 202 "./parsdate.y"
 	{
 	    yyHour = yystack.l_mark[-3].Number;
 	    yyMinutes = yystack.l_mark[-1].Number;
@@ -1272,7 +1271,7 @@ case 11:
 	}
 break;
 case 12:
-#line 207 "parsdate.y"
+#line 209 "./parsdate.y"
 	{
 	    yyHour = yystack.l_mark[-5].Number;
 	    yyMinutes = yystack.l_mark[-3].Number;
@@ -1281,7 +1280,7 @@ case 12:
 	}
 break;
 case 13:
-#line 213 "parsdate.y"
+#line 215 "./parsdate.y"
 	{
 	    yyHour = yystack.l_mark[-5].Number;
 	    yyMinutes = yystack.l_mark[-3].Number;
@@ -1292,28 +1291,28 @@ case 13:
 	}
 break;
 case 14:
-#line 223 "parsdate.y"
+#line 225 "./parsdate.y"
 	{
 	    yyval.Number = yystack.l_mark[0].Number;
 	    yyDSTmode = DSToff;
 	}
 break;
 case 15:
-#line 227 "parsdate.y"
+#line 229 "./parsdate.y"
 	{
 	    yyval.Number = yystack.l_mark[0].Number;
 	    yyDSTmode = DSTon;
 	}
 break;
 case 16:
-#line 231 "parsdate.y"
+#line 233 "./parsdate.y"
 	{
 	    yyTimezone = yystack.l_mark[-1].Number;
 	    yyDSTmode = DSTon;
 	}
 break;
 case 17:
-#line 235 "parsdate.y"
+#line 237 "./parsdate.y"
 	{
 	    /* Only allow "GMT+300" and "GMT-0800" */
 	    if (yystack.l_mark[-1].Number != 0) {
@@ -1324,14 +1323,14 @@ case 17:
 	}
 break;
 case 18:
-#line 243 "parsdate.y"
+#line 245 "./parsdate.y"
 	{
 	    yyval.Number = yystack.l_mark[0].Number;
 	    yyDSTmode = DSToff;
 	}
 break;
 case 19:
-#line 249 "parsdate.y"
+#line 251 "./parsdate.y"
 	{
 	    int	i;
 
@@ -1353,14 +1352,14 @@ case 19:
 	}
 break;
 case 20:
-#line 270 "parsdate.y"
+#line 272 "./parsdate.y"
 	{
 	    yyMonth = yystack.l_mark[-2].Number;
 	    yyDay = yystack.l_mark[0].Number;
 	}
 break;
 case 21:
-#line 274 "parsdate.y"
+#line 276 "./parsdate.y"
 	{
 	    if (yystack.l_mark[-4].Number > 100) {
 		yyYear = yystack.l_mark[-4].Number;
@@ -1375,14 +1374,14 @@ case 21:
 	}
 break;
 case 22:
-#line 286 "parsdate.y"
+#line 288 "./parsdate.y"
 	{
 	    yyMonth = yystack.l_mark[-1].Number;
 	    yyDay = yystack.l_mark[0].Number;
 	}
 break;
 case 23:
-#line 290 "parsdate.y"
+#line 292 "./parsdate.y"
 	{
 	    yyMonth = yystack.l_mark[-3].Number;
 	    yyDay = yystack.l_mark[-2].Number;
@@ -1390,14 +1389,14 @@ case 23:
 	}
 break;
 case 24:
-#line 295 "parsdate.y"
+#line 297 "./parsdate.y"
 	{
 	    yyDay = yystack.l_mark[-1].Number;
 	    yyMonth = yystack.l_mark[0].Number;
 	}
 break;
 case 25:
-#line 299 "parsdate.y"
+#line 301 "./parsdate.y"
 	{
 	    yyDay = yystack.l_mark[-2].Number;
 	    yyMonth = yystack.l_mark[-1].Number;
@@ -1405,7 +1404,7 @@ case 25:
 	}
 break;
 case 26:
-#line 304 "parsdate.y"
+#line 306 "./parsdate.y"
 	{
 	    yyDay = yystack.l_mark[-2].Number;
 	    yyMonth = yystack.l_mark[-1].Number;
@@ -1413,7 +1412,7 @@ case 26:
 	}
 break;
 case 27:
-#line 309 "parsdate.y"
+#line 311 "./parsdate.y"
 	{
 	    yyDay = yystack.l_mark[-3].Number;
 	    yyMonth = yystack.l_mark[-1].Number;
@@ -1421,7 +1420,7 @@ case 27:
 	}
 break;
 case 28:
-#line 314 "parsdate.y"
+#line 316 "./parsdate.y"
 	{
 	    yyDay = yystack.l_mark[-2].Number;
 	    yyMonth = -yystack.l_mark[-1].Number;
@@ -1431,7 +1430,7 @@ case 28:
 	}
 break;
 case 29:
-#line 323 "parsdate.y"
+#line 325 "./parsdate.y"
 	{
 	    yyMonth = yystack.l_mark[-7].Number;
 	    yyDay = yystack.l_mark[-6].Number;
@@ -1442,42 +1441,42 @@ case 29:
 	}
 break;
 case 30:
-#line 333 "parsdate.y"
+#line 335 "./parsdate.y"
 	{
 	    yyRelSeconds += yystack.l_mark[-1].Number * yystack.l_mark[0].Number;
 	}
 break;
 case 31:
-#line 336 "parsdate.y"
+#line 338 "./parsdate.y"
 	{
 	    yyRelSeconds += yystack.l_mark[-1].Number * yystack.l_mark[0].Number;
 	}
 break;
 case 32:
-#line 339 "parsdate.y"
+#line 341 "./parsdate.y"
 	{
 	    yyRelMonth += yystack.l_mark[-1].Number * yystack.l_mark[0].Number;
 	}
 break;
 case 33:
-#line 342 "parsdate.y"
+#line 344 "./parsdate.y"
 	{
 	    yyRelMonth += yystack.l_mark[-1].Number * yystack.l_mark[0].Number;
 	}
 break;
 case 34:
-#line 347 "parsdate.y"
+#line 349 "./parsdate.y"
 	{
 	    yyval.Meridian = MER24;
 	}
 break;
 case 35:
-#line 350 "parsdate.y"
+#line 352 "./parsdate.y"
 	{
 	    yyval.Meridian = yystack.l_mark[0].Meridian;
 	}
 break;
-#line 1480 "y.tab.c"
+#line 1479 "y.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
diff --git a/src/parsdate.y b/src/parsdate.y
index 58e8d7e0..0605863c 100644
--- a/src/parsdate.y
+++ b/src/parsdate.y
@@ -1,7 +1,9 @@
 %{
 
+#include <LYLeaks.h>
+
 /*
- *  $LynxId: parsdate.y,v 1.18 2011/05/24 08:23:53 tom Exp $
+ *  $LynxId: parsdate.y,v 1.19 2012/02/09 20:05:26 tom Exp $
  *
  *  This module is adapted and extended from tin, to use for LYmktime().
  *