about summary refs log tree commit diff stats
path: root/src/HTML.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-11-06 16:18:09 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-11-06 16:18:09 -0500
commit18024037b515bfff83e0230b35151babe6005e18 (patch)
treeb8c80055282a00883284722a3dd6bb25234e07f0 /src/HTML.c
parent3d8ecbe48af249fa0d77ce4d273e32ce4b7e6e18 (diff)
downloadlynx-snapshots-18024037b515bfff83e0230b35151babe6005e18.tar.gz
snapshot of project "lynx", label v2-8-1dev_4
Diffstat (limited to 'src/HTML.c')
-rw-r--r--src/HTML.c728
1 files changed, 371 insertions, 357 deletions
diff --git a/src/HTML.c b/src/HTML.c
index dd1c9020..c456d6e5 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -11,9 +11,8 @@
 **   Being Overidden
 **
 */
-#define DICKEY_TEST
-
 #include <HTUtils.h>
+#include <tcp.h>
 
 #define Lynx_HTML_Handler
 #include <HTChunk.h>
@@ -41,7 +40,6 @@
 #include <HTNestedList.h>
 #include <GridText.h>
 #include <LYSignal.h>
-#include <LYStrings.h>
 #include <LYUtils.h>
 #include <LYMap.h>
 #include <LYList.h>
@@ -49,6 +47,7 @@
 
 #ifdef VMS
 #include <LYCurses.h>
+#include <HTVMSUtils.h>
 #endif /* VMS */
 
 #ifdef USE_COLOR_STYLE
@@ -63,7 +62,7 @@ char Style_className[16384];
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-#define STACKLEVEL(me) ((me->stack + MAX_NESTING - 1) - me->sp)
+#define FREE(x) if (x) {free(x); x = NULL;}
 
 extern BOOL HTPassEightBitRaw;
 extern HTCJKlang HTCJK;
@@ -82,7 +81,7 @@ PRIVATE HTStyleSheet * styleSheet;	/* Application-wide */
 
 /*	Module-wide style cache
 */
-PRIVATE HTStyle *styles[HTML_ELEMENTS+31]; /* adding 24 nested list styles  */
+PUBLIC	HTStyle *styles[HTML_ELEMENTS+31]; /* adding 24 nested list styles  */
 					   /* and 3 header alignment styles */
 					   /* and 3 div alignment styles    */
 PRIVATE HTStyle *default_style;
@@ -100,15 +99,19 @@ PRIVATE void HTML_end_element PARAMS((HTStructured *me,
 				      int element_number,
 				      char **include));
 
+/*		Forward declarations of routines
+*/
+PRIVATE void get_styles NOPARAMS;
+PRIVATE void change_paragraph_style PARAMS((HTStructured * me,
+					    HTStyle * style));
+
 /*
  * If we have verbose_img set, display labels for images.
  */
-#define VERBOSE_IMG(value,src_type,string) \
-      ((verbose_img) ? (newtitle = MakeNewTitle(value,src_type)): string)
+#define VERBOSE_IMG(value,string) \
+      ((verbose_img) ? (newtitle = MakeNewTitle(value)): string)
 
-PRIVATE char* MakeNewTitle PARAMS((CONST char ** value, int src_type));
-PRIVATE char* MakeNewImageValue PARAMS((CONST char ** value));
-PRIVATE char* MakeNewMapValue PARAMS((const char ** value, const char* mapstr));
+PRIVATE char * MakeNewTitle(CONST char ** value);
 
 /*	Set an internal flag that the next call to a stack-affecting method
 **	is only internal and the stack manipulation should be skipped. - kw
@@ -176,18 +179,6 @@ PRIVATE void change_paragraph_style ARGS2(HTStructured *, me, HTStyle *,style)
 **			A C T I O N	R O U T I N E S
 */
 
-/* FIXME:  this should be amended to do the substitution only when not in a
- * multibyte stream.
- */
-#if EXP_JAPANESE_SPACES
-#define FIX_JAPANESE_SPACES \
-	(HTCJK == CHINESE || HTCJK == JAPANESE || HTCJK == TAIPEI)
-	/* don't replace '\n' with ' ' if Chinese or Japanese - HN
-	 */
-#else
-#define FIX_JAPANESE_SPACES 0
-#endif
-
 /*	Character handling
 **	------------------
 */
@@ -227,17 +218,10 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c)
     case HTML_TITLE:
 	if (c == LY_SOFT_HYPHEN)
 	    return;
-	if (c != '\n' && c != '\t' && c != '\r') {
+	if (c != '\n' && c != '\t' && c != '\r')
 	    HTChunkPutc(&me->title, c);
-	} else if (FIX_JAPANESE_SPACES) {
-	    if (c == '\t') {
-		HTChunkPutc(&me->title, ' ');
-	    } else {
-		return;
-	    }
-	} else {
+	else
 	    HTChunkPutc(&me->title, ' ');
-	}
 	return;
 
     case HTML_STYLE:
