about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--BUILD/VS6/lynx/lynx/lynx.dsp406
-rw-r--r--CHANGES12
-rw-r--r--WWW/Library/Implementation/HTAnchor.c21
-rw-r--r--WWW/Library/Implementation/HTFTP.c38
-rw-r--r--WWW/Library/Implementation/HTFile.c6
-rw-r--r--WWW/Library/Implementation/HTMIME.c21
-rw-r--r--WWW/Library/Implementation/HTNews.c9
-rw-r--r--WWW/Library/Implementation/HTParse.c21
-rw-r--r--WWW/Library/Implementation/HTTP.c10
-rw-r--r--WWW/Library/Implementation/SGML.c11
-rw-r--r--WWW/Library/Implementation/www_tcp.h18
-rwxr-xr-xconfig.guess22
-rwxr-xr-xconfig.sub17
-rw-r--r--src/GridText.c19
-rw-r--r--src/HTML.c8
-rw-r--r--src/LYCharUtils.c11
-rw-r--r--src/LYCurses.c13
-rw-r--r--src/LYExtern.c4
-rw-r--r--src/LYHash.h7
-rw-r--r--src/LYLeaks.c474
-rw-r--r--src/LYMain.c4
-rw-r--r--src/LYStyle.c82
-rw-r--r--src/LYStyle.h10
-rw-r--r--src/LYUtils.c45
-rw-r--r--src/LYUtils.h3
26 files changed, 914 insertions, 381 deletions
diff --git a/AUTHORS b/AUTHORS
index 07cfa30a..fb62f589 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,4 @@
--- $LynxId: AUTHORS,v 1.3 2007/06/24 21:33:25 tom Exp $
+-- $LynxId: AUTHORS,v 1.4 2007/07/22 21:58:00 tom Exp $
 -- vile:txtmode
 Most of the people who have contributed more than one patch to Lynx (as well as
 a few who have only one) are noted in the changelogs by their initials (to keep
@@ -40,6 +40,7 @@ PG	Paul Gilmartin
 PHDM	Philippe De Muyter
 PW	Philip Webb
 RN	Ryan Nielsen
+RS	Rado Smiljanic
 SC	Stef Caunter
 SH	Hiroyuki Senshu
 SKY	Sinan Kaan Yerli
diff --git a/BUILD/VS6/lynx/lynx/lynx.dsp b/BUILD/VS6/lynx/lynx/lynx.dsp
index 4397c6a2..e0259d36 100644
--- a/BUILD/VS6/lynx/lynx/lynx.dsp
+++ b/BUILD/VS6/lynx/lynx/lynx.dsp
@@ -49,7 +49,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo

 LINK32=link.exe

 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386

-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib   wsock32.lib pdcurses.lib zlib.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt" /libpath:"..\..\..\..\lib"

+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib pdcurses.lib zlib.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"libcmt" /libpath:"..\..\..\..\lib"

 

 !ELSEIF  "$(CFG)" == "lynx - Win32 Debug"

 

@@ -428,6 +428,410 @@ SOURCE=..\..\..\..\src\Xsystem.c
 # Begin Group "Header Files"

 

 # PROP Default_Filter "h;hpp;hxx;hm;inl"

+# Begin Source File

+

+SOURCE=..\..\..\..\src\AttrList.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\GridText.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAABrow.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAAProt.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAAUtil.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAccess.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTAlert.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAnchor.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAssoc.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTAtom.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTBTree.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTChunk.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTCJK.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTDOS.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HText.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTFile.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTFinger.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTFont.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTFormat.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTForms.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTFTP.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTFWriter.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTGopher.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTGroup.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTInit.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTioctl.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTLex.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTList.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTMIME.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTML.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTMLDTD.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTMLGen.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTNestedList.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTNews.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTParse.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTPlain.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTRules.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\HTSaveToFile.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTStream.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTString.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTStyle.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTTCP.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTTelnet.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTTP.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\htutils.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTUU.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\HTWSRC.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYBookmark.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCgi.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCharSets.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCharUtils.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCharVals.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYClean.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCookie.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYCurses.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYDownload.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYEdit.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\LYexit.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYExtern.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYGCurses.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYGetFile.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYGlobalDefs.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYHash.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYHistory.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYJump.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYJustify.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYKeymap.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\LYLeaks.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYList.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYLocal.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYMail.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYMainLoop.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYMap.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\LYMessages_en.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYNews.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYOptions.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYPrettySrc.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYPrint.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYrcFile.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYReadCFG.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYSearch.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYShowInfo.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYSignal.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYStrings.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYStructs.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYStyle.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYTraversal.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYUpload.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYUtils.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\LYVMSdef.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\SGML.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\structdump.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\TRSTable.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\UCAuto.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\UCAux.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\UCDefs.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\src\UCdomap.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\UCMap.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\userdefs.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\www_tcp.h

+# End Source File

+# Begin Source File

+

+SOURCE=..\..\..\..\WWW\Library\Implementation\www_wait.h

+# End Source File

 # End Group

 # Begin Group "Resource Files"

 

diff --git a/CHANGES b/CHANGES
index e70a225e..e98b83cc 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,16 @@
--- $LynxId: CHANGES,v 1.231 2007/07/02 00:15:38 tom Exp $
+-- $LynxId: CHANGES,v 1.235 2007/07/24 22:44:39 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
 2007-0?-?? (2.8.7dev.6)
+* modify popup for externals added in 2.8.4dev.20 to number the entries if
+  keypad mode is set to one of the numbered forms -PBM
+* free leaks of LYLeaks.c, to make it simpler to check it with a second
+  tool such as valgrind -TD
+* rewrote cached_styles[][] to use memory allocated to match screen size
+  (report by RS) -TD
+* fix typo in SGML.C -RS
 * correct display_lines when -notitle is used while in novice mode -PBM, TD
 * add -child_relaxed option (patch by Andrew Belov).
 * minor typos from OpenBSD (patch by Daniel Dickman).
@@ -25,6 +32,7 @@ Changes since Lynx 2.8 release
 * modify HTDoRead() to add elapsed time to its debug trace -TD
 * fix a case in LYGetfile.c which was broken by 2.8.7dev.3 changes to use
   LYTildeExpand() to expand embedded "~" -TG
+* updated config.guess (2007-05-17), config.sub (2007-06-28)
  
 2007-05-17 (2.8.7dev.5)
 * build/install "en" po file so that GNU gettext LANGUAGE environment variable
@@ -119,7 +127,7 @@ Changes since Lynx 2.8 release
 * modify CF_SRAND to recognize the asymmetric variant of arc4random() -TD
 * updated configure script macros CF_SUBDIR_PATH, CF_XOPEN_SOURCE,
   CF_X_ATHENA_LIBS, CF_X_TOOLKIT -TD
-* updated config.guess, config.sub -TD
+* updated config.guess (2006-12-22), config.sub (2006-12-08)
 
 2006-11-14 (2.8.7dev.4)
 * use RFC-822 encoding for filenames passed via file-upload forms (Debian
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 5b6fc7a2..6bb592c8 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -1,4 +1,7 @@
-/*	Hypertext "Anchor" Object				HTAnchor.c
+/*
+ * $LynxId: HTAnchor.c,v 1.59 2007/07/02 23:42:54 tom Exp $
+ *
+ *	Hypertext "Anchor" Object				HTAnchor.c
  *	==========================
  *
  * An anchor represents a region of a hypertext document which is linked to
@@ -27,21 +30,25 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
+#define HASH_TYPE unsigned short
+
 #ifdef NOT_DEFINED
 /*
  *	This is the hashing function used to determine which list in the
  *		adult_table a parent anchor should be put in.  This is a
  *		much simpler function than the original used.
  */
-#define HASH_FUNCTION(cp_address) ((unsigned short int)strlen(cp_address) *\
-	(unsigned short int)TOUPPER(*cp_address) % HASH_SIZE)
+#define HASH_FUNCTION(cp_address) \
+	( (HASH_TYPE)strlen(cp_address) *\
+	  (HASH_TYPE)TOUPPER(*cp_address) % HASH_SIZE )
 #endif /* NOT_DEFINED */
+
 /*
  *	This is the original function.	We'll use it again. - FM
  */
-static int HASH_FUNCTION(const char *cp_address)
+static HASH_TYPE HASH_FUNCTION(const char *cp_address)
 {
-    int hash;
+    HASH_TYPE hash;
     const unsigned char *p;
 
     for (p = (const unsigned char *) cp_address, hash = 0; *p; p++)
@@ -71,7 +78,7 @@ static HTList adult_table[HASH_SIZE] =
  *	anchor you are creating : use newWithParent or newWithAddress.
  */
 static HTParentAnchor0 *HTParentAnchor0_new(const char *address,
-					    short hash)
+					    HASH_TYPE hash)
 {
     HTParentAnchor0 *newAnchor = typecalloc(HTParentAnchor0);
 
@@ -416,7 +423,7 @@ static HTParentAnchor0 *HTAnchor_findAddress_in_adult_table(const DocAddress *ne
     /*
      * Check whether we have this node.
      */
-    int hash;
+    HASH_TYPE hash;
     HTList *adults;
     HTList *grownups;
     HTParentAnchor0 *foundAnchor;
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index d4b9d695..50720368 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFTP.c,v 1.78 2007/05/22 23:47:17 tom Exp $
+ * $LynxId: HTFTP.c,v 1.79 2007/07/02 23:05:12 tom Exp $
  *
  *			File Transfer Protocol (FTP) Client
  *			for a WorldWideWeb browser
@@ -226,10 +226,12 @@ static int interrupted_in_next_data_char = FALSE;
 static PortNumber port_number = FIRST_TCP_PORT;
 #endif /* POLL_PORTS */
 
-static int master_socket = -1;	/* Listening socket = invalid   */
+static BOOL have_socket = FALSE;	/* true if master_socket is valid */
+static unsigned master_socket;	/* Listening socket = invalid */
+
 static char port_command[255];	/* Command for setting the port */
 static fd_set open_sockets;	/* Mask of active channels */
-static int num_sockets;		/* Number of sockets to scan */
+static unsigned num_sockets;	/* Number of sockets to scan */
 static PortNumber passive_port;	/* Port server specified for data */
 
 #define NEXT_CHAR HTGetCharacter()	/* Use function in HTFormat.c */
@@ -1117,6 +1119,18 @@ static int get_connection(const char *arg,
     return con->socket;		/* Good return */
 }
 
+static void reset_master_socket(void)
+{
+    have_socket = FALSE;
+}
+
+static void set_master_socket(int value)
+{
+    have_socket = (value >= 0);
+    if (have_socket)
+	master_socket = value;
+}
+
 /*	Close Master (listening) socket
  *	-------------------------------
  *
@@ -1126,11 +1140,14 @@ static int close_master_socket(void)
 {
     int status;
 
-    if (master_socket != -1)
+    if (have_socket)
 	FD_CLR(master_socket, &open_sockets);
+
     status = NETCLOSE(master_socket);
     CTRACE((tfp, "HTFTP: Closed master socket %d\n", master_socket));
-    master_socket = -1;
+
+    reset_master_socket();
+
     if (status < 0)
 	return HTInetStatus(gettext("close master socket"));
     else
@@ -1144,6 +1161,7 @@ static int close_master_socket(void)
  *	connect with the data.
  *
  * On entry,
+ *	have_socket	Must be false, if master_socket is not setup already
  *	master_socket	Must be negative if not set up already.
  * On exit,
  *	Returns		socket number if good
@@ -1169,7 +1187,7 @@ static int get_listen_socket(void)
     num_sockets = 0;
 
 #ifndef REPEAT_LISTEN
-    if (master_socket >= 0)
+    if (have_socket)
 	return master_socket;	/* Done already */
 #endif /* !REPEAT_LISTEN */
 
@@ -1336,11 +1354,11 @@ static int get_listen_socket(void)
 #endif /* INET6 */
 
 #ifdef REPEAT_LISTEN
-    if (master_socket >= 0)
+    if (have_socket)
 	(void) close_master_socket();
 #endif /* REPEAT_LISTEN */
 
-    master_socket = new_socket;
+    set_master_socket(new_socket);
 
 /*	Now we must find out who we are to tell the other guy
 */
@@ -1392,7 +1410,7 @@ static int get_listen_socket(void)
 #endif /* SOCKS */
 	    status = listen(master_socket, 1);
 	if (status < 0) {
-	    master_socket = -1;
+	    reset_master_socket();
 	    return HTInetStatus("listen");
 	}
     }
@@ -3020,7 +3038,7 @@ static int setup_connection(const char *name,
 		NETCLOSE(control->socket);
 		control->socket = -1;
 #ifdef INET6
-		if (master_socket >= 0)
+		if (have_socket)
 		    (void) close_master_socket();
 #else
 		close_master_socket();
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index f0fcdbc3..7b190474 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.102 2007/05/13 17:29:41 tom Exp $
+ * $LynxId: HTFile.c,v 1.103 2007/07/22 22:31:01 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -2629,7 +2629,7 @@ int HTLoadFile(const char *addr,
 	    char *best_name = NULL;	/* Best dir entry so far */
 
 	    char *base = strrchr(localname, '/');
-	    int baselen = 0;
+	    unsigned baselen = 0;
 
 	    if (!base || base == localname) {
 		forget_multi = YES;
@@ -2654,7 +2654,7 @@ int HTLoadFile(const char *addr,
 		if (dirbuf->d_ino == 0)
 		    continue;	/* if the entry is not being used, skip it */
 #endif
-		if ((int) strlen(dirbuf->d_name) > baselen &&	/* Match? */
+		if (strlen(dirbuf->d_name) > baselen &&		/* Match? */
 		    !strncmp(dirbuf->d_name, base, baselen)) {
 		    HTAtom *enc;
 		    HTFormat rep = HTFileFormat(dirbuf->d_name, &enc, NULL);
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 28814c65..9e6c03fd 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -1,4 +1,7 @@
-/*			MIME Message Parse			HTMIME.c
+/*
+ * $LynxId: HTMIME.c,v 1.62 2007/07/03 00:16:30 tom Exp $
+ *
+ *			MIME Message Parse			HTMIME.c
  *			==================
  *
  *	This is RFC 1341-specific code.
@@ -2137,8 +2140,8 @@ static void HTmmdec_base64(char **t,
     int d, count, j, val;
     char *buf, *bp, nw[4], *p;
 
-    if ((buf = malloc(strlen(s) * 3 + 1)) == 0)
-	outofmem(__FILE__, "HTmmdec_base64");
+    if ((buf = typeMallocn(char, strlen(s) * 3 + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdec_base64");
 
     for (bp = buf; *s; s += 4) {
 	val = 0;
@@ -2178,8 +2181,8 @@ static void HTmmdec_quote(char **t,
 {
     char *buf, cval, *bp, *p;
 
-    if ((buf = malloc(strlen(s) + 1)) == 0)
-	outofmem(__FILE__, "HTmmdec_quote");
+    if ((buf = typeMallocn(char, strlen(s) + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdec_quote");
 
     for (bp = buf; *s;) {
 	if (*s == '=') {
@@ -2222,8 +2225,8 @@ void HTmmdecode(char **target,
     char *s, *t, *u;
     int base64, quote;
 
-    if ((buf = malloc(strlen(source) + 1)) == 0)
-	outofmem(__FILE__, "HTmmdecode");
+    if ((buf = typeMallocn(char, strlen(source) + 1)) == 0)
+	  outofmem(__FILE__, "HTmmdecode");
 
     for (s = source, u = buf; *s;) {
 	if (!strncasecomp(s, "=?ISO-2022-JP?B?", 16)) {
@@ -2297,8 +2300,8 @@ int HTrjis(char **t,
 	return 1;
     }
 
-    if ((buf = malloc(strlen(s) * 2 + 1)) == 0)
-	outofmem(__FILE__, "HTrjis");
+    if ((buf = typeMallocn(char, strlen(s) * 2 + 1)) == 0)
+	  outofmem(__FILE__, "HTrjis");
 
     for (p = buf; *s;) {
 	if (!kanji && s[0] == '$' && (s[1] == '@' || s[1] == 'B')) {
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index 611d7f1e..bc16318d 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -1,4 +1,7 @@
-/*			NEWS ACCESS				HTNews.c
+/*
+ * $LynxId: HTNews.c,v 1.57 2007/07/03 00:13:21 tom Exp $
+ *
+ *			NEWS ACCESS				HTNews.c
  *			===========
  *
  * History:
@@ -1003,12 +1006,14 @@ void debug_print(unsigned char *p)
 
 static char *decode_mime(char **str)
 {
+    static char empty[] = "";
+
 #ifdef SH_EX
     if (HTCJK != JAPANESE)
 	return *str;
 #endif
     HTmmdecode(str, *str);
-    return HTrjis(str, *str) ? *str : "";
+    return HTrjis(str, *str) ? *str : empty;
 }
 
 /*	Read in an Article					read_article
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index 62f06736..37b1208e 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -1,4 +1,7 @@
-/*		Parse HyperText Document Address		HTParse.c
+/*
+ * $LynxId: HTParse.c,v 1.47 2007/07/22 22:24:37 tom Exp $
+ *
+ *		Parse HyperText Document Address		HTParse.c
  *		================================
  */
 
@@ -212,7 +215,7 @@ char *HTParse(const char *aName,
     char *result = NULL;
     char *tail = NULL;		/* a pointer to the end of the 'result' string */
     char *return_value = NULL;
-    int len, len1, len2;
+    unsigned len, len1, len2;
     char *name = NULL;
     char *rel = NULL;
     char *p, *q;
@@ -900,12 +903,12 @@ char *HTEscape(const char *str,
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (!ACCEPTABLE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
@@ -940,12 +943,12 @@ char *HTEscapeUnsafe(const char *str)
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (UNSAFE(UCH(TOASCII(*p))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscapeUnsafe");
@@ -980,12 +983,12 @@ char *HTEscapeSP(const char *str,
     const char *p;
     char *q;
     char *result;
-    int unacceptable = 0;
+    unsigned unacceptable = 0;
 
     for (p = str; *p; p++)
 	if (!(*p == ' ' || ACCEPTABLE(UCH(TOASCII(*p)))))
 	    unacceptable++;
-    result = typecallocn(char, p - str + unacceptable + unacceptable + 1);
+    result = typecallocn(char, (p - str) + (unacceptable * 2) + 1);
 
     if (result == NULL)
 	outofmem(__FILE__, "HTEscape");
@@ -1131,7 +1134,7 @@ void HTMake822Word(char **str,
     char *q;
     char *result;
     unsigned char a;
-    int added = 0;
+    unsigned added = 0;
 
     if (isEmpty(*str)) {
 	StrAllocCopy(*str, quoted ? "\"\"" : "");
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 5f262bd5..ec14e1ce 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTTP.c,v 1.86 2007/05/22 22:42:12 Thorsten.Glaser Exp $
+ * $LynxId: HTTP.c,v 1.87 2007/07/03 00:20:33 tom Exp $
  *
  * HyperText Tranfer Protocol	- Client implementation		HTTP.c
  * ==========================
@@ -813,8 +813,10 @@ static int HTLoadHTTP(const char *arg,
 	    int i, numalts;
 	    const GENERAL_NAME *gn;
 
-	    if ((gens = X509_get_ext_d2i(peer_cert, NID_subject_alt_name,
-					 NULL, NULL)) != NULL) {
+	    gens = (STACK_OF(GENERAL_NAME) *)
+		X509_get_ext_d2i(peer_cert, NID_subject_alt_name, NULL, NULL);
+
+	    if (gens != NULL) {
 		numalts = sk_GENERAL_NAME_num(gens);
 		for (i = 0; i < numalts; ++i) {
 		    gn = sk_GENERAL_NAME_value(gens, i);
@@ -824,7 +826,7 @@ static int HTLoadHTTP(const char *arg,
 			/* XXX untested -TG */
 			size_t j = ASN1_STRING_length(gn->d.ia5);
 
-			cert_host = malloc(j + 1);
+			cert_host = (char *) malloc(j + 1);
 			memcpy(cert_host, ASN1_STRING_data(gn->d.ia5), j);
 			cert_host[j] = '\0';
 		    } else
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 8412465f..37325689 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,4 +1,7 @@
-/*			General SGML Parser code		SGML.c
+/*
+ * $LynxId: SGML.c,v 1.92 2007/07/22 21:52:43 Rado.Smiljanic Exp $
+ *
+ *			General SGML Parser code		SGML.c
  *			========================
  *
  *	This module implements an HTStream object.  To parse an
@@ -2466,7 +2469,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    /*
 	     * Terminate the numeric entity and try to handle it.  - FM
 	     */
-	    UCode_t code;
+	    unsigned long code;
 	    int i;
 
 	    HTChunkTerminate(string);
@@ -2474,7 +2477,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    entity_string = string->data;
 #endif
 	    if ((context->isHex ? sscanf(string->data, "%lx", &code) :
-		 sscanf(string->data, "%ld", &code)) == 1) {
+		 sscanf(string->data, "%lu", &code)) == 1) {
 /* =============== work in ASCII below here ===============  S/390 -- gil -- 1092 */
 		if ((code == 1) ||
 		    (code > 127 && code < 156)) {
@@ -3525,7 +3528,7 @@ static void SGML_character(HTStream *context, char c_in)
 		PUTS(string->data);
 		if (c == '=' || WHITE(c))
 		    PUTC(c);
-		if (c == '=' || c == '>' || c == ' ') {
+		if (c == '=' || c == '>' || WHITE(c)) {
 		    if (context->current_attribute_number == INVALID)
 			PSRCSTOP(badattr);
 		    else
diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h
index 4f5927e1..ca0ab6d8 100644
--- a/WWW/Library/Implementation/www_tcp.h
+++ b/WWW/Library/Implementation/www_tcp.h
@@ -1,5 +1,5 @@
 /*                System dependencies in the W3 library
- * $LynxId: www_tcp.h,v 1.35 2007/07/01 17:38:38 tom Exp $
+ * $LynxId: www_tcp.h,v 1.36 2007/07/02 23:05:01 tom Exp $
  *
                                    SYSTEM DEPENDENCIES
 
@@ -392,8 +392,8 @@ extern int socket_ioctl();
 #undef NETWRITE
 #define NETWRITE(s,b,l) send((s),(char *)(b),(l))
 
-#define TYPE_FD_SET 1
-typedef int fd_set;
+#define TYPE_FD_SET int
+typedef TYPE_FD_SET fd_set;
 
 #endif /* TCPIP_SERVICES */
 
@@ -874,14 +874,14 @@ ROUGH ESTIMATE OF MAX PATH LENGTH
 #ifdef SELECT
 #ifndef FD_SET
 #ifndef TYPE_FD_SET
-#define TYPE_FD_SET 1
-typedef unsigned int fd_set;
+#define TYPE_FD_SET unsigned
+typedef TYPE_FD_SET fd_set;
 #endif /* !TYPE_FD_SET */
 
-#define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
-#define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
-#define FD_ZERO(pmask)   (*(pmask))=0
-#define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
+#define FD_SET(fd,pmask)   (*(pmask)) |=  (1 << (fd))
+#define FD_CLR(fd,pmask)   (*(pmask)) &= ~(1 << (fd))
+#define FD_ZERO(pmask)     (*(pmask)) = 0
+#define FD_ISSET(fd,pmask) (*(pmask) & (1 << (fd)))
 #endif /* !FD_SET */
 #endif /* SELECT */
 
diff --git a/config.guess b/config.guess
index 1a695461..951383e3 100755
--- a/config.guess
+++ b/config.guess
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
 #   Inc.
 
-timestamp='2006-12-22'
+timestamp='2007-05-17'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -330,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
 	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
-    i86pc:SunOS:5.*:*)
+    i86pc:SunOS:5.*:* | ix86xen:SunOS:5.*:*)
 	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
     sun4*:SunOS:6*:*)
@@ -791,12 +791,15 @@ EOF
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
-    x86:Interix*:[3456]*)
-	echo i586-pc-interix${UNAME_RELEASE}
-	exit ;;
-    EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*)
-	echo x86_64-unknown-interix${UNAME_RELEASE}
-	exit ;;
+    *:Interix*:[3456]*)
+    	case ${UNAME_MACHINE} in
+	    x86) 
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    EM64T | authenticamd)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
     [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
 	echo i${UNAME_MACHINE}-pc-mks
 	exit ;;
@@ -1218,6 +1221,9 @@ EOF
     SX-8:SUPER-UX:*:*)
 	echo sx8-nec-superux${UNAME_RELEASE}
 	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-nec-superux${UNAME_RELEASE}
+	exit ;;
     Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	exit ;;
diff --git a/config.sub b/config.sub
index 4b8cc7b4..1761d8bd 100755
--- a/config.sub
+++ b/config.sub
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
 #   Inc.
 
-timestamp='2006-12-08'
+timestamp='2007-06-28'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -250,7 +250,7 @@ case $basic_machine in
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
 	| m32c | m32r | m32rle | m68000 | m68k | m88k \
-	| maxq | mb | microblaze | mcore \
+	| maxq | mb | microblaze | mcore | mep \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -475,8 +475,8 @@ case $basic_machine in
 		basic_machine=craynv-cray
 		os=-unicosmp
 		;;
-	cr16c)
-		basic_machine=cr16c-unknown
+	cr16)
+		basic_machine=cr16-unknown
 		os=-elf
 		;;
 	crds | unos)
@@ -683,6 +683,10 @@ case $basic_machine in
 		basic_machine=i386-pc
 		os=-mingw32
 		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
@@ -1222,7 +1226,7 @@ case $os in
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-	      | -skyos* | -haiku* | -rdos* | -toppers*)
+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1417,6 +1421,9 @@ case $basic_machine in
 	m68*-cisco)
 		os=-aout
 		;;
+        mep-*)
+		os=-elf
+		;;
 	mips*-cisco)
 		os=-elf
 		;;
diff --git a/src/GridText.c b/src/GridText.c
index 489c5ce8..c0dcdfb5 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.140 2007/05/13 20:42:37 Takeshi.Hataguchi Exp $
+ * $LynxId: GridText.c,v 1.141 2007/07/22 23:04:06 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -50,8 +50,7 @@
 #ifdef USE_COLOR_STYLE
 #include <AttrList.h>
 #include <LYHash.h>
-
-unsigned int cached_styles[CACHEH][CACHEW];
+#include <LYStyle.h>
 
 #endif
 
@@ -81,18 +80,6 @@ unsigned int cached_styles[CACHEH][CACHEW];
 static void HText_trimHightext(HText *text, BOOLEAN final,
 			       int stop_before);
 
-#ifdef USE_COLOR_STYLE
-static void LynxResetScreenCache(void)
-{
-    int i, j;
-
-    for (i = 1; (i < CACHEH && i <= display_lines); i++) {
-	for (j = 0; j < CACHEW; j++)
-	    cached_styles[i][j] = 0;
-    }
-}
-#endif /* USE_COLOR_STYLE */
-
 struct _HTStream {		/* only know it as object */
     const HTStreamClass *isa;
     /* ... */
@@ -2097,7 +2084,7 @@ static void display_page(HText *text,
 	line_number != text->first_lineno_last_disp_partial ||
 	line_number > text->last_lineno_last_disp_partial)
 #endif /* DISP_PARTIAL */
-	LynxResetScreenCache();
+	ResetCachedStyles();
 #endif /* USE_COLOR_STYLE */
 
 #ifdef DISP_PARTIAL
diff --git a/src/HTML.c b/src/HTML.c
index 962993e1..3a9b1d50 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTML.c,v 1.112 2007/05/10 00:20:31 tom Exp $
+ * $LynxId: HTML.c,v 1.113 2007/07/02 23:43:40 tom Exp $
  *
  *		Structured stream to Rich hypertext converter
  *		============================================
@@ -4447,9 +4447,9 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		 */
 		for (i = 0; I.value[i]; i++) {
 		    HTML_put_character(me,
-				       (I.value[i] == ' ')
-				       ? HT_NON_BREAK_SPACE
-				       : I.value[i]);
+				       (char) ((I.value[i] == ' ')
+					       ? HT_NON_BREAK_SPACE
+					       : I.value[i]));
 		}
 		while (i++ < chars) {
 		    HTML_put_character(me, HT_NON_BREAK_SPACE);
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index 82dcb869..a7a7359f 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -1,4 +1,6 @@
 /*
+ * $LynxId: LYCharUtils.c,v 1.88 2007/07/02 23:58:53 tom Exp $
+ *
  *  Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM
  *  ==========================================================================
  */
@@ -1079,7 +1081,7 @@ char **LYUCFullyTranslateString(char **str,
     int uck;
     int lowest_8;
     UCode_t code = 0;
-    long int lcode;
+    unsigned long lcode;
     BOOL output_utf8 = 0, repl_translated_C0 = 0;
     size_t len;
     const char *name = NULL;
@@ -1523,9 +1525,10 @@ char **LYUCFullyTranslateString(char **str,
 	     * (3) Is 127 and we don't have HTPassHighCtrlRaw or HTCJK set.
 	     * (4) Is 128 - 159 and we don't have HTPassHighCtrlNum set.
 	     */
-	    if ((((what == P_hex) ? sscanf(cp, "%lx", &lcode) :
-		  sscanf(cp, "%ld", &lcode)) != 1) ||
-		lcode > 0x7fffffffL || lcode < 0) {
+	    if ((((what == P_hex)
+		  ? sscanf(cp, "%lx", &lcode)
+		  : sscanf(cp, "%lu", &lcode)) != 1) ||
+		lcode > 0x7fffffffL) {
 		state = S_recover;
 		break;
 	    } else {
diff --git a/src/LYCurses.c b/src/LYCurses.c
index a25a20d0..2b1d9beb 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYCurses.c,v 1.129 2007/07/02 00:11:35 tom Exp $ */
+/* $LynxId: LYCurses.c,v 1.131 2007/07/24 21:58:34 tom Exp $ */
 #include <HTUtils.h>
 #include <HTAlert.h>
 
@@ -452,8 +452,8 @@ void curses_w_style(WINDOW * win, int style,
 
     if (style == s_normal && dir) {
 	LYAttrset(win, ds->color, ds->mono);
-	if (win == LYwin && CACHE_VALIDATE_YX(YP, XP))
-	    cached_styles[YP][XP] = s_normal;
+	if (win == LYwin)
+	    SetCachedStyle(YP, XP, s_normal);
 	return;
     }
 
@@ -498,8 +498,8 @@ void curses_w_style(WINDOW * win, int style,
 	    && style != s_aedit_arr) {
 	    CTRACE2(TRACE_STYLE, (tfp, "CACHED: <%s> @(%d,%d)\n",
 				  ds->name, YP, XP));
-	    if (win == LYwin && CACHE_VALIDATE_YX(YP, XP))
-		cached_styles[YP][XP] = style;
+	    if (win == LYwin)
+		SetCachedStyle(YP, XP, style);
 	}
 	LYAttrset(win, ds->color, ds->mono);
 	break;
@@ -1422,6 +1422,9 @@ void lynx_nl2crlf(int normal GCC_UNUSED)
 void stop_curses(void)
 {
     if (LYCursesON) {
+#ifdef USE_COLOR_STYLE
+	FreeCachedStyles();
+#endif
 	echo();
     }
 #if defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401
diff --git a/src/LYExtern.c b/src/LYExtern.c
index 9f5471db..6c0da690 100644
--- a/src/LYExtern.c
+++ b/src/LYExtern.c
@@ -1,4 +1,6 @@
 /*
+ * $LynxId: LYExtern.c,v 1.38 2007/07/24 22:50:21 tom Exp $
+ *
  External application support.
  This feature allows lynx to pass a given URL to an external program.
  It was written for three reasons.
@@ -302,7 +304,7 @@ static char *lookup_external(char *param,
 				       -1,
 				       FALSE,
 				       TRUE,
-				       FALSE);
+				       (keypad_mode != NUMBERS_AS_ARROWS));
 	wmove(LYwin, old_y, old_x);
 	CTRACE((tfp, "selected choice %d of %d\n", cur_choice, num_choices));
 	if (cur_choice < 0) {
diff --git a/src/LYHash.h b/src/LYHash.h
index 448fe42c..c60e24d6 100644
--- a/src/LYHash.h
+++ b/src/LYHash.h
@@ -1,3 +1,4 @@
+/* $LynxId: LYHash.h,v 1.23 2007/07/22 23:08:36 tom Exp $ */
 #ifndef _LYHASH_H_
 #define _LYHASH_H_ 1
 
@@ -76,12 +77,6 @@ extern "C" {
     extern bucket special_bucket;
 #endif
 
-#define CACHEW 128
-#define CACHEH 64
-
-    extern unsigned cached_styles[CACHEH][CACHEW];
-#define CACHE_VALIDATE_YX(y, x) ((y) >= 0 && (x) >= 0 && (y) < CACHEH && (x) < CACHEW)
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/LYLeaks.c b/src/LYLeaks.c
index f41d2a7e..e7a4ee5d 100644
--- a/src/LYLeaks.c
+++ b/src/LYLeaks.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYLeaks.c,v 1.29 2007/05/06 21:43:33 tom Exp $
+ * $LynxId: LYLeaks.c,v 1.32 2007/07/23 22:54:46 tom Exp $
  *
  *	Copyright (c) 1994, University of Kansas, All Rights Reserved
  *	(this file was rewritten twice - 1998/1999 and 2003/2004)
@@ -130,21 +130,21 @@ static void RemoveFromList(AllocationList * ALp_del)
      */
     if (ALp_del == ALp_findbefore) {
 	ALp_RunTimeAllocations = ALp_del->ALp_Next;
-	return;
-    }
+    } else {
 
-    /*
-     * Loop through checking all of the next values, if a match don't continue. 
-     * Always assume the item will be found.
-     */
-    while (ALp_findbefore->ALp_Next != ALp_del) {
-	ALp_findbefore = ALp_findbefore->ALp_Next;
-    }
+	/*
+	 * Loop through checking all of the next values, if a match don't
+	 * continue.  Always assume the item will be found.
+	 */
+	while (ALp_findbefore->ALp_Next != ALp_del) {
+	    ALp_findbefore = ALp_findbefore->ALp_Next;
+	}
 
-    /*
-     * We are one item before the one to get rid of.  Get rid of it.
-     */
-    ALp_findbefore->ALp_Next = ALp_del->ALp_Next;
+	/*
+	 * We are one item before the one to get rid of.  Get rid of it.
+	 */
+	ALp_findbefore->ALp_Next = ALp_del->ALp_Next;
+    }
 }
 
 /*
@@ -179,8 +179,17 @@ void LYLeaks(void)
 
     CTRACE((tfp, "entering LYLeaks, flag=%d\n", LYfind_leaks));
 
-    if (LYfind_leaks == FALSE)
+    if (LYfind_leaks == FALSE) {
+	/*
+	 * Free MY leaks too, in case someone else is watching.
+	 */
+	while (ALp_RunTimeAllocations != NULL) {
+	    ALp_head = ALp_RunTimeAllocations;
+	    ALp_RunTimeAllocations = ALp_head->ALp_Next;
+	    free(ALp_head);
+	}
 	return;
+    }
 
     /*
      * Open the leakage sink to take all the output.  Recreate the file each
@@ -199,7 +208,7 @@ void LYLeaks(void)
 	ALp_RunTimeAllocations = ALp_head->ALp_Next;
 
 	/*
-	 * Print the type of leak/error.  Free off memory when we no longer
+	 * Print the type of leak/error.  Release memory when we no longer
 	 * need it.
 	 */
 	if (ALp_head->vp_Alloced == NULL) {
@@ -337,44 +346,45 @@ void *LYLeakMalloc(size_t st_bytes, const char *cp_File,
 {
     void *vp_malloc;
 
-    if (LYfind_leaks == FALSE)
-	return (void *) malloc(st_bytes);
-
-    /*
-     * Do the actual allocation.
-     */
-    vp_malloc = (void *) malloc(st_bytes);
-    CountMallocs(st_bytes);
-
-    /*
-     * Only on successful allocation do we track any information.
-     */
-    if (vp_malloc != NULL) {
-	/*
-	 * Further allocate memory to store the information.  Just return on
-	 * failure to allocate more.
-	 */
-	AllocationList *ALp_new = typecalloc(AllocationList);
+    if (LYfind_leaks == FALSE) {
+	vp_malloc = (void *) malloc(st_bytes);
+    } else {
 
-	if (ALp_new == NULL) {
-	    return (vp_malloc);
-	}
 	/*
-	 * Copy over the relevant information.  There is no need to allocate
-	 * more memory for the file name as it is a static string anyhow.
+	 * Do the actual allocation.
 	 */
-	ALp_new->st_Sequence = count_mallocs;
-	ALp_new->vp_Alloced = vp_malloc;
-	ALp_new->st_Bytes = st_bytes;
-	ALp_new->SL_memory.cp_FileName = cp_File;
-	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+	vp_malloc = (void *) malloc(st_bytes);
+	CountMallocs(st_bytes);
 
 	/*
-	 * Add the new item to the allocation list.
+	 * Only on successful allocation do we track any information.
 	 */
-	AddToList(ALp_new);
+	if (vp_malloc != NULL) {
+	    /*
+	     * Further allocate memory to store the information.  Just return
+	     * on failure to allocate more.
+	     */
+	    AllocationList *ALp_new = typecalloc(AllocationList);
+
+	    if (ALp_new != NULL) {
+		/*
+		 * Copy over the relevant information.  There is no need to
+		 * allocate more memory for the file name as it is a static
+		 * string anyway.
+		 */
+		ALp_new->st_Sequence = count_mallocs;
+		ALp_new->vp_Alloced = vp_malloc;
+		ALp_new->st_Bytes = st_bytes;
+		ALp_new->SL_memory.cp_FileName = cp_File;
+		ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+
+		/*
+		 * Add the new item to the allocation list.
+		 */
+		AddToList(ALp_new);
+	    }
+	}
     }
-
     return (vp_malloc);
 }
 
@@ -405,48 +415,44 @@ AllocationList *LYLeak_mark_malloced(void *vp_malloced,
 {
     AllocationList *ALp_new = NULL;
 
-    if (LYfind_leaks == FALSE)
-	return NULL;
-
-    /*
-     * The actual allocation has already been done!
-     *
-     * Only on successful allocation do we track any information.
-     */
-    if (vp_malloced != NULL) {
+    if (LYfind_leaks != FALSE) {
 	/*
-	 * See if there is already an entry.  If so, just update the source
-	 * location info.
+	 * The actual allocation has already been done!
+	 *
+	 * Only on successful allocation do we track any information.
 	 */
-	ALp_new = FindInList(vp_malloced);
-	if (ALp_new) {
-	    ALp_new->SL_memory.cp_FileName = cp_File;
-	    ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
-	    return (ALp_new);
-	}
-	/*
-	 * Further allocate memory to store the information.  Just return on
-	 * failure to allocate more.
-	 */
-	ALp_new = typecalloc(AllocationList);
-
-	if (ALp_new == NULL) {
-	    return (NULL);
+	if (vp_malloced != NULL) {
+	    /*
+	     * See if there is already an entry.  If so, just update the source
+	     * location info.
+	     */
+	    ALp_new = FindInList(vp_malloced);
+	    if (ALp_new) {
+		ALp_new->SL_memory.cp_FileName = cp_File;
+		ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+	    } else {
+		/*
+		 * Further allocate memory to store the information.  Just
+		 * return on failure to allocate more.
+		 */
+		ALp_new = typecalloc(AllocationList);
+		if (ALp_new != NULL) {
+		    /*
+		     * Copy over the relevant information.
+		     */
+		    ALp_new->vp_Alloced = vp_malloced;
+		    ALp_new->st_Bytes = st_bytes;
+		    ALp_new->SL_memory.cp_FileName = cp_File;
+		    ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+
+		    /*
+		     * Add the new item to the allocation list.
+		     */
+		    AddToList(ALp_new);
+		}
+	    }
 	}
-	/*
-	 * Copy over the relevant information.
-	 */
-	ALp_new->vp_Alloced = vp_malloced;
-	ALp_new->st_Bytes = st_bytes;
-	ALp_new->SL_memory.cp_FileName = cp_File;
-	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
-
-	/*
-	 * Add the new item to the allocation list.
-	 */
-	AddToList(ALp_new);
     }
-
     return (ALp_new);
 }
 
@@ -471,45 +477,46 @@ void *LYLeakCalloc(size_t st_number, size_t st_bytes, const char *cp_File,
 {
     void *vp_calloc;
 
-    if (LYfind_leaks == FALSE)
-	return (void *) calloc(st_number, st_bytes);
-
-    /*
-     * Allocate the requested memory.
-     */
-    vp_calloc = (void *) calloc(st_number, st_bytes);
-    CountMallocs(st_bytes);
-
-    /*
-     * Only if the allocation was a success do we track information.
-     */
-    if (vp_calloc != NULL) {
-	/*
-	 * Allocate memory for the item to be in the list.  If unable, just
-	 * return.
-	 */
-	AllocationList *ALp_new = typecalloc(AllocationList);
-
-	if (ALp_new == NULL) {
-	    return (vp_calloc);
-	}
+    if (LYfind_leaks == FALSE) {
+	vp_calloc = (void *) calloc(st_number, st_bytes);
+    } else {
 
 	/*
-	 * Copy over the relevant information.  There is no need to allocate
-	 * memory for the file name as it is a static string anyway.
+	 * Allocate the requested memory.
 	 */
-	ALp_new->st_Sequence = count_mallocs;
-	ALp_new->vp_Alloced = vp_calloc;
-	ALp_new->st_Bytes = (st_number * st_bytes);
-	ALp_new->SL_memory.cp_FileName = cp_File;
-	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+	vp_calloc = (void *) calloc(st_number, st_bytes);
+	CountMallocs(st_bytes);
 
 	/*
-	 * Add the item to the allocation list.
+	 * Only if the allocation was a success do we track information.
 	 */
-	AddToList(ALp_new);
+	if (vp_calloc != NULL) {
+	    /*
+	     * Allocate memory for the item to be in the list.  If unable, just
+	     * return.
+	     */
+	    AllocationList *ALp_new = typecalloc(AllocationList);
+
+	    if (ALp_new != NULL) {
+
+		/*
+		 * Copy over the relevant information.  There is no need to
+		 * allocate memory for the file name as it is a static string
+		 * anyway.
+		 */
+		ALp_new->st_Sequence = count_mallocs;
+		ALp_new->vp_Alloced = vp_calloc;
+		ALp_new->st_Bytes = (st_number * st_bytes);
+		ALp_new->SL_memory.cp_FileName = cp_File;
+		ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+
+		/*
+		 * Add the item to the allocation list.
+		 */
+		AddToList(ALp_new);
+	    }
+	}
     }
-
     return (vp_calloc);
 }
 
@@ -543,68 +550,70 @@ void *LYLeakRealloc(void *vp_Alloced,
     void *vp_realloc;
     AllocationList *ALp_renew;
 
-    if (LYfind_leaks == FALSE)
-	return (void *) realloc(vp_Alloced, st_newBytes);
-
-    /*
-     * If we are asked to resize a NULL pointer, this is just a malloc call.
-     */
-    if (vp_Alloced == NULL) {
-	return (LYLeakMalloc(st_newBytes, cp_File, ssi_Line));
-    }
+    if (LYfind_leaks == FALSE) {
+	vp_realloc = (void *) realloc(vp_Alloced, st_newBytes);
 
-    /*
-     * Find the current vp_Alloced block in the list.  If NULL, this is an
-     * invalid pointer value.
-     */
-    ALp_renew = FindInList(vp_Alloced);
-    if (ALp_renew == NULL) {
+    } else if (vp_Alloced == NULL) {
 	/*
-	 * Track the invalid pointer value and then exit.  If unable to
-	 * allocate, just exit.
+	 * If we are asked to resize a NULL pointer, this is just a malloc
+	 * call.
 	 */
-	auto AllocationList *ALp_new = typecalloc(AllocationList);
+	vp_realloc = LYLeakMalloc(st_newBytes, cp_File, ssi_Line);
 
-	if (ALp_new == NULL) {
-	    exit_immediately(EXIT_FAILURE);
-	}
+    } else {
 
 	/*
-	 * Set the information up; no need to allocate file name since it is a
-	 * static string.
+	 * Find the current vp_Alloced block in the list.  If NULL, this is an
+	 * invalid pointer value.
 	 */
-	ALp_new->vp_Alloced = NULL;
-	ALp_new->vp_BadRequest = vp_Alloced;
-	ALp_new->SL_realloc.cp_FileName = cp_File;
-	ALp_new->SL_realloc.ssi_LineNumber = ssi_Line;
+	ALp_renew = FindInList(vp_Alloced);
+	if (ALp_renew == NULL) {
+	    /*
+	     * Track the invalid pointer value and then exit.  If unable to
+	     * allocate, just exit.
+	     */
+	    AllocationList *ALp_new = typecalloc(AllocationList);
 
-	/*
-	 * Add the item to the list.  Exit.
-	 */
-	AddToList(ALp_new);
-	exit_immediately(EXIT_FAILURE);
-    }
+	    if (ALp_new == NULL) {
+		exit_immediately(EXIT_FAILURE);
+	    }
 
-    /*
-     * 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);
+	    /*
+	     * Set the information up; no need to allocate file name since it is a
+	     * static string.
+	     */
+	    ALp_new->vp_Alloced = NULL;
+	    ALp_new->vp_BadRequest = vp_Alloced;
+	    ALp_new->SL_realloc.cp_FileName = cp_File;
+	    ALp_new->SL_realloc.ssi_LineNumber = ssi_Line;
 
-    if (vp_realloc != NULL) {
-	ALp_renew->st_Sequence = count_mallocs;
-	ALp_renew->vp_Alloced = vp_realloc;
-	ALp_renew->st_Bytes = st_newBytes;
+	    /*
+	     * Add the item to the list.  Exit.
+	     */
+	    AddToList(ALp_new);
+	    exit_immediately(EXIT_FAILURE);
+	}
 
 	/*
-	 * Update the realloc information, too.  No need to allocate file name,
-	 * static string.
+	 * Perform the resize.  If not NULL, record the information.
 	 */
-	ALp_renew->SL_realloc.cp_FileName = cp_File;
-	ALp_renew->SL_realloc.ssi_LineNumber = ssi_Line;
-    }
+	vp_realloc = (void *) realloc(vp_Alloced, st_newBytes);
+	CountMallocs(st_newBytes);
+	CountFrees(ALp_renew->st_Bytes);
 
+	if (vp_realloc != NULL) {
+	    ALp_renew->st_Sequence = count_mallocs;
+	    ALp_renew->vp_Alloced = vp_realloc;
+	    ALp_renew->st_Bytes = st_newBytes;
+
+	    /*
+	     * Update the realloc information, too.  No need to allocate file name,
+	     * static string.
+	     */
+	    ALp_renew->SL_realloc.cp_FileName = cp_File;
+	    ALp_renew->SL_realloc.ssi_LineNumber = ssi_Line;
+	}
+    }
     return (vp_realloc);
 }
 
@@ -682,47 +691,46 @@ void LYLeakFree(void *vp_Alloced,
 
     if (LYfind_leaks == FALSE) {
 	free(vp_Alloced);
-	return;
-    }
+    } else {
 
-    /*
-     * Find the pointer in the allocated list.  If not found, bad pointer.  If
-     * found, free list item and vp_Allloced.
-     */
-    ALp_free = FindInList(vp_Alloced);
-    if (ALp_free == NULL) {
 	/*
-	 * Create the final entry before exiting marking this error.  If unable
-	 * to allocate more memory just exit.
+	 * Find the pointer in the allocated list.  If not found, bad pointer. 
+	 * If found, free list item and vp_Alloced.
 	 */
-	AllocationList *ALp_new = typecalloc(AllocationList);
+	ALp_free = FindInList(vp_Alloced);
+	if (ALp_free == NULL) {
+	    /*
+	     * Create the final entry before exiting marking this error.  If
+	     * unable to allocate more memory just exit.
+	     */
+	    AllocationList *ALp_new = typecalloc(AllocationList);
 
-	if (ALp_new == NULL) {
-	    exit_immediately(EXIT_FAILURE);
-	}
+	    if (ALp_new == NULL) {
+		exit_immediately(EXIT_FAILURE);
+	    }
 
-	/*
-	 * Set up the information, no memory need be allocated for the file
-	 * name since it is a static string.
-	 */
-	ALp_new->vp_Alloced = NULL;
-	ALp_new->vp_BadRequest = vp_Alloced;
-	ALp_new->SL_memory.cp_FileName = cp_File;
-	ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
+	    /*
+	     * Set up the information, no memory need be allocated for the file
+	     * name since it is a static string.
+	     */
+	    ALp_new->vp_Alloced = NULL;
+	    ALp_new->vp_BadRequest = vp_Alloced;
+	    ALp_new->SL_memory.cp_FileName = cp_File;
+	    ALp_new->SL_memory.ssi_LineNumber = ssi_Line;
 
-	/*
-	 * Add the entry to the list and then return.
-	 */
-	AddToList(ALp_new);
-	return;
-    } else {
-	/*
-	 * Free off the memory.  Take entry out of allocation list.
-	 */
-	CountFrees(ALp_free->st_Bytes);
-	RemoveFromList(ALp_free);
-	FREE(ALp_free);
-	FREE(vp_Alloced);
+	    /*
+	     * Add the entry to the list and then return.
+	     */
+	    AddToList(ALp_new);
+	} else {
+	    /*
+	     * Free off the memory.  Take entry out of allocation list.
+	     */
+	    CountFrees(ALp_free->st_Bytes);
+	    RemoveFromList(ALp_free);
+	    FREE(ALp_free);
+	    free(vp_Alloced);
+	}
     }
 }
 
@@ -740,17 +748,17 @@ char *LYLeakSACopy(char **dest,
 	CTRACE((tfp,
 		"LYLeakSACopy: *dest equals src, contains \"%s\"\n",
 		src));
-	return *dest;
-    }
-    if (*dest) {
-	LYLeakFree(*dest, cp_File, ssi_Line);
-	*dest = NULL;
-    }
-    if (src) {
-	*dest = (char *) LYLeakMalloc(strlen(src) + 1, cp_File, ssi_Line);
-	if (*dest == NULL)
-	    outofmem(__FILE__, "LYLeakSACopy");
-	strcpy(*dest, src);
+    } else {
+	if (*dest) {
+	    LYLeakFree(*dest, cp_File, ssi_Line);
+	    *dest = NULL;
+	}
+	if (src) {
+	    *dest = (char *) LYLeakMalloc(strlen(src) + 1, cp_File, ssi_Line);
+	    if (*dest == NULL)
+		outofmem(__FILE__, "LYLeakSACopy");
+	    strcpy(*dest, src);
+	}
     }
     return *dest;
 }
@@ -770,9 +778,7 @@ char *LYLeakSACat(char **dest,
 	    CTRACE((tfp,
 		    "LYLeakSACat:  *dest equals src, contains \"%s\"\n",
 		    src));
-	    return *dest;
-	}
-	if (*dest) {
+	} else if (*dest) {
 	    int length = strlen(*dest);
 
 	    *dest = (char *) LYLeakRealloc(*dest,
@@ -873,7 +879,7 @@ static char *LYLeakSAVsprintf(char **dest,
 	     * Track the invalid pointer value and then exit.  If unable to
 	     * allocate, just exit.
 	     */
-	    auto AllocationList *ALp_new = typecalloc(AllocationList);
+	    AllocationList *ALp_new = typecalloc(AllocationList);
 
 	    if (ALp_new == NULL) {
 		exit_immediately(EXIT_FAILURE);
@@ -943,53 +949,35 @@ static char *LYLeakSAVsprintf(char **dest,
 
 /* Note: the following may need updating if HTSprintf in HTString.c
  * is changed. - kw */
-#ifdef ANSI_VARARGS
 static char *LYLeakHTSprintf(char **pstr, const char *fmt,...)
-#else
-static char *LYLeakHTSprintf(va_alist)
-    va_dcl
-#endif
 {
     char *str;
     size_t inuse = 0;
     va_list ap;
 
     LYva_start(ap, fmt);
-    {
-#ifndef ANSI_VARARGS
-	char **pstr = va_arg(ap, char **);
-	const char *fmt = va_arg(ap, const char *);
-#endif
-	if (pstr != 0 && *pstr != 0)
-	    inuse = strlen(*pstr);
-	str = LYLeakSAVsprintf(pstr, leak_cp_File_hack, leak_ssi_Line_hack,
-			       inuse, fmt, &ap);
-    }
+
+    if (pstr != 0 && *pstr != 0)
+	inuse = strlen(*pstr);
+    str = LYLeakSAVsprintf(pstr, leak_cp_File_hack, leak_ssi_Line_hack,
+			   inuse, fmt, &ap);
+
     va_end(ap);
     return str;
 }
 
 /* Note: the following may need updating if HTSprintf0 in HTString.c
  * is changed. - kw */
-#ifdef ANSI_VARARGS
 static char *LYLeakHTSprintf0(char **pstr, const char *fmt,...)
-#else
-static char *LYLeakHTSprintf0(va_alist)
-    va_dcl
-#endif
 {
     char *str;
     va_list ap;
 
     LYva_start(ap, fmt);
-    {
-#ifndef ANSI_VARARGS
-	char **pstr = va_arg(ap, char **);
-	const char *fmt = va_arg(ap, const char *);
-#endif
-	str = LYLeakSAVsprintf(pstr, leak_cp_File_hack, leak_ssi_Line_hack,
-			       0, fmt, &ap);
-    }
+
+    str = LYLeakSAVsprintf(pstr, leak_cp_File_hack, leak_ssi_Line_hack,
+			   0, fmt, &ap);
+
     va_end(ap);
     return str;
 }
diff --git a/src/LYMain.c b/src/LYMain.c
index 90020c92..b27bd7be 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYMain.c,v 1.174 2007/07/02 00:07:27 tom Exp $ */
+/* $LynxId: LYMain.c,v 1.175 2007/07/02 22:41:49 tom Exp $ */
 #include <HTUtils.h>
 #include <HTTP.h>
 #include <HTParse.h>
@@ -4121,7 +4121,7 @@ static BOOL parse_arg(char **argv,
 	    arg_name, mask, countp ? *countp : -1));
 
 #if EXTENDED_STARTFILE_RECALL
-    if (mask == ((countp != 0) ? 0 : 1)) {
+    if (mask == (unsigned) ((countp != 0) ? 0 : 1)) {
 	no_options_further = FALSE;
 	/* want to reset nonoption when beginning scan for --stdin */
 	if (nonoption != 0) {
diff --git a/src/LYStyle.c b/src/LYStyle.c
index e577a256..512a5bde 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,6 +1,8 @@
-/* character level styles for Lynx
+/*
+ * $LynxId: LYStyle.c,v 1.61 2007/07/23 19:57:17 tom Exp $
+ *
+ * character level styles for Lynx
  * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
- * $LynxId: LYStyle.c,v 1.58 2007/05/23 00:32:21 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTML.h>
@@ -22,6 +24,7 @@
 #include <LYexit.h>
 #include <LYLeaks.h>
 #include <LYStrings.h>
+#include <LYHash.h>
 
 #define CTRACE1(p) CTRACE2(TRACE_CFG || TRACE_STYLE, p)
 
@@ -35,6 +38,13 @@ static void style_initialiseHashTable(void);
  */
 static HTList *lss_styles = NULL;
 
+#define CACHEW 128
+#define CACHEH 64
+
+static unsigned *cached_styles_ptr = NULL;
+static int cached_styles_rows = 0;
+static int cached_styles_cols = 0;
+
 /* stack of attributes during page rendering */
 int last_styles[MAX_LAST_STYLES] =
 {0};
@@ -382,6 +392,7 @@ static void free_colorstylestuff(void)
     style_initialiseHashTable();
     style_deleteStyleList();
     memset(our_pairs, 0, sizeof(our_pairs));
+    FreeCachedStyles();
 }
 
 /*
@@ -701,9 +712,9 @@ void FastTrimColorClass(const char *tag_name,
     *phcode = hash_code(tag_start + 1);
 }
 
- /* This is called each time lss styles are read. It will fill
-  * each elt of 'cached_tag_styles' -HV
-  */
+/* This is called each time lss styles are read. It will fill
+ * each element of 'cached_tag_styles' -HV
+ */
 void cache_tag_styles(void)
 {
     char buf[200];
@@ -716,4 +727,65 @@ void cache_tag_styles(void)
     }
 }
 
+#define SIZEOF_CACHED_STYLES (cached_styles_rows * cached_styles_cols)
+
+static unsigned *RefCachedStyle(int y, int x)
+{
+    unsigned *result = 0;
+
+    if (cached_styles_ptr == 0) {
+	cached_styles_rows = display_lines;
+	cached_styles_cols = LYcols;
+	cached_styles_ptr = typecallocn(unsigned, SIZEOF_CACHED_STYLES);
+    }
+    if (y >= 0 &&
+	x >= 0 &&
+	y < cached_styles_rows &&
+	x < cached_styles_cols) {
+	result = cached_styles_ptr + (y * cached_styles_cols) + x;
+    }
+    return result;
+}
+
+BOOL ValidCachedStyle(int y, int x)
+{
+    return (RefCachedStyle(y, x) != 0);
+}
+
+unsigned GetCachedStyle(int y, int x)
+{
+    unsigned value = 0;
+    unsigned *cache = RefCachedStyle(y, x);
+
+    if (cache != 0) {
+	value = *cache;
+    }
+    return value;
+}
+
+void SetCachedStyle(int y, int x, unsigned value)
+{
+    unsigned *cache = RefCachedStyle(y, x);
+
+    if (cache != 0) {
+	*cache = value;
+    }
+}
+
+void ResetCachedStyles(void)
+{
+    if (cached_styles_ptr != NULL) {
+	memset(cached_styles_ptr, 0, sizeof(unsigned) * SIZEOF_CACHED_STYLES);
+    }
+}
+
+void FreeCachedStyles(void)
+{
+    if (cached_styles_ptr != NULL) {
+	FREE(cached_styles_ptr);
+	cached_styles_rows = 0;
+	cached_styles_cols = 0;
+    }
+}
+
 #endif /* USE_COLOR_STYLE */
diff --git a/src/LYStyle.h b/src/LYStyle.h
index edc4051a..d1cf9db1 100644
--- a/src/LYStyle.h
+++ b/src/LYStyle.h
@@ -1,3 +1,4 @@
+/* $LynxId: LYStyle.h,v 1.15 2007/07/23 19:21:54 tom Exp $ */
 #ifndef LYSTYLE_H
 #define LYSTYLE_H
 
@@ -63,6 +64,15 @@ extern "C" {
 				   char **pstylename_end,
 				   int *hcode);
 
+/*
+ * Functions for cached-styles
+ */
+    extern BOOL ValidCachedStyle(int y, int x);
+    extern unsigned GetCachedStyle(int y, int x);
+    extern void FreeCachedStyles(void);
+    extern void ResetCachedStyles(void);
+    extern void SetCachedStyle(int y, int x, unsigned value);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 629f24f6..18199133 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYUtils.c,v 1.157 2007/05/20 23:28:43 Thorsten.Glaser Exp $ */
+/* $LynxId: LYUtils.c,v 1.161 2007/07/22 23:53:16 tom Exp $ */
 #include <HTUtils.h>
 #include <HTTCP.h>
 #include <HTParse.h>
@@ -6,12 +6,19 @@
 #include <HTCJK.h>
 #include <HTAlert.h>
 
-#ifdef __MINGW32__
-int kbhit(void);		/* FIXME: use conio.h */
+#if defined(__MINGW32__)
+
+extern int kbhit(void);		/* FIXME: use conio.h */
 
-#ifdef UNIX
 #undef UNIX
-#endif /* UNIX */
+
+#elif defined(_WINDOWS)
+
+#include <conio.h>
+#if !defined(kbhit) && defined(_WCONIO_DEFINED)
+#define kbhit() _kbhit()	/* reasonably recent conio.h */
+#endif
+
 #endif /* __MINGW32__ */
 
 #include <LYCurses.h>
@@ -960,25 +967,22 @@ static int find_cached_style(int cur,
 
 	/*
 	 * This is where we try to restore the original style when a link is
-	 * unhighlighted.  The purpose of cached_styles[][] is to save the
-	 * original style just for this case.  If it doesn't have a color
-	 * change saved at just the right position, we look at preceding
-	 * positions in the same line until we find one.
+	 * unhighlighted.  The cached styles array saves the original style
+	 * just for this case.  If it doesn't have a color change saved at just
+	 * the right position, we look at preceding positions in the same line
+	 * until we find one.
 	 */
-	if (CACHE_VALIDATE_YX(LYP, LXP)) {
+	if (ValidCachedStyle(LYP, LXP)) {
 	    CTRACE2(TRACE_STYLE,
 		    (tfp, "STYLE.highlight.off: cached style @(%d,%d): ",
 		     LYP, LXP));
-	    s = cached_styles[LYP][LXP];
+	    s = GetCachedStyle(LYP, LXP);
 	    if (s == 0) {
 		for (x = LXP - 1; x >= 0; x--) {
-		    if (cached_styles[LYP][x]) {
-			if (cached_styles[LYP][x] > 0) {
-			    s = cached_styles[LYP][x];
-			    cached_styles[LYP][LXP] = s;
-			}
-			CTRACE((tfp, "found %u, x_offset=%d.\n",
-				cached_styles[LYP][x], (int) x - LXP));
+		    s = GetCachedStyle(LYP, x);
+		    if (s != 0) {
+			SetCachedStyle(LYP, LXP, s);
+			CTRACE((tfp, "found %u, x_offset=%d.\n", s, x - LXP));
 			break;
 		    }
 		}
@@ -5877,11 +5881,12 @@ static BOOL IsOurSymlink(const char *name)
     BOOL result = FALSE;
     int size = LY_MAXPATH;
     int used;
-    char *buffer = malloc(size);
+    char *buffer = typeMallocn(char, size);
 
     if (buffer != 0) {
 	while ((used = readlink(name, buffer, size)) == -1) {
-	    buffer = realloc(buffer, size *= 2);
+	    buffer = typeRealloc(char, buffer, size *= 2);
+
 	    if (buffer == 0)
 		break;
 	}
diff --git a/src/LYUtils.h b/src/LYUtils.h
index bc5da5ab..9d44c9d0 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -1,3 +1,4 @@
+/* $LynxId: LYUtils.h,v 1.76 2007/07/02 23:43:21 tom Exp $ */
 #ifndef LYUTILS_H
 #define LYUTILS_H
 
@@ -215,7 +216,7 @@ extern "C" {
     extern int Cygwin_Shell(void);
 #endif
 
-#ifdef _WIN_CC
+#if defined(_WIN_CC) || defined(WIN_EX)
     extern int exec_command(char *cmd, int wait_flag);	/* xsystem.c */
     extern int xsystem(char *cmd);
 #endif