about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-09-13 14:41:19 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1998-09-13 14:41:19 -0400
commit02f2851492143446abaaa33cc9536fade7b51124 (patch)
tree613e06824c47ca1592dd53eab57ed1ddb1409404 /WWW
parent5816641fc3a761e00d154c4dea9551a0027a7c63 (diff)
downloadlynx-snapshots-02f2851492143446abaaa33cc9536fade7b51124.tar.gz
snapshot of project "lynx", label v2-8-1dev_26
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTAnchor.c25
-rw-r--r--WWW/Library/Implementation/HTFile.c36
-rw-r--r--WWW/Library/Implementation/HTFormat.c8
-rw-r--r--WWW/Library/Implementation/HTMIME.c48
-rw-r--r--WWW/Library/Implementation/HTPlain.c2
-rw-r--r--WWW/Library/Implementation/HTTCP.c246
-rw-r--r--WWW/Library/Implementation/HTUtils.h4
-rw-r--r--WWW/Library/Implementation/SGML.c4
-rw-r--r--WWW/Library/Implementation/UCMap.h40
9 files changed, 219 insertions, 194 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 59b4cd50..ec332eb3 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -1179,7 +1179,7 @@ PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2(
 {
     if (me && !me->UCStages) {
 	int i;
-	int chndl = UCLYhndl_for_unspec;
+	int chndl = UCLYhndl_for_unspec;  /* always >= 0 */
 	UCAnchorInfo * stages = (UCAnchorInfo*)calloc(1,
 						      sizeof(UCAnchorInfo));
 	if (stages == NULL)
@@ -1190,21 +1190,18 @@ PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2(
 	}
 	if (me->charset) {
 	    chndl = UCGetLYhndl_byMIME(me->charset);
-	    if (chndl < 0) {
+	    if (chndl < 0)
 		chndl = UCLYhndl_for_unrec;
-	    }
-	}
-	if (chndl >= 0) {
-	    memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl],
-		   sizeof(LYUCcharset));
-	    stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT;
-	} else {
-	    /*
-	     *	Should not happen...
-	     */
-	    stages->s[UCT_STAGE_MIME].C.UChndl = -1;
-	    stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_NONE;
+	    if (chndl < 0)
+		/*
+		**  UCLYhndl_for_unrec not defined :-(
+		**  fallback to UCLYhndl_for_unspec which always valid.
+		*/
+		chndl = UCLYhndl_for_unspec;  /* always >= 0 */
 	}
+	memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl],
+	       sizeof(LYUCcharset));
+	stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT;
 	stages->s[UCT_STAGE_MIME].LYhndl = chndl;
 	me->UCStages = stages;
     }
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index c530db85..3ede11c9 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -900,6 +900,12 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
 	    **	Got something but we don't recognize it.
 	    */
 	    chndl = UCLYhndl_for_unrec;
+	    if (chndl < 0)
+	    /*
+	    **  UCLYhndl_for_unrec not defined :-(
+	    **  fallback to UCLYhndl_for_unspec which always valid.
+	    */
+	    chndl = UCLYhndl_for_unspec;  /* always >= 0 */
 	    if (UCCanTranslateFromTo(chndl, current_char_set)) {
 		chartrans_ok = YES;
 		HTAnchor_setUCInfoStage(anchor, chndl,
@@ -944,35 +950,9 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
 		    HTPassEightBitRaw = TRUE;
 		}
 	    } else if (p_out->enc == UCT_ENC_CJK) {
-		if (LYRawMode) {
-		    if ((!strcmp(p_in->MIMEname, "euc-jp") ||
-			 !strcmp(p_in->MIMEname, "shift_jis")) &&
-			(!strcmp(p_out->MIMEname, "euc-jp") ||
-			 !strcmp(p_out->MIMEname, "shift_jis"))) {
-			HTCJK = JAPANESE;
-		    } else if (!strcmp(p_in->MIMEname, "euc-cn") &&
-			       !strcmp(p_out->MIMEname, "euc-cn")) {
-			HTCJK = CHINESE;
-		    } else if (!strcmp(p_in->MIMEname, "big-5") &&
-			       !strcmp(p_out->MIMEname, "big-5")) {
-			HTCJK = TAIPEI;
-		    } else if (!strcmp(p_in->MIMEname, "euc-kr") &&
-			       !strcmp(p_out->MIMEname, "euc-kr")) {
-			HTCJK = KOREAN;
-		    } else {
-			HTCJK = NOCJK;
-		    }
-		} else {
-		    HTCJK = NOCJK;
-		}
+		Set_HTCJK(p_in->MIMEname, p_out->MIMEname);
 	    }
