about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2004-12-30 12:20:28 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2004-12-30 12:20:28 -0500
commitbed9a2c79bfdde6e4ec89d9d02a5d6e88ae12f79 (patch)
treedd916bd7c1040bd69a1fe9f9ed1aa98d44ca623d /WWW
parentb52ca53f448d0f9c01708a6ce2b03be3a71d3993 (diff)
downloadlynx-snapshots-bed9a2c79bfdde6e4ec89d9d02a5d6e88ae12f79.tar.gz
snapshot of project "lynx", label v2-8-6dev_9
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTAccess.c2
-rw-r--r--WWW/Library/Implementation/HTDOS.c51
-rw-r--r--WWW/Library/Implementation/HTDOS.h7
-rw-r--r--WWW/Library/Implementation/HTFTP.c156
-rw-r--r--WWW/Library/Implementation/HTFile.c9
-rw-r--r--WWW/Library/Implementation/HTFormat.c6
-rw-r--r--WWW/Library/Implementation/HTNews.c1
-rw-r--r--WWW/Library/Implementation/HTNews.h2
-rw-r--r--WWW/Library/Implementation/HTParse.c6
-rw-r--r--WWW/Library/Implementation/HTPlain.c4
-rw-r--r--WWW/Library/Implementation/HTTCP.c2
-rw-r--r--WWW/Library/Implementation/HTTP.c2
-rw-r--r--WWW/Library/Implementation/HTUtils.h28
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c2
-rw-r--r--WWW/Library/Implementation/HTVMS_WaisUI.c2
-rw-r--r--WWW/Library/Implementation/HTWSRC.c6
-rw-r--r--WWW/Library/Implementation/LYexit.h1
-rw-r--r--WWW/Library/Implementation/SGML.c10
18 files changed, 179 insertions, 118 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 443891c8..8deb5162 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1077,7 +1077,7 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
 	fprintf(stderr,
 		gettext("**** HTAccess: Internal software error.  Please mail lynx-dev@nongnu.org!\n"));
 	fprintf(stderr, gettext("**** HTAccess: Status returned was: %d\n"), status);
-	exit(EXIT_FAILURE);
+	exit_immediately(EXIT_FAILURE);
     }
 
     /* Failure in accessing a document */
diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c
index c5c2fb83..d560954c 100644
--- a/WWW/Library/Implementation/HTDOS.c
+++ b/WWW/Library/Implementation/HTDOS.c
@@ -167,33 +167,45 @@ char *HTDOS_short_name(char *path)
 }
 #endif
 
-#if defined(DJGPP) && defined(DJGPP_KEYHANDLER)
+#if defined(DJGPP)
+/*
+ * Poll tcp/ip lib and yield to DPMI-host while nothing in
+ * keyboard buffer (head = tail) (simpler than kbhit).
+ * This is required to be able to finish off dead sockets,
+ * answer pings etc.
+ */
+#include <pc.h>
+#include <dpmi.h>
+#include <libc/farptrgs.h>
+#include <go32.h>
+
+void djgpp_idle_loop(void)
+{
+    while (_farpeekw(_dos_ds, 0x41a) == _farpeekw(_dos_ds, 0x41c)) {
+	tcp_tick(NULL);
+	__dpmi_yield();
+#if defined(USE_SLANG)
+	if (SLang_input_pending(1))
+	    break;
+#endif
+    }
+}
+
 /* PUBLIC       getxkey()
  *              Replaces libc's getxkey() with polling of tcp/ip
- *              library (WatTcp or Watt-32). This is required to
- *              be able to finish off dead sockets, answer pings etc.
- *
+ *              library (WatTcp or Watt-32). *
  * ON EXIT:
  *      returns extended keypress.
  */
 
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
-#include <pc.h>
-#include <dpmi.h>
-#include <libc/farptrgs.h>
-#include <go32.h>
 
 int getxkey(void)
 {
+#if defined(DJGPP_KEYHANDLER)
     __dpmi_regs r;
 
-    /* poll tcp/ip lib and yield to DPMI-host while nothing in
-     * keyboard buffer (head = tail) (simpler than kbhit).
-     */
-    while (_farpeekw(_dos_ds, 0x41a) == _farpeekw(_dos_ds, 0x41c)) {
-	tcp_tick(NULL);
-	__dpmi_yield();
-    }
+    djgpp_idle_loop();
 
     r.h.ah = 0x10;
     __dpmi_int(0x16, &r);
@@ -203,5 +215,12 @@ int getxkey(void)
     if (r.h.al == 0xe0)
 	return 0x0200 | r.h.ah;
     return r.h.al;
+
+#elif defined(USE_SLANG)
+    djgpp_idle_loop();
+    return SLkp_getkey();
+#else
+    /* PDcurses uses myGetChar() in LYString.c */
+#endif
 }
