about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTFTP.c44
-rw-r--r--WWW/Library/Implementation/HTFile.c43
-rw-r--r--WWW/Library/Implementation/HTFinger.c102
-rw-r--r--WWW/Library/Implementation/HTFormat.c12
-rw-r--r--WWW/Library/Implementation/HTFormat.h2
-rw-r--r--WWW/Library/Implementation/HTGopher.c32
-rw-r--r--WWW/Library/Implementation/HTNews.c40
-rw-r--r--WWW/Library/Implementation/HTString.c9
8 files changed, 164 insertions, 120 deletions
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index 2392c439..923d7a0e 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -303,7 +303,7 @@ PUBLIC char * HTMake_VMS_name ARGS2(
 /*	Procedure: Read a character from the data connection
 **	----------------------------------------------------
 */
-PRIVATE char next_data_char NOARGS
+PRIVATE int next_data_char NOARGS
 {
     int status;
     if (data_read_pointer >= data_write_pointer) {
@@ -311,7 +311,7 @@ PRIVATE char next_data_char NOARGS
       if (status == HT_INTERRUPTED)
 	interrupted_in_next_data_char = 1;
       if (status <= 0)
-	return (char)-1;
+	return -1;
       data_write_pointer = data_buffer + status;
       data_read_pointer = data_buffer;
     }
@@ -321,7 +321,7 @@ PRIVATE char next_data_char NOARGS
 	return FROMASCII(c);
     }
 #else
-    return *data_read_pointer++;
+    return (unsigned char)(*data_read_pointer++);
 #endif /* NOT_ASCII */
 }
 