-	/*
-	**  Check for an iso-8859-# we don't know. - FM
-	*/
-	} else if (!strncmp(cp4, "iso-8859-", 9) &&
-		   isdigit((unsigned char)cp4[9]) &&
-		   !strncmp(LYchar_set_names[current_char_set],
-			    "Other ISO Latin", 15)) {
+	} else {
 	    /*
 	    **	Hope it's a match, for now. - FM
 	    */
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index e1c9a851..899b8640 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -503,9 +503,11 @@ PRIVATE void HTDisplayPartial NOARGS
 		/* new hypertext document available  */
 	&& ((Newline_partial + display_lines) > NumOfLines_partial)
 		/* current page not complete... */
-	&& ((Newline_partial + 2)  < HText_getNumOfLines())) {
-		/* and we MAY display at least a couple of lines on the top.
-		 *
+	&& ((Newline_partial + display_lines)  < HText_getNumOfLines())) {
+		/*             ^^^^^^^^^^^^^
+		 * and we MAY display the page in one stage:
+		 * incremental rendering of the first page reported annoying
+		 * on slow network connection.
 		 */
 	    NumOfLines_partial = HText_getNumOfLines();
 	    HText_pageDisplay(Newline_partial, "");
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 82c0c8f1..d7b11a15 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -360,6 +360,13 @@ PRIVATE void HTMIME_put_character ARGS2(
 			    else if (chndl < 0) {/* got something but we don't
 						 recognize it */
 				chndl = UCLYhndl_for_unrec;
+				if (chndl < 0)
+				/*
+				 **  UCLYhndl_for_unrec not defined :-(
+				 **  fallback to UCLYhndl_for_unspec
+				 **  which always valid.
+				 */
+				chndl = UCLYhndl_for_unspec;  /* always >= 0 */
 				if (UCCanTranslateFromTo(chndl,
 							 current_char_set)) {
 				    chartrans_ok = YES;
@@ -414,46 +421,9 @@ PRIVATE void HTMIME_put_character ARGS2(
 					HTPassEightBitRaw = TRUE;
 				    }
 				} else if (p_out->enc == UCT_ENC_CJK) {
-				    if (LYRawMode) {
-					if ((!strcmp(p_in->MIMEname,
-						     "euc-jp") ||
-					     !strcmp(p_in->MIMEname,
-						     "shift_jis")) &&
-					    (!strcmp(p_out->MIMEname,
-						     "euc-jp") ||
-					     !strcmp(p_out->MIMEname,
-						     "shift_jis"))) {
-					    HTCJK = JAPANESE;
-					} else if (!strcmp(p_in->MIMEname,
-							   "euc-cn") &&
-						   !strcmp(p_out->MIMEname,
-							   "euc-cn")) {
-					    HTCJK = CHINESE;
-					} else if (!strcmp(p_in->MIMEname,
-							   "big-5") &&
-						   !strcmp(p_out->MIMEname,
-							   "big-5")) {
-					    HTCJK = TAIPEI;
-					} else if (!strcmp(p_in->MIMEname,
-							   "euc-kr") &&
-						   !strcmp(p_out->MIMEname,
-							   "euc-kr")) {
-					    HTCJK = KOREAN;
-					} else {
-					    HTCJK = NOCJK;
-					}
-				    } else {
-					HTCJK = NOCJK;
-				    }
+				    Set_HTCJK(p_in->MIMEname, p_out->MIMEname);
 				}
-			    /*
-			    **  Check for an iso-8859-# we don't know. - FM
-			    */
-			    } else if
-			       (!strncmp(cp4, "iso-8859-", 9) &&
-				isdigit((unsigned char)cp4[9]) &&
-				!strncmp(LYchar_set_names[current_char_set],
-					 "Other ISO Latin", 15)) {
+			    } else {
 				/*
 				**  Hope it's a match, for now. - FM
 				*/
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index 2744b7df..f46616f7 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -155,7 +155,7 @@ PRIVATE void HTPlain_put_character ARGS2(
 	HText_appendCharacter(me->text, c);
     } else if ((unsigned char)c > 160) {
 	if (!HTPassEightBitRaw &&
-	    !((me->outUCLYhndl == 0) ||
+	    !((me->outUCLYhndl == LATIN1) ||
 	      (me->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1)))) {
 	    int len, high, low, i, diff = 1;
 	    CONST char * name;
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 2eb3b458..76447fe0 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -121,7 +121,7 @@ extern int sys_nerr;
 
 unsigned long _fork_func (void *arglist)
 {
-		  return (unsigned long)(phost = gethostbyname(host));
+    return (unsigned long)(phost = gethostbyname(host));
 }
 #endif /* _WINDOWS_NSL */
 
@@ -324,15 +324,16 @@ PUBLIC int HTParseInet ARGS2(
 {
     char *port;
     int dotcount_ip = 0;	/* for dotted decimal IP addr */
+    int success = 0;
 #ifndef _WINDOWS_NSL
     char *host = NULL;
-    struct hostent  *phost;	/* Pointer to host - See netdb.h */
 #endif /* _WINDOWS_NSL */
 
     if (!str) {
 	CTRACE(tfp, "HTParseInet: Can't parse `NULL'.\n");
 	return -1;
     }
+    CTRACE(tfp, "HTParseInet: parsing `%s'.\n", str);
     if (HTCheckForInterrupt()) {
 	CTRACE (tfp, "HTParseInet: INTERRUPTED for '%s'.\n", str);
 	return -1;
@@ -428,48 +429,120 @@ PUBLIC int HTParseInet ARGS2(
 	*/
 	{
 	    /*
-	    **	Pipe, child pid, and status buffers.
+	    **	Pipe, child pid, status buffers, cycle count, select()
+	    **	control variables.
 	    */
 	    pid_t fpid, waitret = (pid_t)0;
-	    int pfd[2], cstat, cst1 = 0;
+	    int pfd[2], cstat, cst1 = 0, cycle = 0;
+	    fd_set readfds;
+	    struct timeval timeout;
 
 	    pipe(pfd);
 
 	    if ((fpid = fork()) == 0 ) {
+		struct hostent  *phost;	/* Pointer to host - See netdb.h */
 		/*
 		**  Child - for the long call.
+		**  Child won't use read side.  -BL
 		*/
+		close(pfd[0]);
 		phost = gethostbyname(host);
-		cst1 = 0;
+#ifdef MVS
+		CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
+#endif /* MVS */
+
 		/*
-		**  Return value (or nulls).
+		**  Send length of subsequent value to parent (as a
+		**  native int).
 		*/
-		if (OK_HOST(phost)) {
+		if (OK_HOST(phost))
+			cstat = phost->h_length;
+		else
+			cstat = 0;
+		write(pfd[1], &cstat, sizeof cstat);
+
+		if (cstat) {
+		    /*
+		    **  Return value through pipe...
+		    */
 		    write(pfd[1], phost->h_addr, phost->h_length);
 		    _exit(0);
 		} else {
-		    write(pfd[1], &cst1, 4);
-		    _exit(1);	/* return an error code */
+		    /*
+		    **  ... or return error as exit code.
+		    */
+		    _exit(1);
 		}
 	    }
 
 	    /*
-	    **	(parent) Wait until lookup finishes, or interrupt.
+	    **	(parent) Wait until lookup finishes, or interrupt,
+	    **	or cycled too many times (just in case) -BL
 	    */
-	    cstat = 0;
-	    while (cstat <= 0) {
+
+	    close(pfd[1]);      /* parent won't use write side -BL */
+
+	    while (cycle < 50) {
+		/*
+		**  Avoid infinite loop in the face of the unexpected.  -BL
+		*/
+		cycle++;
+
+		timeout.tv_sec = 1;
+		timeout.tv_usec = 0;
+		FD_ZERO(&readfds);
+		FD_SET(pfd[0], &readfds);
+#ifndef USE_SLANG
+		/*
+		**  This allows us to abort immediately, not after 1-second
+		**  timeout, when user hits abort key.  Can't do this when
+		**  using SLANG (or at least I don't know how), so SLANG
+		**  users must live with up-to-1s timeout.  -BL
+		*/
+		FD_SET(0, &readfds);    /* stdin -BL */
+#endif /* USE_SLANG */
+
 		/*
-		**  Exit when data sent.
+		**  Return when data received, interrupted, or failed.
+		**  If nothing is waiting, we sleep for 1 second in
+		**  select(), to be nice to the system.  -BL
 		*/
-		IOCTL(pfd[0], FIONREAD, &cstat);
-		if (cstat > 0)
+#ifdef SOCKS
+		if (socks_flag)
+		    cst1 = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout);
+		else
+#endif /* SOCKS */
+		    cst1 = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, &timeout);
+
+		if ((cst1 > 0) && FD_ISSET(pfd[0], &readfds)) {
+		    /*
+		    **	First get length of address.  -BL
+		    */
+		    cst1 = read(pfd[0], (void *)&cstat, sizeof cstat);
+		    if (cstat == sizeof soc_in->sin_addr) {
+			/*
+			**  Then get address itself.  -BL
+			*/
+			cst1 = read(pfd[0], (void *)&soc_in->sin_addr, cstat);
+			if (cst1 == cstat) success = 1;
+	    	    }
+		    /*
+		    **  Make sure child is cleaned up.  -BL
+		    */
+		    waitret = waitpid(fpid, &cst1, WNOHANG);
+		    if (!WIFEXITED(cst1) && !WIFSIGNALED(cst1)) {
+			kill(fpid, SIGKILL);
+			waitret = waitpid(fpid, &cst1, WNOHANG);
+		    }
 		    break;
+	    	}
+
 		/*
-		**  Exit if child exited.
+		**  End loop if child exited.
 		*/
-		if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0) {
+		if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0)
 		    break;
-		}
+
 		/*
 		**  Abort if interrupt key pressed.
 		*/
@@ -479,83 +552,43 @@ PUBLIC int HTParseInet ARGS2(
 		    waitpid(fpid, NULL, 0);
 		    FREE(host);
 		    close(pfd[0]);
-		    close(pfd[1]);
 		    return HT_INTERRUPTED;
 		}
-		/*
-		**  Be nice to the system.
-		*/
-		sleep(1);
 	    }
+	    close(pfd[0]);
 	    if (waitret <= 0) {
 		waitret = waitpid(fpid, &cst1, WNOHANG);
 	    }
-	    if (WIFEXITED(cst1)) {
-		CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n",
-			    (int)waitret, cst1);
-	    } else if (WIFSIGNALED(cst1)) {
-		CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n",
-			    (int)waitret, cst1);
+	    if (waitret > 0) {
+		if (WIFEXITED(cst1)) {
+		    CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n",
+				(int)waitret, cst1);
+		} else if (WIFSIGNALED(cst1)) {
+		    CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n",
+				(int)waitret, cst1);
 #ifdef WCOREDUMP
-		if (WCOREDUMP(cst1)) {
-		    CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped core!\n",
-				(int)waitret);
+		    if (WCOREDUMP(cst1)) {
+			CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped core!\n",
+				    (int)waitret);
 		    }
 #endif /* WCOREDUMP */
-	    } else if (WIFSTOPPED(cst1)) {
-		CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n",
-			    (int)waitret, cst1);
-	    }
-	    /*
-	    **	Read as much as we can - should be the address.
-	    */
-	    IOCTL(pfd[0], FIONREAD, &cstat);
-	    if (cstat < 4) {
-		CTRACE(tfp, "HTParseInet: NSL_FORK child returns only %d bytes.\n",
-			    cstat);
-		CTRACE(tfp, "             Trying again without forking.\n");
-		phost = gethostbyname(host);	/* See netdb.h */
-		if (!OK_HOST(phost)) {
-		    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
-				host);
-		    memset((void *)&soc_in->sin_addr, 0, sizeof(soc_in->sin_addr));
-		} else {
-		    memcpy((void *)&soc_in->sin_addr,
-			   phost->h_addr, phost->h_length);
+		} else if (WIFSTOPPED(cst1)) {
+		    CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n",
+				(int)waitret, cst1);
 		}
-#ifdef NOTDEFINED
-		cstat = read(pfd[0], (void *)&soc_in->sin_addr , 4);
-#endif /* NOTDEFINED */
-	    } else {
-		cstat = read(pfd[0], (void *)&soc_in->sin_addr , cstat);
 	    }
-	    close(pfd[0]);
-	    close(pfd[1]);
-	}
-	if (soc_in->sin_addr.s_addr == 0) {
-	    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
-			host);
-#ifndef _WINDOWS_NSL
-	    FREE(host);
-#endif /* _WINDOWS_NSL */
-	    return -1;
+	    if (!success) {
+		memset((void *)&soc_in->sin_addr, 0, sizeof(soc_in->sin_addr));
+		goto failed;
+	    }
 	}