-#endif /* DJGPP && DJGPP_KEYHANDLER */
+#endif /* DJGPP */
diff --git a/WWW/Library/Implementation/HTDOS.h b/WWW/Library/Implementation/HTDOS.h
index a0021d0a..188b9794 100644
--- a/WWW/Library/Implementation/HTDOS.h
+++ b/WWW/Library/Implementation/HTDOS.h
@@ -42,4 +42,11 @@ char *HTDOS_short_name(char *fn);
 #define HTDOS_short_name(fn)  fn
 #endif
 
+#ifdef DJGPP
+/*
+ * Poll tcp/ip lib and yield to DPMI-host while nothing in
+ * keyboard buffer (head = tail) (simpler than kbhit).
+ */
+void djgpp_idle_loop(void);
+#endif
 #endif /*  HTDOS_H */
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 49e2279b..1cb75232 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -144,6 +144,14 @@ static char *last_username_and_host = NULL;
 #define BROKEN_PROFTPD 1
 static int ProFTPD_bugs = FALSE;
 
+/*
+ * wu-ftpd 2.6.2(12) is known to have a broken implementation of EPSV.  The
+ * server will hang for a long time when we attempt to connect after issuing
+ * this command - TD 2004/12/28
+ */
+#define BROKEN_WUFTPD 1
+static int WU_FTPD_bugs = FALSE;
+
 typedef enum {
     GENERIC_SERVER
     ,MACHTEN_SERVER
@@ -219,14 +227,12 @@ static void free_FTPGlobals(void)
 char *HTVMS_name(const char *nn,
 		 const char *fn)
 {
-
-/*	We try converting the filename into Files-11 syntax.  That is, we assume
- *	first that the file is, like us, on a VMS node.  We try remote
- *	(or local) DECnet access.  Files-11, VMS, VAX and DECnet
- *	are trademarks of Digital Equipment Corporation.
- *	The node is assumed to be local if the hostname WITHOUT DOMAIN
- *	matches the local one. @@@
- */
+    /* We try converting the filename into Files-11 syntax.  That is, we assume
+     * first that the file is, like us, on a VMS node.  We try remote (or
+     * local) DECnet access.  Files-11, VMS, VAX and DECnet are trademarks of
+     * Digital Equipment Corporation.  The node is assumed to be local if the
+     * hostname WITHOUT DOMAIN matches the local one.  @@@
+     */
     static char *vmsname;
     char *filename = (char *) malloc(strlen(fn) + 1);
     char *nodename = (char *) malloc(strlen(nn) + 2 + 1);	/* Copies to hack */
@@ -395,7 +401,7 @@ static int write_cmd(const char *cmd)
 
     if (!control) {
 	CTRACE((tfp, "HTFTP: No control connection set up!!\n"));
-	return -99;
+	return HT_NO_CONNECTION;
     }
 
     if (cmd) {
@@ -494,6 +500,13 @@ static int response(const char *cmd)
 		    CTRACE((tfp, "This server is broken (RETR)\n"));
 		}
 #endif
+#ifdef BROKEN_WUFTPD
+		if (result == 220 && LYstrstr(response_text,
+					      "(Version wu-2.6.2-12)")) {
+		    WU_FTPD_bugs = TRUE;
+		    CTRACE((tfp, "This server is broken (EPSV)\n"));
+		}
+#endif
 		break;
 	    }
 	    /* if end of line */
@@ -579,7 +592,6 @@ static int set_mac_binary(eServerType ServerType)
 
 static void get_ftp_pwd(eServerType *ServerType, BOOLEAN *UseList)
 {
-
     char *cp;
 
     /* get the working directory (to see what it looks like) */
@@ -634,7 +646,6 @@ static void get_ftp_pwd(eServerType *ServerType, BOOLEAN *UseList)
 
 static void set_unix_dirstyle(eServerType *ServerType, BOOLEAN *UseList)
 {
-
     char *cp;
 
     /* This is a toggle.  It seems we have to toggle in order to see
@@ -866,30 +877,27 @@ static int get_connection(const char *arg,
 	    /*
 	     * Create and send a mail address as the password. - FM
 	     */
+	    char *the_address;
 	    char *user = NULL;
 	    const char *host = NULL;
 	    char *cp;
 
-	    if (personal_mail_address && *personal_mail_address) {
-		/*
-		 * We have a non-zero length personal
-		 * mail address, so use that. - FM
-		 */
-		StrAllocCopy(user, personal_mail_address);
-		if ((cp = strchr(user, '@')) != NULL) {
-		    *cp++ = '\0';
-		    host = cp;
-		} else {
+	    the_address = anonftp_password;
+	    if (isEmpty(the_address))
+		the_address = personal_mail_address;
+	    if (isEmpty(the_address))
+		the_address = LYGetEnv("USER");
+	    if (isEmpty(the_address))
+		the_address = "WWWuser";
+
+	    StrAllocCopy(user, the_address);
+	    if ((cp = strchr(user, '@')) != NULL) {
+		*cp++ = '\0';
+		if (*cp == '\0')
 		    host = HTHostName();
-		}
-	    } else {
-		/*
-		 * Use an environment variable and the host global. - FM
-		 */
-		if ((cp = LYGetEnv("USER")) != NULL)
-		    StrAllocCopy(user, cp);
 		else
-		    StrAllocCopy(user, "WWWuser");
+		    host = cp;
+	    } else {
 		host = HTHostName();
 	    }
 
@@ -1810,7 +1818,7 @@ static void parse_vms_dir_entry(char *line,
     }
 
     /* Wrap it up */
-    CTRACE((tfp, "HTFTP: VMS filename: %s  date: %s  size: %d\n",
+    CTRACE((tfp, "HTFTP: VMS filename: %s  date: %s  size: %u\n",
 	    entry_info->filename,
 	    NonNull(entry_info->date),
 	    entry_info->size));
@@ -1882,7 +1890,7 @@ static void parse_ms_windows_dir_entry(char *line,
     }
 
     /* Wrap it up */
-    CTRACE((tfp, "HTFTP: MS Windows filename: %s  date: %s  size: %d\n",
+    CTRACE((tfp, "HTFTP: MS Windows filename: %s  date: %s  size: %u\n",
 	    entry_info->filename,
 	    NonNull(entry_info->date),
 	    entry_info->size));
@@ -2130,7 +2138,7 @@ static void parse_cms_dir_entry(char *line,
     }
 
     /* Wrap it up. */
-    CTRACE((tfp, "HTFTP: VM/CMS filename: %s  date: %s  size: %d\n",
+    CTRACE((tfp, "HTFTP: VM/CMS filename: %s  date: %s  size: %u\n",
 	    entry_info->filename,
 	    NonNull(entry_info->date),
 	    entry_info->size));
@@ -2790,7 +2798,7 @@ static int read_directory(HTParentAnchor *parent,
 	HTChunkFree(chunk);
 	FREE(spilledname);
 
-	/* print out the handy help message if it exits :) */
+	/* print out the handy help message if it exists :) */
 	if (help_message_cache_non_empty()) {
 	    START(HTML_PRE);
 	    START(HTML_HR);
@@ -2876,10 +2884,10 @@ static int read_directory(HTParentAnchor *parent,
 				entry_info->size / 1024);
 #else
 		    if (entry_info->size < 1024)
-			sprintf(string_buffer, "  %d bytes",
+			sprintf(string_buffer, "  %u bytes",
 				entry_info->size);
 		    else
-			sprintf(string_buffer, "  %dKb",
+			sprintf(string_buffer, "  %uKb",
 				entry_info->size / 1024);
 #endif
 		    PUTS(string_buffer);
@@ -2929,17 +2937,21 @@ static int setup_connection(const char *name,
     int retry;			/* How many times tried? */
     int status;
 
+    CTRACE((tfp, "setup_connection(%s)\n", name));
+
     /* set use_list to NOT since we don't know what kind of server
      * this is yet.  And set the type to GENERIC
      */
     use_list = FALSE;
     server_type = GENERIC_SERVER;
     ProFTPD_bugs = FALSE;
+    WU_FTPD_bugs = FALSE;
 
     for (retry = 0; retry < 2; retry++) {	/* For timed out/broken connections */
 	status = get_connection(name, anchor);
-	if (status < 0)
-	    return status;
+	if (status < 0) {
+	    break;
+	}
 
 	if (!ftp_local_passive) {
 	    status = get_listen_socket();
@@ -2954,7 +2966,7 @@ static int setup_connection(const char *name,
 #endif /* INET6 */
 		/* HT_INTERRUPTED would fall through, if we could interrupt
 		   somehow in the middle of it, which we currently can't. */
-		return status;
+		break;
 	    }
 #ifdef REPEAT_PORT
 	    /*  Inform the server of the port number we will listen on
@@ -2966,18 +2978,20 @@ static int setup_connection(const char *name,
 		NETCLOSE(control->socket);
 		control->socket = -1;
 		close_master_socket();
-		return HT_INTERRUPTED;
+		status = HT_INTERRUPTED;
+		break;
 	    }
 	    if (status != 2) {	/* Could have timed out */
 		if (status < 0)
 		    continue;	/* try again - net error */
-		return -status;	/* bad reply */
+		status = -status;	/* bad reply */
+		break;
 	    }
 	    CTRACE((tfp, "HTFTP: Port defined.\n"));
 #endif /* REPEAT_PORT */
 	} else {		/* Tell the server to be passive */
 	    char *command = NULL;
-	    const char *p;
+	    const char *p = "?";
 	    int h0, h1, h2, h3, p0, p1;		/* Parts of reply */
 
 #ifdef INET6
@@ -2987,39 +3001,51 @@ static int setup_connection(const char *name,
 	    data_soc = status;
 
 #ifdef INET6
-	    status = send_cmd_1(p = "EPSV");
+	    /* see RFC 2428 */
+	    if (WU_FTPD_bugs)
+		status = 1;
+	    else
+		status = send_cmd_1(p = "EPSV");
 	    if (status < 0)	/* retry or Bad return */
 		continue;
 	    else if (status != 2) {
 		status = send_cmd_1(p = "PASV");
-		if (status < 0)	/* retry or Bad return */
+		if (status < 0) {	/* retry or Bad return */
 		    continue;
-		else if (status != 2) {
-		    return -status;	/* bad reply */
+		} else if (status != 2) {
+		    status = -status;	/* bad reply */
+		    break;
 		}
 	    }
 
 	    if (strcmp(p, "PASV") == 0) {
-		for (p = response_text; *p && *p != ','; p++) ;		/* null body */
+		for (p = response_text; *p && *p != ','; p++) {
+		    ;		/* null body */
+		}
 
-		while (--p > response_text && '0' <= *p && *p <= '9') ;		/* null body */
+		while (--p > response_text && '0' <= *p && *p <= '9') {
+		    ;		/* null body */
+		}
 		status = sscanf(p + 1, "%d,%d,%d,%d,%d,%d",
 				&h0, &h1, &h2, &h3, &p0, &p1);
 		if (status < 4) {
 		    fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
-		    return -99;
+		    status = HT_NO_CONNECTION;
+		    break;
 		}
 		passive_port = (p0 << 8) + p1;
 		sprintf(dst, "%d.%d.%d.%d", h0, h1, h2, h3);
 	    } else if (strcmp(p, "EPSV") == 0) {
-		unsigned char c0, c1, c2, c3;
+		char c0, c1, c2, c3;
 		struct sockaddr_storage ss;
 		int sslen;
 
 		/*
 		 * EPSV bla (|||port|)
 		 */
-		for (p = response_text; *p && !isspace(*p); p++) ;	/* null body */
+		for (p = response_text; *p && !isspace(*p); p++) {
+		    ;		/* null body */
+		}
 		for ( /*nothing */ ;
 		     *p && *p && *p != '(';
 		     p++)	/*) */
@@ -3027,7 +3053,8 @@ static int setup_connection(const char *name,
 		status = sscanf(p, "(%c%c%c%d%c)", &c0, &c1, &c2, &p0, &c3);
 		if (status != 5) {
 		    fprintf(tfp, "HTFTP: EPSV reply has invalid format!\n");
-		    return -99;
+		    status = HT_NO_CONNECTION;
+		    break;
 		}
 		passive_port = p0;
 
@@ -3035,12 +3062,14 @@ static int setup_connection(const char *name,
 		if (getpeername(control->socket, (struct sockaddr *) &ss,
 				&sslen) < 0) {
 		    fprintf(tfp, "HTFTP: getpeername(control) failed\n");
-		    return -99;
+		    status = HT_NO_CONNECTION;
+		    break;
 		}
 		if (getnameinfo((struct sockaddr *) &ss, sslen, dst,
 				sizeof(dst), NULL, 0, NI_NUMERICHOST)) {
 		    fprintf(tfp, "HTFTP: getnameinfo failed\n");
-		    return -99;
+		    status = HT_NO_CONNECTION;
+		    break;
 		}
 	    }
 #else
@@ -3048,17 +3077,23 @@ static int setup_connection(const char *name,
 	    if (status != 2) {
 		if (status < 0)
 		    continue;	/* retry or Bad return */
-		return -status;	/* bad reply */
+		status = -status;	/* bad reply */
+		break;
+	    }
+	    for (p = response_text; *p && *p != ','; p++) {
+		;		/* null body */
 	    }
-	    for (p = response_text; *p && *p != ','; p++) ;	/* null body */
 
-	    while (--p > response_text && '0' <= *p && *p <= '9') ;	/* null body */
+	    while (--p > response_text && '0' <= *p && *p <= '9') {
+		;		/* null body */
+	    }
 
 	    status = sscanf(p + 1, "%d,%d,%d,%d,%d,%d",
 			    &h0, &h1, &h2, &h3, &p0, &p1);
 	    if (status < 4) {
 		fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
-		return -99;
+		status = HT_NO_CONNECTION;
+		break;
 	    }
 	    passive_port = (PortNumber) ((p0 << 8) + p1);
 #endif /* INET6 */
@@ -3079,7 +3114,7 @@ static int setup_connection(const char *name,
 	    if (status < 0) {
 		(void) HTInetStatus(gettext("connect for data"));
 		NETCLOSE(data_soc);
-		return status;	/* Bad return */
+		break;
 	    }
 
 	    CTRACE((tfp, "FTP data connected, socket %d\n", data_soc));
@@ -3088,6 +3123,7 @@ static int setup_connection(const char *name,
 	break;			/* No more retries */
 
     }				/* for retries */
+    CTRACE((tfp, "setup_connection returns %d\n", status));
     return status;
 }
 
@@ -3126,8 +3162,8 @@ int HTFTPLoad(const char *name,
     if (status < 0)
 	return status;		/* Failed with this code */
 
-/*	Ask for the file:
-*/
+    /*  Ask for the file:
+     */
     {
 	char *filename = HTParse(name, "", PARSE_PATH + PARSE_PUNCTUATION);
 	char *fname = filename;	/* Save for subsequent free() */
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 0dba3fd1..a0064f53 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1236,7 +1236,7 @@ CompressFileType HTCompressFileType(const char *filename,
     *rootlen = (ftype - filename);
 
     CTRACE((tfp, "HTCompressFileType(%s) returns %d:%s\n",
-	    filename, result, filename + *rootlen));
+	    filename, (int) result, filename + *rootlen));
     return result;
 }
 
@@ -2857,12 +2857,13 @@ void HTSetProgramPath(ProgramPaths code, const char *path)
  */
 void HTInitProgramPaths(void)
 {
-    int code;
+    ProgramPaths code;
+    int n;
     const char *path;
     const char *test;
 
-    for (code = (int) ppUnknown + 1; code < (int) pp_Last; ++code) {
-	switch (code) {
+    for (n = (int) ppUnknown + 1; n < (int) pp_Last; ++n) {
+	switch (code = (ProgramPaths) n) {
 #ifdef BZIP2_PATH
 	case ppBZIP2:
 	    path = BZIP2_PATH;
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index bdcdef17..43c7892a 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -16,9 +16,7 @@
 */
 #include <HTFormat.h>
 
-float HTMaxSecs = 1e10;		/* No effective limit */
-float HTMaxLength = 1e10;	/* No effective limit */
-long int HTMaxBytes = 0;	/* No effective limit */
+static float HTMaxSecs = 1e10;	/* No effective limit */
 
 #ifdef UNIX
 #ifdef NeXT
@@ -1134,7 +1132,7 @@ static int HTZzFileCopy(FILE *zzfp, HTStream *sink)
     status = inflateInit(&s);
     if (status != Z_OK) {
 	CTRACE((tfp, "HTZzFileCopy inflateInit() %s\n", zError(status)));
-	exit(1);
+	exit_immediately(1);
     }
     s.avail_in = 0;
     s.next_out = (Bytef *) output_buffer;
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index bb8dd812..2b0f2bec 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -41,7 +41,6 @@ int HTNewsMaxChunk = 40;	/* Largest number of articles in one window */
 #endif /* NEWS_AUTH_FILE */
 
 #ifdef USE_SSL
-extern SSL_CTX *ssl_ctx;
 static SSL *Handle = NULL;
 static int channel_s = 1;
 
diff --git a/WWW/Library/Implementation/HTNews.h b/WWW/Library/Implementation/HTNews.h
index 798f211f..4fb7ac63 100644
--- a/WWW/Library/Implementation/HTNews.h
+++ b/WWW/Library/Implementation/HTNews.h
@@ -42,6 +42,8 @@ extern char *HTNewsHost;
 extern void HTClearNNTPAuthInfo(void);
 
 #ifdef USE_SSL
+extern SSL_CTX *ssl_ctx;
+
 extern int HTNewsProxyConnect(int sock,
 			      const char *url,
 			      HTParentAnchor *anAnchor,
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index b291264b..70dfa175 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -477,6 +477,8 @@ char *HTParse(const char *aName,
 	    strcpy(tail, given.absolute);
 	    CTRACE((tfp, "HTParse: (ABS)\n"));
 	} else if (related.absolute) {	/* Adopt path not name */
+	    char *base = tail;
+
 	    *tail++ = '/';
 	    strcpy(tail, related.absolute);
 	    if (given.relative) {
@@ -498,7 +500,9 @@ char *HTParse(const char *aName,
 		    p[1] = '\0';	/* Remove filename */
 		    strcat(p, given.relative);	/* Add given one */
 		}
-		HTSimplify(result);
+		HTSimplify(base);
+		if (*base == '\0')
+		    strcpy(base, "/");
 	    }
 	    CTRACE((tfp, "HTParse: (Related-ABS)\n"));
 	} else if (given.relative) {
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index 72e7dde7..dbcedc1f 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -30,7 +30,7 @@
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
-int HTPlain_lastraw = -1;
+static int HTPlain_lastraw = -1;
 static int HTPlain_bs_pending = 0;	/* 1:bs 2:underline 3:underline+bs - kw */
 
 /*		HTML Object
@@ -664,7 +664,7 @@ static void HTPlain_abort(HTStream *me, HTError e GCC_UNUSED)
 /*		Structured Object Class
  *		-----------------------
  */
-const HTStreamClass HTPlain =
+static const HTStreamClass HTPlain =
 {
     "PlainPresenter",
     HTPlain_free,
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index fc479848..fb55e185 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -1817,7 +1817,7 @@ int HTDoConnect(const char *url,
 		     * EALREADY.
 		     *
 		     * For some reason, UCX pre 3 apparently returns errno =
-		     * 18242 instead the EALREADY or EISCONN.
+		     * 18242 instead of EALREADY or EISCONN.
 		     */
 #ifdef INET6
 		    status = connect(*s, res->ai_addr, res->ai_addrlen);
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 187f4023..2204e651 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -54,7 +54,7 @@ BOOL redirect_post_content = FALSE;	/* Don't convert to GET? */
 #ifdef USE_SSL
 SSL_CTX *ssl_ctx = NULL;	/* SSL ctx */
 SSL *SSL_handle = NULL;
-int ssl_okay;
+static int ssl_okay;
 
 static void free_ssl_ctx(void)
 {
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 9e3734b6..ef2ac732 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -366,29 +366,27 @@ are generally not the response status from any specific protocol.
 
  */
 
-#define HT_REDIRECTING 399
-#define HT_LOADED 200		/* Instead of a socket */
-#define HT_PARTIAL_CONTENT      206	/* Partial Content */
-#define HT_INTERRUPTED -29998
-#define HT_NOT_LOADED -29999
-#define HT_OK           0	/* Generic success */
-
-#define HT_ERROR                -1	/* Generic failure */
+#define HT_PARSER_OTHER_CONTENT  701	/* tells SGML to change content model */
+#define HT_PARSER_REOPEN_ELT     700	/* tells SGML parser to keep tag open */
+#define HT_REDIRECTING           399
+#define HT_PARTIAL_CONTENT       206	/* Partial Content */
+#define HT_LOADED                200	/* Instead of a socket */
 
-#define HT_CANNOT_TRANSLATE -4
+#define HT_OK                      0	/* Generic success */
 
-#define HT_NO_DATA		-204	/* OK but no data was loaded - */
+#define HT_ERROR                  -1	/* Generic failure */
+#define HT_CANNOT_TRANSLATE       -4
+#define HT_BAD_EOF               -12	/* Premature EOF */
+#define HT_NO_CONNECTION         -99	/* ERR no connection available - */
+#define HT_NO_DATA              -204	/* OK but no data was loaded - */
 					/* possibly other app started or forked */
 #define HT_NO_ACCESS            -401	/* Access not available */
 #define HT_FORBIDDEN            -403	/* Access forbidden */
 #define HT_NOT_ACCEPTABLE       -406	/* Not Acceptable */
-
-#define HT_PARSER_REOPEN_ELT     700	/* tells SGML parser to keep tag open */
-#define HT_PARSER_OTHER_CONTENT  701	/* tells SGML to change content model */
 #define HT_H_ERRNO_VALID        -800	/* see h_errno for resolver error */
-
 #define HT_INTERNAL             -900	/* Weird -- should never happen. */
-#define HT_BAD_EOF      -12	/* Premature EOF */
+#define HT_INTERRUPTED        -29998
+#define HT_NOT_LOADED         -29999
 
 #ifndef va_arg
 # if defined(HAVE_STDARG_H) && defined(ANSI_VARARGS)
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index 7b609eb3..a4657760 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -547,7 +547,7 @@ static int HTVMSclosedir(DIR *dirp)
 
     status = lib$find_file_end(&(dirp->context));
     if (!(status & 0x01))
-	exit(status);
+	exit_immediately(status);
     dirp->context = 0;
     return (0);
 }
diff --git a/WWW/Library/Implementation/HTVMS_WaisUI.c b/WWW/Library/Implementation/HTVMS_WaisUI.c
index 1b131dd9..31bfa4fb 100644
--- a/WWW/Library/Implementation/HTVMS_WaisUI.c
+++ b/WWW/Library/Implementation/HTVMS_WaisUI.c
@@ -2122,7 +2122,7 @@ static void exitAction(long error GCC_UNUSED)
     long i;
 
     for (i = 0; i < 100000; i++) ;
-    exit(0);
+    exit_immediately(0);
 }
 
 /*----------------------------------------------------------------------*/
diff --git a/WWW/Library/Implementation/HTWSRC.c b/WWW/Library/Implementation/HTWSRC.c
index 31822b8e..3916bd86 100644
--- a/WWW/Library/Implementation/HTWSRC.c
+++ b/WWW/Library/Implementation/HTWSRC.c
@@ -105,11 +105,8 @@ struct _HTStream {
     int param_count;
 };
 
-const char *hex = "0123456789ABCDEF";
-
 /*	Decode one hex character
 */
-
 char from_hex(char c)
 {
     return (char) ((c >= '0') && (c <= '9') ? c - '0'
@@ -446,7 +443,7 @@ static void WSRCParser_abort(HTStream *me, HTError e GCC_UNUSED)
  *		---------------
  */
 
-HTStreamClass WSRCParserClass =
+static HTStreamClass WSRCParserClass =
 {
     "WSRCParser",
     WSRCParser_free,
@@ -454,7 +451,6 @@ HTStreamClass WSRCParserClass =
     WSRCParser_put_character,
     WSRCParser_put_string,
     WSRCParser_write
-
 };
 
 /*		Converter from WAIS Source to whatever
diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h
index 21d8a11b..7f134d83 100644
--- a/WWW/Library/Implementation/LYexit.h
+++ b/WWW/Library/Implementation/LYexit.h
@@ -54,6 +54,7 @@
 /*
  *	Function declarations
  */
+extern void reset_signals(void);
 extern void exit_immediately(int status) GCC_NORETURN;
 extern void LYexit(int status) GCC_NORETURN;
 extern int LYatexit(void (*function) (void));
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 684efd50..988c8d6f 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -44,7 +44,7 @@
 
 #ifdef USE_PRETTYSRC
 
-char *entity_string;		/* this is used for printing entity name.
+static char *entity_string;	/* this is used for printing entity name.
 
 				   Unconditionally added since redundant assigments don't hurt much */
 
@@ -916,7 +916,7 @@ static void handle_sgmlatt(HTStream *context)
 #define ALT_TAGNUM(e) ((e == HTML_OBJECT) ? HTML_ALT_OBJECT : e)
 
 /* return 'TAGNUM' of the normal mode for 'TAGNUM' e which may be alt. */
-#define NORMAL_TAGNUM(e) ((e >= HTML_ELEMENTS) ? HTML_OBJECT : e)
+#define NORMAL_TAGNUM(e) (((int)(e) >= HTML_ELEMENTS) ? HTML_OBJECT : e)
 
 /* More convenience stuff. - kw */
 #define ALT_TAGP_OF_TAGNUM(e) TAGP_OF_TAGNUM(ALT_TAGNUM(e))
@@ -1106,7 +1106,7 @@ static void end_element(HTStream *context, HTTag * old_tag)
 	}
 
 	e = NORMAL_TAGNUM(TAGNUM_OF_TAGP(t));
-	CTRACE2(TRACE_SGML, (tfp, "tagnum(%p) = %d\n", t, e));
+	CTRACE2(TRACE_SGML, (tfp, "tagnum(%p) = %d\n", t, (int) e));
 #ifdef USE_PRETTYSRC
 	if (!psrc_view)		/* Don't actually pass call on if viewing psrc - kw */
 #endif
@@ -4504,7 +4504,7 @@ History:
 ///////////////////////////////////////////////////////////////////////
 */
 
-int TREAT_SJIS = 1;
+static int TREAT_SJIS = 1;
 
 void JISx0201TO0208_EUC(unsigned char IHI,
 			unsigned char ILO,
@@ -4766,7 +4766,7 @@ unsigned char *EUC_TO_JIS(unsigned char *src,
 #define SO		('N'-0x40)
 #define SI		('O'-0x40)
 
-int repair_JIS = 0;
+static int repair_JIS = 0;
 
 static const unsigned char *repairJIStoEUC(const unsigned char *src,
 					   unsigned char **dstp)