@@ -439,7 +439,8 @@ PRIVATE int response ARGS1(
     do {
 	char *p = response_text;
 	for (;;) {
-	    if (((*p++ = NEXT_CHAR) == LF)
+	    int ich = NEXT_CHAR;
+	    if (((*p++ = ich) == LF)
 			|| (p == &response_text[LINE_LENGTH])) {
 
 		char continuation;
@@ -479,7 +480,7 @@ PRIVATE int response ARGS1(
 		return HT_INTERRUPTED;
 	    }
 
-	    if (*(p-1) == (char) EOF) {
+	    if (ich == EOF) {
 		CTRACE(tfp, "Error on rx: closing socket %d\n",
 			    control->socket);
 		strcpy(response_text, "000 *** TCP read error on response\n");
@@ -1349,7 +1350,7 @@ PRIVATE void parse_eplf_line ARGS2(
 		StrAllocCopy(info->date, ct);
 		break;
 	    case '/':
-		StrAllocCopy(info->type, "Directory");
+		StrAllocCopy(info->type, ENTRY_IS_DIRECTORY);
 	    default:
 		while (*cp) {
 		    if (*cp++ == ',')
@@ -1579,7 +1580,7 @@ PRIVATE void parse_ms_windows_dir_entry ARGS2(
 	if (isdigit(*cps)) {
 	    entry_info->size = atoi(cps);
 	} else {
-	    StrAllocCopy(entry_info->type, "Directory");
+	    StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 	}
     } else {
 	StrAllocCopy(entry_info->type, "");
@@ -1715,7 +1716,7 @@ PRIVATE void parse_windows_nt_dir_entry ARGS2(
 	if (isdigit(*cps)) {
 	    entry_info->size = atoi(cps);
 	} else {
-	    StrAllocCopy(entry_info->type, "Directory");
+	    StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 	}
     } else {
 	StrAllocCopy(entry_info->type, "");
@@ -1772,7 +1773,7 @@ PRIVATE void parse_cms_dir_entry ARGS2(
     *cps++ ='\0';
     if ((0 == strcasecomp(cp, "DIR")) && (cp - line) > 17) {
 	/** It's an SFS directory. **/
-	StrAllocCopy(entry_info->type, "Directory");
+	StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 	entry_info->size = 0;
     } else {
 	/** It's a file. **/
@@ -1945,7 +1946,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 		/*
 		**  It's a directory.
 		*/
-		StrAllocCopy(entry_info->type, "Directory");
+		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 		remove_size=TRUE; /* size is not useful */
 	    } else if (entry[0] == 'l') {
 		/*
@@ -1953,7 +1954,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 		**  knowing if it is symbolic?	I think so since
 		**  it might be a directory.
 		*/
-		StrAllocCopy(entry_info->type, "Symbolic Link");
+		StrAllocCopy(entry_info->type, gettext("Symbolic Link"));
 		remove_size=TRUE; /* size is not useful */
 
 		/*
@@ -2000,7 +2001,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 	    len = strlen(entry_info->filename);
 	    if ((len > 4) && !strcmp(&entry_info->filename[len-4], ".dir")) {
 		entry_info->filename[len-4] = '\0';
-		StrAllocCopy(entry_info->type, "Directory");
+		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 		remove_size=TRUE; /* size is not useful */
 	    }
 	    /*
@@ -2087,7 +2088,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 		**  It's a dir, remove / and mark it as such.
 		*/
 		entry[len-1] = '\0';
-		StrAllocCopy(entry_info->type, "Directory");
+		StrAllocCopy(entry_info->type, ENTRY_IS_DIRECTORY);
 		remove_size=TRUE; /* size is not useful */
 	    }
 	    /*
@@ -2353,13 +2354,13 @@ PRIVATE int read_directory ARGS4(
 
     {
 	HTBTree * bt = HTBTree_new((HTComparer)compare_EntryInfo_structs);
-	char c;
+	int ic;
 	HTChunk * chunk = HTChunkCreate(128);
 	int BytesReceived = 0;
 	int BytesReported = 0;
 	char NumBytes[64];
 	PUTS("\n");  /* prettier LJM */
-	for (c = 0; c != (char)EOF;) {	/* For each entry in the directory */
+	for (ic = 0; ic != EOF;) {	/* For each entry in the directory */
 	    HTChunkClear(chunk);
 
 	    if (HTCheckForInterrupt()) {
@@ -2376,7 +2377,7 @@ PRIVATE int read_directory ARGS4(
 	    /*	 read directory entry
 	     */
 	    for (;;) {		       /* Read in one line as filename */
-		c = NEXT_DATA_CHAR;
+		ic = NEXT_DATA_CHAR;
 AgainForMultiNet:
 		if (interrupted_in_next_data_char) {
 		    WasInterrupted = TRUE;
@@ -2387,7 +2388,7 @@ AgainForMultiNet:
 			HTBTreeAndObject_free(bt);
 			return HT_INTERRUPTED;
 		    }
-		} else if (c == CR || c == LF) {    /* Terminator? */
+		} else if ((char)ic == CR || (char)ic == LF) {    /* Terminator? */
 		    if (chunk->size != 0) {  /* got some text */
 			/* Deal with MultiNet's wrapping of long lines */
 			if (server_type == VMS_SERVER) {
@@ -2403,7 +2404,7 @@ AgainForMultiNet:
 				    goto AgainForMultiNet;
 				}
 				if (status <= 0) {
-				    c = (char)EOF;
+				    ic = EOF;
 				    break;
 				}
 				data_write_pointer = data_buffer + status;
@@ -2419,10 +2420,10 @@ AgainForMultiNet:
 			else
 			    break;	      /* finish getting one entry */
 		    }
-		} else if (c == (char)EOF) {
+		} else if (ic == EOF) {
 		    break;	       /* End of file */
 		} else {
-		    HTChunkPutc(chunk, c);
+		    HTChunkPutc(chunk, (char)ic);
 		}
 	    }
 	    HTChunkTerminate(chunk);
@@ -2434,7 +2435,7 @@ AgainForMultiNet:
 		BytesReported = BytesReceived;
 	    }
 
-	    if (c == (char) EOF && chunk->size == 1)
+	    if (ic == EOF && chunk->size == 1)
 	    /* 1 means empty: includes terminating 0 */
 		break;
 	    CTRACE(tfp, "HTFTP: Line in %s is %s\n",
@@ -2446,6 +2447,7 @@ AgainForMultiNet:
 			    entry_info->filename);
 		HTBTree_add(bt, (EntryInfo *)entry_info);
 	    } else {
+		free_entryinfo_struct_contents(entry_info);
 		FREE(entry_info);
 	    }
 
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 1c419daa..5991ca7d 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -154,7 +154,7 @@ PRIVATE void free_suffixes NOPARAMS;
 PRIVATE char *FormatStr ARGS3(
     char **,	bufp,
     char *,	start,
-    char *,	entry)
+    CONST char *,	entry)
 {
     char fmt[512];
     if (*start) {
@@ -218,7 +218,7 @@ PRIVATE void LYListFmtParse ARGS5(
 #endif
 
 	if (lstat(file, &st) < 0)
-		fmtstr = "%a";	/* can't stat so just do anchor */
+		fmtstr = "    %a";	/* can't stat so just do anchor */
 
 	StrAllocCopy(str, fmtstr);
 	s = str;
@@ -251,7 +251,7 @@ PRIVATE void LYListFmtParse ARGS5(
 
 		switch (c) {
 		case '\0':
-		        PUTS(start);
+			PUTS(start);
 			continue;
 
 		case 'A':
@@ -271,6 +271,37 @@ PRIVATE void LYListFmtParse ARGS5(
 #endif
 			break;
 
+		case 'T':	/* MIME type */
+		case 't':	/* MIME type description */
+		    if (S_ISDIR(st.st_mode)) {
+			if (c != 'T') {
+			    FormatStr(&buf, start, ENTRY_IS_DIRECTORY);
+			} else {
+			    FormatStr(&buf, start, "");
+			}
+		    } else {
+			CONST char *cp2;
+			HTFormat format;
+			format = HTFileFormat(file, NULL, &cp2);
+
+			if (c != 'T') {
+			    if (cp2 == NULL) {
+				if (!strncmp(HTAtom_name(format),
+					     "application",11)) {
+				    cp2 = HTAtom_name(format) + 12;
+				    if (!strncmp(cp2,"x-",2))
+					cp2 += 2;
+				} else {
+				    cp2 = HTAtom_name(format);
+				}
+			    }
+			    FormatStr(&buf, start, cp2);
+			} else {
+			    FormatStr(&buf, start, HTAtom_name(format));
+			}
+		    }
+		    break;
+
 		case 'd':	/* date */
 			now = time(0);
 			datestr = ctime(&st.st_mtime);
@@ -593,7 +624,7 @@ PUBLIC char * HTnameOfFile_WWW ARGS3(
     char * result = NULL;
 
     if (expand_all)
-    	HTUnEscape(path);		/* Interpret all % signs */
+	HTUnEscape(path);		/* Interpret all % signs */
     else
 	HTUnEscapeSome(path, "/");	/* Interpret % signs for path delims */
 
@@ -2139,7 +2170,7 @@ PUBLIC int HTLoadFile ARGS4(
 				    if (dir_list_style != MIXED_STYLE) {
 				       START(HTML_EM);
 				       PUTS(state == 'D'
-				          ? LABEL_SUBDIRECTORIES
+					  ? LABEL_SUBDIRECTORIES
 					  : LABEL_FILES);
 				       END(HTML_EM);
 				    }
@@ -2161,7 +2192,7 @@ PUBLIC int HTLoadFile ARGS4(
 				    START(HTML_H2);
 				    START(HTML_EM);
 				    PUTS(state == 'D'
-				        ? LABEL_SUBDIRECTORIES
+					? LABEL_SUBDIRECTORIES
 					: LABEL_FILES);
 				    END(HTML_EM);
 				    END(HTML_H2);
diff --git a/WWW/Library/Implementation/HTFinger.c b/WWW/Library/Implementation/HTFinger.c
index c99563cc..4d1aeeca 100644
--- a/WWW/Library/Implementation/HTFinger.c
+++ b/WWW/Library/Implementation/HTFinger.c
@@ -45,7 +45,7 @@
 #define START(e) (*targetClass.start_element)(target, e, 0, 0, -1, 0)
 #define END(e) (*targetClass.end_element)(target, e, 0)
 #define FREE_TARGET (*targetClass._free)(target)
-#define NEXT_CHAR HTGetCharacter() 
+#define NEXT_CHAR HTGetCharacter()
 
 
 /*	Module-wide variables
@@ -79,15 +79,15 @@ PRIVATE void start_anchor ARGS1(CONST char *,  href)
 {
     BOOL		present[HTML_A_ATTRIBUTES];
     CONST char*		value[HTML_A_ATTRIBUTES];
-    
+
     {
-    	int i;
-    	for(i=0; i<HTML_A_ATTRIBUTES; i++)
+	int i;
+	for(i=0; i<HTML_A_ATTRIBUTES; i++)
 	    present[i] = (i==HTML_A_HREF);
     }
     ((CONST char **)value)[HTML_A_HREF] = href;
     (*targetClass.start_element)(target, HTML_A, present,
-    				 (CONST char **)value, -1, 0);
+				 (CONST char **)value, -1, 0);
 
 }
 
@@ -117,7 +117,7 @@ PRIVATE int response ARGS5(
     char *p = line, *href=NULL;
 
     if (length == 0)
-        return(-1);
+	return(-1);
 
     /* Set up buffering.
     */
@@ -129,11 +129,11 @@ PRIVATE int response ARGS5(
     status = NETWRITE(s, (char *)command, length);
     if (status < 0) {
 	CTRACE(tfp, "HTFinger: Unable to send command. Disconnecting.\n");
-        NETCLOSE(s);
-        s = -1;
-        return status;
+	NETCLOSE(s);
+	s = -1;
+	return status;
     } /* if bad status */
-  
+
     /* Make a hypertext object with an anchor list.
     */
     target = HTML_new(anAnchor, format_out, sink);
@@ -162,12 +162,12 @@ PRIVATE int response ARGS5(
     END(HTML_EM);
     PUTS(": ");
     if (command) {
-        StrAllocCopy(cmd, command);
+	StrAllocCopy(cmd, command);
     } else {
-        StrAllocCopy(cmd, "");
+	StrAllocCopy(cmd, "");
     }
     for (i = (strlen(cmd) - 1); i >= 0; i--) {
-        if (cmd[i] == LF || cmd[i] == CR) {
+	if (cmd[i] == LF || cmd[i] == CR) {
 	    cmd[i] = '\0';
 	} else {
 	    break;
@@ -179,18 +179,18 @@ PRIVATE int response ARGS5(
     PUTS("\n");
     START(HTML_PRE);
 
-    while ((ch=NEXT_CHAR) != (char)EOF) {
+    while ((ch=NEXT_CHAR) != EOF) {
 
 	if (interrupted_in_htgetcharacter) {
 	    CTRACE(tfp, "HTFinger: Interrupted in HTGetCharacter, apparently.\n");
 	    _HTProgress (CONNECTION_INTERRUPTED);
 	    goto end_html;
-        }
+	}
 
 	if (ch != LF) {
 	    *p = ch;		/* Put character in line */
 	    if (p < &line[BIG-1]) {
-	        p++;
+		p++;
 	    }
 	} else {
 	    *p = '\0';		/* Terminate line */
@@ -215,13 +215,13 @@ PRIVATE int response ARGS5(
 		    strncmp(l, "wais://", 7) &&
 		    strncmp(l, "mailto:", 7) &&
 		    strncmp(l, "cso://", 6) &&
-		    strncmp(l, "gopher://", 9)) 
+		    strncmp(l, "gopher://", 9))
 		    PUTC(*l++);
 		else {
 		    StrAllocCopy(href, l);
 		    start_anchor(strtok(href, " \r\n\t,>)\""));
 		    while (*l && !strchr(" \r\n\t,>)\"", *l))
-		        PUTC(*l++);
+			PUTC(*l++);
 		    END(HTML_A);
 		    FREE(href);
 		}
@@ -258,68 +258,68 @@ PUBLIC int HTLoadFinger ARGS4(
     char *command, *str;		/* Buffers */
     int port;				/* Port number from URL */
     int status;				/* tcp return */
-  
+
     CTRACE(tfp, "HTFinger: Looking for %s\n", (arg ? arg : "NULL"));
-  
+
     if (!(arg && *arg)) {
-        HTAlert(COULD_NOT_LOAD_DATA);
+	HTAlert(COULD_NOT_LOAD_DATA);
 	return HT_NOT_LOADED;			/* Ignore if no name */
     }
-  
-    if (!initialized) 
-        initialized = initialize();
+
+    if (!initialized)
+	initialized = initialize();
     if (!initialized) {
-        HTAlert (gettext("Could not set up finger connection."));
+	HTAlert (gettext("Could not set up finger connection."));
 	return HT_NOT_LOADED;	/* FAIL */
     }
-    
+
   {
     CONST char * p1=arg;
     BOOL IsGopherURL = FALSE;
-    
+
     /*  Set up the host and command fields.
-    */        
+    */
     if (!strncasecomp(arg, "finger://", 9)) {
-        p1 = arg + 9;  /* Skip "finger://" prefix */
+	p1 = arg + 9;  /* Skip "finger://" prefix */
     } else if (!strncasecomp(arg, "gopher://", 9)) {
-        p1 = arg + 9;  /* Skip "gopher://" prefix */
+	p1 = arg + 9;  /* Skip "gopher://" prefix */
 	IsGopherURL = TRUE;
     }
     sitename = (char *)p1;
 
     if ((slash = strchr(sitename, '/')) != NULL) {
-        *slash++ = '\0';
+	*slash++ = '\0';
 	HTUnEscape(slash);
 	if (IsGopherURL) {
 	    if (*slash != '0') {
-	        HTAlert(COULD_NOT_LOAD_DATA);
+		HTAlert(COULD_NOT_LOAD_DATA);
 		return HT_NOT_LOADED;	/* FAIL */
 	    }
 	    *slash++ = '\0';
 	}
     }
     if ((at_sign = strchr(sitename, '@')) != NULL) {
-        if (IsGopherURL) {
-            HTAlert(COULD_NOT_LOAD_DATA);
+	if (IsGopherURL) {
+	    HTAlert(COULD_NOT_LOAD_DATA);
 	    return HT_NOT_LOADED;	/* FAIL */
 	}
-        *at_sign++ = '\0';
-        username = sitename;
+	*at_sign++ = '\0';
+	username = sitename;
 	sitename = at_sign;
 	HTUnEscape(username);
     } else if (slash) {
-        username = slash;
+	username = slash;
     } else {
-        username = "";
+	username = "";
     }
-    
+
     if (*sitename == '\0') {
-        HTAlert(gettext("Could not load data (no sitename in finger URL)"));
+	HTAlert(gettext("Could not load data (no sitename in finger URL)"));
 	return HT_NOT_LOADED;		/* Ignore if no name */
     }
 
     if ((colon = strchr(sitename, ':')) != NULL) {
-        *colon++ = '\0';
+	*colon++ = '\0';
 	port = atoi(colon);
 	if (port != 79) {
 	    HTAlert(gettext("Invalid port number - will only use port 79!"));
@@ -331,12 +331,12 @@ PUBLIC int HTLoadFinger ARGS4(
     */
     str = 0;
     HTSprintf0(&str, "lose://%s/", sitename);
-    
+
     /* Load the command for the finger server.
     */
     command = 0;
     if (at_sign && slash) {
-        if (*slash == 'w' || *slash == 'W') {
+	if (*slash == 'w' || *slash == 'W') {
 	    HTSprintf0(&command, "/w %s%c%c", username, CR, LF);
 	} else {
 	    HTSprintf0(&command, "%s%c%c", username, CR, LF);
@@ -344,12 +344,12 @@ PUBLIC int HTLoadFinger ARGS4(
     } else if (at_sign) {
 	HTSprintf0(&command, "%s%c%c", username, CR, LF);
     } else if (*username == '/') {
-        if ((slash = strchr((username+1), '/')) != NULL) {
+	if ((slash = strchr((username+1), '/')) != NULL) {
 	    *slash = ' ';
 	}
 	HTSprintf0(&command, "%s%c%c", username, CR, LF);
     } else if ((*username == 'w' || *username == 'W') &&
-    	       *(username+1) == '/') {
+	       *(username+1) == '/') {
 	if (*username+2 != '\0') {
 	    *(username+1) = ' ';
 	} else {
@@ -357,7 +357,7 @@ PUBLIC int HTLoadFinger ARGS4(
 	}
 	HTSprintf0(&command, "/%s%c%c", username, CR, LF);
     } else if ((*username == 'w' || *username == 'W') &&
-    	       *(username+1) == '\0') {
+	       *(username+1) == '\0') {
 	HTSprintf0(&command, "/%s%c%c", username, CR, LF);
     } else if ((slash = strchr(username, '/')) != NULL) {
 	*slash++ = '\0';
@@ -370,7 +370,7 @@ PUBLIC int HTLoadFinger ARGS4(
 	HTSprintf0(&command, "%s%c%c", username, CR, LF);
     }
   } /* scope of p1 */
-  
+
     /* Now, let's get a stream setup up from the FingerHost:
     ** CONNECTING to finger host
     */
@@ -379,7 +379,7 @@ PUBLIC int HTLoadFinger ARGS4(
     CTRACE(tfp, "HTFinger: Done DoConnect; status %d\n", status);
 
     if (status == HT_INTERRUPTED) {
-        /* Interrupt cleanly */
+	/* Interrupt cleanly */
 	CTRACE(tfp, "HTFinger: Interrupted on connect; recovering cleanly.\n");
 	HTProgress (CONNECTION_INTERRUPTED);
 	FREE(str);
@@ -387,10 +387,10 @@ PUBLIC int HTLoadFinger ARGS4(
 	return HT_NOT_LOADED;
     }
     if (status < 0) {
-        NETCLOSE(s);
+	NETCLOSE(s);
 	s = -1;
 	CTRACE(tfp, "HTFinger: Unable to connect to finger host.\n");
-        HTAlert(gettext("Could not access finger host."));
+	HTAlert(gettext("Could not access finger host."));
 	FREE(str);
 	FREE(command);
 	return HT_NOT_LOADED;	/* FAIL */
@@ -401,7 +401,7 @@ PUBLIC int HTLoadFinger ARGS4(
     /* Send the command, and process response if successful.
     */
     if (response(command, sitename, anAnchor, format_out, stream) != 0) {
-        HTAlert(gettext("No response from finger server."));
+	HTAlert(gettext("No response from finger server."));
 	FREE(command);
 	return HT_NOT_LOADED;
     }
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index ca065016..33c6e344 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -218,7 +218,7 @@ PUBLIC void HTInitInput ARGS1 (int,file_number)
 }
 
 PUBLIC int interrupted_in_htgetcharacter = 0;
-PUBLIC char HTGetCharacter NOARGS
+PUBLIC int HTGetCharacter NOARGS
 {
     char ch;
     interrupted_in_htgetcharacter = 0;
@@ -228,15 +228,15 @@ PUBLIC char HTGetCharacter NOARGS
 				 input_buffer, INPUT_BUFFER_SIZE);
 	    if (status <= 0) {
 		if (status == 0)
-		    return (char)EOF;
+		    return EOF;
 		if (status == HT_INTERRUPTED) {
 		    CTRACE(tfp, "HTFormat: Interrupted in HTGetCharacter\n");
 		    interrupted_in_htgetcharacter = 1;
-		    return (char)EOF;
+		    return EOF;
 		}
 		CTRACE(tfp, "HTFormat: File read error %d\n", status);
-		return (char)EOF; /* -1 is returned by UCX
-				     at end of HTTP link */
+		return EOF; /* -1 is returned by UCX
+			       at end of HTTP link */
 	    }
 	    input_pointer = input_buffer;
 	    input_limit = input_buffer + status;
@@ -244,7 +244,7 @@ PUBLIC char HTGetCharacter NOARGS
 	ch = *input_pointer++;
     } while (ch == (char) 13); /* Ignore ASCII carriage return */
 
-    return FROMASCII(ch);
+    return FROMASCII((unsigned char)ch);
 }
 
 /*  Match maintype to any MIME type starting with maintype,
diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h
index c9b6392e..f4b3caf5 100644
--- a/WWW/Library/Implementation/HTFormat.h
+++ b/WWW/Library/Implementation/HTFormat.h
@@ -348,7 +348,7 @@ Get next character from buffer
 
  */
 extern int interrupted_in_htgetcharacter;
-extern char HTGetCharacter NOPARAMS;
+extern int HTGetCharacter NOPARAMS;
 
 
 /*
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index e2ec7b0f..276569b5 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -209,7 +209,7 @@ PRIVATE void parse_menu ARGS2(
 	HTParentAnchor *,	anAnchor)
 {
     char gtype;
-    char ch;
+    int ich;
     char line[BIG];
     char *name = NULL, *selector = NULL;	/* Gopher menu fields */
     char *host = NULL;
@@ -248,15 +248,15 @@ PRIVATE void parse_menu ARGS2(
     END(HTML_H1);
     PUTS("\n");
     START(HTML_PRE);
-    while ((ch=NEXT_CHAR) != (char)EOF) {
+    while ((ich=NEXT_CHAR) != EOF) {
 
 	if (interrupted_in_htgetcharacter) {
 	    CTRACE(tfp, "HTGopher: Interrupted in HTGetCharacter, apparently.\n");
 	    goto end_html;
 	}
 
-	if (ch != LF) {
-	    *p = ch;		/* Put character in line */
+	if ((char)ich != LF) {
+	    *p = ich;		/* Put character in line */
 	    if (p< &line[BIG-1]) p++;
 
 	} else {
@@ -462,7 +462,7 @@ PRIVATE void parse_cso ARGS2(
 	CONST char *,		arg,
 	HTParentAnchor *,	anAnchor)
 {
-    char ch;
+    int ich;
     char line[BIG];
     char *p = line;
     char *second_colon, last_char='\0';
@@ -493,11 +493,11 @@ PRIVATE void parse_cso ARGS2(
     /*
     **	Start grabbing chars from the network.
     */
-    while ((ch=NEXT_CHAR) != (char)EOF)
+    while ((ich=NEXT_CHAR) != EOF)
 	{
-	    if (ch != LF)
+	    if ((char)ich != LF)
 		{
-		    *p = ch;		/* Put character in line */
+		    *p = ich;		/* Put character in line */
 		    if (p< &line[BIG-1]) p++;
 		}
 	    else
@@ -924,7 +924,7 @@ PRIVATE int parse_cso_fields ARGS2(
 	char *, 	buf,
 	int,		size)
 {
-    char ch;
+    int ich;
     char *p = buf;
     int i, code = 0, prev_code;
     size_t alen;
@@ -938,7 +938,7 @@ PRIVATE int parse_cso_fields ARGS2(
     /*
     **	Start grabbing chars from the network.
     */
-    while ((ch = NEXT_CHAR) != (char)EOF) {
+    while ((ich = NEXT_CHAR) != EOF) {
 	if (interrupted_in_htgetcharacter) {
 	    CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
 	    free_CSOfields();
@@ -946,8 +946,8 @@ PRIVATE int parse_cso_fields ARGS2(
 	    return HT_INTERRUPTED;
 	}
 
-	if (ch != LF) {
-	    *p = ch;		/* Put character in buffer */
+	if ((char)ich != LF) {
+	    *p = ich;		/* Put character in buffer */
 	    if (p < &buf[size-1]) {
 		p++;
 	    }
@@ -1219,7 +1219,7 @@ PRIVATE int generate_cso_form ARGS4(
 PRIVATE int generate_cso_report ARGS1(
 	HTStream *,	Target)
 {
-    char ch;
+    int ich;
     char line[BIG];
     char *buf = 0;
     char *p = line, *href = NULL;
@@ -1235,15 +1235,15 @@ PRIVATE int generate_cso_report ARGS1(
     /*
     **	Start grabbing chars from the network.
     */
-    while (!stop && (ch = NEXT_CHAR) != (char)EOF) {
+    while (!stop && (ich = NEXT_CHAR) != EOF) {
 	if (interrupted_in_htgetcharacter) {
 	    CTRACE(tfp, "HTLoadCSO: Interrupted in HTGetCharacter, apparently.\n");
 	    _HTProgress (CONNECTION_INTERRUPTED);
 	    goto end_CSOreport;
 	}
 
-	if (ch != LF) {
-	    *p = ch;		/* Put character in line */
+	if ((char)ich != LF) {
+	    *p = ich;		/* Put character in line */
 	    if (p < &line[BIG-1]) {
 		p++;
 	    }
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index 4640f106..8669db3e 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -227,7 +227,7 @@ PRIVATE int response ARGS1(CONST char *,command)
 {
     int result;
     char * p = response_text;
-    char ch;
+    int ich;
 
     if (command) {
 	int status;
@@ -255,7 +255,8 @@ PRIVATE int response ARGS1(CONST char *,command)
     } /* if command to be sent */
 
     for (;;) {
-	if (((*p++ = NEXT_CHAR) == LF) ||
+	ich = NEXT_CHAR;
+	if (((*p++ = ich) == LF) ||
 	    (p == &response_text[LINE_LENGTH])) {
 	    *--p = '\0';			/* Terminate the string */
 	    CTRACE(tfp, "NNTP Response: %s\n", response_text);
@@ -263,7 +264,7 @@ PRIVATE int response ARGS1(CONST char *,command)
 	    return result;
 	} /* if end of line */
 
-	if ((ch = *(p-1)) == (char)EOF) {
+	if (ich == EOF) {
 	    *(p-1) = '\0';
 	    if (interrupted_in_htgetcharacter) {
 		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -965,8 +966,9 @@ PRIVATE int read_article ARGS1(
     */
     if (!diagnostic && !rawtext) {
 	while (!done) {
-	    char ch = *p++ = NEXT_CHAR;
-	    if (ch == (char)EOF) {
+	    int ich = NEXT_CHAR;
+	    *p++ = ich;
+	    if (ich == EOF) {
 		if (interrupted_in_htgetcharacter) {
 		    interrupted_in_htgetcharacter = 0;
 		    CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -978,7 +980,7 @@ PRIVATE int read_article ARGS1(
 		abort_socket(); 	/* End of file, close socket */
 		return(HT_LOADED);	/* End of file on response */
 	    }
-	    if ((ch == LF) || (p == &line[LINE_LENGTH])) {
+	    if (((char)ich == LF) || (p == &line[LINE_LENGTH])) {
 		*--p = '\0';			/* Terminate the string */
 		CTRACE(tfp, "H %s\n", line);
 
@@ -1309,8 +1311,9 @@ PRIVATE int read_article ARGS1(
 
     p = line;
     while (!done) {
-	char ch = *p++ = NEXT_CHAR;
-	if (ch == (char)EOF) {
+	int ich = NEXT_CHAR;
+	*p++ = ich;
+	if (ich == EOF) {
 	    if (interrupted_in_htgetcharacter) {
 		interrupted_in_htgetcharacter = 0;
 		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -1322,7 +1325,7 @@ PRIVATE int read_article ARGS1(
 	    abort_socket();	/* End of file, close socket */
 	    return(HT_LOADED);	/* End of file on response */
 	}
-	if ((ch == LF) || (p == &line[LINE_LENGTH])) {
+	if (((char)ich == LF) || (p == &line[LINE_LENGTH])) {
 	    *p++ = '\0';			/* Terminate the string */
 	    CTRACE(tfp, "B %s", line);
 	    if (line[0] == '.') {
@@ -1513,8 +1516,9 @@ PRIVATE int read_list ARGS1(char *, arg)
     START(HTML_DLC);
     PUTC('\n');
     while (!done) {
-	char ch = NEXT_CHAR;
-	if (ch == (char)EOF) {
+	int ich = NEXT_CHAR;
+	char ch = ich;
+	if (ich == EOF) {
 	    if (interrupted_in_htgetcharacter) {
 		interrupted_in_htgetcharacter = 0;
 		CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -1738,8 +1742,9 @@ PRIVATE int read_group ARGS3(
 	if (status == 221) {
 	    p = line;
 	    while (!done) {
-		char ch = *p++ = NEXT_CHAR;
-		if (ch == (char)EOF) {
+		int ich = NEXT_CHAR;
+		*p++ = ich;
+		if (ich == EOF) {
 		    if (interrupted_in_htgetcharacter) {
 			interrupted_in_htgetcharacter = 0;
 			CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -1751,7 +1756,7 @@ PRIVATE int read_group ARGS3(
 		    abort_socket();	/* End of file, close socket */
 		    return(HT_LOADED);	/* End of file on response */
 		}
-		if ((ch == '\n') || (p == &line[LINE_LENGTH])) {
+		if (((char)ich == '\n') || (p == &line[LINE_LENGTH])) {
 		    *p = '\0';		/* Terminate the string */
 		    CTRACE(tfp, "X %s", line);
 		    if (line[0] == '.') {
@@ -1841,8 +1846,9 @@ PRIVATE int read_group ARGS3(
 		p = line;				/* Write pointer */
 		done = NO;
 		while( !done ) {
-		    char ch = *p++ = NEXT_CHAR;
-		    if (ch == (char)EOF) {
+		    int ich = NEXT_CHAR;
+		    *p++ = ich;
+		    if (ich == EOF) {
 			if (interrupted_in_htgetcharacter) {
 			    interrupted_in_htgetcharacter = 0;
 			    CTRACE(tfp, "HTNews: Interrupted on read, closing socket %d\n",
@@ -1854,7 +1860,7 @@ PRIVATE int read_group ARGS3(
 			abort_socket(); 	/* End of file, close socket */
 			return(HT_LOADED);	/* End of file on response */
 		    }
-		    if ((ch == LF) ||
+		    if (((char)ich == LF) ||
 			(p == &line[LINE_LENGTH])) {
 
 			*--p = '\0';		/* Terminate  & chop LF*/
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index 9a89afdf..6beb2f44 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -813,14 +813,19 @@ PUBLIC void HTAddParam ARGS4(
 
 /*
  * Append the remaining command-string to a system command (compare with
- * HTAddParam).  Any remaining "%s" tokens are copied as-is.
+ * HTAddParam).  Any remaining "%s" tokens are copied as empty strings.
  */
 PUBLIC void HTEndParam ARGS3(
     char **,		result,
     CONST char *,	command,
     int,		number)
 {
-    CONST char *last = HTAfterCommandArg(command, number);
+    CONST char *last;
+    int count;
+    count = HTCountCommandArgs (command);
+    if (count < number)
+	number = count;
+    last = HTAfterCommandArg(command, number);
     if (last[0] != 0) {
 	HTSACat(result, last);
     }