-#ifndef _WINDOWS_NSL
-	FREE(host);
-#endif /* _WINDOWS_NSL */
-#ifdef MVS
-	CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
-#endif /* MVS */
-
 #else /* Not NSL_FORK: */
 #ifdef DJGPP
 	soc_in->sin_addr.s_addr = htonl(resolve(host));
-	FREE(host);
 	if (soc_in->sin_addr.s_addr == 0) {
-	    CTRACE(tfp, "HTTPAccess: Can't find internet node name `%s'.\n",host);
-	    return -1;  /* Fail? */
+	    goto failed;
 	}
-#else
+#else /* !NSL_FORK, !DJGPP: */
 #ifdef _WINDOWS_NSL
 	{
 #ifdef __BORLANDC__
@@ -585,38 +618,35 @@ PUBLIC int HTParseInet ARGS2(
 			  return HT_INTERRUPTED;
 			};
 	};
-#else /* !_WINDOWS_NSL */
-	phost = gethostbyname(host);	/* See netdb.h */
-#endif /* _WINDOWS_NSL */
+#else /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL: */
+	{
+	    struct hostent  *phost;
+	    phost = gethostbyname(host);	/* See netdb.h */
 #ifdef MVS
-	CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
+	    CTRACE(tfp, "HTParseInet: gethostbyname() returned %d\n", phost);
 #endif /* MVS */
-	if (!phost) {
-	    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
-			host);
-#ifndef _WINDOWS_NSL
-	    FREE(host);
-#endif /* _WINDOWS_NSL */
-	    return -1;	/* Fail? */
+	    if (!phost) goto failed;
+#if defined(VMS) && defined(CMU_TCP)
+	    /*
+	    **  In LIBCMU, phost->h_length contains not the length of one address
+	    **  (four bytes) but the number of bytes in *h_addr, i.e. some multiple
+	    **  of four. Thus we need to hard code the value here, and remember to
+	    **  change it if/when IP addresses change in size. :-(	LIBCMU is no
+	    **  longer supported, and CMU users are encouraged to obtain and use
+	    **  SOCKETSHR/NETLIB instead. - S. Bjorndahl
+	    */
+	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4);
+#else
+	    memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
+#endif /* VMS && CMU_TCP */
 	}