@@ -349,15 +333,13 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c)
 		UPDATE_STYLE;
 	    }
 	    if (c == '\n') {
-		if (!FIX_JAPANESE_SPACES) {
-		    if (me->in_word) {
-			if (HText_getLastChar(me->text) != ' ') {
-			    me->inP = TRUE;
-			    me->inLABEL = FALSE;
-			    HText_appendCharacter(me->text, ' ');
-			}
-			me->in_word = NO;
+		if (me->in_word) {
+		    if (HText_getLastChar(me->text) != ' ') {
+			me->inP = TRUE;
+			me->inLABEL = FALSE;
+			HText_appendCharacter(me->text, ' ');
 		    }
+		    me->in_word = NO;
 		}
 
 	    } else if (c == ' ' || c == '\t') {
@@ -380,15 +362,15 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c)
     } /* end second switch */
 
     if (c == '\n' || c == '\t') {
-	HText_setLastChar(me->text, ' '); /* set it to a generic separator */
+	HText_setLastChar(me->text, ' '); /* set it to a generic seperater */
 
 	/*
 	 *  \r's are ignored.  In order to keep collapsing spaces
 	 *  correctly we must default back to the previous
-	 *  separator if there was one
+	 *  seperater if there was one
 	 */
     } else if (c == '\r' && HText_getLastChar(me->text) == ' ') {
-	HText_setLastChar(me->text, ' '); /* set it to a generic separator */
+	HText_setLastChar(me->text, ' '); /* set it to a generic seperater */
     } else {
 	HText_setLastChar(me->text, c);
     }
@@ -486,12 +468,10 @@ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s)
 		    UPDATE_STYLE;
 		}
 		if (c == '\n') {
-		    if (!FIX_JAPANESE_SPACES) {
-			if (me->in_word) {
-			    if (HText_getLastChar(me->text) != ' ')
-				HText_appendCharacter(me->text, ' ');
-				me->in_word = NO;
-			}
+		    if (me->in_word) {
+			if (HText_getLastChar(me->text) != ' ')
+			    HText_appendCharacter(me->text, ' ');
+			me->in_word = NO;
 		    }
 
 		} else if (c == ' ' || c == '\t') {
@@ -507,15 +487,15 @@ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s)
 
 		/* set the Last Character */
 		if (c == '\n' || c == '\t') {
-		    /* set it to a generic separator */
+		    /* set it to a generic seperater */
 		    HText_setLastChar(me->text, ' ');
 		} else if (c == '\r' &&
 			   HText_getLastChar(me->text) == ' ') {
 		    /*
 		     *	\r's are ignored.  In order to keep collapsing
 		     *	spaces correctly, we must default back to the
-		     *	previous separator, if there was one.  So we
-		     *	set LastChar to a generic separator.
+		     *	previous seperator, if there was one.  So we
+		     *	set LastChar to a generic seperater.
 		     */
 		    HText_setLastChar(me->text, ' ');
 		} else {
@@ -636,7 +616,7 @@ PRIVATE void HTML_start_element ARGS6(
     char *I_value = NULL;
     char *I_name = NULL;
     char *temp = NULL;
-    int dest_char_set = UCLYhndl_for_unrec;
+    int dest_char_set  = -1;
     HTParentAnchor *dest = NULL;	     /* An anchor's destination */
     BOOL dest_ismap = FALSE;		     /* Is dest an image map script? */
     BOOL UseBASE = TRUE;		     /* Resoved vs. BASE if present? */
@@ -691,30 +671,31 @@ PRIVATE void HTML_start_element ARGS6(
 
 	if (TRACE)
 	{
-		fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode);
+		fprintf(stderr, "CSSTRIM:%s -> %d", myHash, hcode);
 		if (hashStyles[hcode].code!=hcode)
 		{
 			char *rp=strrchr(myHash, '.');
-			fprintf(tfp, " (undefined) %s\n", myHash);
+			fprintf(stderr, " (undefined) %s\n", myHash);
 			if (rp)
 			{
 				int hcd;
 				*rp='\0'; /* trim the class */
 				hcd = hash_code(myHash);
-				fprintf(tfp, "CSS:%s -> %d", myHash, hcd);
+				fprintf(stderr, "CSS:%s -> %d", myHash, hcd);
 				if (hashStyles[hcd].code!=hcd)
-					fprintf(tfp, " (undefined) %s\n", myHash);
+					fprintf(stderr, " (undefined) %s\n", myHash);
 				else
-					fprintf(tfp, " ca=%d\n", hashStyles[hcd].color);
+					fprintf(stderr, " ca=%d\n", hashStyles[hcd].color);
 			}
 		}
 		else
-			fprintf(tfp, " ca=%d\n", hashStyles[hcode].color);
+			fprintf(stderr, " ca=%d\n", hashStyles[hcode].color);
 	}
 
     if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
     {
-	CTRACE(tfp, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name);
+	if (TRACE)
+		fprintf(stderr, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name);
 	HText_characterStyle(me->text, hcode, 1);
     }
 #endif /* USE_COLOR_STYLE */
@@ -737,8 +718,11 @@ PRIVATE void HTML_start_element ARGS6(
 	    char *related = NULL;
 
 	    StrAllocCopy(base, value[HTML_BASE_HREF]);
-	    if (!(url_type = LYLegitimizeHREF(me, &base, TRUE, TRUE))) {
-		CTRACE(tfp, "HTML: BASE '%s' is not an absolute URL.\n",
+	    if (!(url_type = LYLegitimizeHREF(me, (char**)&base,
+					      TRUE, TRUE))) {
+		if (TRACE)
+		    fprintf(stderr,
+			    "HTML: BASE '%s' is not an absolute URL.\n",
 			    (base ? base : ""));
 		if (me->inBadBASE == FALSE)
 		    HTAlert(BASE_NOT_ABSOLUTE);
@@ -831,7 +815,7 @@ PRIVATE void HTML_start_element ARGS6(
 
     case HTML_META:
 	if (present)
-	    LYHandleMETA(me, present, value, include);
+	    LYHandleMETA(me, present, value, (char **)&include);
 	break;
 
     case HTML_TITLE:
@@ -855,7 +839,7 @@ PRIVATE void HTML_start_element ARGS6(
 		}
 	    } else {
 		StrAllocCopy(href, value[HTML_LINK_HREF]);
-		url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+		url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 	    }
 
 	    /*
@@ -873,7 +857,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '\0' && *href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
@@ -898,13 +882,15 @@ PRIVATE void HTML_start_element ARGS6(
 					PARSE_ALL);
 			StrAllocCopy(href, temp);
 			FREE(temp);
-			LYFillLocalFileURL(&href,
+			LYFillLocalFileURL((char **)&href,
 					   (me->inBASE ?
 					 me->base_href :
 					 me->node_anchor->address));
 		    }
 		    HTAnchor_setOwner(me->node_anchor, href);
-		    CTRACE(tfp, "HTML: DOC OWNER '%s' found\n", href);
+		    if (TRACE)
+			fprintf(stderr,
+				"HTML: DOC OWNER '%s' found\n", href);
 		    FREE(href);
 
 		    /*
@@ -936,7 +922,10 @@ PRIVATE void HTML_start_element ARGS6(
 		 */
 		if (!strcasecomp(value[HTML_LINK_REL], "StyleSheet") ||
 		    !strcasecomp(value[HTML_LINK_REL], "Style")) {
-		    CTRACE(tfp, "HTML: StyleSheet link found.\n");
+		    if (TRACE) {
+			fprintf(stderr,
+				"HTML: StyleSheet link found.\n");
+		    }
 #ifdef LINKEDSTYLES
 		    if (href && *href != '\0')
 		    {
@@ -956,16 +945,18 @@ PRIVATE void HTML_start_element ARGS6(
 				res = style_readFromFile(href);
 			    }
 			}
-			CTRACE(tfp, "CSS: StyleSheet=%s %d\n", href, res);
+			if (TRACE)
+			    fprintf(stderr, "CSS: StyleSheet=%s %d\n", href, res);
 			if (res == 0)
 			    HTAnchor_setStyle (me->node_anchor, href);
 		    }
-		    else {
-			CTRACE(tfp,
+		    else
+			if (TRACE)
+			    fprintf(stderr,
 				"        non-local StyleSheets not yet implemented.\n");
-		    }
 #else
-		    CTRACE(tfp,
+		    if (TRACE)
+			fprintf(stderr,
 				"        StyleSheets not yet implemented.\n");
 #endif
 		    FREE(href);
@@ -1021,8 +1012,11 @@ PRIVATE void HTML_start_element ARGS6(
 		    !strcasecomp(value[HTML_LINK_REL], "Bibliography")) {
 		    StrAllocCopy(title, value[HTML_LINK_REL]);
 		} else {
-		    CTRACE(tfp, "HTML: LINK with REL=\"%s\" ignored.\n",
+		    if (TRACE) {
+			fprintf(stderr,
+				"HTML: LINK with REL=\"%s\" ignored.\n",
 				 value[HTML_LINK_REL]);
+		    }
 		    FREE(href);
 		    break;
 		}
@@ -1040,8 +1034,11 @@ PRIVATE void HTML_start_element ARGS6(
 	    } else if (!strcasecomp(value[HTML_LINK_REL], "Index")) {
 		StrAllocCopy(href, indexfile);
 	    } else {
-		CTRACE(tfp, "HTML: LINK with REL=\"%s\" and no HREF ignored.\n",
+		if (TRACE) {
+		    fprintf(stderr,
+			    "HTML: LINK with REL=\"%s\" and no HREF ignored.\n",
 			    value[HTML_LINK_REL]);
+		}
 		break;
 	    }
 	    StrAllocCopy(title, value[HTML_LINK_REL]);
@@ -1073,7 +1070,7 @@ PRIVATE void HTML_start_element ARGS6(
 		 *  fingers. - FM
 		 */
 		SET_SKIP_STACK(HTML_A);
-		HTML_end_element(me, HTML_A, include);
+		HTML_end_element(me, HTML_A, (char **)&include);
 	    }
 
 	    /*
@@ -1096,13 +1093,12 @@ PRIVATE void HTML_start_element ARGS6(
 		    dest_char_set = UCGetLYhndl_byMIME(value[HTML_LINK_CHARSET]);
 		    if (dest_char_set < 0)
 			dest_char_set = UCLYhndl_for_unrec;
-		    if (dest_char_set < 0)  /* recover if not defined :-( */
-			dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */
 		}
-		if (dest)
+		if (dest && dest_char_set >= 0)
 		    HTAnchor_setUCInfoStage(dest, dest_char_set,
 					    UCT_STAGE_PARSER,
 					    UCT_SETBY_LINK);
+		dest_char_set = -1;
 	    }
 	    UPDATE_STYLE;
 	    if (!HText_hasToolbar(me->text) &&
@@ -1126,7 +1122,8 @@ PRIVATE void HTML_start_element ARGS6(
 	    {
 		char tmp[1024];
 		sprintf(tmp, "link.%s.%s.%s", value[HTML_LINK_CLASS], title, value[HTML_LINK_CLASS]);
-		CTRACE(tfp, "CSSTRIM:link=%s\n", tmp);
+		if (TRACE)
+			fprintf(stderr, "CSSTRIM:link=%s\n", tmp);
 
 		HText_characterStyle(me->text, hash_code(tmp), 1);
 		HTML_put_string(me, title);
@@ -1163,7 +1160,8 @@ PRIVATE void HTML_start_element ARGS6(
 		StrAllocCopy(isindex_href, value[HTML_ISINDEX_HREF]);
 	    else
 		StrAllocCopy(isindex_href, value[HTML_ISINDEX_ACTION]);
-	    url_type = LYLegitimizeHREF(me, &isindex_href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&isindex_href,
+					TRUE, TRUE);
 
 	    /*
 	     *	Check whether a base tag is in effect.
@@ -1259,7 +1257,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_FRAME_SRC] && *value[HTML_FRAME_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_FRAME_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 
 	    /*
 	     *	Check whether a base tag is in effect. - FM
@@ -1276,14 +1274,14 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '\0' && *href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
 
 	    if (me->inA) {
 		SET_SKIP_STACK(HTML_A);
-		HTML_end_element(me, HTML_A, include);
+		HTML_end_element(me, HTML_A, (char **)&include);
 	    }
 	    me->CurrentA = HTAnchor_findChildAndLink(
 				me->node_anchor,	/* Parent */
@@ -1331,7 +1329,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_IFRAME_SRC] && *value[HTML_IFRAME_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_IFRAME_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 
 	    /*
 	     *	Check whether a base tag is in effect. - FM
@@ -1348,13 +1346,13 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '\0' && *href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
 
 	    if (me->inA)
-		HTML_end_element(me, HTML_A, include);
+		HTML_end_element(me, HTML_A, (char **)&include);
 	    me->CurrentA = HTAnchor_findChildAndLink(
 				me->node_anchor,	/* Parent */
 				NULL,			/* Tag */
@@ -1414,8 +1412,8 @@ PRIVATE void HTML_start_element ARGS6(
     case HTML_DIV:
 	if (me->Division_Level < (MAX_NESTING - 1)) {
 	    me->Division_Level++;
-	} else {
-	    CTRACE(tfp,
+	} else if (TRACE) {
+	    fprintf(stderr,
 		"HTML: ****** Maximum nesting of %d divisions exceeded!\n",
 		MAX_NESTING);
 	}
@@ -1543,20 +1541,13 @@ PRIVATE void HTML_start_element ARGS6(
 	break;
 
     case HTML_P:
-	LYHandleP(me, present, value, include, TRUE);
+	LYHandleP(me, present, value, (char **)&include, TRUE);
 	break;
 
     case HTML_BR:
 	UPDATE_STYLE;
 	CHECK_ID(HTML_GEN_ID);
-	  /* Add a \r (new line) if these three conditions are true:
-	   *   1. We are not collapsing BR's, and
-	   *   2. The previous line has text on it, or
-	   *   3. This line has text on it.
-	   * Otherwise, don't do anything. -DH 980814, TD 980827
-	   */
-	if ((LYCollapseBRs == FALSE &&
-	     HText_PreviousLineSize(me->text, FALSE)) ||
+	if ((LYCollapseBRs == FALSE) ||
 	    HText_LastLineSize(me->text, FALSE)) {
 	    HText_setLastChar(me->text, ' ');  /* absorb white space */
 	    HText_appendCharacter(me->text, '\r');
@@ -1684,7 +1675,9 @@ PRIVATE void HTML_start_element ARGS6(
 
     case HTML_TAB:
 	if (!present) { /* Bad tag.  Must have at least one attribute. - FM */
-	    CTRACE(tfp, "HTML: TAB tag has no attributes. Ignored.\n");
+	    if (TRACE)
+		fprintf(stderr,
+			"HTML: TAB tag has no attributes. Ignored.\n");
 	    break;
 	}
 	UPDATE_STYLE;
@@ -1697,7 +1690,9 @@ PRIVATE void HTML_start_element ARGS6(
 	     *	the ALIGN and DP attributes implemented. - FM
 	     */
 	    HTML_put_character(me, ' ');
-	    CTRACE(tfp, "HTML: ALIGN not 'left'. Using space instead of TAB.\n");
+	    if (TRACE)
+		fprintf(stderr,
+		     "HTML: ALIGN not 'left'. Using space instead of TAB.\n");
 
 	} else if (!LYoverride_default_alignment(me) &&
 		   me->current_default_alignment != HT_LEFT) {
@@ -1708,7 +1703,9 @@ PRIVATE void HTML_start_element ARGS6(
 	     *	that the alignment be HT_LEFT. - FM
 	     */
 	    HTML_put_character(me, ' ');
-	    CTRACE(tfp, "HTML: Not HT_LEFT. Using space instead of TAB.\n");
+	    if (TRACE)
+		fprintf(stderr,
+			"HTML: Not HT_LEFT. Using space instead of TAB.\n");
 
 	} else if ((present[HTML_TAB_TO] &&
 		    value[HTML_TAB_TO] && *value[HTML_TAB_TO]) ||
@@ -1747,7 +1744,9 @@ PRIVATE void HTML_start_element ARGS6(
 	    if (target < column ||
 		target > HText_getMaximumColumn(me->text)) {
 		HTML_put_character(me, ' ');
-		CTRACE(tfp, "HTML: Column out of bounds. Using space instead of TAB.\n");
+		if (TRACE)
+		    fprintf(stderr,
+		 "HTML: Column out of bounds. Using space instead of TAB.\n");
 	    } else {
 		for (i = column; i < target; i++)
 		    HText_appendCharacter(me->text, ' ');
@@ -1790,7 +1789,7 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 #ifdef NOTUSED_FOTEMODS
 	if (me->inFONT == TRUE)
-	    HTML_end_element(me, HTML_FONT, &include);
+	    HTML_end_element(me, HTML_FONT, (char **)&include);
 #endif /* NOTUSED_FOTEMODS */
 
 	/*
@@ -1816,15 +1815,18 @@ PRIVATE void HTML_start_element ARGS6(
 	 *  Can't display both underline and bold at same time.
 	 */
 	if (me->inBoldA == TRUE || me->inBoldH == TRUE) {
-	    CTRACE(tfp, "Underline Level is %d\n", me->Underline_Level);
+	    if (TRACE)
+		fprintf(stderr,"Underline Level is %d\n", me->Underline_Level);
 	    break;
 	}
 	if (me->inUnderline == FALSE) {
 	    HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR);
 	    me->inUnderline = TRUE;
-	    CTRACE(tfp,"Beginning underline\n");
+	    if (TRACE)
+		fprintf(stderr,"Beginning underline\n");
 	} else {
-	    CTRACE(tfp,"Underline Level is %d\n", me->Underline_Level);
+	    if (TRACE)
+		fprintf(stderr,"Underline Level is %d\n", me->Underline_Level);
 	}
 	break;
 
@@ -1930,14 +1932,16 @@ PRIVATE void HTML_start_element ARGS6(
 		(!strcasecomp(value[HTML_NOTE_CLASS], "CAUTION") ||
 		 !strcasecomp(value[HTML_NOTE_CLASS], "WARNING"))) {
 		StrAllocCopy(note, value[HTML_NOTE_CLASS]);
-		LYUpperCase(note);
+		for (i = 0; note[i] != '\0'; i++)
+		    note[i] = TOUPPER(note[i]);
 		StrAllocCat(note, ":");
 	    } else if (present && present[HTML_NOTE_ROLE] &&
 		       value[HTML_NOTE_ROLE] &&
 		       (!strcasecomp(value[HTML_NOTE_ROLE], "CAUTION") ||
 			!strcasecomp(value[HTML_NOTE_ROLE], "WARNING"))) {
 		StrAllocCopy(note, value[HTML_NOTE_ROLE]);
-		LYUpperCase(note);
+		for (i = 0; note[i] != '\0'; i++)
+		    note[i] = TOUPPER(note[i]);
 		StrAllocCat(note, ":");
 	    } else {
 		StrAllocCopy(note, "NOTE:");
@@ -2393,7 +2397,7 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	/*
 	 *  Set to know we are in an anchor.
@@ -2440,7 +2444,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    } else {
 		StrAllocCopy(href, value[HTML_A_HREF]);
 	    }
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 
 	    /*
 	     *	Deal with our ftp gateway kludge. - FM
@@ -2448,8 +2452,8 @@ PRIVATE void HTML_start_element ARGS6(
 	    if (!url_type && !strncmp(href, "/foo/..", 7) &&
 		(!strncmp(me->node_anchor->address, "ftp:", 4) ||
 		 !strncmp(me->node_anchor->address, "file:", 5))) {
-		for (i = 0; (href[i] = href[i+7]) != 0; i++)
-		    ;
+		for (i = 0; href[i]; i++)
+		    href[i] = href[i+7];
 	    }
 
 	    /*
@@ -2472,7 +2476,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '\0' && *href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
@@ -2492,7 +2496,9 @@ PRIVATE void HTML_start_element ARGS6(
 		** Found TYPE="internal link" but not in a valid context
 		** where we have written it. - kw
 		*/
-		CTRACE(tfp, "HTML: Found invalid HREF=\"%s\" TYPE=\"%s\"!\n",
+		if (TRACE)
+		    fprintf(stderr,
+			    "HTML: Found invalid HREF=\"%s\" TYPE=\"%s\"!\n",
 			    href, temp);
 		FREE(temp);
 	    }
@@ -2533,8 +2539,6 @@ PRIVATE void HTML_start_element ARGS6(
 		dest_char_set = UCGetLYhndl_byMIME(temp);
 		if (dest_char_set < 0) {
 			dest_char_set = UCLYhndl_for_unrec;
-		if (dest_char_set < 0) /* recover if not defined :-( */
-			dest_char_set = UCLYhndl_for_unspec; /* always >= 0 */
 		}
 	    }
 	    if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) {
@@ -2546,7 +2550,7 @@ PRIVATE void HTML_start_element ARGS6(
 		HTAnchor_setTitle(dest, title);
 	    if (dest && dest_ismap)
 		dest->isISMAPScript = TRUE;
-	    if (dest) {
+	    if (dest && dest_char_set >= 0) {
 		/*
 		**  Load the anchor's chartrans structures.
 		**  This should be done more intelligently
@@ -2563,6 +2567,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    FREE(temp);
 	    dest = NULL;
 	    dest_ismap = FALSE;
+	    dest_char_set = -1;
 	    FREE(title);
 	}
 	me->CurrentANum = HText_beginAnchor(me->text,
@@ -2577,7 +2582,7 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (href == NULL && me->inBoldA == FALSE) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, &include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 #endif /* NOTUSED_FOTEMODS */
 	FREE(href);
@@ -2596,12 +2601,16 @@ PRIVATE void HTML_start_element ARGS6(
 				      )) != NULL) {
 		if (dest->isISMAPScript == TRUE) {
 		    dest_ismap = TRUE;
-		    CTRACE(tfp, "HTML: '%s' is an ISMAP script\n",
+		    if (TRACE)
+			fprintf(stderr,
+				"HTML: '%s' is an ISMAP script\n",
 				dest->address);
 		} else if (present && present[HTML_IMG_ISMAP]) {
 		    dest_ismap = TRUE;
 		    dest->isISMAPScript = TRUE;
-		    CTRACE(tfp, "HTML: Designating '%s' as an ISMAP script\n",
+		    if (TRACE)
+			fprintf(stderr,
+				"HTML: Designating '%s' as an ISMAP script\n",
 				dest->address);
 		}
 	    }
@@ -2617,7 +2626,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_IMG_USEMAP] && *value[HTML_IMG_USEMAP]) {
 	    StrAllocCopy(map_href, value[HTML_IMG_USEMAP]);
 	    CHECK_FOR_INTERN(map_href);
-	    url_type = LYLegitimizeHREF(me, &map_href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&map_href, TRUE, TRUE);
 	    /*
 	     *	If map_href ended up zero-length or otherwise doesn't
 	     *	have a hash, it can't be valid, so ignore it. - FM
@@ -2665,7 +2674,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&map_href,
+	    LYFillLocalFileURL((char **)&map_href,
 			       ((UseBASE && me->inBASE) ?
 			  me->base_href : me->node_anchor->address));
 	    UseBASE = TRUE;
@@ -2734,16 +2743,16 @@ PRIVATE void HTML_start_element ARGS6(
 		LYTrimTail(alt_string);
 		if (*alt_string == '\0') {
 		    if (map_href) {
-			StrAllocCopy(alt_string, (title ? title :
-				     MakeNewMapValue(value,"USEMAP")));
+			StrAllocCopy(alt_string, (title ?
+						  title : "[USEMAP]"));
 		    } else if (dest_ismap) {
-			StrAllocCopy(alt_string, (title ? title :
-				     MakeNewMapValue(value,"ISMAP")));
+			StrAllocCopy(alt_string, (title ?
+						  title : "[ISMAP]"));
 
 		    } else if (me->inA == TRUE && dest) {
 			StrAllocCopy(alt_string, (title ?
 						  title :
-						  VERBOSE_IMG(value, HTML_IMG_SRC, "[LINK]")));
+						  VERBOSE_IMG(value, "[LINK]")));
 
 		    } else {
 			StrAllocCopy(alt_string,
@@ -2751,24 +2760,24 @@ PRIVATE void HTML_start_element ARGS6(
 						  ((present &&
 						    present[HTML_IMG_ISOBJECT]) ?
 						    "(OBJECT)" :
-						    VERBOSE_IMG(value, HTML_IMG_SRC, "[INLINE]"))));
+						    VERBOSE_IMG(value, "[INLINE]"))));
 		    }
 		}
 	    }
 
 	} else if (map_href) {
-	    StrAllocCopy(alt_string, (title ? title :
-				      MakeNewMapValue(value,"USEMAP")));
+	    StrAllocCopy(alt_string, (title ?
+				      title : "[USEMAP]"));
 
 	} else if ((dest_ismap == TRUE) ||
 		   (me->inA && present && present[HTML_IMG_ISMAP])) {
-	    StrAllocCopy(alt_string, (title ? title :
-				      MakeNewMapValue(value,"ISMAP")));
+	    StrAllocCopy(alt_string, (title ?
+				      title : "[ISMAP]"));
 
 	} else if (me->inA == TRUE && dest) {
 	    StrAllocCopy(alt_string, (title ?
 				      title :
-				      VERBOSE_IMG(value, HTML_IMG_SRC, "[LINK]")));
+				      VERBOSE_IMG(value, "[LINK]")));
 
 	} else {
 	    if (pseudo_inline_alts || clickable_images)
@@ -2776,19 +2785,22 @@ PRIVATE void HTML_start_element ARGS6(
 			  ((present &&
 			    present[HTML_IMG_ISOBJECT]) ?
 					     "(OBJECT)" :
-					     VERBOSE_IMG(value, HTML_IMG_SRC, "[INLINE]"))));
+					     VERBOSE_IMG(value, "[INLINE]"))));
 	    else
 		StrAllocCopy(alt_string, (title ?
 					  title : ""));
 	}
 	if (*alt_string == '\0' && map_href) {
-	    StrAllocCopy(alt_string, MakeNewMapValue(value,"USEMAP"));
+	    StrAllocCopy(alt_string, "[USEMAP]");
 	}
 
-	CTRACE(tfp, "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n",
+	if (TRACE) {
+	    fprintf(stderr,
+		    "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n",
 		    map_href ? 1 : 0,
 		    (dest_ismap == TRUE) ? 1 : 0,
 		    me->inA, me->inP);
+	}
 
 	/*
 	 *  Check for an ID attribute. - FM
@@ -2809,7 +2821,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    present && present[HTML_IMG_SRC] &&
 	    value[HTML_IMG_SRC] && *value[HTML_IMG_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_IMG_SRC]);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 
 	    /*
 	     *	Check whether a base tag is in effect. - FM
@@ -2826,7 +2838,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '\0' && *href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
@@ -2844,7 +2856,7 @@ PRIVATE void HTML_start_element ARGS6(
 		    if (dest_ismap) {
 			HTML_put_character(me, ' ');
 			me->in_word = NO;
-			HTML_put_string(me, MakeNewMapValue(value,"ISMAP"));
+			HTML_put_string(me, "[ISMAP]");
 		    } else if (dest) {
 			HTML_put_character(me, ' ');
 			me->in_word = NO;
@@ -2905,7 +2917,7 @@ PRIVATE void HTML_start_element ARGS6(
 			       present[HTML_IMG_ISOBJECT]) ?
 		   ((map_href || dest_ismap) ?
 				   "(IMAGE)" : "(OBJECT)") :
-				   VERBOSE_IMG(value, HTML_IMG_SRC, "[IMAGE]")));
+				   VERBOSE_IMG(value, "[IMAGE]")));
 		if (id_string && !map_href) {
 		    if ((ID_A = HTAnchor_findChildAndLink(
 				  me->node_anchor,	/* Parent */
@@ -2960,7 +2972,7 @@ PRIVATE void HTML_start_element ARGS6(
 			     ((present &&
 			       present[HTML_IMG_ISOBJECT]) ?
 						 "(IMAGE)" :
-						 VERBOSE_IMG(value, HTML_IMG_SRC, "[IMAGE]")));
+						 VERBOSE_IMG(value, "[IMAGE]")));
 	    } else {
 		HTML_put_character(me, ' ');  /* space char may be ignored */
 		me->in_word = NO;
@@ -3012,7 +3024,7 @@ PRIVATE void HTML_start_element ARGS6(
 		if (dest_ismap) {
 		    HTML_put_character(me, ' ');/* space char may be ignored */
 		    me->in_word = NO;
-		    HTML_put_string(me, MakeNewMapValue(value,"ISMAP"));
+		    HTML_put_string(me, "[ISMAP]");
 		} else if (dest) {
 		    HTML_put_character(me, ' ');/* space char may be ignored */
 		    me->in_word = NO;
@@ -3151,7 +3163,7 @@ PRIVATE void HTML_start_element ARGS6(
 	     */
 	    StrAllocCopy(href, value[HTML_AREA_HREF]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 
 	    /*
 	     *	Check whether a BASE tag is in effect, and use it
@@ -3173,7 +3185,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((((me->inBASE && *href != '\0') &&
 				  !(*href == '#' &&
 				    LYSeekFragAREAinCur == TRUE)))
@@ -3256,7 +3268,7 @@ PRIVATE void HTML_start_element ARGS6(
 	me->inFIG = TRUE;
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (!present ||
 	    (present && !present[HTML_FIG_ISOBJECT])) {
@@ -3275,7 +3287,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_FIG_SRC] && *value[HTML_FIG_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_FIG_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 	    if (*href) {
 		/*
 		 *  Check whether a base tag is in effect. - FM
@@ -3292,7 +3304,7 @@ PRIVATE void HTML_start_element ARGS6(
 		/*
 		 *  Check whether to fill in localhost. - FM
 		 */
-		LYFillLocalFileURL(&href,
+		LYFillLocalFileURL((char **)&href,
 				   ((*href != '#' &&
 				     me->inBASE) ?
 				   me->base_href : me->node_anchor->address));
@@ -3435,7 +3447,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_OVERLAY_SRC] && *value[HTML_OVERLAY_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_OVERLAY_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 	    if (*href) {
 		/*
 		 *  Check whether a base tag is in effect. - FM
@@ -3452,14 +3464,14 @@ PRIVATE void HTML_start_element ARGS6(
 		/*
 		 *  Check whether to fill in localhost. - FM
 		 */
-		LYFillLocalFileURL(&href,
+		LYFillLocalFileURL((char **)&href,
 				   ((*href != '#' &&
 				     me->inBASE) ?
 				   me->base_href : me->node_anchor->address));
 
 		if (me->inA) {
 		    SET_SKIP_STACK(HTML_A);
-		    HTML_end_element(me, HTML_A, include);
+		    HTML_end_element(me, HTML_A, (char **)&include);
 		}
 		me->CurrentA = HTAnchor_findChildAndLink(
 					me->node_anchor,	/* Parent */
@@ -3548,20 +3560,21 @@ PRIVATE void HTML_start_element ARGS6(
 	    if (present[HTML_APPLET_CODEBASE] &&
 		value[HTML_APPLET_CODEBASE] && *value[HTML_APPLET_CODEBASE]) {
 		StrAllocCopy(base, value[HTML_APPLET_CODEBASE]);
-		LYRemoveBlanks(base);
+		collapse_spaces(base);
 		TRANSLATE_AND_UNESCAPE_TO_STD(&base);
 		/*
 		 *  Force it to be a directory. - FM
 		 */
 		if (*base == '\0')
 		    StrAllocCopy(base, "/");
-		LYAddHtmlSep(&base);
-		url_type = LYLegitimizeHREF(me, &base, TRUE, FALSE);
+		if (base[strlen(base)-1] != '/')
+		    StrAllocCat(base, "/");
+		url_type = LYLegitimizeHREF(me, (char**)&base, TRUE, FALSE);
 
 		/*
 		 *  Check whether to fill in localhost. - FM
 		 */
-		LYFillLocalFileURL(&base,
+		LYFillLocalFileURL((char **)&base,
 				   (me->inBASE ?
 				 me->base_href : me->node_anchor->address));
 
@@ -3587,7 +3600,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    }
 
 	    StrAllocCopy(code, value[HTML_APPLET_CODE]);
-	    url_type = LYLegitimizeHREF(me, &code, TRUE, FALSE);
+	    url_type = LYLegitimizeHREF(me, (char**)&code, TRUE, FALSE);
 	    href = HTParse(code, base, PARSE_ALL);
 	    FREE(base);
 	    FREE(code);
@@ -3640,7 +3653,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_BGSOUND_SRC] && *value[HTML_BGSOUND_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_BGSOUND_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 	    if (*href == '\0') {
 		FREE(href);
 		break;
@@ -3661,7 +3674,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    /*
 	     *	Check whether to fill in localhost. - FM
 	     */
-	    LYFillLocalFileURL(&href,
+	    LYFillLocalFileURL((char **)&href,
 			       ((*href != '#' &&
 				 me->inBASE) ?
 			       me->base_href : me->node_anchor->address));
@@ -3754,7 +3767,7 @@ PRIVATE void HTML_start_element ARGS6(
 	    value[HTML_EMBED_SRC] && *value[HTML_EMBED_SRC] != '\0') {
 	    StrAllocCopy(href, value[HTML_EMBED_SRC]);
 	    CHECK_FOR_INTERN(href);
-	    url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+	    url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 	    if (*href != '\0') {
 		/*
 		 *  Check whether a base tag is in effect. - FM
@@ -3771,7 +3784,7 @@ PRIVATE void HTML_start_element ARGS6(
 		/*
 		 *  Check whether to fill in localhost. - FM
 		 */
-		LYFillLocalFileURL(&href,
+		LYFillLocalFileURL((char **)&href,
 				   ((*href != '#' &&
 				     me->inBASE) ?
 				   me->base_href : me->node_anchor->address));
@@ -3898,9 +3911,12 @@ PRIVATE void HTML_start_element ARGS6(
 	     *	that one now. - FM
 	     */
 	    if (me->inFORM) {
-		CTRACE(tfp, "HTML: Missing FORM end tag. Faking it!\n");
+		if (TRACE) {
+		    fprintf(stderr,
+			    "HTML: Missing FORM end tag. Faking it!\n");
+		}
 		SET_SKIP_STACK(HTML_FORM);
-		HTML_end_element(me, HTML_FORM, include);
+		HTML_end_element(me, HTML_FORM, (char **)&include);
 	    }
 
 	    /*
@@ -3918,7 +3934,7 @@ PRIVATE void HTML_start_element ARGS6(
 		 *  Prepare to do housekeeping on the reference. - FM
 		 */
 		StrAllocCopy(action, value[HTML_FORM_ACTION]);
-		url_type = LYLegitimizeHREF(me, &action, TRUE, TRUE);
+		url_type = LYLegitimizeHREF(me, (char**)&action, TRUE, TRUE);
 
 		/*
 		 *  Check whether a base tag is in effect.  Note that
@@ -3979,7 +3995,11 @@ PRIVATE void HTML_start_element ARGS6(
 	    if (present && present[HTML_FORM_ENCTYPE] &&
 		value[HTML_FORM_ENCTYPE] && *value[HTML_FORM_ENCTYPE]) {
 		StrAllocCopy(enctype, value[HTML_FORM_ENCTYPE]);
-		LYLowerCase(enctype);
+		/*
+		 *  Force the enctype value to all lower case. - FM
+		 */
+		for (cp = enctype; *cp; cp++)
+		    *cp = TOLOWER(*cp);
 	    }
 
 	    if (present) {
@@ -4073,11 +4093,12 @@ PRIVATE void HTML_start_element ARGS6(
 	     */
 	    if (!me->inFORM) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			    "Bad HTML: BUTTON tag not within FORM tag\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		/*
 		 *  We'll process it, since the chances of a crash are
@@ -4227,7 +4248,6 @@ PRIVATE void HTML_start_element ARGS6(
 	    int chars;
 	    BOOL UseALTasVALUE = FALSE;
 	    BOOL HaveSRClink = FALSE;
-	    char* ImageSrc = NULL;
 	    BOOL IsSubmitOrReset = FALSE;
 
 	    /* init */
@@ -4280,7 +4300,8 @@ PRIVATE void HTML_start_element ARGS6(
 		    if (me->inFORM)
 			HText_DisableCurrentForm();
 #endif /* NOTDEFINED */
-		    CTRACE(tfp, "HTML: Ignoring TYPE=\"range\"\n");
+		    if (TRACE)
+			fprintf(stderr, "HTML: Ignoring TYPE=\"range\"\n");
 		    break;
 
 		} else if (!strcasecomp(I.type, "file")) {
@@ -4302,7 +4323,8 @@ PRIVATE void HTML_start_element ARGS6(
 		    if (me->inFORM)
 			HText_DisableCurrentForm();
 #endif /* NOTDEFINED */
-		    CTRACE(tfp, "HTML: Ignoring TYPE=\"file\"\n");
+		    if (TRACE)
+			fprintf(stderr, "HTML: Ignoring TYPE=\"file\"\n");
 		    break;
 
 		} else if (!strcasecomp(I.type, "button")) {
@@ -4319,11 +4341,12 @@ PRIVATE void HTML_start_element ARGS6(
 	     */
 	    if (!me->inFORM) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			    "Bad HTML: INPUT tag not within FORM tag\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		/*
 		 *  We'll process it, since the chances of a crash are
@@ -4338,11 +4361,12 @@ PRIVATE void HTML_start_element ARGS6(
 	     */
 	    if (me->inTEXTAREA) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			    "Bad HTML: Missing TEXTAREA end tag.\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 	    }
 
@@ -4350,11 +4374,13 @@ PRIVATE void HTML_start_element ARGS6(
 	     *	Check for an unclosed SELECT, try to close it if found.
 	     */
 	    if (me->inSELECT) {
-		CTRACE(tfp, "HTML: Missing SELECT end tag, faking it...\n");
+		if (TRACE) {
+		    fprintf(stderr, "HTML: Missing SELECT end tag, faking it...\n");
+		}
 		if (me->sp->tag_number != HTML_SELECT) {
 		    SET_SKIP_STACK(HTML_SELECT);
 		}
-		HTML_end_element(me, HTML_SELECT, include);
+		HTML_end_element(me, HTML_SELECT, (char **)&include);
 	    }
 
 	    /*
@@ -4384,12 +4410,7 @@ PRIVATE void HTML_start_element ARGS6(
 		 */
 		UseALTasVALUE = TRUE;
 	    }
-	    if (verbose_img && !clickable_images &&
-		present && present[HTML_INPUT_SRC] &&
-		value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] &&
-		I.type && !strcasecomp(I.type, "image")) {
-		ImageSrc = MakeNewImageValue(value);
-	    } else if (clickable_images == TRUE &&
+	    if (clickable_images == TRUE &&
 		present && present[HTML_INPUT_SRC] &&
 		value[HTML_INPUT_SRC] && *value[HTML_INPUT_SRC] &&
 		I.type && !strcasecomp(I.type, "image")) {
@@ -4400,7 +4421,7 @@ PRIVATE void HTML_start_element ARGS6(
 		 *  SRC's value a link if it's still not zero-length
 		 *  legitiimizing it. - FM
 		 */
-		url_type = LYLegitimizeHREF(me, &href, TRUE, TRUE);
+		url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE);
 		if (*href) {
 		    /*
 		     *	Check whether a base tag is in effect. - FM
@@ -4417,7 +4438,7 @@ PRIVATE void HTML_start_element ARGS6(
 		    /*
 		     *	Check whether to fill in localhost. - FM
 		     */
-		    LYFillLocalFileURL(&href,
+		    LYFillLocalFileURL((char **)&href,
 				       ((*href != '#' &&
 					 me->inBASE) ?
 				       me->base_href :
@@ -4425,7 +4446,7 @@ PRIVATE void HTML_start_element ARGS6(
 
 		    if (me->inA) {
 			SET_SKIP_STACK(HTML_A);
-			HTML_end_element(me, HTML_A, include);
+			HTML_end_element(me, HTML_A, (char **)&include);
 		    }
 		    me->CurrentA = HTAnchor_findChildAndLink(
 					me->node_anchor,	/* Parent */
@@ -4435,7 +4456,7 @@ PRIVATE void HTML_start_element ARGS6(
 		    HText_beginAnchor(me->text, me->inUnderline, me->CurrentA);
 		    if (me->inBoldH == FALSE)
 			HText_appendCharacter(me->text, LY_BOLD_START_CHAR);
-		    HTML_put_string(me, VERBOSE_IMG(value,HTML_INPUT_SRC,"[IMAGE]"));
+		    HTML_put_string(me, VERBOSE_IMG(value, "[IMAGE]"));
 		    if (me->inBoldH == FALSE)
 			HText_appendCharacter(me->text, LY_BOLD_END_CHAR);
 		    HText_endAnchor(me->text, 0);
@@ -4458,7 +4479,7 @@ PRIVATE void HTML_start_element ARGS6(
 
 		if (I.type && !strcasecomp(I.type, "hidden")) {
 		    me->HiddenValue = TRUE;
-		    current_char_set = LATIN1;	/* Default ISO-Latin1 */
+		    current_char_set = 0;	/* Default ISO-Latin1 */
 		    LYUseDefaultRawMode = TRUE;
 		    HTMLSetCharacterHandling(current_char_set);
 		}
@@ -4516,11 +4537,6 @@ PRIVATE void HTML_start_element ARGS6(
 		 */
 		StrAllocCopy(I_value, "Submit");
 		I.value = I_value;
-	    } else if ( ImageSrc ) {
-		/* [IMAGE]-Submit with verbose images and not clickable images.
-		 * Use ImageSrc if no other alt or value is supplied. --LE
-		 */
-		I.value = ImageSrc;
 	    }
 	    if (present && present[HTML_INPUT_CHECKED])
 		I.checked = YES;
@@ -4698,11 +4714,12 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (!me->inFORM) {
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 			"Bad HTML: TEXTAREA start tag not within FORM tag\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	    /*
 	     *	Too likely to cause a crash, so we'll ignore it. - FM
@@ -4788,16 +4805,17 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inSELECT) {
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 		   "Bad HTML: SELECT start tag in SELECT element. Faking SELECT end tag. *****\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	    if (me->sp->tag_number != HTML_SELECT) {
 		SET_SKIP_STACK(HTML_SELECT);
 	    }
-	    HTML_end_element(me, HTML_SELECT, include);
+	    HTML_end_element(me, HTML_SELECT, (char **)&include);
 	}
 
 	/*
@@ -4805,7 +4823,7 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	LYHandleSELECT(me,
 		       present, (CONST char **)value,
-		       include,
+		       (char **)&include,
 		       TRUE);
 	break;
 
@@ -4821,11 +4839,12 @@ PRIVATE void HTML_start_element ARGS6(
 	     */
 	    if (!me->inSELECT) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			    "Bad HTML: OPTION tag not within SELECT tag\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 
 		/*
@@ -5021,11 +5040,11 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	me->inTABLE = TRUE;
 	if (!strcmp(me->sp->style->name, "Preformatted")) {
@@ -5035,8 +5054,8 @@ PRIVATE void HTML_start_element ARGS6(
 	}
 	if (me->Division_Level < (MAX_NESTING - 1)) {
 	    me->Division_Level++;
-	} else {
-	    CTRACE(tfp,
+	} else if (TRACE) {
+	    fprintf(stderr,
 	    "HTML: ****** Maximum nesting of %d divisions/tables exceeded!\n",
 		    MAX_NESTING);
 	}
@@ -5075,11 +5094,11 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	UPDATE_STYLE;
 	if (HText_LastLineSize(me->text, FALSE)) {
@@ -5127,11 +5146,11 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	UPDATE_STYLE;
 	CHECK_ID(HTML_TR_ID);
@@ -5144,11 +5163,11 @@ PRIVATE void HTML_start_element ARGS6(
 	 */
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	UPDATE_STYLE;
 	CHECK_ID(HTML_COL_ID);
@@ -5157,11 +5176,11 @@ PRIVATE void HTML_start_element ARGS6(
     case HTML_TH:
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	UPDATE_STYLE;
 	CHECK_ID(HTML_TD_ID);
@@ -5175,11 +5194,11 @@ PRIVATE void HTML_start_element ARGS6(
     case HTML_TD:
 	if (me->inA) {
 	    SET_SKIP_STACK(HTML_A);
-	    HTML_end_element(me, HTML_A, include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	}
 	if (me->Underline_Level > 0) {
 	    SET_SKIP_STACK(HTML_U);
-	    HTML_end_element(me, HTML_U, include);
+	    HTML_end_element(me, HTML_U, (char **)&include);
 	}
 	UPDATE_STYLE;
 	CHECK_ID(HTML_TD_ID);
@@ -5204,12 +5223,11 @@ PRIVATE void HTML_start_element ARGS6(
 
     } /* end switch */
 
-#if defined(DICKEY_TEST)
-    if (HTML_dtd.tags[ElementNumber].contents != SGML_EMPTY)
-#endif
-    {
+    if (HTML_dtd.tags[ElementNumber].contents != SGML_EMPTY) {
 	if (me->skip_stack > 0) {
-	    CTRACE(tfp, "HTML:begin_element: internal call (level %d), leaving on stack - %s\n",
+	    if (TRACE)
+		fprintf(stderr,
+	    "HTML:begin_element: internal call (level %d), leaving on stack - %s\n",
 			me->skip_stack, me->sp->style->name);
 	    me->skip_stack--;
 	    return;
@@ -5217,7 +5235,7 @@ PRIVATE void HTML_start_element ARGS6(
 	if (me->sp == me->stack) {
 	    if (me->stack_overrun == FALSE) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			"HTML: ****** Maximum nesting of %d tags exceeded!\n",
 			MAX_NESTING);
 
@@ -5229,19 +5247,21 @@ PRIVATE void HTML_start_element ARGS6(
 	    return;
 	}
 
-	CTRACE(tfp,"HTML:begin_element[%d]: adding style to stack - %s\n",
-	    						(int) STACKLEVEL(me),
-							me->new_style->name);
 	(me->sp)--;
 	me->sp[0].style = me->new_style;	/* Stack new style */
 	me->sp[0].tag_number = ElementNumber;
+
+	if (TRACE)
+	    fprintf(stderr,"HTML:begin_element: adding style to stack - %s\n",
+							me->new_style->name);
     }
 
-#if defined(DICKEY_TEST) && defined(USE_COLOR_STYLE)
+#if defined(USE_COLOR_STYLE)
 /* end empty tags straight away */
 	if (HTML_dtd.tags[ElementNumber].contents == SGML_EMPTY)
 	{
-		CTRACE(tfp, "STYLE:begin_element:ending EMPTY element style\n");
+		if (TRACE)
+			fprintf(stderr, "STYLE:begin_element:ending EMPTY element style\n");
 #if !defined(USE_HASH)
 	HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
 #else
@@ -5268,12 +5288,14 @@ PRIVATE void HTML_start_element ARGS6(
 #if defined(PREVAIL)
 			start=strrchr(Style_className, '.');
 			if (start)
-				strcpy(prevailing_class, (start+1));
+				strcpy(prevailing_class, (char*)(start+1));
 			else
 				strcpy(prevailing_class, "");
 #endif
 
-			CTRACE(tfp, "CSS:%s (trimmed %s, SGML_EMPTY)\n", Style_className, tmp);
+
+			if (TRACE)
+			fprintf(stderr, "CSS:%s (trimmed %s, SGML_EMPTY)\n", Style_className, tmp);
 		}
 	}
 #endif /* USE_COLOR_STYLE */
@@ -5305,7 +5327,7 @@ PRIVATE void HTML_end_element ARGS3(
 #ifdef CAREFUL			/* parser assumed to produce good nesting */
     if (element_number != me->sp[0].tag_number &&
 	HTML_dtd.tags[element_number].contents != SGML_EMPTY) {
-	CTRACE(tfp,
+	fprintf(stderr,
 		"HTMLText: end of element %s when expecting end of %s\n",
 		HTML_dtd.tags[element_number].name,
 		HTML_dtd.tags[me->sp->tag_number].name);
@@ -5349,7 +5371,9 @@ PRIVATE void HTML_end_element ARGS3(
 	    BreakFlag = TRUE;
 	}
 	if (me->skip_stack > 0) {
-	     CTRACE(tfp, "HTML:end_element: Internal call (level %d), leaving on stack - %s\n",
+	    if (TRACE)
+		fprintf(stderr,
+	    "HTML:end_element: Internal call (level %d), leaving on stack - %s\n",
 			me->skip_stack, me->sp->style->name);
 	    me->skip_stack--;
 	} else if (me->stack_overrun == TRUE &&
@@ -5395,11 +5419,13 @@ PRIVATE void HTML_end_element ARGS3(
 	    return;
 	} else if (me->sp < (me->stack + MAX_NESTING - 1)) {
 	    (me->sp)++;
-	    CTRACE(tfp, "HTML:end_element[%d]: Popped style off stack - %s\n",
-	    		(int) STACKLEVEL(me),
+	    if (TRACE)
+		fprintf(stderr,
+			"HTML:end_element: Popped style off stack - %s\n",
 			me->sp->style->name);
 	} else {
-	    CTRACE(tfp,
+	    if (TRACE)
+		fprintf(stderr,
   "Stack underflow error!  Tried to pop off more styles than exist in stack\n");
 	}
     }
@@ -5411,10 +5437,11 @@ PRIVATE void HTML_end_element ARGS3(
      */
     if (me->inTEXTAREA && element_number != HTML_TEXTAREA) {
 	if (TRACE) {
-	    fprintf(tfp, "Bad HTML: Missing TEXTAREA end tag\n");
+	    fprintf(stderr, "Bad HTML: Missing TEXTAREA end tag\n");
 	} else if (!me->inBadHTML) {
-	    HTUserMsg(BAD_HTML_USE_TRACE);
+	    _statusline(BAD_HTML_USE_TRACE);
 	    me->inBadHTML = TRUE;
+	    sleep(MessageSecs);
 	}
     }
 
@@ -5428,9 +5455,9 @@ PRIVATE void HTML_end_element ARGS3(
     switch(element_number) {
 
     case HTML_HTML:
-	if (me->inA || me->inSELECT || me->inTEXTAREA) {
+	if (me->inA || me->inSELECT || me->inTEXTAREA)
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 			"Bad HTML: %s%s%s%s%s not closed before HTML end tag *****\n",
 			me->inSELECT ? "SELECT" : "",
 			(me->inSELECT && me->inTEXTAREA) ? ", " : "",
@@ -5438,10 +5465,10 @@ PRIVATE void HTML_end_element ARGS3(
 			((me->inSELECT || me->inTEXTAREA) && me->inA) ? ", " : "",
 			me->inA ? "A" : "");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
-	}
 	break;
 
     case HTML_HEAD:
@@ -5488,7 +5515,7 @@ PRIVATE void HTML_end_element ARGS3(
 				     ((MBM_A_subdescript[i] &&
 				       *MBM_A_subdescript[i]) ?
 					 MBM_A_subdescript[i] : "(none)"));
-			LYEntify(&temp, TRUE);
+			LYEntify((char **)&temp, TRUE);
 			StrAllocCat(*include, temp);
 			StrAllocCat(*include,
 				"<BR><EM>&nbsp;&nbsp;&nbsp;Filepath:</EM> ");
@@ -5496,7 +5523,7 @@ PRIVATE void HTML_end_element ARGS3(
 				     ((MBM_A_subbookmark[i] &&
 				       *MBM_A_subbookmark[i]) ?
 					 MBM_A_subbookmark[i] : "(unknown)"));
-			LYEntify(&temp, TRUE);
+			LYEntify((char **)&temp, TRUE);
 			StrAllocCat(*include, temp);
 			FREE(temp);
 			StrAllocCat(*include, "</H2>");
@@ -5513,8 +5540,10 @@ PRIVATE void HTML_end_element ARGS3(
 	 *  we'll just ignore. - FM
 	 */
 	HTChunkTerminate(&me->style_block);
-	CTRACE(tfp, "HTML: STYLE content =\n%s\n",
+	if (TRACE) {
+	    fprintf(stderr, "HTML: STYLE content =\n%s\n",
 			    me->style_block.data);
+	}
 	HTChunkClear(&me->style_block);
 	break;
 
@@ -5524,15 +5553,17 @@ PRIVATE void HTML_end_element ARGS3(
 	 *  we'll just ignore. - FM
 	 */
 	HTChunkTerminate(&me->script);
-	CTRACE(tfp, "HTML: SCRIPT content =\n%s\n",
+	if (TRACE) {
+	    fprintf(stderr, "HTML: SCRIPT content =\n%s\n",
 			    me->script.data);
+	}
 	HTChunkClear(&me->script);
 	break;
 
     case HTML_BODY:
-	if (me->inA || me->inSELECT || me->inTEXTAREA) {
+	if (me->inA || me->inSELECT || me->inTEXTAREA)
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 			"Bad HTML: %s%s%s%s%s not closed before BODY end tag *****\n",
 			me->inSELECT ? "SELECT" : "",
 			(me->inSELECT && me->inTEXTAREA) ? ", " : "",
@@ -5540,10 +5571,10 @@ PRIVATE void HTML_end_element ARGS3(
 			((me->inSELECT || me->inTEXTAREA) && me->inA) ? ", " : "",
 			me->inA ? "A" : "");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
-	}
 	break;
 
     case HTML_FRAMESET:
@@ -5625,7 +5656,7 @@ PRIVATE void HTML_end_element ARGS3(
     case HTML_P:
 	LYHandleP(me,
 		 (CONST BOOL*)0, (CONST char **)0,
-		 include,
+		 (char **)&include,
 		 FALSE);
 	break;
 
@@ -5656,9 +5687,11 @@ PRIVATE void HTML_end_element ARGS3(
 	if (me->inUnderline && me->Underline_Level < 1) {
 	    HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR);
 	    me->inUnderline = FALSE;
-	    CTRACE(tfp, "Ending underline\n");
+	    if (TRACE)
+		fprintf(stderr,"Ending underline\n");
 	} else {
-	    CTRACE(tfp, "Underline Level is %d\n", me->Underline_Level);
+	    if (TRACE)
+		fprintf(stderr,"Underline Level is %d\n", me->Underline_Level);
 	}
 	break;
 
@@ -5754,8 +5787,11 @@ PRIVATE void HTML_end_element ARGS3(
     case HTML_MENU:
     case HTML_DIR:
 	me->List_Nesting_Level--;
-	CTRACE(tfp, "HTML_end_element: Reducing List Nesting Level to %d\n",
+	if (TRACE) {
+	    fprintf(stderr,
+		    "HTML_end_element: Reducing List Nesting Level to %d\n",
 		    me->List_Nesting_Level);
+	}
 	change_paragraph_style(me, me->sp->style);  /* Often won't really change */
 	UPDATE_STYLE;
 	if (me->List_Nesting_Level >= 0)
@@ -5879,7 +5915,8 @@ PRIVATE void HTML_end_element ARGS3(
 		 *  pass a dummy start tag to the SGML parser so that it
 		 *  will resume the accumulation of OBJECT content. - FM
 		 */
-		CTRACE(tfp, "HTML: Nested OBJECT tags.  Recycling.\n");
+		if (TRACE)
+		    fprintf(stderr, "HTML: Nested OBJECT tags.  Recycling.\n");
 		if (*include == NULL) {
 		    StrAllocCopy(*include, "<OBJECT>");
 		} else {
@@ -5898,12 +5935,13 @@ PRIVATE void HTML_end_element ARGS3(
 		 *  we have bad HTML or otherwise misparsed. - FM
 		 */
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
   "Bad HTML: Unmatched OBJECT start and end tags.  Discarding content:\n%s\n",
 			    me->object.data);
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		goto End_Object;
 	    }
@@ -5913,7 +5951,8 @@ PRIVATE void HTML_end_element ARGS3(
 	     *	assuming we weren't tripped up by comments
 	     *	or quoted attributes. - FM
 	     */
-	    CTRACE(tfp, "HTML:OBJECT content:\n%s\n", me->object.data);
+	    if (TRACE)
+		fprintf(stderr, "HTML:OBJECT content:\n%s\n", me->object.data);
 
 	    /*
 	     *	OBJECTs with DECLARE should be saved but
@@ -5926,7 +5965,8 @@ PRIVATE void HTML_end_element ARGS3(
 	    if (me->object_declare == TRUE) {
 		if (me->object_id && *me->object_id)
 		    LYHandleID(me, me->object_id);
-		CTRACE(tfp, "HTML: DECLAREd OBJECT.  Ignoring!\n");
+		if (TRACE)
+		    fprintf(stderr, "HTML: DECLAREd OBJECT.  Ignoring!\n");
 		goto End_Object;
 	    }
 
@@ -5939,7 +5979,8 @@ PRIVATE void HTML_end_element ARGS3(
 	    if (me->object_name != NULL) {
 		if (me->object_id && *me->object_id)
 		    LYHandleID(me, me->object_id);
-		CTRACE(tfp, "HTML: NAMEd OBJECT.  Ignoring!\n");
+		if (TRACE)
+		    fprintf(stderr, "HTML: NAMEd OBJECT.  Ignoring!\n");
 		goto End_Object;
 	    }
 
@@ -5965,19 +6006,22 @@ PRIVATE void HTML_end_element ARGS3(
 		    }
 		    StrAllocCat(data, "</OBJECT>");
 		    StrAllocCat(*include, data);
-		    CTRACE(tfp, "HTML: Recycling nested OBJECT%s.\n",
+		    if (TRACE)
+			fprintf(stderr, "HTML: Recycling nested OBJECT%s.\n",
 					(e > 1) ? "s" : "");
 		    FREE(data);
 		    goto End_Object;
 		} else {
 		    if (TRACE) {
-			fprintf(tfp,
+			fprintf(stderr,
      "Bad HTML: Unmatched OBJECT start and end tags.  Discarding content.\n");
+			goto End_Object;
 		    } else if (!me->inBadHTML) {
-			HTUserMsg(BAD_HTML_USE_TRACE);
+			_statusline(BAD_HTML_USE_TRACE);
 			me->inBadHTML = TRUE;
+			sleep(MessageSecs);
+			goto End_Object;
 		    }
-		    goto End_Object;
 		}
 	    }
 
@@ -5985,7 +6029,9 @@ PRIVATE void HTML_end_element ARGS3(
 	     *	If it's content has SHAPES, convert it to FIG. - FM
 	     */
 	    if (me->object_shapes == TRUE) {
-		CTRACE(tfp, "HTML: OBJECT has SHAPES.  Converting to FIG.\n");
+		if (TRACE)
+		    fprintf(stderr,
+		    "HTML: OBJECT has SHAPES.  Converting to FIG.\n");
 		StrAllocCat(*include, "<FIG ISOBJECT IMAGEMAP");
 		if (me->object_ismap == TRUE)
 		    StrAllocCat(*include, " IMAGEMAP");
@@ -6013,7 +6059,9 @@ PRIVATE void HTML_end_element ARGS3(
 	     *	convert it to IMG. - FM
 	     */
 	    if (me->object_usemap != NULL) {
-		CTRACE(tfp, "HTML: OBJECT has USEMAP.  Converting to IMG.\n");
+		if (TRACE)
+		    fprintf(stderr,
+		    "HTML: OBJECT has USEMAP.  Converting to IMG.\n");
 
 		StrAllocCat(*include, "<IMG ISOBJECT");
 		if (me->object_id != NULL) {
@@ -6170,10 +6218,11 @@ End_Object:
 	 */
 	if (!me->inFORM) {
 	    if (TRACE) {
-		fprintf(tfp, "Bad HTML: Unmatched FORM end tag\n");
+		fprintf(stderr, "Bad HTML: Unmatched FORM end tag\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	}
 
@@ -6190,16 +6239,17 @@ End_Object:
 	 */
 	if (me->inSELECT) {
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 		   "Bad HTML: Open SELECT at FORM end. Faking SELECT end tag. *****\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	    if (me->sp->tag_number != HTML_SELECT) {
 		SET_SKIP_STACK(HTML_SELECT);
 	    }
-	    HTML_end_element(me, HTML_SELECT, include);
+	    HTML_end_element(me, HTML_SELECT, (char **)&include);
 	}
 
 	/*
@@ -6248,10 +6298,11 @@ End_Object:
 	     */
 	    if (!me->inTEXTAREA) {
 		if (TRACE) {
-		    fprintf(tfp, "Bad HTML: Unmatched TEXTAREA end tag\n");
+		    fprintf(stderr, "Bad HTML: Unmatched TEXTAREA end tag\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		break;
 	    }
@@ -6427,10 +6478,11 @@ End_Object:
 	     */
 	    if (!me->inSELECT) {
 		if (TRACE) {
-		    fprintf(tfp, "Bad HTML: Unmatched SELECT end tag *****\n");
+		    fprintf(stderr, "Bad HTML: Unmatched SELECT end tag *****\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		break;
 	    }
@@ -6450,11 +6502,12 @@ End_Object:
 	     */
 	    if (!me->inFORM) {
 		if (TRACE) {
-		    fprintf(tfp,
+		    fprintf(stderr,
 			    "Bad HTML: SELECT end tag not within FORM element *****\n");
 		} else if (!me->inBadHTML) {
-		    HTUserMsg(BAD_HTML_USE_TRACE);
+		    _statusline(BAD_HTML_USE_TRACE);
 		    me->inBadHTML = TRUE;
+		    sleep(MessageSecs);
 		}
 		/*
 		 *  Hopefully won't crash, so we'll ignore it. - kw
@@ -6631,15 +6684,15 @@ End_Object:
 */
 	if (end)
 	    *end='\0';
-	hcode = hash_code(lookfrom && *lookfrom ? lookfrom : &tmp[1]);
-	CTRACE(tfp, "CSS:%s (trimmed %s, END_ELEMENT)\n", Style_className, tmp);
+	hcode=hash_code(lookfrom && *lookfrom ? lookfrom : &tmp[1]);
+	if (TRACE)
+	    fprintf(stderr, "CSS:%s (trimmed %s, END_ELEMENT)\n", Style_className, tmp);
     }
 
-#if defined(DICKEY_TEST)
     if (HTML_dtd.tags[element_number].contents != SGML_EMPTY)
-#endif
     {
-	CTRACE(tfp, "STYLE:end_element: ending non-EMPTY style\n");
+	if (TRACE)
+	    fprintf(stderr, "STYLE:end_element: ending non-EMPTY style\n");
 #if !defined(USE_HASH)
 	HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
 #else
@@ -6650,7 +6703,7 @@ End_Object:
 	{
 		char *dot=strrchr(Style_className,'.');
 		LYstrncpy(prevailing_class,
-			  dot ? (dot+1) : "",
+			  dot ? (char*)(dot+1) : "",
 			  (TEMPSTRINGSIZE - 1));
 	}
 #endif
@@ -6726,18 +6779,19 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	    HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR);
 	    me->inUnderline = FALSE;
 	    me->Underline_Level = 0;
-	    CTRACE(tfp,"HTML_free: Ending underline\n");
+	    if (TRACE)
+		fprintf(stderr,"HTML_free: Ending underline\n");
 	}
 	if (me->inA) {
-	    HTML_end_element(me, HTML_A, &include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	    me->inA = FALSE;
 	}
 	if (me->inFONT) {
-	    HTML_end_element(me, HTML_FONT, &include);
+	    HTML_end_element(me, HTML_FONT, (char **)&include);
 	    me->inFONT = FALSE;
 	}
 	if (me->inFORM) {
-	    HTML_end_element(me, HTML_FORM, &include);
+	    HTML_end_element(me, HTML_FORM, (char **)&include);
 	    me->inFORM = FALSE;
 	}
 	if (me->option.size > 0) {
@@ -6747,18 +6801,20 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	     *	have gone very wrong. - kw
 	     */
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 			"Bad HTML: SELECT or OPTION not ended properly *****\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	    HTChunkTerminate(&me->option);
 	    /*
 	     *	Output the left-over data as text, maybe it was invalid
 	     *	markup meant to be shown somewhere. - kw
 	     */
-	    CTRACE(tfp, "HTML_free: ***** leftover option data: %s\n",
+	    if (TRACE)
+		fprintf(stderr, "HTML_free: ***** leftover option data: %s\n",
 			me->option.data);
 	    HTML_put_string(me, me->option.data);
 	    HTChunkClear(&me->option);
@@ -6770,18 +6826,20 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	     *	have gone very wrong. - kw
 	     */
 	    if (TRACE) {
-		fprintf(tfp,
+		fprintf(stderr,
 			"Bad HTML: TEXTAREA not used properly *****\n");
 	    } else if (!me->inBadHTML) {
-		HTUserMsg(BAD_HTML_USE_TRACE);
+		_statusline(BAD_HTML_USE_TRACE);
 		me->inBadHTML = TRUE;
+		sleep(MessageSecs);
 	    }
 	    HTChunkTerminate(&me->textarea);
 	    /*
 	     *	Output the left-over data as text, maybe it was invalid
 	     *	markup meant to be shown somewhere. - kw
 	     */
-	    CTRACE(tfp, "HTML_free: ***** leftover textarea data: %s\n",
+	    if (TRACE)
+		fprintf(stderr, "HTML_free: ***** leftover textarea data: %s\n",
 			me->textarea.data);
 	    HTML_put_string(me, me->textarea.data);
 	    HTChunkClear(&me->textarea);
@@ -6794,14 +6852,14 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	if (!dump_output_immediately &&
 	    HText_sourceAnchors(me->text) < 1 &&
 	    HText_HiddenLinkCount(me->text) > 0) {
-	    HTML_start_element(me, HTML_P, 0, 0, -1, &include);
+	    HTML_start_element(me, HTML_P, 0, 0, -1, (char **)&include);
 	    HTML_put_character(me, '[');
-	    HTML_start_element(me, HTML_EM, 0, 0, -1, &include);
+	    HTML_start_element(me, HTML_EM, 0, 0, -1, (char **)&include);
 	    HTML_put_string(me,
 		"Document has only hidden links. Use the 'l'ist command.");
-	    HTML_end_element(me, HTML_EM, &include);
+	    HTML_end_element(me, HTML_EM, (char **)&include);
 	    HTML_put_character(me, ']');
-	    HTML_end_element(me, HTML_P, &include);
+	    HTML_end_element(me, HTML_P, (char **)&include);
 	}
 
 	/*
@@ -6816,15 +6874,16 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	 *  have gone very wrong. - kw
 	 */
 	if (TRACE) {
-	    fprintf(tfp,
+	    fprintf(stderr,
 		    "Bad HTML: SELECT or OPTION not ended properly *****\n");
 	} else if (!me->inBadHTML) {
-	    HTUserMsg(BAD_HTML_USE_TRACE);
+	    _statusline(BAD_HTML_USE_TRACE);
 	    me->inBadHTML = TRUE;
+	    sleep(MessageSecs);
 	}
 	if (TRACE) {
 	    HTChunkTerminate(&me->option);
-	    fprintf(tfp, "HTML_free: ***** leftover option data: %s\n",
+	    fprintf(stderr, "HTML_free: ***** leftover option data: %s\n",
 		    me->option.data);
 	}
 	HTChunkClear(&me->option);
@@ -6836,15 +6895,16 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me)
 	 *  have gone very wrong. - kw
 	 */
 	if (TRACE) {
-	    fprintf(tfp,
+	    fprintf(stderr,
 		    "Bad HTML: TEXTAREA not used properly *****\n");
 	} else if (!me->inBadHTML) {
-	    HTUserMsg(BAD_HTML_USE_TRACE);
+	    _statusline(BAD_HTML_USE_TRACE);
 	    me->inBadHTML = TRUE;
+	    sleep(MessageSecs);
 	}
 	if (TRACE) {
 	    HTChunkTerminate(&me->textarea);
-	    fprintf(tfp, "HTML_free: ***** leftover textarea data: %s\n",
+	    fprintf(stderr, "HTML_free: ***** leftover textarea data: %s\n",
 		    me->textarea.data);
 	}
 	HTChunkClear(&me->textarea);
@@ -6887,15 +6947,15 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
 	    me->Underline_Level = 0;
 	}
 	if (me->inA) {
-	    HTML_end_element(me, HTML_A, &include);
+	    HTML_end_element(me, HTML_A, (char **)&include);
 	    me->inA = FALSE;
 	}
 	if (me->inFONT) {
-	    HTML_end_element(me, HTML_FONT, &include);
+	    HTML_end_element(me, HTML_FONT, (char **)&include);
 	    me->inFONT = FALSE;
 	}
 	if (me->inFORM) {
-	    HTML_end_element(me, HTML_FORM, &include);
+	    HTML_end_element(me, HTML_FORM, (char **)&include);
 	    me->inFORM = FALSE;
 	}
 
@@ -6912,10 +6972,10 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
 	 *  have gone very wrong. - kw
 	 */
 	if (TRACE) {
-	    fprintf(tfp,
+	    fprintf(stderr,
 		    "HTML_abort: SELECT or OPTION not ended properly *****\n");
 	    HTChunkTerminate(&me->option);
-	    fprintf(tfp, "HTML_abort: ***** leftover option data: %s\n",
+	    fprintf(stderr, "HTML_abort: ***** leftover option data: %s\n",
 		    me->option.data);
 	}
 	HTChunkClear(&me->option);
@@ -6927,10 +6987,10 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
 	 *  have gone very wrong. - kw
 	 */
 	if (TRACE) {
-	    fprintf(tfp,
+	    fprintf(stderr,
 		    "HTML_abort: TEXTAREA not used properly *****\n");
 	    HTChunkTerminate(&me->textarea);
-	    fprintf(tfp, "HTML_abort: ***** leftover textarea data: %s\n",
+	    fprintf(stderr, "HTML_abort: ***** leftover textarea data: %s\n",
 		    me->textarea.data);
 	}
 	HTChunkClear(&me->textarea);
@@ -6967,7 +7027,6 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
 */
 PRIVATE void get_styles NOARGS
 {
-    styleSheet = DefaultStyle();
     default_style =		HTStyleNamed(styleSheet, "Normal");
 
     styles[HTML_H1] =		HTStyleNamed(styleSheet, "Heading1");
@@ -7034,17 +7093,6 @@ PRIVATE void get_styles NOARGS
     styles[HTML_LISTING] =	HTStyleNamed(styleSheet, "Listing");
 }
 
-/*
- * If we're called from another module, make sure we've initialized styles
- * array first.
- */
-PUBLIC  HTStyle *LYstyles ARGS1(int, style_number)
-{
-    if (styles[style_number] == 0)
-	get_styles();
-    return styles[style_number];
-}
-
 /*				P U B L I C
 */
 
@@ -7106,6 +7154,7 @@ PUBLIC HTStructured* HTML_new ARGS3(
      * array is not necessarily the same as it was from 'get_styles()'.  So
      * we reinitialize the whole thing.
      */
+    styleSheet = DefaultStyle();
     get_styles();
 
     me->isa = &HTMLPresentation;
@@ -7266,16 +7315,16 @@ PUBLIC HTStructured* HTML_new ARGS3(
 	    LYUCcharset *p_in = HTAnchor_getUCInfoStage(me->node_anchor,
 							UCT_STAGE_MIME);
 	    if (p_in->enc == UCT_ENC_CJK && HTCJK == NOCJK) {
-		HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1,
+		HTAnchor_resetUCInfoStage(me->node_anchor, 0,
 					  UCT_STAGE_MIME,
 					  UCT_SETBY_DEFAULT);
-		HTAnchor_setUCInfoStage(me->node_anchor, LATIN1,
+		HTAnchor_setUCInfoStage(me->node_anchor, 0,
 					UCT_STAGE_MIME,
 					UCT_SETBY_DEFAULT);
-		HTAnchor_resetUCInfoStage(me->node_anchor, LATIN1,
+		HTAnchor_resetUCInfoStage(me->node_anchor, 0,
 					  UCT_STAGE_PARSER,
 					  UCT_SETBY_DEFAULT);
-		HTAnchor_setUCInfoStage(me->node_anchor, LATIN1,
+		HTAnchor_setUCInfoStage(me->node_anchor, 0,
 					UCT_STAGE_PARSER,
 					UCT_SETBY_DEFAULT);
 	    }
@@ -7460,54 +7509,19 @@ PUBLIC int HTLoadError ARGS3(
     return -number;
 }
 
-PRIVATE char * MakeNewTitle ARGS2(CONST char **, value, int, src_type)
-{
-    char *ptr;
-    char *newtitle = NULL;
 
-    StrAllocCopy(newtitle, "[");
-    ptr = strrchr(value[src_type], '/');
-    if (!ptr) {
-	StrAllocCat(newtitle, value[src_type]);
-    } else {
-	StrAllocCat(newtitle, ptr + 1);
-    }
-    StrAllocCat(newtitle, "]");
-    return newtitle;
-}
-
-PRIVATE char * MakeNewImageValue ARGS1(CONST char **, value)
+PRIVATE char * MakeNewTitle(CONST char ** value)
 {
     char *ptr;
     char *newtitle = NULL;
 
     StrAllocCopy(newtitle, "[");
-    ptr = strrchr(value[HTML_INPUT_SRC], '/');
+    ptr = strrchr(value[HTML_IMG_SRC], '/');
     if (!ptr) {
-	StrAllocCat(newtitle, value[HTML_INPUT_SRC]);
+	StrAllocCat(newtitle, value[HTML_IMG_SRC]);
     } else {
 	StrAllocCat(newtitle, ptr + 1);
     }
-    StrAllocCat(newtitle, "]-Submit");
-    return newtitle;
-}
-
-PRIVATE char * MakeNewMapValue ARGS2(const char **, value, const char*, mapstr)
-{
-    char *ptr;
-    char *newtitle = NULL;
-
-    StrAllocCopy(newtitle, "[");
-    StrAllocCat(newtitle,mapstr); /* ISMAP or USEMAP */
-    if ( verbose_img ) {
-	StrAllocCat(newtitle,":");
-	ptr = strrchr(value[HTML_IMG_SRC], '/');
-	if (!ptr) {
-	    StrAllocCat(newtitle, value[HTML_IMG_SRC]);
-	} else {
-	    StrAllocCat(newtitle, ptr + 1);
-	}
-    }
     StrAllocCat(newtitle, "]");
     return newtitle;
 }