+#endif /* !NSL_FORK, !DJGPP, !_WINDOWS_NSL */
+#endif /* !NSL_FORK, !DJGPP */
+#endif /* !NSL_FORK */
 #ifndef _WINDOWS_NSL
 	FREE(host);
 #endif /* _WINDOWS_NSL */
-#if defined(VMS) && defined(CMU_TCP)
-	/*
-	**  In LIBCMU, phost->h_length contains not the length of one address
-	**  (four bytes) but the number of bytes in *h_addr, i.e. some multiple
-	**  of four. Thus we need to hard code the value here, and remember to
-	**  change it if/when IP addresses change in size. :-(	LIBCMU is no
-	**  longer supported, and CMU users are encouraged to obtain and use
-	**  SOCKETSHR/NETLIB instead. - S. Bjorndahl
-	*/
-	memcpy((void *)&soc_in->sin_addr, phost->h_addr, 4);
-#else
-	memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length);
-#endif /* VMS && CMU_TCP */
-#endif /* DJGPP */
-#endif /* NSL_FORK */
+
     }
 
     CTRACE(tfp, "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
@@ -628,6 +658,14 @@ PUBLIC int HTParseInet ARGS2(
 #endif	/* Internet vs. Decnet */
 
     return 0;	/* OK */
+
+failed:
+    CTRACE(tfp, "HTParseInet: Can't find internet node name `%s'.\n",
+		host);
+#ifndef _WINDOWS_NSL
+    FREE(host);
+#endif /* _WINDOWS_NSL */
+    return -1;
 }
 
 /*	Free our name for the host on which we are - FM
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 100dd390..a4afa28b 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -79,6 +79,10 @@
 
 #endif /* HAVE_CONFIG_H */ 
 
+#ifndef LY_MAXPATH
+#define LY_MAXPATH 256
+#endif
+
 #ifndef	GCC_UNUSED
 #define	GCC_UNUSED /* nothing */
 #endif
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 20aaa33e..5ecbf3ea 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -196,7 +196,7 @@ PRIVATE void set_chartrans_handling ARGS3(
 	       context->T.trans_from_uni) {
 	context->current_tag_charset = UCGetLYhndl_byMIME("utf-8");
     } else {
-	context->current_tag_charset = 0;
+	context->current_tag_charset = LATIN1;
     }
 }
 
@@ -396,7 +396,7 @@ PRIVATE char replace_buf [64];	      /* buffer for replacement strings */
 PRIVATE BOOL FoundEntity = FALSE;
 
 #define IncludesLatin1Enc \
-		(context->outUCLYhndl == 0 || \
+		(context->outUCLYhndl == LATIN1 || \
 		 (context->outUCI && \
 		  (context->outUCI->enc & (UCT_CP_SUPERSETOF_LAT1))))
 
diff --git a/WWW/Library/Implementation/UCMap.h b/WWW/Library/Implementation/UCMap.h
index 5a8c1210..23d88515 100644
--- a/WWW/Library/Implementation/UCMap.h
+++ b/WWW/Library/Implementation/UCMap.h
@@ -1,4 +1,3 @@
-
 #ifndef UCMAP_H
 #define UCMAP_H
 
@@ -33,16 +32,51 @@ extern int UCTransCharStr PARAMS((
 extern UCode_t UCTransToUni PARAMS((
 	char		ch_in,
 	int		charset_in));
-extern int UCGetLYhndl_byMIME PARAMS((
-	CONST char *	p));
 extern int UCGetRawUniMode_byLYhndl PARAMS((
 	int		i));
+extern int UCGetLYhndl_byMIME PARAMS((
+	CONST char *	p)); /* returns -1 if name not recognized */
+extern int safeUCGetLYhndl_byMIME PARAMS((
+	CONST char *	p)); /* returns LATIN1 if MIME name not recognized */
 
 extern int UCLYhndl_for_unspec;
 extern int UCLYhndl_for_unrec;
 extern int UCLYhndl_HTFile_for_unspec;
 extern int UCLYhndl_HTFile_for_unrec;
 
+/* easy to type: */
+#define LATIN1   UCGetLYhndl_byMIME("iso-8859-1")
+
+/*
+In general, Lynx translates letters from document charset to display charset.
+If document charset is not specified or not recognized by Lynx, we fall back
+to different assumptions below, read also lynx.cfg for info.
+
+UCLYhndl_for_unspec -  assume this as charset for documents that don't
+                       specify a charset parameter in HTTP headers or via META
+                       this corresponds to "assume_charset"
+
+UCLYhndl_HTFile_for_unspec -  assume this as charset of local file
+                       this corresponds to "assume_local_charset"
+
+UCLYhndl_for_unrec  -  in case a charset parameter is not recognized;
+                       this corresponds to "assume_unrec_charset"
+
+UCLYhndl_HTFile_for_unrec  - the same but only for local files,
+                             currently not used.
+
+
+current_char_set  -	this corresponds to "display charset",
+			declared in LYCharSets.c and really important.
+
+All external charset information is available in so called MIME format.
+For internal needs Lynx uses charset handlers as integers
+from UCGetLYhndl_byMIME().  However, there is no way to recover
+from user's error in configuration file lynx.cfg or command line switches,
+those unrecognized MIME names are assumed as LATIN1 (via safeUCGetLYhndl...).
+*/
+
+
 #define UCTRANS_NOTFOUND (-4)
 
 #endif /* UCMAP_H */