about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.configure9
-rw-r--r--CHANGES.new110
-rw-r--r--LYMessages_en.h3
-rw-r--r--PROBLEMS36
-rw-r--r--WWW/Library/Implementation/HTAccess.c62
-rw-r--r--WWW/Library/Implementation/HTAccess.h3
-rw-r--r--WWW/Library/Implementation/HTChunk.c37
-rw-r--r--WWW/Library/Implementation/HTChunk.h8
-rw-r--r--WWW/Library/Implementation/HTFTP.c104
-rw-r--r--WWW/Library/Implementation/HTFile.c3
-rw-r--r--WWW/Library/Implementation/HTFormat.c120
-rw-r--r--WWW/Library/Implementation/HTFormat.h11
-rw-r--r--WWW/Library/Implementation/HTMIME.c2
-rw-r--r--WWW/Library/Implementation/HTMLGen.c2
-rw-r--r--WWW/Library/Implementation/HTParse.c2
-rw-r--r--WWW/Library/Implementation/HTTP.c4
-rw-r--r--WWW/Library/Implementation/LYLeaks.h15
-rw-r--r--WWW/Library/Implementation/SGML.c235
-rw-r--r--WWW/Library/Implementation/SGML.h7
-rw-r--r--WWW/Library/Implementation/UCAux.h22
-rw-r--r--WWW/Library/Implementation/tcp.h30
-rw-r--r--WWW/Library/vms/descrip.mms3
-rw-r--r--WWW/Library/vms/libmake.com27
-rw-r--r--about_lynx/about_lynx-dev.html70
-rw-r--r--build-slang.com53
-rw-r--r--build.com53
-rwxr-xr-xconfigure2
-rw-r--r--configure.in2
-rw-r--r--docs/CHANGES2-3 (renamed from CHANGES2-3)0
-rw-r--r--docs/CHANGES2-4 (renamed from CHANGES2-4)0
-rw-r--r--docs/CHANGES2-5 (renamed from CHANGES2-5)0
-rw-r--r--docs/CHANGES2-6 (renamed from CHANGES2-6)0
-rw-r--r--docs/CMU.announce (renamed from CMU.announce)0
-rw-r--r--docs/CRAWL.announce (renamed from CRAWL.announce)0
-rw-r--r--docs/FM.announce (renamed from FM.announce)0
-rw-r--r--docs/IBMPC-charsets.announce (renamed from IBMPC-charsets.announce)0
-rw-r--r--docs/RFC-MAILCAP.txt742
-rw-r--r--docs/SOCKETSHR.announce (renamed from SOCKETSHR.announce)0
-rw-r--r--docs/TCPWARE.announce (renamed from TCPWARE.announce)0
-rw-r--r--docs/VMSWAIS.announce (renamed from VMSWAIS.announce)0
-rw-r--r--lynx.cfg3
-rw-r--r--lynx_help/Lynx_users_guide.html30
-rw-r--r--lynx_help/keystrokes/bookmark_help.html (renamed from lynx_help/keystroke_commands/bookmark_help.html)0
-rw-r--r--lynx_help/keystrokes/cookie_help.html (renamed from lynx_help/keystroke_commands/cookie_help.html)0
-rw-r--r--lynx_help/keystrokes/dired_help.html (renamed from lynx_help/keystroke_commands/dired_help.html)0
-rw-r--r--lynx_help/keystrokes/edit_help.html (renamed from lynx_help/keystroke_commands/edit_help.html)0
-rw-r--r--lynx_help/keystrokes/follow_help.html (renamed from lynx_help/keystroke_commands/follow_help.html)0
-rw-r--r--lynx_help/keystrokes/gopher_types_help.html (renamed from lynx_help/keystroke_commands/gopher_types_help.html)0
-rw-r--r--lynx_help/keystrokes/history_help.html (renamed from lynx_help/keystroke_commands/history_help.html)0
-rw-r--r--lynx_help/keystrokes/keystroke_help.html (renamed from lynx_help/keystroke_commands/keystroke_help.html)1
-rw-r--r--lynx_help/keystrokes/movement_help.html (renamed from lynx_help/keystroke_commands/movement_help.html)0
-rw-r--r--lynx_help/keystrokes/option_help.html (renamed from lynx_help/keystroke_commands/option_help.html)0
-rw-r--r--lynx_help/keystrokes/other_help.html (renamed from lynx_help/keystroke_commands/other_help.html)4
-rw-r--r--lynx_help/keystrokes/print_help.html (renamed from lynx_help/keystroke_commands/print_help.html)0
-rw-r--r--lynx_help/keystrokes/scrolling_help.html (renamed from lynx_help/keystroke_commands/scrolling_help.html)0
-rw-r--r--lynx_help/keystrokes/visited_help.html (renamed from lynx_help/keystroke_commands/visited_help.html)0
-rw-r--r--lynx_help/keystrokes/xterm_help.html (renamed from lynx_help/keystroke_commands/xterm_help.html)0
-rw-r--r--lynx_help/lynx_help_main.html4
-rw-r--r--lynx_help/lynx_url_support.html8
-rw-r--r--makefile.in4
-rw-r--r--samples/lynx.cfg1
-rw-r--r--samples/lynx.lss (renamed from styles/lynx.lss)0
-rw-r--r--src/AttrList.h3
-rw-r--r--src/GridText.c680
-rw-r--r--src/GridText.h5
-rw-r--r--src/HTFWriter.c2
-rw-r--r--src/HTForms.h1
-rw-r--r--src/HTInit.c66
-rw-r--r--src/HTML.c70
-rw-r--r--src/LYCharSets.c3
-rw-r--r--src/LYCharUtils.c887
-rw-r--r--src/LYCharUtils.h2
-rw-r--r--src/LYCookie.c2
-rw-r--r--src/LYCurses.c3
-rw-r--r--src/LYEditmap.c2
-rw-r--r--src/LYForms.c16
-rw-r--r--src/LYGetFile.c15
-rw-r--r--src/LYHash.c11
-rw-r--r--src/LYHash.h16
-rw-r--r--src/LYKeymap.c2
-rw-r--r--src/LYLeaks.c77
-rw-r--r--src/LYMain.c76
-rw-r--r--src/LYMainLoop.c65
-rw-r--r--src/LYOptions.c6
-rw-r--r--src/LYStrings.c33
-rw-r--r--src/LYStrings.h1
-rw-r--r--src/LYStyle.c54
-rw-r--r--src/LYUtils.c53
-rw-r--r--src/LYUtils.h1
-rw-r--r--src/LYexit.c2
-rw-r--r--src/UCAux.c50
-rw-r--r--src/chrtrans/def7_uni.tbl9
-rw-r--r--src/chrtrans/makefile.dos92
-rw-r--r--test/ALT88592.html170
-rw-r--r--test/iso88592.html173
-rw-r--r--utils/inews/Makefile69
-rw-r--r--utils/inews/Manifest11
-rw-r--r--utils/inews/README55
-rw-r--r--utils/inews/README.NN83
-rw-r--r--utils/inews/clientlib.c525
-rw-r--r--utils/inews/clientlib.h11
-rw-r--r--utils/inews/conf.h146
-rw-r--r--utils/inews/config.h392
-rw-r--r--utils/inews/config.h-dist392
-rw-r--r--utils/inews/inews.c392
-rw-r--r--utils/inews/nntp.h73
-rw-r--r--utils/inews/version.c5
107 files changed, 2481 insertions, 4153 deletions
diff --git a/CHANGES.configure b/CHANGES.configure
index 5e43dedb..3cd7a4cd 100644
--- a/CHANGES.configure
+++ b/CHANGES.configure
@@ -1,3 +1,12 @@
+97-10-08
+--------
+* add logic to implement mouse button 2 "previous document" for
+  ncurses configuration. - TD
+* add dependencies on 'lynx' to top-level 'all' and 'install' rules
+  in makefile.in - TD
+* add osf4.0 to special case compiler options using -g3 in place of
+  -O -g, for Heikki Kantola <hezu@iki.fi>. - TD
+* correct some of the uninitialized-variable warnings. - TD
 97-09-19
 --------
 * minor ifdef/declaration fixes required to build on IRIX 6.2,
diff --git a/CHANGES.new b/CHANGES.new
index bb080cbb..2f765a09 100644
--- a/CHANGES.new
+++ b/CHANGES.new
@@ -10,6 +10,110 @@ README.configure), and miscellaneous other changes.  Note that the 2.7 ->
 2.7.1 changes (which are listed at the beginning of the current CHANGES
 file) are duplicated here. - KW]
 
+1997-10-16
+* Tweaks to recognition of Japanese (better recognize x-euc-*), and to
+  the mechanism in GridText.c keeping track of which encoding is used for
+  Japanese.  The state for this is now reset on explicit '\n' and '\r'
+  received by the HText object in addition to space chars. - KW
+* Tweaks in HTTP.c to avoid access to uninitialized memory and pacify
+  paranoid dbx. - KW
+* Try to more consistently remember the charset in effect for a document
+  when going to SOURCE view, using new LYUC{Push,Pop}Assumed functions.
+  Note that this is only in effect immediately when swithching to SOURCE
+  view; any later reloading while within SOURCE view (including those
+  caused by RELOAD, RAW_TOGGLE and other keys, or by Options Screen changes)
+  may still revert to the usual assumption about charset, which means a
+  charset specified in a META tag may be forgotten at that point; this may
+  be considered a feature... - KW
+* Refer to TagSoup and SortaSGML parsing (coinded by FM), rather than "old"
+  and "new" DTD. - KW
+* Made some of the changes concerning and removal and location changes of
+  files proposed by NHE. - KW
+* Restored LYCheckForCSI example function to its previous form, with a check
+  added and comments added. - KW 
+1997-10-15
+* Various fixes for color style code, should prevent memory corruption. - KW
+* Some LYCharUtils.c cleanup. - KW
+* Added some of the changes from fotemods to SGML.c, especially handling of
+  &zwnj; as allowing a line break, and conversion to UNICODE UTF-8. - KW
+* Mods in code handling mailcap lines, to avoid access to invalid memory. - KW
+1997-10-12
+* Added LYLeakSACopy and LYLeakSACat to LYLeaks.c.  Running Lynx compiled
+  with LY_FIND_LEAKS defined will now give the source locations where
+  StrAllocCopy and StrAllocCat are used, if those create leaks.  Added
+  missing incude of LYLeaks.h in LYCookie.c. - KW
+* More heavy tweaks in LYCharUtils.c.  Associated changes in HTChunk.c
+  (new functions), small change for -raw (in connection with attribute
+  values) in SGML_character.  LYCharUtils.c is still a work in
+  progress... - KW
+* Tweaks to allow some chars as data input (0x97, 0x9b, 0xa0) if the
+  current display character set seems to have those values as printable
+  charactes (by testing LYlowest_eightbit[]). - KW
+1997-10-11
+* Mods in HTFTP.c to recognize NetPresenz server (variation of AppleShare
+  claiming to be Peter Lewis server?, try current ftp://www.unicode.org/),
+  and to show server's identification from initial greeting on info
+  screen for FTP URLs.  Other cosmetic changes in HTFTP.c. - KW
+* Fixed various memory leaks. - KW
+* Some more minor cleanup tweaks for color style code. - KW
+* Avoid unnecessary pauses if TRACE is on and a Trace Log file is in use. - KW
+1997-10-10
+* Renamed lynx_help/keystroke_commands/ directory to lynx_help/keystrokes/
+  for the benefit of DOS, and changed references accordingly. - KW
+* Changed parsing of command line options for -lss file, it should now
+  be used and override the default from userdefs.h or environmetn variables
+  as advertised. - KW
+* More tweaks and cleanup in HText_SubmitForm. - KW
+* Code to recover from memory exhaustion, sometimes.  The requests for
+  dynamic memory which heuristically most often fail for lack of memory
+  when rndering large documents are the calloc() calls in split_line.
+  They are replaced by LY_check_calloc() which has the same calling
+  conventions as calloc() but additionally checks if "enough" memory is
+  available for the requested amount plus some margin and tries some
+  remedial action if this is not the case.  The additional safty margins
+  are required to make it likely that other allocation requests in other
+  places of the program won't fail before the next check.  The actions
+  which may be taken in order to avoid exiting if low memory is detected:
+  (1) Try to unload cached documents (other than the one currently being
+  loaded), until we seem to have enough memory.  (2) If that fails (or
+  there are no other documents cached in memory), try to fake a 'Z' key
+  interruption; this will have the same effect as if the user had pressed
+  'Z' so it will only detected if some other part of the program tests
+  HTCheckForInterrupt() and acts on it.  (3) If this seems not to be
+  sufficient to stop loading, halt appending of normal text data to the
+  document structure (A warning *** MEMORY EXHAUSTED *** is appended
+  instead). - KW
+* A tweak of color style memory allocation. - KW
+1997-10-09
+* Some more tweaks from FM for VMS build - KW
+* For DJGPP compilation, src/chrtrans/makefile.dos - Bill Schiavo
+  <Wschiavo@concentric.net>
+* Some cleanup in Hext_SubmitForm (needs more). Start using ACCEPT-CHARSET
+  (doesn't recognize list yet, only recognized if on the INPUT field that
+  causes submission). - KW
+* Added two test files for iso-8859-2 charset. - KW
+* Tweaks in LYMainLoop.c for various keys that page up, to better preserve
+  keep the current link selected if possible and to correct a glitch with
+  UP_LINK. - KW
+* Reorder text/html and text/plain to the beginning of HTPresentations list,
+  so they will be found more quickly and will appear at the beginning of
+  Accept request header fields. - KW
+1997-10-08
+* add logic to implement mouse button 2 "previous document" for
+  ncurses configuration. - TD
+* add dependencies on 'lynx' to top-level 'all' and 'install' rules
+  in makefile.in - TD
+* add osf4.0 to special case compiler options using -g3 in place of
+  -O -g, for Heikki Kantola <hezu@iki.fi>. - TD
+* correct some of the uninitialized-variable warnings. - TD
+* Removed the compilation of the old libwww-FM HTAlert.c module for VMS,
+  as previously removed for Unix. - FM
+* Added comments and tweaks of build.com, build-slang.com and libmake.com,
+  (and a complementary tweak of tcp.h) to make more clear how compiler
+  definitions and compiler and linker options can be added. - FM
+1997-10-07
+* Changed PROBLEMS file for ^Z and for "forgetting emphasis of link text"
+  problem (which shouldn't occur any more). - KW
 1997-10-05
 * Changed SGML.c parsing of unrecognized and invalid start tags. If the
   '<' character in HTML is followed by a 7-bit letter character, we now
@@ -44,14 +148,14 @@ file) are duplicated here. - KW]
   specifying a CJK charset as assumed is currently not very useful, since we
   cannot translate from that to other character sets. - KW
 * Oh, by the way: compilation without defining EXP_CHARTRANS won't work any
-  more.  Regard #ifdef EXP_CHARTRANS is some strange kind of comment for
+  more.  Regard #ifdef EXP_CHARTRANS as some strange kind of comment for
   now, until it goes away. - KW
 * Write comment at top of .lynxrc file to make clear that it is different
   from lynx.cfg, suggested by LWV. - KW 
 1997-09-30
 * Changed order of display character sets on options screen a bit, and
   corrected charset listings in lynx.cfg and userdefs.h files - KW
-* Added comment on lynx.lss in lynx.cfg, moved it. - KW
+* Added comment on lynx.lss in userdefs.h, moved it. - KW
 1997-09-27
 * Made TRACE messages which correspond to BAD_HTML_USE_TRACE warnings stand
   out more by decorating them with ***** characters, so that users who
@@ -1867,7 +1971,7 @@ file) are duplicated here. - KW]
   seeking a position in the currently loaded document. - FM
 * Commented out the above change in HTAccess.c.  There's a more complete
   mechanism for it already in this code... - KW
-* Fixed a typo in the bookmark file lead text. - DK (Doug Kaufmann
+* Fixed a typo in the bookmark file lead text. - DK (Doug Kaufman
   <dkaufman@rahul.net>)
 1997-04-19
 * Changed the inappropriate StrAllocCat() to StrAllocCopy() for
diff --git a/LYMessages_en.h b/LYMessages_en.h
index 9f84b0bd..6286c464 100644
--- a/LYMessages_en.h
+++ b/LYMessages_en.h
@@ -126,6 +126,7 @@
 #define RESETTING_FORM "Resetting form..."
 #define RELOADING_FORM \
  "Reloading document.  Any form entries will be lost!"
+#define CANNOT_TRANSCODE_FORM "Warning: Cannot transcode form data to charset %s!"
 #define BAD_FORM_MAILTO "Malformed mailto form submission!  Cancelled!"
 #define FORM_MAILTO_DISALLOWED "Mail disallowed!  Cannot submit."
 #define FORM_MAILTO_FAILED "Mailto form submission failed!"
@@ -259,6 +260,8 @@
  "Minimal comment parsing OFF (Historical is in effect)!"
 #define SOFT_DOUBLE_QUOTE_ON "Soft double-quote parsing ON!"
 #define SOFT_DOUBLE_QUOTE_OFF "Soft double-quote parsing OFF!"
+#define USING_DTD_0 "Now using TagSoup parsing of HTML."
+#define USING_DTD_1 "Now using SortaSGML parsing of HTML!"
 #define ALREADY_AT_END "You are already at the end of this document."
 #define ALREADY_AT_BEGIN "You are already at the beginning of this document."
 #define ALREADY_AT_PAGE "You are already at page %d of this document."
diff --git a/PROBLEMS b/PROBLEMS
index c824c7d5..772c0b1c 100644
--- a/PROBLEMS
+++ b/PROBLEMS
@@ -8,6 +8,7 @@ they will be outlined in this file.
     problems, use -restrictions=suspend to disable it, and only '!'
     for escapes to shell (on VMS control-Z is unconditional 'Q'uit,
     with no attempt to suspend the Lynx process only temporarily).
+    Control-Z on Unix often works better with slang.
 
     Screen resizing can be a bit funny.  If you resize the screen, 
     documents that have been cached will be out of whack.  Any further 
@@ -95,13 +96,34 @@ they will be outlined in this file.
     	  patches PHCO_8086 and PHCO_8947 from HP.
 
     Lynx juggles variable abilities of curses packages or emulations to
-    display bolding and underlining simultaneously.  One consequence of
-    the current code, affected (fancy) curses and slang implementations,
-    is that if a link is both bolded and underlined based on the markup,
-    the underlining will be lost and only the bolding will be restored
-    following it's being reversed to indicate it as the current link,
-    and the additional underlining will not be restored until/unless
-    the page is refreshed.  
+    display bolding and underlining simultaneously.  This may fail if
+    Lynx thinks that your terminal, in connection with the curses package,
+    supports a capability which the terminal hardware or emulation does not
+    in fact support.  Setting the right TERM environment variable, tweaking
+    terminfo or termcap files, or compiling with a newer version of ncurses
+    or slang may solve problems with missing highlighting or strange
+    characters appearing on the screen.  Also, for a mono terminal, make sure
+    that there is no "show color (&)  : ON" on the Options screen.
+
+    The Wyse 50 and older TeleVideo terminals, among others, are
+    "magic cookie" terminals.  This means that display attributes like
+    reverse, blink, underline, etc. work in a bizarre way that makes them
+    difficult to program.  You may see extra spaces scattered around your
+    screen (separating different sorts of highlight); or sections of the
+    screen may be unexpectedly highlighted.
+    There is a workaround which works by restricting the terminal to a
+    single standout attribute (e.g.  normal and reverse, but no others).
+    Implementing the workaround is specific to your curses implementation.
+    Most versions of curses use one of two terminal databases, called
+    "termcap" and "terminfo".  Updating these databases is system-specific.
+    New databases should be available from the vendor or other sources.
+    For the Wyse 50, try
+       <URL: http://www.wyse.com/text/custserv/faq/wy50faq.htm>;
+    extract the "wy50" (NOT "wy50-mc") entry and use that in place of the
+    existing one.  See `terminfo', `infocmp', `tic' etc. man pages if
+    necessary.
+    Alternatively, compiling Lynx with the slang library may avoid problems
+    with theses terminals.
 
     On VMS, Lynx, and other TCP-IP software, have been experiencing chronic
     problems of incompatibilites between DECC and MultiNet headers whenever
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 816d64d2..2f21eaad 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -61,6 +61,8 @@
 #include "HText.h"	/* See bugs above */
 #include "HTAlert.h"
 #include "HTCJK.h"
+#include "UCMap.h"
+#include "LYGlobalDefs.h"
 
 #include "LYexit.h"
 #include "LYLeaks.h"
@@ -88,11 +90,14 @@ PRIVATE HTList * protocols = NULL; /* List of registered protocol descriptors */
 
 PUBLIC char *use_this_url_instead = NULL;
 
+PRIVATE int pushed_assume_LYhndl = -1; /* see LYUC* functions below - kw */
+PRIVATE char * pushed_assume_MIMEname = NULL;
 
 PRIVATE void free_protocols NOARGS
 {
     HTList_delete(protocols);
     protocols = NULL;
+    FREE(pushed_assume_MIMEname); /* shouldn't happen, just in case - kw */
 }
 
 /*	Register a Protocol.				HTRegisterProtocol()
@@ -241,11 +246,11 @@ PUBLIC BOOL override_proxy ARGS1(
         if (!strcmp("file", access) &&
 	    (!strcmp(Host, "localhost") ||
 #ifdef VMS
-             !strcasecomp(Host, HTHostName())))
+             !strcasecomp(Host, HTHostName())
 #else
-             !strcmp(Host, HTHostName())))
+             !strcmp(Host, HTHostName())
 #endif /* VMS */
-        {
+        )) {
 	    FREE(host);
 	    FREE(access);
 	    return YES;
@@ -524,6 +529,56 @@ PRIVATE int get_physical ARGS2(
     return HT_NO_ACCESS;
 }
 
+/*
+ *  Temporarily set the int UCLYhndl_for_unspec and string
+ *  UCLYhndl_for_unspec used for charset "assuming" to the values
+ *  implied by a HTParentAnchor's UCStages, after saving the current
+ *  values for later restoration. - kw
+ *  @@@ These functions may not really belong here, but where else?
+ *  I want the "pop" to occur as soon as possible after loading
+ *  has finished. - kw @@@   
+ */
+
+PUBLIC void LYUCPushAssumed ARGS1(
+    HTParentAnchor *,	anchor)
+{
+    int anchor_LYhndl = -1;
+    LYUCcharset * anchor_UCI = NULL;
+    if (anchor) {
+	anchor_LYhndl = HTAnchor_getUCLYhndl(anchor, UCT_STAGE_PARSER);
+	if (anchor_LYhndl >= 0)
+	    anchor_UCI = HTAnchor_getUCInfoStage(anchor,
+						 UCT_STAGE_PARSER);
+	if (anchor_UCI && anchor_UCI->MIMEname) {
+	    pushed_assume_LYhndl = anchor_LYhndl;
+	    UCLYhndl_for_unspec = anchor_LYhndl;
+	    pushed_assume_MIMEname = UCAssume_MIMEcharset;
+	    UCAssume_MIMEcharset = NULL;
+	    StrAllocCopy(UCAssume_MIMEcharset, anchor_UCI->MIMEname);
+	    return;
+	}
+    }
+    pushed_assume_LYhndl = -1;
+    FREE(pushed_assume_MIMEname);
+}
+/*
+ *  Restore the int UCLYhndl_for_unspec and string
+ *  UCLYhndl_for_unspec used for charset "assuming" from the values
+ *  saved by LYUCPushAssumed, if any. - kw
+ */
+PRIVATE int LYUCPopAssumed NOARGS
+{
+    if (pushed_assume_LYhndl >= 0) {
+	UCLYhndl_for_unspec = pushed_assume_LYhndl;
+	pushed_assume_LYhndl = -1;
+	FREE(UCAssume_MIMEcharset);
+	UCAssume_MIMEcharset = pushed_assume_MIMEname;
+	pushed_assume_MIMEname = NULL;
+	return UCLYhndl_for_unspec;
+    }
+    return -1;
+}
+
 /*	Load a document					HTLoad()
 **	---------------
 **
@@ -559,6 +614,7 @@ PRIVATE int HTLoad ARGS4(
     status= (*(p->load))(HTAnchor_physical(anchor),
     			anchor, format_out, sink);
     anchor->underway = FALSE;
+    LYUCPopAssumed();
     return status;
 }
 
diff --git a/WWW/Library/Implementation/HTAccess.h b/WWW/Library/Implementation/HTAccess.h
index d883e10f..2826d13a 100644
--- a/WWW/Library/Implementation/HTAccess.h
+++ b/WWW/Library/Implementation/HTAccess.h
@@ -316,6 +316,9 @@ For registering protocols supported by Lynx
 */
 extern void LYRegisterLynxProtocols NOARGS;
 
+extern void LYUCPushAssumed PARAMS((
+    HTParentAnchor *	anchor));
+
 #endif /* HTACCESS_H */
 /*
 
diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c
index 64a7e0ba..497e5173 100644
--- a/WWW/Library/Implementation/HTChunk.c
+++ b/WWW/Library/Implementation/HTChunk.c
@@ -27,6 +27,27 @@ PUBLIC HTChunk * HTChunkCreate ARGS1 (int,grow)
     return ch;
 }
 
+/*	Create a chunk with a certain allocation unit and ensured size
+**	--------------
+*/
+PUBLIC HTChunk * HTChunkCreate2 ARGS2 (int,grow, size_t, needed)
+{
+    HTChunk * ch = (HTChunk *) calloc(1, sizeof(HTChunk));
+    if (ch == NULL)
+        outofmem(__FILE__, "HTChunkCreate2");
+
+    ch->growby = grow;
+    if (needed > 0) {
+	ch->allocated = needed-1 - ((needed-1) % ch->growby)
+	    + ch->growby; /* Round up */
+	ch->data = (char *)calloc(1, ch->allocated);
+	if (!ch->data)
+	    outofmem(__FILE__, "HTChunkCreate2 data");
+    }
+    ch->size = 0;
+    return ch;
+}
+
 
 /*	Clear a chunk of all data
 **	--------------------------
@@ -79,6 +100,22 @@ PUBLIC void HTChunkEnsure ARGS2 (HTChunk *,ch, int,needed)
         outofmem(__FILE__, "HTChunkEnsure");
 }
 
+PUBLIC void HTChunkPutb ARGS3 (HTChunk *,ch, CONST char *,b, int,l)
+{
+    int needed = ch->size + l;
+    if (l <= 0) return;
+    if (needed > ch->allocated) {
+	ch->allocated = needed-1 - ((needed-1) % ch->growby)
+	    + ch->growby; /* Round up */
+        ch->data = ch->data ? (char *)realloc(ch->data, ch->allocated)
+			    : (char *)calloc(1, ch->allocated);
+	if (ch->data == NULL)
+	    outofmem(__FILE__, "HTChunkPutb");
+    }
+    memcpy(ch->data + ch->size, b, l);
+    ch->size += l;
+}
+
 #ifdef EXP_CHARTRANS
 
 #define PUTC(code) ch->data[ch->size++] = (char)(code)
diff --git a/WWW/Library/Implementation/HTChunk.h b/WWW/Library/Implementation/HTChunk.h
index c7308165..a5e89b31 100644
--- a/WWW/Library/Implementation/HTChunk.h
+++ b/WWW/Library/Implementation/HTChunk.h
@@ -47,6 +47,12 @@ Create new chunk
 
 extern HTChunk * HTChunkCreate PARAMS((int growby));
 
+/*
+ *  Like HTChunkCreate but with initial allocation - kw
+ *
+ */
+extern HTChunk * HTChunkCreate2 PARAMS((int growby, size_t needed));
+
 
 /*
 
@@ -118,6 +124,8 @@ Append a character to a  chunk
  */
 extern void HTChunkPutc PARAMS((HTChunk * ch, char c));
 
+extern void HTChunkPutb PARAMS((HTChunk * ch, CONST char *b, int l));
+
 #ifdef EXP_CHARTRANS
 extern void HTChunkPutUtf8Char PARAMS((HTChunk * ch, UCode_t code));
 
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index a3ad9de1..0e5b801b 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -162,7 +162,7 @@ extern char *personal_mail_address;
 */
 PRIVATE connection * connections = 0;	/* Linked list of connections */
 PRIVATE char response_text[LINE_LENGTH+1];/* Last response from NewsHost */
-PRIVATE connection * control;		/* Current connection */
+PRIVATE connection * control = NULL;		/* Current connection */
 PRIVATE int data_soc = -1;		/* Socket for data transfer =invalid */
 
 #define GENERIC_SERVER	   0
@@ -178,6 +178,7 @@ PRIVATE int data_soc = -1;		/* Socket for data transfer =invalid */
 #define MS_WINDOWS_SERVER 10
 #define MSDOS_SERVER      11
 #define APPLESHARE_SERVER 12
+#define NETPRESENZ_SERVER 13
 
 PRIVATE int     server_type = GENERIC_SERVER;   /* the type of ftp host */
 PRIVATE int     unsure_type = FALSE;            /* sure about the type? */
@@ -318,8 +319,13 @@ PRIVATE int close_connection ARGS1(
 {
     connection * scan;
     int status = NETCLOSE(con->socket);
-    if (TRACE)
+    if (TRACE) {
         fprintf(stderr, "HTFTP: Closing control socket %d\n", con->socket);
+#ifdef UNIX
+	if (status != 0)
+	    perror("HTFTP:close_connection");
+#endif
+    }
     con->socket = -1;
     if (connections == con) {
         connections = con->next;
@@ -336,6 +342,15 @@ PRIVATE int close_connection ARGS1(
     return -1;		/* very strange -- was not on list. */
 }
 
+PRIVATE void cleanup_ftp NOARGS
+{
+    if (control) {
+	if (control->socket != -1)
+	    close_connection(control);
+	FREE(control);
+    }
+}
+
 PRIVATE char *help_message_buffer = NULL;  /* global :( */
 
 PRIVATE void init_help_message_cache NOARGS
@@ -509,7 +524,8 @@ PRIVATE int set_mac_binary ARGS1(
         int,		server_type)
 {
     /* try to set mac binary mode */
-    if (server_type == APPLESHARE_SERVER) {
+    if (server_type == APPLESHARE_SERVER ||
+	server_type == NETPRESENZ_SERVER) {
 	/*
 	 *  Presumably E means "Enable"  - kw
 	 */
@@ -573,7 +589,8 @@ PRIVATE void get_ftp_pwd ARGS2(
 
         if ((*server_type == NCSA_SERVER) ||
             (*server_type == TCPC_SERVER) ||
-            (*server_type == PETER_LEWIS_SERVER))
+            (*server_type == PETER_LEWIS_SERVER) ||
+            (*server_type == NETPRESENZ_SERVER))
             set_mac_binary(*server_type);
     }
 }
@@ -593,8 +610,9 @@ PRIVATE void get_ftp_pwd ARGS2(
 **	It ensures that all connections are logged in if they exist.
 **	It ensures they have the port number transferred.
 */
-PRIVATE int get_connection ARGS1(
-	CONST char *,	arg)
+PRIVATE int get_connection ARGS2(
+	CONST char *,		arg,
+	HTParentAnchor *,	anchor)
 {
     int status;
     char * command;
@@ -603,15 +621,32 @@ PRIVATE int get_connection ARGS1(
     char * password=NULL;
     static char *user_entered_password=NULL;
     static char *last_username_and_host=NULL;
+    static BOOLEAN firstuse = TRUE;
 
-    /*
-    **  Allocate and init control struct.
-    */
-    con = (connection *)calloc(1, sizeof(connection));
-    
     if (!arg) return -1;		/* Bad if no name sepcified	*/
     if (!*arg) return -1;		/* Bad if name had zero length	*/
 
+    if (control) {
+	/*
+	**  Reuse this object - kw
+	*/
+	if (control->socket != -1)
+	    NETCLOSE(control->socket);
+	con = control;
+    } else {
+	/*
+	**  Allocate and init control struct.
+	*/
+	con = (connection *)calloc(1, sizeof(connection));
+	if (con == NULL)
+	    outofmem(__FILE__, "get_connection");
+	if (firstuse) {
+	    atexit(cleanup_ftp);
+	    firstuse = FALSE;
+	}
+    }
+    con->socket = -1;
+
 /* Get node name:
 */
     {
@@ -691,12 +726,15 @@ PRIVATE int get_connection ARGS1(
         }
 
       FREE(username);
+      if (control == con)
+	  control = NULL;
       FREE(con);
       return status;                    /* Bad return */
     }
 
     if (TRACE) 
- 	fprintf(stderr, "FTP connected, socket %ld\n", (long)con);
+ 	fprintf(stderr, "FTP connected, socket %d  control %ld\n",
+			con->socket, (long)con);
     control = con;		/* Current control connection */
 
     /* Initialise buffering for control connection */
@@ -719,7 +757,23 @@ PRIVATE int get_connection ARGS1(
         control->socket = -1;
         return HT_INTERRUPTED;
       }
+    server_type = GENERIC_SERVER;	/* reset */
     if (status == 2) {		/* Send username */
+	{
+	    char *cp;		/* look at greeting text */
+	    if (strlen(response_text) > 4) {
+		if ((cp = strstr(response_text, " awaits your command")) ||
+		    (cp = strstr(response_text, " ready."))) {
+		    *cp = '\0';
+		}
+		cp = response_text + 4;
+		if (!strncasecomp(cp, "NetPresenz", 10))
+		    server_type = NETPRESENZ_SERVER;
+	    } else {
+		cp = response_text;
+	    }
+	    StrAllocCopy(anchor->server, cp);
+	}
 	if (username && *username) {
 	    command = (char*)malloc(10+strlen(username)+2+1);
 	    if (command == NULL)
@@ -837,7 +891,8 @@ PRIVATE int get_connection ARGS1(
     if (TRACE) fprintf(stderr, "HTFTP: Logged in.\n");
 
     /** Check for host type **/
-    server_type = GENERIC_SERVER;	/* reset */
+    if (server_type != NETPRESENZ_SERVER)
+	server_type = GENERIC_SERVER;	/* reset */
     use_list = FALSE; 			/* reset */
     if ((status=response("SYST\r\n")) == 2) {
         /* we got a line -- what kind of server are we talking to? */
@@ -887,6 +942,13 @@ PRIVATE int get_connection ARGS1(
             get_ftp_pwd(&server_type, &use_list);
 	    unsure_type = TRUE;
 
+        } else if (server_type == NETPRESENZ_SERVER) { /* already set above */
+            use_list = TRUE;
+            set_mac_binary(server_type);
+	    if (TRACE)
+	        fprintf(stderr,
+	 	 	"HTFTP: Treating as NetPresenz (MACOS) server.\n");
+
         } else if (strncmp(response_text+4, "MACOS Peter's Server", 20) == 0) {
             server_type = PETER_LEWIS_SERVER;
             use_list = TRUE;
@@ -1924,6 +1986,7 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 	case MSDOS_SERVER:
         case WINDOWS_NT_SERVER:
         case APPLESHARE_SERVER:
+        case NETPRESENZ_SERVER:
 	    /*
 	    **  Check for EPLF output (local times).
 	    */
@@ -1937,6 +2000,11 @@ PRIVATE EntryInfo * parse_dir_entry ARGS2(
 	    */
             len = strlen(entry);
 	    if (*first) {
+		if (!strcmp(entry, "can not access directory .")) {
+		    /* don't reset *first, nothing real will follow - kw */
+		    entry_info->display=FALSE;
+		    return(entry_info);
+		}
 	        *first = FALSE;
                 if (!strncmp(entry, "total ", 6) ||
                     strstr(entry, "not available") != NULL) {
@@ -2462,7 +2530,9 @@ AgainForMultiNet:
 		 if (TRACE)
 		     fprintf(stderr, "Adding file to BTree: %s\n",
 		     		     entry_info->filename);
-	         HTBTree_add(bt, (EntryInfo *)entry_info); 
+	         HTBTree_add(bt, (EntryInfo *)entry_info);
+	    } else {
+		FREE(entry_info);
 	    }
 
 	}  /* next entry */
@@ -2532,13 +2602,15 @@ unload_btree:
 		free_entryinfo_struct_contents(entry_info);
 	    }
 	}
+	END(HTML_PRE);
 	FREE_TARGET;
 	HTBTreeAndObject_free(bt);
     }
 
     FREE(lastpath);
 
-    if (server_type == APPLESHARE_SERVER) {
+    if (server_type == APPLESHARE_SERVER ||
+	server_type == NETPRESENZ_SERVER) {
 	/*
 	 *  Without closing the data socket first,
 	 *  the response(NIL) below hangs... - kw
@@ -2590,7 +2662,7 @@ PUBLIC int HTFTPLoad ARGS4(
     server_type = GENERIC_SERVER;
 
     for (retry = 0; retry < 2; retry++) { /* For timed out/broken connections */
-	status = get_connection(name);
+	status = get_connection(name, anchor);
 	if (status < 0)
 	    return status;
 
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 93553bcb..3ec307fc 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -743,7 +743,7 @@ PUBLIC HTFormat HTFileFormat ARGS3(
 #ifdef VMS
     char *semicolon = NULL;
 #endif /* VMS */
-    extern char LYforce_HTML_mode;
+    extern BOOLEAN LYforce_HTML_mode;
 
     if (pencoding)
 	*pencoding = NULL;
@@ -2370,6 +2370,7 @@ PUBLIC int HTLoadFile ARGS4(
 		}
 		return status;
 	    }  /* If succesfull open */
+	    FREE(localname);
 	}    /* scope of fp */
     }  /* local unix file system */    
 #endif /* !NO_UNIX_IO */
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index 3b33fb9a..2653833f 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -296,38 +296,29 @@ PRIVATE int half_match ARGS2(char *,trial_type, char *,target)
     return 0;
 }
 
-/*		Create a filter stack
-**		---------------------
+/*		Look up a presentation
+**		----------------------
 **
-**	If a wildcard match is made, a temporary HTPresentation
-**	structure is made to hold the destination format while the
-**	new stack is generated. This is just to pass the out format to
-**	MIME so far.  Storing the format of a stream in the stream might
-**	be a lot neater.
+**	If fill_in is NULL, only look for an exact match.
+**	If a wildcard match is made, *fill_in is used to store
+**	a possibly modified presentation, and a pointer to it is
+**	returned.  For an exact match, a pointer to the presentation
+**	in the HTPresentations list is returned.  Returns NULL if
+**	nothing found. - kw
 **
 */
-PUBLIC HTStream * HTStreamStack ARGS4(
+PRIVATE HTPresentation * HTFindPresentation ARGS3(
 	HTFormat,		rep_in,
 	HTFormat,		rep_out,
-	HTStream*,		sink,
-	HTParentAnchor*,	anchor)
+	HTPresentation*,	fill_in)
 {
     HTAtom * wildcard = HTAtom_for("*");
 
     if (TRACE)
         fprintf(stderr,
-		"HTFormat: Constructing stream stack for %s to %s\n",
+		"HTFormat: Looking up presentation for %s to %s\n",
 		HTAtom_name(rep_in), HTAtom_name(rep_out));
 		
-    /* don't return on WWW_SOURCE some people might like
-     * to make use of the source!!!!  LJM
-     *//*
-    if (rep_out == WWW_SOURCE || rep_out == rep_in)
-	return sink;  LJM */
-
-    if (rep_out == rep_in)
-        return sink;
-
     /* don't do anymore do it in the Lynx code at startup LJM */
     /* if (!HTPresentations) HTFormatInit(); */	/* set up the list */
     
@@ -346,10 +337,12 @@ PUBLIC HTStream * HTStreamStack ARGS4(
 	        if (pres->rep_out == rep_out) {
 		    if (TRACE)
 			fprintf(stderr,
-				"StreamStack: found exact match: %s\n",
+				"FindPresentation: found exact match: %s\n",
 				HTAtom_name(pres->rep));
-	    	    return (*pres->converter)(pres, anchor, sink);
+	    	    return pres;
 
+		} else if (!fill_in) {
+		    continue;
 		} else if (pres->rep_out == wildcard) {
 		    if (!strong_wildcard_match)
 		        strong_wildcard_match = pres;
@@ -360,6 +353,9 @@ PUBLIC HTStream * HTStreamStack ARGS4(
 				HTAtom_name(pres->rep));
 		}
 
+	    } else if (!fill_in) {
+		continue;
+
 	    } else if (half_match(HTAtom_name(pres->rep),
 					      HTAtom_name(rep_in))) {
 	        if (pres->rep_out == rep_out) {
@@ -397,20 +393,82 @@ PUBLIC HTStream * HTStreamStack ARGS4(
 		last_default_match;
 	
 	if (match) {
-	    HTPresentation temp;
-	    temp = *match;		/* Specific instance */
-	    temp.rep = rep_in;		/* yuk */
-	    temp.rep_out = rep_out;	/* yuk */
-	    if (TRACE)
-		fprintf(stderr,
-			"StreamStack: Using %s\n", HTAtom_name(temp.rep_out));
-	    return (*match->converter)(&temp, anchor, sink);
+	    *fill_in = *match;		/* Specific instance */
+	    fill_in->rep = rep_in;		/* yuk */
+	    fill_in->rep_out = rep_out;	/* yuk */
+	    return fill_in;
         }
     }
 
     return NULL;
 }
-	
+
+/*		Create a filter stack
+**		---------------------
+**
+**	If a wildcard match is made, a temporary HTPresentation
+**	structure is made to hold the destination format while the
+**	new stack is generated. This is just to pass the out format to
+**	MIME so far.  Storing the format of a stream in the stream might
+**	be a lot neater.
+**
+*/
+PUBLIC HTStream * HTStreamStack ARGS4(
+	HTFormat,		rep_in,
+	HTFormat,		rep_out,
+	HTStream*,		sink,
+	HTParentAnchor*,	anchor)
+{
+    HTPresentation temp;
+    HTPresentation *match;
+
+    if (TRACE)
+        fprintf(stderr,
+		"HTFormat: Constructing stream stack for %s to %s\n",
+		HTAtom_name(rep_in), HTAtom_name(rep_out));
+		
+    /* don't return on WWW_SOURCE some people might like
+     * to make use of the source!!!!  LJM
+     *//*
+    if (rep_out == WWW_SOURCE || rep_out == rep_in)
+	return sink;  LJM */
+
+    if (rep_out == rep_in)
+        return sink;
+
+    if ((match = HTFindPresentation(rep_in, rep_out, &temp))) {
+	if (match == &temp) {
+	    if (TRACE)
+		fprintf(stderr,
+			"StreamStack: Using %s\n", HTAtom_name(temp.rep_out));
+	} else {
+	    if (TRACE)
+		fprintf(stderr,
+			"StreamStack: found exact match: %s\n",
+			HTAtom_name(match->rep));
+	}
+	return (*match->converter)(match, anchor, sink);
+    } else {
+	return NULL;
+    }
+}
+
+/*		Put a presentation near start of list
+**		-------------------------------------
+**
+**	Look up a presentation (exact match only) and, if found, reorder
+**	it to the start of the HTPresentations list. - kw
+*/
+PUBLIC void HTReorderPresentation ARGS2(
+	HTFormat,		rep_in,
+	HTFormat,		rep_out)
+{
+    HTPresentation *match;
+    if ((match = HTFindPresentation(rep_in, rep_out, NULL))) {
+	HTList_removeObject(HTPresentations, match);
+	HTList_addObject(HTPresentations, match);
+    }
+}    
 /*		Find the cost of a filter stack
 **		-------------------------------
 **
diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h
index b21a0ec3..80fb91dd 100644
--- a/WWW/Library/Implementation/HTFormat.h
+++ b/WWW/Library/Implementation/HTFormat.h
@@ -256,6 +256,17 @@ extern HTStream * HTStreamStack PARAMS((
         HTParentAnchor*         anchor));
 
 /*
+HTReorderPresentation: put presentation near head of list
+
+    Look up a presentation (exact match only) and, if found, reorder
+    it to the start of the HTPresentations list. - kw
+    */
+
+extern void HTReorderPresentation PARAMS((
+        HTFormat                format_in,
+        HTFormat                format_out));
+
+/*
 
 HTStackValue: Find the cost of a filter stack
 
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 0d5c6fdd..67795a22 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -2096,7 +2096,7 @@ PUBLIC HTStream* HTMIMEConvert ARGS3(
     
     me = (HTStream *)calloc(1, sizeof(*me));
     if (me == NULL)
-        outofmem(__FILE__, "HTML_new");
+        outofmem(__FILE__, "HTMIME_new");
     me->isa	=	&HTMIME;       
     me->sink	=	sink;
     me->anchor	=	anchor;
diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c
index ef5c2faa..7190d947 100644
--- a/WWW/Library/Implementation/HTMLGen.c
+++ b/WWW/Library/Implementation/HTMLGen.c
@@ -425,7 +425,7 @@ PRIVATE void PlainToHTML_abort ARGS2(
 */
 PRIVATE CONST HTStructuredClass HTMLGeneration = /* As opposed to print etc */
 {		
-	"text/html",
+	"HTMLGen",
 	HTMLGen_free,
 	HTMLGen_abort,
 	HTMLGen_put_character, 	HTMLGen_put_string, HTMLGen_write,
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index e69b77ad..3c5fafc5 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -799,7 +799,7 @@ PUBLIC void HTMake822Word ARGS1(
     	a = TOASCII(*p);
 	if ((a != '\t') && ((a & 127) < 32 ||
 			    ( a < 128 && ((crfc[a-32]) & 2))))
-	    *q++ = '\'';
+	    *q++ = '\\';
 	*q++ = *p;
 	if (a == '\n' || (a == '\r' && (TOASCII(*(p+1)) != '\n')))
 	    *q++ = ' ';
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index f4009328..2fc9145b 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -653,7 +653,7 @@ try_again:
     BOOL end_of_file = NO;
     int buffer_length = INIT_LINE_SIZE;
 
-    line_buffer = (char *) malloc(buffer_length * sizeof(char));
+    line_buffer = (char *) calloc(1, buffer_length * sizeof(char));
 
     do {/* Loop to read in the first line */
         /*
@@ -1119,7 +1119,7 @@ try_again:
 	       *  any, and then close the connection. - FM
 	       */
 	      while ((status = HTTP_NETREAD(s, line_buffer,
-	      				    INIT_LINE_SIZE,
+					    (INIT_LINE_SIZE - 1),
 					    handle)) > 0) {
 	          line_buffer[status] = '\0';
 		  StrAllocCat(line_kept_clean, line_buffer);
diff --git a/WWW/Library/Implementation/LYLeaks.h b/WWW/Library/Implementation/LYLeaks.h
index 4109be80..d7d47a01 100644
--- a/WWW/Library/Implementation/LYLeaks.h
+++ b/WWW/Library/Implementation/LYLeaks.h
@@ -130,6 +130,17 @@ AllocationList;
 #endif /* free */
 #define free(vp_alloced) LYLeakFree(vp_alloced, __FILE__, __LINE__)
 
+/*
+ *   Added the following two defines to track Lynx's frequent use
+ *   of those macros. - kw 1997-10-12
+ */
+#ifdef StrAllocCopy
+#undef StrAllocCopy
+#undef StrAllocCat
+#endif
+#define StrAllocCopy(dest, src) LYLeakSACopy (&(dest), src, __FILE__, __LINE__)
+#define StrAllocCat(dest, src)  LYLeakSACat  (&(dest), src, __FILE__, __LINE__)
+
 #endif /* LY_FIND_LEAKS && !NO_MEMORY_TRACKING */
 
 /*
@@ -145,5 +156,9 @@ PUBLIC void *LYLeakRealloc PARAMS((void *vp_alloced, size_t st_newbytes, CONST
 	char *cp_File, CONST short ssi_Line));
 PUBLIC void LYLeakFree PARAMS((void *vp_alloced, CONST char *cp_File, CONST
 	short ssi_Line));
+extern char * LYLeakSACopy PARAMS ((char **dest, CONST char *src, CONST char
+	*cp_File, CONST short ssi_Line));
+extern char * LYLeakSACat  PARAMS ((char **dest, CONST char *src, CONST char
+	*cp_File, CONST short ssi_Line));
 
 #endif /* __LYLEAKS_H */
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 51434a66..2a210561 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -44,8 +44,6 @@ PUBLIC BOOL HTPassEightBitNum = FALSE;	/* Pass ^ numeric entities raw.	*/
 PUBLIC BOOL HTPassHighCtrlRaw = FALSE;	/* Pass 127-160,173,&#127; raw.	*/
 PUBLIC BOOL HTPassHighCtrlNum = FALSE;	/* Pass &#128;-&#159; raw.	*/
 
-extern BOOLEAN LYCheckForCSI PARAMS((HTParentAnchor *anchor, char **url));
-extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi));
 
 /*	The State (context) of the parser
 **
@@ -118,8 +116,8 @@ struct _HTStream {
     LYUCcharset	*		htmlUCI;	/* anchor UCInfo for target */
     int				html_char_set;	/* feed it to target stream */
     char			utf_count;
-    long			utf_char;
-    char 			utf_buf[7];
+    UCode_t			utf_char;
+    char 			utf_buf[8];
     char *			utf_buf_p;
     UCTransParams		T;
     int			current_tag_charset; /* charset to pass attributes */
@@ -137,9 +135,9 @@ struct _HTStream {
 #ifdef EXP_CHARTRANS
 
 PRIVATE void set_chartrans_handling ARGS3(
-	HTStream *,	context,
-	HTParentAnchor *, anchor,
-	int,	chndl)
+	HTStream *,		context,
+	HTParentAnchor *,	anchor,
+	int,			chndl)
 {
     extern int current_char_set;
 
@@ -150,9 +148,9 @@ PRIVATE void set_chartrans_handling ARGS3(
 	if (chndl < 0)
 	    chndl = current_char_set;
 	HTAnchor_setUCInfoStage(anchor, chndl, UCT_STAGE_HTEXT,
-			    UCT_SETBY_DEFAULT);
+				UCT_SETBY_DEFAULT);
 	HTAnchor_setUCInfoStage(anchor, chndl, UCT_STAGE_STRUCTURED,
-			    UCT_SETBY_DEFAULT);
+				UCT_SETBY_DEFAULT);
 	context->htmlUCI = HTAnchor_getUCInfoStage(anchor,
 						   UCT_STAGE_STRUCTURED);
 	context->html_char_set = HTAnchor_getUCLYhndl(context->node_anchor,
@@ -178,7 +176,7 @@ PRIVATE void set_chartrans_handling ARGS3(
 }
 
 PRIVATE void change_chartrans_handling ARGS1(
-	HTStream *,	context)
+	HTStream *,		context)
 {
     int new_LYhndl = HTAnchor_getUCLYhndl(context->node_anchor,
 					  UCT_STAGE_PARSER);
@@ -301,22 +299,28 @@ PRIVATE void handle_attribute_value ARGS2(
 /* translate some Unicodes to Lynx special codes and output them. */
 PRIVATE BOOL put_special_unicodes ARGS2(
 	HTStream *,	context,
-	long, code)
+	UCode_t,	code)
 {
     if (code == 160) {
+	/*
+	**  Use Lynx special character for nbsp.
+	*/
 	PUTC(HT_NON_BREAK_SPACE);
-    } else  if (code==173) {
+    } else  if (code == 173) {
+	/*
+	**  Use Lynx special character for shy.
+	*/
 	PUTC(LY_SOFT_HYPHEN);
     } else if (code == 8194 || code == 8195 || code == 8201) {
-		        /*
-			**  ensp, emsp or thinsp.
-			*/
+	/*
+	**  Use Lynx special character for ensp, emsp or thinsp.
+	*/
 	PUTC(HT_EM_SPACE);
     } else if (code == 8211 || code == 8212) {
-		        /*
-			**  ndash or mdash.
-			*/
-			PUTC('-');
+	/*
+	**  Use ASCII hyphen for ndash/endash or mdash/emdash.
+	*/
+	PUTC('-');
     } else {
 	/*
 	**  Return NO if nothing done.
@@ -342,11 +346,11 @@ PRIVATE BOOL put_special_unicodes ARGS2(
 **	Modified SGML_character() so we only come here with terminator
 **	as '\0' and check a FoundEntity flag. -- Foteos Macrides
 **
-** Modified more (for use with CHARTRANS):
+** Modified more (for use with Lynx character translation code):
 */
 
 #ifdef EXP_CHARTRANS
-PRIVATE char replace_buf [61];        /* buffer for replacement strings */
+PRIVATE char replace_buf [64];        /* buffer for replacement strings */
 #endif
 
 PRIVATE BOOL FoundEntity = FALSE;
@@ -356,11 +360,9 @@ PRIVATE void handle_entity ARGS2(
 	char,		term)
 {
     CONST char ** entities = context->dtd->entity_names;
-#ifdef EXP_CHARTRANS
     CONST UC_entity_info * extra_entities = context->dtd->extra_entity_info;
     extern int current_char_set;
     int rc;
-#endif
     CONST char *s = context->string->data;
     int high, low, i, diff;
 
@@ -451,7 +453,7 @@ PRIVATE void handle_entity ARGS2(
     **  If entity string not found, display as text.
     */
     if (TRACE)
-	fprintf(stderr, "SGML: Unknown entity %s\n", s); 
+	fprintf(stderr, "SGML: Unknown entity '%s'\n", s); 
     PUTC('&');
     {
 	CONST char *p;
@@ -477,7 +479,7 @@ PRIVATE void handle_comment ARGS1(
 
     if (context->csi == NULL &&
         strncmp(s, "!--#", 4) == 0 &&
-        LYCheckForCSI(context->node_anchor, (char **)&context->url) == TRUE) {
+        LYCheckForCSI(context->target, (char **)&context->url) == TRUE) {
 	LYDoCSI(context->url, s, (char **)&context->csi);
     }
 
@@ -871,7 +873,7 @@ PUBLIC HTTag * SGMLFindTag ARGS2(
     int high, low, i, diff;
     for (low = 0, high=dtd->number_of_tags;
     	 high > low;
-	 diff < 0 ? (low = i+1) : (high = i)) {  /* Binary serach */
+	 diff < 0 ? (low = i+1) : (high = i)) {  /* Binary search */
 	i = (low + (high-low)/2);
 	diff = strcasecomp(dtd->tags[i].name, string);	/* Case insensitive */
 	if (diff == 0) {		/* success: found it */
@@ -1005,20 +1007,19 @@ PUBLIC void SGML_character ARGS2(
     HTChunk	*string = 	context->string;
     CONST char * EntityName;
     extern int current_char_set;
-    extern CONST char * LYchar_set_names[];
     extern CONST char * HTMLGetEntityName PARAMS((int i));
 
 #ifdef EXP_CHARTRANS
     extern int LYlowest_eightbit[];
     char * p;
     BOOLEAN chk;	/* Helps (?) walk through all the else ifs... */
-    long clong, uck;	/* Enough bits for UCS4 ... */
+    UCode_t clong, uck;	/* Enough bits for UCS4 ... */
     char c;
     char saved_char_in = '\0';
     /*
-    **  Now some fun with the preprocessor...
-    **  use copies for c an unsign_c == clong, so that we
-    **  can revert back to the unchanged c_in.
+    **  Now some fun with the preprocessor.
+    **  Use copies for c and unsign_c == clong, so that
+    **  we can revert back to the unchanged c_in. - KW
     */
 #define unsign_c clong
 
@@ -1035,9 +1036,9 @@ PUBLIC void SGML_character ARGS2(
 	/*
 	**  Combine UTF-8 into Unicode.
 	**  Incomplete characters silently ignored.
-	**  From Linux kernel's console.c.
+	**  From Linux kernel's console.c. - KW
 	*/
-	if((unsigned char)c > 0x7f) {
+	if ((unsigned char)c > 127) {
 	    if (context->utf_count > 0 && (c & 0xc0) == 0x80) {
 		context->utf_char = (context->utf_char << 6) | (c & 0x3f);
 		context->utf_count--;
@@ -1051,7 +1052,7 @@ PUBLIC void SGML_character ARGS2(
 		    goto top1;
 		} else {
 		    /*
-		    **  Wait for more.
+		    **  Wait for more. - KW
 		    */
 		    return;
 		}
@@ -1075,20 +1076,20 @@ PUBLIC void SGML_character ARGS2(
 		    context->utf_char = (c & 0x01);
 		} else {
 		    /*
-		    **  Garbage.
+		    **  Garbage. - KW
 		    */
 		    context->utf_count = 0;
 		    context->utf_buf_p = context->utf_buf;
 		    *(context->utf_buf_p) = '\0';
 		}
 		/*
-		**  Wait for more.
+		**  Wait for more. - KW
 		*/
 		return;
 	    }
 	} else {
 	    /*
-	    **  Got an ASCII char.
+	    **  Got an ASCII char. - KW
 	    */
 	    context->utf_count = 0;
 	    context->utf_buf_p = context->utf_buf;
@@ -1101,9 +1102,9 @@ PUBLIC void SGML_character ARGS2(
 	saved_char_in = c;
 
     if (context->T.trans_to_uni &&
-	(unsign_c >= 127 ||
-	    (unsign_c < 32 && unsign_c != 0 &&
-	     context->T.trans_C0_to_uni))) {
+	((unsign_c >= 127) ||
+	 (unsign_c < 32 && unsign_c != 0 &&
+	  context->T.trans_C0_to_uni))) {
 	clong = UCTransToUni(c, context->in_char_set);
 	if (clong > 0) {
 	    saved_char_in = c;
@@ -1233,7 +1234,7 @@ top1:
 	}
 	if (c == '&' && unsign_c < 127  &&
 	    (!context->element_stack ||
-			 (context->element_stack->tag  &&
+	     (context->element_stack->tag  &&
 	      (context->element_stack->tag->contents == SGML_MIXED ||
 	       context->element_stack->tag->contents == SGML_PCDATA ||
 	       context->element_stack->tag->contents == SGML_RCDATA)))) {
@@ -1276,7 +1277,7 @@ top1:
 	} else if (context->T.use_raw_char_in && saved_char_in) {
 	    /*
 	    **  Only if the original character is still in saved_char_in,
-	    **  otherwise we may be iterating from a goto top
+	    **  otherwise we may be iterating from a goto top. - KW
 	    */
 	    PUTC(saved_char_in);
 	    saved_char_in = '\0';
@@ -1305,10 +1306,15 @@ top1:
 					    0) >= 0)) { 
 	    /*
 	    **  No further tests for valididy - assume that whoever
-	    **  defined replacement strings knew what she was doing.
+	    **  defined replacement strings knew what she was doing. - KW
 	    */
-	      for (p=replace_buf; *p; p++)
+	    for (p = replace_buf; *p; p++)
 		PUTC(*p);
+	/*
+	**  If we're displaying UTF-8, try that now. - FM
+	*/
+	} else if (context->T.output_utf8 && PUTUTF8(clong)) {
+	    ; /* do nothing more */
 #endif /* EXP_CHARTRANS */
 
 	/*
@@ -1321,11 +1327,14 @@ top1:
 #define PASSHI8BIT HTPassEightBitRaw
 #else
 #define PASSHI8BIT (HTPassEightBitRaw || (context->T.do_8bitraw && !context->T.trans_from_uni))
+#define IncludesLatin1Enc(cs) \
+		(cs == 0 || \
+		 (context->htmlUCI && \
+		  (context->htmlUCI->enc & (UCT_CP_SUPERSETOF_LAT1))))
 #endif /* EXP_CHARTRANS */
 	} else if (unsign_c > 160 && unsign_c < 256 &&
 		   !(PASSHI8BIT || HTCJK != NOCJK) &&
-		   strncmp(LYchar_set_names[current_char_set],
-		   	   "ISO Latin 1", 11)) {
+		   !IncludesLatin1Enc(current_char_set)) {
 	    int i;
 	    int value;
 
@@ -1347,10 +1356,10 @@ top1:
 	    PUTC(c);
 	/*
 	**  If we get to here, and should have translated,
-	**  translation has failed so far.  
+	**  translation has failed so far. - KW
 	*/
 	} else if (context->T.output_utf8 && *context->utf_buf) {
-	    for (p=context->utf_buf; *p; p++)
+	    for (p = context->utf_buf; *p; p++)
 		PUTC(*p);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
@@ -1360,15 +1369,15 @@ top1:
 		   ((unsigned char)saved_char_in < 255)) {
 	    /*
 	    **  KOI8 special: strip high bit, gives (somewhat) readable
-	    **  ASCII or KOI7 - it was constructed that way!
+	    **  ASCII or KOI7 - it was constructed that way! - KW
 	    */
 	    PUTC((char)(saved_char_in & 0x7f));
 	    saved_char_in = '\0';
 	} else if ((unsigned char)c <
 			LYlowest_eightbit[context->html_char_set] ||
 		   (context->T.trans_from_uni && !HTPassEightBitRaw)) {
-	    sprintf(replace_buf,"U%.2lx",unsign_c);
-	    for (p=replace_buf; *p; p++)
+	    sprintf(replace_buf, "U%.2lX", unsign_c);
+	    for (p = replace_buf; *p; p++)
 		PUTC(*p);
 #endif /* EXP_CHARTRANS */
 	/*
@@ -1383,7 +1392,7 @@ top1:
     **  In litteral mode, waits only for specific end tag (for
     **  compatibility with old servers, and for Lynx). - FM
     */
-    case S_litteral :
+    case S_litteral:
 	HTChunkPutc(string, c);
 	if (TOUPPER(c) != ((string->size == 1) ?
 					   '/' :
@@ -1448,7 +1457,36 @@ top1:
 	    **  Terminate entity name and try to handle it. - FM
 	    */
 	    HTChunkTerminate(string);
-	    handle_entity(context, '\0');
+	    if (!strcmp(string->data, "zwnj") &&
+		(!context->element_stack ||
+		 (context->element_stack->tag  &&
+		  context->element_stack->tag->contents == SGML_MIXED))) {
+		/*
+		**  Handle zwnj (8204) as <WBR>. - FM
+		*/
+		char temp[8];
+
+		if (TRACE) {
+		    fprintf(stderr,
+		"SGML_character: Handling 'zwnj' entity as 'WBR' element.\n");
+		}
+		if (c != ';') {
+		    sprintf(temp, "<WBR>%c", c); 
+		} else {
+		    sprintf(temp, "<WBR>"); 
+		}
+		if (context->recover == NULL) {
+		    StrAllocCopy(context->recover, temp);
+		    context->recover_index = 0;
+		} else {
+		    StrAllocCat(context->recover, temp);
+		}
+		string->size = 0;
+		context->state = S_text;
+		break;
+	    } else {
+		handle_entity(context, '\0');
+	    }
 	    string->size = 0;
 	    context->state = S_text;
 	    /*
@@ -1518,6 +1556,46 @@ top1:
 	    HTChunkTerminate(string);
 	    if ((context->isHex ? sscanf(string->data, "%x", &value) :
 				  sscanf(string->data, "%d", &value)) == 1) {
+		/*
+		**  Check for special values. - FM
+		*/
+		if ((value == 8204) &&
+		    (!context->element_stack ||
+		     (context->element_stack->tag  &&
+		      context->element_stack->tag->contents == SGML_MIXED))) {
+		    /*
+		    **  Handle zwnj (8204) as <WBR>. - FM
+		    */
+		    char temp[8];
+
+		    if (TRACE) {
+		        fprintf(stderr,
+      "SGML_character: Handling '8204' (zwnj) reference as 'WBR' element.\n");
+		    }
+		    /*
+		    **  Include the terminator if it is not
+		    **  the standard semi-colon. - FM
+		    */
+		    if (c != ';') {
+			sprintf(temp, "<WBR>%c", c); 
+		    } else {
+			sprintf(temp, "<WBR>"); 
+		    }
+		    /*
+		    **  Add the replacement string to the
+		    **  recover buffer for processing. - FM
+		    */
+		    if (context->recover == NULL) {
+			StrAllocCopy(context->recover, temp);
+			context->recover_index = 0;
+		    } else {
+			StrAllocCat(context->recover, temp);
+		    }
+		    string->size = 0;
+		    context->isHex = FALSE;
+		    context->state = S_text;
+		    break;
+		}
 #ifdef EXP_CHARTRANS
 		if (value == 160 || value == 173) {
 		    /*
@@ -1546,13 +1624,13 @@ top1:
 		     uck >= LYlowest_eightbit[context->html_char_set])) {
 		    if (uck == 160 && current_char_set == 0) {
 			/*
-			**  Would only happen if some other unicode
+			**  Would only happen if some other Unicode
 			**  is mapped to Latin-1 160.
 			*/
 			PUTC(HT_NON_BREAK_SPACE);
 		    } else if (uck == 173 && current_char_set == 0) {
 			/*
-			**  Would only happen if some other unicode
+			**  Would only happen if some other Unicode
 			**  is mapped to Latin-1 173.
 			*/
 			PUTC(LY_SOFT_HYPHEN);
@@ -1593,13 +1671,13 @@ top1:
 		**  and the value:
 		**   (1) Is greater than 255 (but use ASCII characters
 		**	 for spaces or dashes).
-		**  (2) Is less than 32, and not valid or we don't
-		**	have HTCJK set.
-		**  (3) Is 127 and we don't have HTPassHighCtrlRaw or
-		**	HTCJK set.
-		**  (4) Is 128 - 159 and we don't have HTPassHighCtrlNum
-		**	set.
-		** - FM
+		**   (2) Is less than 32, and not valid or we don't
+		**	 have HTCJK set.
+		**   (3) Is 127 and we don't have HTPassHighCtrlRaw or
+		**	 HTCJK set.
+		**   (4) Is 128 - 159 and we don't have HTPassHighCtrlNum
+		**	 set.
+		**  - FM
 		*/
 		} else if ((value > 255) ||
 		    (value < 32 &&
@@ -1640,8 +1718,7 @@ top1:
 			goto top1;
 		    }
 		} else if (value < 161 || HTPassEightBitNum ||
-			   !strncmp(LYchar_set_names[current_char_set],
-			   	    "ISO Latin 1", 11)) {
+			   IncludesLatin1Enc(current_char_set)) {
 		    /*
 		    **  No conversion needed. - FM
 		    */
@@ -1696,6 +1773,7 @@ top1:
 		**  the "standard" semi-colon for HTML. - FM
 		*/
 		if (c != ';')
+
 		    goto top1;
 	    } else {
 	        /*
@@ -1814,7 +1892,7 @@ top1:
 	    */
 	    {
 	        int i;
-	        for (i=0; i< context->current_tag->number_of_attributes; i++)
+	        for (i = 0; i < context->current_tag->number_of_attributes; i++)
 	    	    context->present[i] = NO;
 	    }
 	    string->size = 0;
@@ -2188,13 +2266,18 @@ top1:
 	    else context->state = S_tag_gap;
 #ifdef EXP_CHARTRANS
 	} else if (context->T.decode_utf8 &&
-		*context->utf_buf) {
+		   *context->utf_buf) {
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
 	} else if (HTCJK == NOCJK && (context->T.output_utf8 ||
 				      context->T.trans_from_uni)) {
-	    HTChunkPutUtf8Char(string, clong);
+	    if (clong == 0xfffd && saved_char_in && HTPassEightBitRaw &&
+		(unsigned char)saved_char_in >= LYlowest_eightbit[current_char_set])
+		HTChunkPutUtf8Char(string,
+				   (0xf000 | (unsigned char)saved_char_in));
+	    else
+		HTChunkPutUtf8Char(string, clong);
 	} else if (saved_char_in && context->T.use_raw_char_in) {
 	    HTChunkPutc(string, saved_char_in);
 #endif /* EXP_CHARTRANS */
@@ -2218,13 +2301,18 @@ top1:
 	    HTChunkPutc(string, c);
 #ifdef EXP_CHARTRANS
 	} else if (context->T.decode_utf8 &&
-		*context->utf_buf) {
+		   *context->utf_buf) {
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
 	} else if (HTCJK == NOCJK && (context->T.output_utf8 ||
 				      context->T.trans_from_uni)) {
-	    HTChunkPutUtf8Char(string, clong);
+	    if (clong == 0xfffd && saved_char_in && HTPassEightBitRaw &&
+		(unsigned char)saved_char_in >= LYlowest_eightbit[current_char_set])
+		HTChunkPutUtf8Char(string,
+				   (0xf000 | (unsigned char)saved_char_in));
+	    else
+		HTChunkPutUtf8Char(string, clong);
 	} else if (saved_char_in && context->T.use_raw_char_in) {
 	    HTChunkPutc(string, saved_char_in);
 #endif /* EXP_CHARTRANS */
@@ -2252,13 +2340,18 @@ top1:
 	    HTChunkPutc(string, c);
 #ifdef EXP_CHARTRANS
 	} else if (context->T.decode_utf8 &&
-		*context->utf_buf) {
+		   *context->utf_buf) {
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
 	} else if (HTCJK == NOCJK && (context->T.output_utf8 ||
 				      context->T.trans_from_uni)) {
-	    HTChunkPutUtf8Char(string, clong);
+	    if (clong == 0xfffd && saved_char_in && HTPassEightBitRaw &&
+		(unsigned char)saved_char_in >= LYlowest_eightbit[current_char_set])
+		HTChunkPutUtf8Char(string,
+				   (0xf000 | (unsigned char)saved_char_in));
+	    else
+		HTChunkPutUtf8Char(string, clong);
 	} else if (saved_char_in && context->T.use_raw_char_in) {
 	    HTChunkPutc(string, saved_char_in);
 #endif /* EXP_CHARTRANS */
diff --git a/WWW/Library/Implementation/SGML.h b/WWW/Library/Implementation/SGML.h
index a3ea248a..0799c055 100644
--- a/WWW/Library/Implementation/SGML.h
+++ b/WWW/Library/Implementation/SGML.h
@@ -222,6 +222,13 @@ typedef struct _HTStructuredClass{
 }HTStructuredClass;
 
 /*
+  The following functions possibly should be generalised into
+  additional HTStructuredClass memebers. - kw
+  */
+extern BOOLEAN LYCheckForCSI PARAMS((HTStructured *target, char **url));
+extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi));
+
+/*
 
 Find a Tag by Name
 
diff --git a/WWW/Library/Implementation/UCAux.h b/WWW/Library/Implementation/UCAux.h
index ffe0a652..a21521c4 100644
--- a/WWW/Library/Implementation/UCAux.h
+++ b/WWW/Library/Implementation/UCAux.h
@@ -1,9 +1,25 @@
 #ifndef UCAUX_H
 #define UCAUX_H
 
-extern BOOL UCCanUniTranslateFrom PARAMS((int from));
-extern BOOL UCCanTranslateUniTo PARAMS((int to));
-extern BOOL UCCanTranslateFromTo PARAMS((int from, int to));
+/*
+ *  A type for a "Translation Quality" (actually, Transcoding Quality).
+ *  This is a fuzzy concept since we are just looking at the charset
+ *  not what characters are actually there, so it's just a guess for
+ *  "common" cases.  TQ_NO must be 0 since callers of functions that
+ *  return this type may treat result as a boolean flag.
+ *  The functions returning this type could be improved to use more
+ *  knowledge from the translation tables.
+ */
+typedef enum {
+    TQ_NO	= 0,		/* must be 0 */
+    TQ_POOR	= 1,
+    TQ_GOOD	= 2,
+    TQ_EXCELLENT = 3
+} UCTQ_t;
+
+extern UCTQ_t UCCanUniTranslateFrom PARAMS((int from));
+extern UCTQ_t UCCanTranslateUniTo PARAMS((int to));
+extern UCTQ_t UCCanTranslateFromTo PARAMS((int from, int to));
 extern BOOL UCNeedNotTranslate PARAMS((int from, int to));
 
 struct _UCTransParams
diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h
index d8c723fe..7dde5f34 100644
--- a/WWW/Library/Implementation/tcp.h
+++ b/WWW/Library/Implementation/tcp.h
@@ -329,6 +329,7 @@ extern char *vms_errno_string();
 #include "multinet_root:[multinet.include.arpa]inet.h"
 #include "multinet_root:[multinet.include]netdb.h"
 #include "multinet_root:[multinet.include.sys]ioctl.h"
+#define TCP_INCLUDES_DONE
 /*
 **  Uncomment this if you get compiler messages
 **  about struct timeval having no linkage. - FM
@@ -352,6 +353,7 @@ struct timeval {
 #include "dn"
 #include "dnetdb"
 /* #include "vms.h" */
+#define TCP_INCLUDES_DONE
 #endif /* DECNET */
 
 
@@ -369,6 +371,7 @@ struct timeval {
 #include <netdb.h>
 #include <ucx$inetdef.h>
 #endif /* TCPWARE */
+#define TCP_INCLUDES_DONE
 #endif /* UCX */
 
 
@@ -381,6 +384,7 @@ struct timeval {
 #include <inet.h>
 #include <netdb.h>
 #include "cmuip_root:[syslib]ioctl.h"
+#define TCP_INCLUDES_DONE
 #endif /* CMU_TCP */
 
 
@@ -394,6 +398,7 @@ struct timeval {
 #include <netdb.h>
 #include "socketshr_library:socketshr.h"
 #include "socketshr_library:ioctl.h"
+#define TCP_INCLUDES_DONE
 #endif /* SOCKETSHR_TCP */
 
 #ifdef WIN_TCP
@@ -407,10 +412,33 @@ struct timeval {
 #ifndef NO_IOCTL
 #include <ioctl.h>
 #endif /* !NO_IOCTL */
+#define TCP_INCLUDES_DONE
 #endif /* WIN_TCP */
 
-
+#ifndef TCP_INCLUDES_DONE
+#include <types.h>
+#include <errno.h>
+#include <time.h>
+#ifdef VMS_SOCKET_HEADERS
+/*
+**  Not all versions of VMS have the full set of headers
+**  for socket library functions, because the TCP/IP
+**  packages were layered products.  If we want these
+**  specifically, instead of those for the above packages,
+**  the module should be compiled with VMS_SOCKET_HEADERS
+**  defined instead of layered product definitions, above.
+**  If the module is not using socket library functions,
+**  none of the definitions need be used, and we include
+**  only the above three headers. - FM
+*/
+#include <socket.h>
+#include <in.h>
+#include <inet.h>
+#include <netdb.h>
+#include <ioctl.h>
+#endif /* VMS_SOCKET_HEADERS */
 #define TCP_INCLUDES_DONE
+#endif /* !TCP_INCLUDES_DONE */
 
 /*
 
diff --git a/WWW/Library/vms/descrip.mms b/WWW/Library/vms/descrip.mms
index d34fe347..216e6aee 100644
--- a/WWW/Library/vms/descrip.mms
+++ b/WWW/Library/vms/descrip.mms
@@ -177,7 +177,7 @@ CC = gcc
 
 MODULES = HTParse, HTAccess, HTTP, HTFile, HTBTree, HTFTP, HTTCP, HTString, -
 	SGML, HTMLDTD, HTChunk, HTPlain, HTWriter, HTMLGen, -
-	HTAtom, HTAnchor, HTStyle, HTList, HTAlert, HTRules, HTFormat, -
+	HTAtom, HTAnchor, HTStyle, HTList, HTRules, HTFormat, -
 	HTMIME, HTHistory, HTNews, HTGopher, HTTelnet, HTFinger, -
 	HTWSRC, HTAAUtil, HTAABrow, HTAAServ, HTAAFile, HTPasswd, HTGroup, -
 	HTACL, HTAuth, HTAAProt, HTAssoc, HTLex, HTUU, HTVMSUtils, getpass, -
@@ -219,7 +219,6 @@ clean :
 !HTPlain.obj :	HTPlain.c HTPlain.h HTStream.h
 !HTWriter.obj :	HTWriter.c HTWriter.h HTStream.h
 !HTMLGen.obj :	HTMLGen.c HTMLGen.h HTUtils.h HTMLDTD.h
-!HTAlert.obj :	HTAlert.c HTAlert.h HTUtils.h Version.make
 !HTRules.obj :	HTRules.c HTRules.h HTUtils.h Version.make
 !HTMIME.obj :	HTMIME.c HTMIME.h HTUtils.h HTList.h
 !HTTelnet.obj :	HTTelnet.c HTTelnet.h HTUtils.h
diff --git a/WWW/Library/vms/libmake.com b/WWW/Library/vms/libmake.com
index 7d812cfd..83ac1b4d 100644
--- a/WWW/Library/vms/libmake.com
+++ b/WWW/Library/vms/libmake.com
@@ -3,6 +3,9 @@ $!			LIBMAKE.COM
 $!
 $!   Command file to build the WWWLibrary on VMS systems.
 $!
+$!   08-Oct-1997	F.Macrides		macrides@sci.wfeb.edu
+$!	Added comments and minor tweaks for convenient addition of
+$!	compiler definitions and compiler and linker options.
 $!   26-Jul-1995	F.Macrides		macrides@sci.wfeb.edu
 $!	Adding support for GNUC.
 $!   03-May-1995	F.Macrides		macrides@sci.wfeb.edu
@@ -27,8 +30,19 @@ $!	Initial version, for WWWLibrary v2.14 with Lynx v2.1
 $!
 $ ON CONTROL_Y THEN GOTO CLEANUP
 $ ON ERROR THEN GOTO CLEANUP
-$ agent = 0
+$!
+$!	Compiler definitions can be added here as a comma separated
+$!	list with a lead comma, e.g., ",HAVE_FOO_H,DO_BLAH".  They
+$!	will apply only to the libwww-FM modules. - FM
+$!
 $ extra = ""
+$!
+$!	If no TCP/IP agent is specified (as the first argument),
+$!	prompt for a number from the list.   Note that the agent
+$!	must be the first argument if the debugger mode is to be
+$!	set via a second argument (see below). - FM
+$!
+$ agent = 0
 $ IF P1 .EQS. ""
 $ THEN
 $ 	write sys$output "Acceptable TCP/IP agents are"
@@ -50,10 +64,14 @@ $ if agent .eq. 5 .or. p1 .eqs. "SOCKETSHR_TCP" then transport = "SOCKETSHR_TCP"
 $ if agent .eq. 6 .or. p1 .eqs. "TCPWARE" then transport = "TCPWARE"
 $ if agent .eq. 7 .or. p1 .eqs. "DECNET" then transport = "DECNET"
 $!
-$ if transport .eqs. "TCPWARE" then extra = ",UCX"
+$ if transport .eqs. "TCPWARE" then extra = extra + ",UCX"
+$!
+$!	Compiler options can be specified here.  If there was
+$!	a second argument (with any value), then debugger mode
+$!	with no optimization will be specified as well. - FM
 $!
 $ cc_opts = ""
-$ if p2 .nes. "" then cc_opts = "/DEBUG/NOOPT"
+$ if p2 .nes. "" then cc_opts = cc_opts + "/DEBUG/NOOPT"
 $!
 $ IF f$trnlnm("VAXCMSG") .eqs. "DECC$MSG" .or. -
      f$trnlnm("DECC$CC_DEFAULT") .eqs. "/DECC" .or. -
@@ -80,7 +98,7 @@ $!
 $  v1 = 'f$verify(0)'
 $  Else
 $  if transport .eqs. "MULTINET" then -
-	extra = ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
+	extra = extra + ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
 $  v1 = f$verify(1)
 $!
 $ cc/decc/prefix=ansi /nomember 'cc_opts'-
@@ -142,7 +160,6 @@ $ cc [-.Implementation]HTAtom.c
 $ cc [-.Implementation]HTAnchor.c
 $ cc [-.Implementation]HTStyle.c
 $ cc [-.Implementation]HTList.c
-$ cc [-.Implementation]HTAlert.c
 $ cc [-.Implementation]HTRules.c
 $ cc [-.Implementation]HTFormat.c
 $ cc [-.Implementation]HTMIME.c
diff --git a/about_lynx/about_lynx-dev.html b/about_lynx/about_lynx-dev.html
deleted file mode 100644
index f062f674..00000000
--- a/about_lynx/about_lynx-dev.html
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html public "-//IETF//DTD HTML 3.0//EN">
-<html>
-<head>
-<title>Lynx-Dev Discussion List</title>
-<link rev="made" href="mailto:lynx-dev@sig.net">
-</head>
-
-<body>
-<banner>
-[ <a href="http://www.flora.org/lynx-dev/html/">Lynx-Dev Archives</a> |
-<a href="about_lynx.html">About Lynx</a> ]
-</banner>
-
-<h1><em>Lynx-Dev Discussion List</em></h1>
-
-Lynx-dev is a majordomo mailing list used by developers and interested
-users as a forum to discuss the further development of the Lynx World
-Wide Web browser.  Topic issues include fixing known bugs, porting Lynx
-to various systems, and increasing the usability of Lynx.
-
-<h2><em>Subscribing to Lynx-Dev</em></h2>
-
-If you are interested in <em>joining</em> this mailing list,
-send email to <a href="mailto:majordomo@sig.net"
->majordomo@sig.net</a> with only the following request
-in the body of your message: <em>SUBSCRIBE LYNX-DEV address</em><br>
-where inclusion of your email address is optional if it can be obtained,
-correctly, from the mail headers of your subscription request.
-
-<p><em>NOTE:</em> Subject headers are ignored by the majordomo.
-
-<h2><em>Unsubscribing from Lynx-Dev</em></h2>
-
-To <em>unsubscribe</em>, send an email message to
-<a href="mailto:majordomo@sig.net"
->majordomo@sig.net</a> with only the following request
-in the body: <em>UNSUBSCRIBE LYNX-DEV address</em><br>
-where inclusion of your email address is optional if it can be obtained,
-correctly, from the mail headers of your request.
-
-<h2><em>Majordomo Commands</em></h2>
-
-To receive a brief description of majordomo <em>commands</em>, place
-the following request in a message to <a href="mailto:majordomo@sig.net"
->majordomo@sig.net</a>: <em>HELP</em>
-
-<h2><em>Contacting Lynx-Dev</em></h2>
-
-If you have questions, problems, or comments about using Lynx or
-installing it on your system, send email to 
-<a href="mailto:lynx-dev@sig.net"
->lynx-dev@sig.net</a> (<em>after you've subscribed</em>).
-
-<p>If you have problems with majordomo not responding to your requests,
-send email to the <em>list owner</em>: <a
-href="mailto:majordomo-owner@sig.net"
->majordomo-owner@sig.net</a>. Please,
-<em>DO NOT</em> send them to <em>lynx-dev@sig.net</em> as they
-will be distributed to everyone on the list and will clutter
-up their mailboxes.
-
-<h2><em>Lynx-Dev Archives</em></h2>
-
-Archives of messages posted to lynx-dev are now in html format so that
-you can view them using Lynx.
-
-<p>Go to the <a href="http://www.flora.org/lynx-dev/html/"
->Lynx-Dev Archives</a>.
-</body>
-</html>
diff --git a/build-slang.com b/build-slang.com
index d2806907..e7d2d5d2 100644
--- a/build-slang.com
+++ b/build-slang.com
@@ -24,6 +24,9 @@ $   exit
 $ EndIf
 $!==========================================================================
 $!
+$!   08-Oct-1997	F.Macrides		macrides@sci.wfeb.edu
+$!	Added comments and minor tweaks for convenient addition of
+$!	compiler definitions and compiler and linker options.
 $!   28-Jun-1997	F.Macrides		macrides@sci.wfeb.edu
 $!	Added chartrans support.
 $!   29-Mar-1996	F.Macrides		macrides@sci.wfeb.edu
@@ -71,8 +74,20 @@ $ write sys$output "Default directory:"
 $ show default
 $ write sys$output ""
 $!
-$ agent = 0
+$!	Compiler definitions can be added here as a comma separated
+$!	list with a lead comma, e.g., ",HAVE_FOO_H,DO_BLAH".  The
+$!	definitions will apply only to the LYfoo.c modules.  Ones
+$!	for the libwww-FM modules can be added equivalently in
+$!	[.WWW.Library.vms]libmake.com. - FM
+$!
 $ extra = ""
+$!
+$!	If no TCP/IP agent is specified (as the first argument),
+$!	prompt for a number from the list.   Note that the agent
+$!	must be the first argument if the debugger mode is to be
+$!	set via a second argument (see below). - FM
+$!
+$ agent = 0
 $ IF P1 .EQS. ""
 $ THEN
 $   If f$mode() .eqs. "BATCH"
@@ -103,18 +118,28 @@ $!
 $ if option .eqs. "TCPWARE"
 $ then
 $    write sys$output "Building Lynx for TCPWARE with UCX emulation..."
-$    extra   = ",UCX"
+$    extra = extra + ",UCX"
 $ endif
 $!
 $ optfile = "''option'"
 $!
+$!	Compiler and linker options can be specified here.  If
+$!	there was a second argument (with any value), then debugger
+$!	mode with no optimization will be specified as well.  The
+$!	compiler options will apply only to the LYfoo.c and UCfoo.c
+$!	modules.  Ones for the libwww-FM modules can be specified
+$!	in [.WWW.Library.vms]libmake.com. - FM
+$!
+$ cc_opts = ""
+$ link_opts = ""
+$!
 $ if p2 .nes. ""
 $   then
-$      cc_opts = "/DEBUG/NOOPT"
-$      link_opts = "/DEBUG"
+$      debug_arg = "DEBUG"
+$      cc_opts = cc_opts + "/DEBUG/NOOPT"
+$      link_opts = link_opts + "/DEBUG"
 $   else
-$      cc_opts = ""
-$      link_opts = ""
+$      debug_arg = ""
 $ endif
 $!
 $ IF f$search("[.WWW.Library.Implementation]WWWLib_''option'.olb") .nes. ""
@@ -136,7 +161,7 @@ $!	Build the WWWLibrary
 $!
 $ set default [.WWW.Library.VMS]
 $ v1 = 'f$verify(0)'
-$ @libmake 'option' 'cc_opts'
+$ @libmake 'option' 'debug_arg'
 $ v1 = f$verify(1)
 $ set default [-.-.-]
 $ v1 = 'f$verify(0)'
@@ -165,7 +190,7 @@ $!	Build the chrtrans modules.
 $!
 $ set default [.src.chrtrans]
 $ v1 = 'f$verify(0)'
-$ @build-chrtrans 'cc_opts'
+$ @build-chrtrans
 $ v1 = f$verify(1)
 $ set default [-.-]
 $ v1 = 'f$verify(0)'
@@ -187,10 +212,10 @@ $  compiler := "DECC"
 $  if option .eqs. "UCX" then optfile = "UCXSHR"
 $  if option .eqs. "TCPWARE" then optfile = "TCPWARESHR"
 $  if option .eqs. "MULTINET" then -
-	extra = ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
+	extra = extra + ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
 $  v1 = f$verify(1)
 $! DECC:
-$  cc := cc/decc/prefix=all /nomember 'cc_opts'-
+$  cc := cc/decc/prefix=all/nomember'cc_opts' -
 	   /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',USE_SLANG,__VMS_CURSES)-
 	   /INCLUDE=([-],[-.WWW.Library.Implementation],'SLANGINC') 
 $  v1 = 'f$verify(0)'
@@ -202,14 +227,16 @@ $  THEN
 $   compiler := "GNUC"
 $   v1 = f$verify(1)
 $! GNUC:
-$   cc := gcc/DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',USE_SLANG) 'cc_opts'-
+$   cc := gcc'cc_opts' -
+	     /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',USE_SLANG)-
 	     /INCLUDE=([-],[-.WWW.Library.Implementation],'SLANGINC') 
 $   v1 = 'f$verify(0)'
 $  ELSE
 $   compiler := "VAXC"
 $   v1 = f$verify(1)
 $! VAXC:
-$   cc := cc/DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',USE_SLANG) 'cc_opts'-
+$   cc := cc'cc_opts' -
+	    /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',USE_SLANG)-
 	    /INCLUDE=([-],[-.WWW.Library.Implementation],'SLANGINC')
 $   v1 = 'f$verify(0)'
 $  ENDIF
@@ -261,7 +288,7 @@ $ cc UCdomap
 $!
 $!	Link the objects and libaries.
 $!
-$ link/exe=lynx.exe 'link_opts' -
+$ link/exe=lynx.exe'link_opts' -
 DefaultStyle.obj, -
 GridText.obj, -
 HTAlert.obj, -
diff --git a/build.com b/build.com
index cbd9c04a..6235892d 100644
--- a/build.com
+++ b/build.com
@@ -5,6 +5,9 @@ $!   Command file to build LYNX.EXE on VMS systems.
 $!   Also invokes build of the WWWLibrary if its
 $!    object library does not already exist.
 $!
+$!   08-Oct-1997	F.Macrides		macrides@sci.wfeb.edu
+$!	Added comments and minor tweaks for convenient addition of
+$!	compiler definitions and compiler and linker options.
 $!   28-Jun-1997	F.Macrides		macrides@sci.wfeb.edu
 $!	Added chartrans support.
 $!   29-Feb-1996	F.Macrides		macrides@sci.wfeb.edu
@@ -50,8 +53,20 @@ $ write sys$output "Default directory:"
 $ show default
 $ write sys$output ""
 $!
-$ agent = 0
+$!	Compiler definitions can be added here as a comma separated
+$!	list with a lead comma, e.g., ",HAVE_FOO_H,DO_BLAH".  The
+$!	definitions will apply only to the LYfoo.c modules.  Ones
+$!	for the libwww-FM modules can be added equivalently in
+$!	[.WWW.Library.vms]libmake.com. - FM
+$!
 $ extra = ""
+$!
+$!	If no TCP/IP agent is specified (as the first argument),
+$!	prompt for a number from the list.   Note that the agent
+$!	must be the first argument if the debugger mode is to be
+$!	set via a second argument (see below). - FM
+$!
+$ agent = 0
 $ IF P1 .EQS. ""
 $ THEN
 $   If f$mode() .eqs. "BATCH"
@@ -82,18 +97,28 @@ $!
 $ if option .eqs. "TCPWARE"
 $ then
 $    write sys$output "Building Lynx for TCPWARE with UCX emulation..."
-$    extra   = ",UCX"
+$    extra = extra + ",UCX"
 $ endif
 $!
 $ optfile = "''option'"
 $!
+$!	Compiler and linker options can be specified here.  If
+$!	there was a second argument (with any value), then debugger
+$!	mode with no optimization will be specified as well.  The
+$!	compiler options will apply only to the LYfoo.c and UCfoo.c
+$!	modules.  Ones for the libwww-FM modules can be specified
+$!	in [.WWW.Library.vms]libmake.com. - FM
+$!
+$ cc_opts = ""
+$ link_opts = ""
+$!
 $ if p2 .nes. ""
 $   then
-$      cc_opts = "/DEBUG/NOOPT"
-$      link_opts = "/DEBUG"
+$      debug_arg = "DEBUG"
+$      cc_opts = cc_opts + "/DEBUG/NOOPT"
+$      link_opts = link_opts + "/DEBUG"
 $   else
-$      cc_opts = ""
-$      link_opts = ""
+$      debug_arg = ""
 $ endif
 $!
 $ IF f$search("[.WWW.Library.Implementation]WWWLib_''option'.olb") .nes. ""
@@ -115,7 +140,7 @@ $!	Build the WWWLibrary
 $!
 $ set default [.WWW.Library.VMS]
 $ v1 = 'f$verify(0)'
-$ @libmake 'option' 'cc_opts'
+$ @libmake 'option' 'debug_arg'
 $ v1 = f$verify(1)
 $ set default [-.-.-]
 $ v1 = 'f$verify(0)'
@@ -144,7 +169,7 @@ $!	Build the chrtrans modules.
 $!
 $ set default [.src.chrtrans]
 $ v1 = 'f$verify(0)'
-$ @build-chrtrans 'cc_opts'
+$ @build-chrtrans
 $ v1 = f$verify(1)
 $ set default [-.-]
 $ v1 = 'f$verify(0)'
@@ -166,10 +191,10 @@ $  compiler := "DECC"
 $  if option .eqs. "UCX" then optfile = "UCXSHR"
 $  if option .eqs. "TCPWARE" then optfile = "TCPWARESHR"
 $  if option .eqs. "MULTINET" then -
-	extra = ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
+	extra = extra + ",_DECC_V4_SOURCE,__SOCKET_TYPEDEFS"
 $  v1 = f$verify(1)
 $! DECC:
-$  cc := cc/decc/prefix=all /nomember 'cc_opts'-
+$  cc := cc/decc/prefix=all/nomember'cc_opts'-
 	   /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra',__VMS_CURSES)-
 	   /INCLUDE=([-],[-.WWW.Library.Implementation]) 
 $  v1 = 'f$verify(0)'
@@ -181,14 +206,16 @@ $  THEN
 $   compiler := "GNUC"
 $   v1 = f$verify(1)
 $! GNUC:
-$   cc := gcc/DEFINE=(DEBUG,ACCESS_AUTH,'option''extra') 'cc_opts'-
+$   cc := gcc'cc_opts' -
+	     /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra')-
 	     /INCLUDE=([-],[-.WWW.Library.Implementation]) 
 $   v1 = 'f$verify(0)'
 $  ELSE
 $   compiler := "VAXC"
 $   v1 = f$verify(1)
 $! VAXC:
-$   cc := cc/DEFINE=(DEBUG,ACCESS_AUTH,'option''extra') 'cc_opts'-
+$   cc := cc'cc_opts' -
+	    /DEFINE=(DEBUG,ACCESS_AUTH,'option''extra')-
 	    /INCLUDE=([-],[-.WWW.Library.Implementation]) 
 $   v1 = 'f$verify(0)'
 $  ENDIF
@@ -240,7 +267,7 @@ $ cc UCdomap
 $!
 $!	Link the objects and libaries.
 $!
-$ link/exe=lynx.exe 'link_opts' -
+$ link/exe=lynx.exe'link_opts' -
 DefaultStyle.obj, -
 GridText.obj, -
 HTAlert.obj, -
diff --git a/configure b/configure
index b6a15e96..61e24720 100755
--- a/configure
+++ b/configure
@@ -1141,7 +1141,7 @@ fi
 echo "$ac_t""$with_debug" 1>&6
 if test "$with_debug" = "yes" ; then
 	case $host_os in
-	ultrix*)
+	ultrix*|osf4.*)
 		
 CFLAGS=`echo ${CFLAGS} | sed -e 's/-O[1-9]\? //' -e 's/-O[1-9]\?$//'`
 
diff --git a/configure.in b/configure.in
index d0dd1b23..f10c968b 100644
--- a/configure.in
+++ b/configure.in
@@ -47,7 +47,7 @@ CF_ARG_ENABLE(debug,
 AC_MSG_RESULT($with_debug)
 if test "$with_debug" = "yes" ; then
 	case $host_os in
-	ultrix*)
+	ultrix*|osf4.*)
 		CF_STRIP_O_OPT(CFLAGS)
 		if test -z "$GCC" ; then
 			CFLAGS="$CFLAGS -g3"
diff --git a/CHANGES2-3 b/docs/CHANGES2-3
index f9653d4e..f9653d4e 100644
--- a/CHANGES2-3
+++ b/docs/CHANGES2-3
diff --git a/CHANGES2-4 b/docs/CHANGES2-4
index 2d242e2e..2d242e2e 100644
--- a/CHANGES2-4
+++ b/docs/CHANGES2-4
diff --git a/CHANGES2-5 b/docs/CHANGES2-5
index 38621df6..38621df6 100644
--- a/CHANGES2-5
+++ b/docs/CHANGES2-5
diff --git a/CHANGES2-6 b/docs/CHANGES2-6
index 73c158ab..73c158ab 100644
--- a/CHANGES2-6
+++ b/docs/CHANGES2-6
diff --git a/CMU.announce b/docs/CMU.announce
index a4cc6ead..a4cc6ead 100644
--- a/CMU.announce
+++ b/docs/CMU.announce
diff --git a/CRAWL.announce b/docs/CRAWL.announce
index e734bcba..e734bcba 100644
--- a/CRAWL.announce
+++ b/docs/CRAWL.announce
diff --git a/FM.announce b/docs/FM.announce
index dc3530c4..dc3530c4 100644
--- a/FM.announce
+++ b/docs/FM.announce
diff --git a/IBMPC-charsets.announce b/docs/IBMPC-charsets.announce
index 40d2854c..40d2854c 100644
--- a/IBMPC-charsets.announce
+++ b/docs/IBMPC-charsets.announce
diff --git a/docs/RFC-MAILCAP.txt b/docs/RFC-MAILCAP.txt
deleted file mode 100644
index f93538c1..00000000
--- a/docs/RFC-MAILCAP.txt
+++ /dev/null
@@ -1,742 +0,0 @@
-
-
-
-
-
-
-            Network Working Group               N. Borenstein, Bellcore
-            Internet Draft                                  March, 1993
-
-                        A User Agent Configuration Mechanism
-
-                       For Multimedia Mail Format Information
-
-
-          Status of This Memo
-
-            This  RFC  specifies  an  informational  protocol  for   the
-            Internet  community, and requests discussion and suggestions
-            for improvements.  Distribution of this memo is unlimited.
-
-          Abstract
-
-            This memo suggests a  file  format  to  be  used  to  inform
-            multiple   mail   reading  user  agent  programs  about  the
-            locally-installed facilities for handling  mail  in  various
-            formats.  The  mechanism is explicitly designed to work with
-            mail systems based Internet mail as defined  by  RFC's  821,
-            822,  934,  1049,  1113,  and the Multipurpose Internet Mail
-            Extensions, known as MIME.  However, with some extensions it
-            could  probably be made to work for X.400-based mail systems
-            as well.  The format and mechanism are proposed in a  manner
-            that  is  generally  operating-system independent.  However,
-            certain  implementation  details  will  inevitably   reflect
-            operating  system differences, some of which will have to be
-            handled in a uniform manner for each operating system.  This
-            memo  makes  such  situations explicit, and, in an appendix,
-            suggests  a  standard  behavior  under  the  UNIX  operating
-            system.
-
-          Introduction
-
-            The electronic mail world is in the midst  of  a  transition
-            from  single-part  text-only mail to multi-part, multi-media
-            mail.  In support of this transition, various extensions  to
-            RFC  821  and  RFC  822  have  been proposed and/or adopted,
-            notably including  MIME  [RFC-1341].  Various  parties  have
-            demonstrated  extremely  high-functionality multimedia mail,
-            but the problem of mail interchange between  different  user
-            agents has been severe.  In general, only text messages have
-            been shared between user agents  that  were  not  explicitly
-            designed   to   work   together.   This  limitation  is  not
-            compatible with a smooth transition to  a  multi-media  mail
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 1]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            world.
-
-            One approach to this transition is to modify diverse sets of
-            mail  reading user agents so that, when they need to display
-            mail of an  unfamiliar  (non-text)  type,  they  consult  an
-            external  file  for information on how to display that file.
-            That file might say, for example, that if  the  content-type
-            of  a  message  is "foo" it can be displayed to the user via
-            the "displayfoo" program.
-
-            This approach means that, with a  one-time  modification,  a
-            wide  variety  of  mail  reading  programs  can be given the
-            ability to display a  wide  variety  of  types  of  message.
-            Moreover,  extending  the  set of media types supported at a
-            site becomes a simple matter  of  installing  a  binary  and
-            adding  a  single  line to a configuration file.  Crucial to
-            this scheme, however, is that all of the user  agents  agree
-            on  a common representation and source for the configuration
-            file.  This memo proposes such a common representation.
-
-          Location of Configuration Information
-
-            Each  user  agent  must  clearly  obtain  the  configuration
-            information  from a common location, if the same information
-            is to be  used  to  configure  all  user  agents.   However,
-            individual  users  should  be  able to override or augment a
-            site's configuration.  The configuration information  should
-            therefore  be  obtained  from a designated set of locations.
-            The overall  configuration  will  be  obtained  through  the
-            virtual  concatenation  of  several individual configuration
-            files known as mailcap files.  The configuration information
-            will  be obtained from the FIRST matching entry in a mailcap
-            file, where "matching" depends on both a  matching  content-
-            type   specification,   an   entry   containing   sufficient
-            information for the purposes of the  application  doing  the
-            searching, and the success of any test in the "test=" field,
-            if present.
-
-            The precise location of  the  mailcap  files  is  operating-
-            system dependent.  A standard location for UNIX is specified
-            in Appendix A.
-
-          Overall Format of a Mailcap File
-
-            Each mailcap file consists of a set of entries that describe
-            the  proper  handling  of  one media type at the local site.
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 2]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            For example, one line might tell how to display a message in
-            Group III fax format.  A mailcap file consists of a sequence
-            of such individual entries, separated by newlines (according
-            to  the operating system's newline conventions). Blank lines
-            and lines that start with the "#" character (ASCII  35)  are
-            considered  comments,  and are ignored.  Long entries may be
-            continued on multiple lines if each non-terminal  line  ends
-            with  a  backslash  character ('\', ASCII 92), in which case
-            the multiple lines are to be treated  as  a  single  mailcap
-            entry.   Note that for such "continued" lines, the backslash
-            must be the last character on the line to be continued.
-
-            Thus the overall format of a mailcap file is given,  in  the
-            modified BNF of RFC 822, as:
-
-                 Mailcap-File = *Mailcap-Line
-
-                 Mailcap-Line = Comment / Mailcap-Entry
-
-                 Comment = NEWLINE  /  "#" *CHAR NEWLINE
-
-                 NEWLINE = <newline as defined by OS convention>
-
-            Note that the above specification implies that comments must
-            appear  on  lines all to themselves, with a "#" character as
-            the first character on each comment line.
-
-          Format of a Mailcap Entry
-
-            Each mailcap entry consists of a number of fields, separated
-            by semi-colons.  The first two fields are required, and must
-            occur in the specified  order.   The  remaining  fields  are
-            optional, and may appear in any order.
-
-            The first field is the  content-type,  which  indicates  the
-            type of data this mailcap entry describes how to handle.  It
-            is to be matched against the type/subtype  specification  in
-            the "Content-Type" header field of an Internet mail message.
-            If the subtype is specified as "*", it is intended to  match
-            all subtypes of the named content-type.
-
-            The second field, view-command, is a  specification  of  how
-            the  message  or  body part can be viewed at the local site.
-            Although the syntax of this field is  fully  specified,  the
-            semantics  of  program  execution  are  necessarily somewhat
-            operating system dependent.  UNIX  semantics  are  given  in
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 3]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            Appendix A.
-
-            The optional fields, which may be given in any order, are as
-            follows:
-
-            -- The "compose" field may be used to specify a program that
-            can  be used to compose a new body or body part in the given
-            format.  Its intended  use  is  to  support  mail  composing
-            agents  that  support  the  composition of multiple types of
-            mail using external composing  agents.  As  with  the  view-
-            command,  the  semantics  of program execution are operating
-            system dependent, with UNIX semantics specified in  Appendix
-            A.   The result of the composing program may be data that is
-            not yet suitable for mail transport -- that is,  a  Content-
-            Transfer-Encoding may need to be applied to the data.
-
-            -- The "composetyped" field  is  similar  to  the  "compose"
-            field, but is to be used when the composing program needs to
-            specify the Content-type header field to be applied  to  the
-            composed  data.   The  "compose"  field  is  simpler, and is
-            preferred for use with existing (non-mail-oriented) programs
-            for  composing  data  in a given format.  The "composetyped"
-            field is necessary when the  Content-type  information  must
-            include  auxilliary  parameters, and the composition program
-            must then know enough about mail formats to  produce  output
-            that includes the mail type information.
-
-            -- The "edit" field may be used to specify  a  program  that
-            can be used to edit a body or body part in the given format.
-            In many cases,  it  may  be  identical  in  content  to  the
-            "compose"  field,  and shares the operating-system dependent
-            semantics for program execution.
-
-            -- The "print" field may be used to specify a  program  that
-            can  be  used  to  print a message or body part in the given
-            format.  As with the view-command, the semantics of  program
-            execution   are   operating   system  dependent,  with  UNIX
-            semantics specified in Appendix A.
-
-            -- The "test" field  may  be  used  to  test  some  external
-            condition  (e.g.  the  machine  architecture,  or the window
-            system in use) to determine whether or not the mailcap  line
-            applies.   It  specifies  a  program  to be run to test some
-            condition.  The semantics of  execution  and  of  the  value
-            returned by the test program are operating system dependent,
-            with UNIX semantics specified in Appendix A.   If  the  test
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 4]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            fails,   a   subsequent  mailcap  entry  should  be  sought.
-            Multiple test fields are not permitted -- since a  test  can
-            call a program, it can already be arbitrarily complex.
-
-            -- The "needsterminal" field indicates that the view-command
-            must  be  run on an interactive terminal.  This is needed to
-            inform  window-oriented  user  agents  that  an  interactive
-            terminal  is  needed.  (The decision is not left exclusively
-            to the view-command because in some circumstances it may not
-            be  possible  for  such programs to tell whether or not they
-            are on interactive terminals.)   The  needsterminal  command
-            should be assumed to apply to the compose and edit commands,
-            too, if they exist.  Note that this is NOT a test -- it is a
-            requirement for the environment in which the program will be
-            executed, and should  typically  cause  the  creation  of  a
-            terminal  window when not executed on either a real terminal
-            or a terminal window.
-
-            -- The "copiousoutput" field indicates that the output  from
-            the  view-command  will be an extended stream of output, and
-            is to be interpreted as advice to the UA (User  Agent  mail-
-            reading  program)  that the output should be either paged or
-            made scrollable. Note that  it  is  probably  a  mistake  if
-            needsterminal and copiousoutput are both specified.
-
-            --  The  "description"  field  simply  provides  a   textual
-            description,  optionally  quoted, that describes the type of
-            data, to be used optionally by mail  readers  that  wish  to
-            describe the data before offering to display it.
-
-            -- The "textualnewlines"  field,  if  set  to  any  non-zero
-            value, indicates that this type of data is line-oriented and
-            that, if encoded in base64, all newlines should be converted
-            to  canonical  form  (CRLF)  before encoding, and will be in
-            that form after decoding.  In general, this field is  needed
-            only  if there is line-oriented data of some type other than
-            text/* or non-line-oriented data that is a subtype of text.
-
-            -- The "x11-bitmap" field names a file, in X11 bitmap  (xbm)
-            format,  which  points  to an appropriate icon to be used to
-            visually denote the presence of this kind of data.
-
-            -- The "nametemplate" field gives a  file  name  format,  in
-            which  %s  will be replaced by a short unique string to give
-            the name of the temporary file to be passed to  the  viewing
-            command.    This   is   only  expected  to  be  relevant  in
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 5]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            environments where filename extensions are meaningful,  e.g.
-            one  coulld  specify  that  a GIF file being passed to a gif
-            viewer  should  have  a  name  eding  in  ".gif"  by   using
-            "nametemplate=%s.gif".
-
-            -- Any other fields beginning with "x-" may be included  for
-            local   or   mailer-specific   extensions  of  this  format.
-            Implementations should simply ignore all  such  unrecognized
-            fields  to  permit  such  extensions, some of which might be
-            standardized in a future version of this document.
-
-            Some of the fields above, such as "needsterminal", apply  to
-            the  actions of the view-command, edit-command, and compose-
-            command, alike.  In some unusual  cases,  this  may  not  be
-            desirable,  but  differentiation  can  be  accomplished  via
-            separate mailcap entries, taking advantage of the fact  that
-            subsequent  mailcap  entries  are  searched  if  an  earlier
-            mailcap entry does not provide enough information:
-
-                 application/postscript; ps-to-terminal %s; \
-                     needsterminal
-                 application/postscript; ps-to-terminal %s; \
-                     compose=idraw %s
-
-            In RFC 822 modified BNF, the following grammar  describes  a
-            mailcap entry:
-
-                 Mailcap-Entry = typefield ; view-command
-                                     [";" 1#field]
-
-                 typefield = propertype / implicit-wild
-
-                 propertype = type "/" wildsubtype
-
-                 implicitwild = type
-
-                 wildsubtype = subtype / "*"
-
-                 view-command = mtext
-
-                 mtext = *mchar
-
-                 mchar = schar / qchar
-
-                 schar = * <any CHAR except
-
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 6]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-                            ";", "\", and CTLS>
-
-                 qchar = "\" CHAR ; may quote any char
-
-                 field = flag / namedfield
-
-                 namedfield = fieldname "=" mtext
-
-                 flag = "needsterminal"   ; All these literals are to
-                      / "copiousoutput"   ; be interpreted as
-                      / x-token           ; case-insensitive
-
-                 fieldname =    / "compose"      ;Also all of these
-                                / "composetyped" ;are case-insensitive.
-                                / "print"
-                                / "edit"
-                                / "test"
-                                / "x11-bitmap"
-                                / "textualnewlines"
-                                / "description"
-                                / x-token
-
-            Note that  "type",  "subtype", and "x-token" are defined  in
-            MIME.   Note  also  that  while  the  definition  of "schar"
-            includes the percent sign, "%", this character has a special
-            meaning  in  at least the UNIX semantics, and will therefore
-            need to be quoted as a qchar to be used literally.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 7]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-          Appendix A:  Implementation Details for UNIX
-
-            Although this memo fully specifies a  syntax  for  "mailcap"
-            files,  the  semantics  of the mailcap file are of necessity
-            operating-system dependent in four respects.   In  order  to
-            clarify  the  intent,  and to promote a standard usage, this
-            appendix proposes a UNIX semantics for these four cases.  If
-            a  mailcap  mechanism  is  implemented  on non-UNIX systems,
-            similar semantic decisions should be made and published.
-
-            Location of the Mailcap File(s)
-
-            For UNIX, a path search of mailcap files is specified.   The
-            default  path  search is specified as including at least the
-            following:
-
-            $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap
-
-            However,  this  path  may  itself  be  overridden  by a path
-            specified by the MAILCAPS environment variable.
-
-            Semantics of executable commands
-
-            Several portions of a mailcap entry specify commands  to  be
-            executed.   In  particular,  the mandatory second field, the
-            view-command, takes a command to  be  executed,  as  do  the
-            optional print, edit, test, and compose fields.
-
-            On a UNIX system, such commands will each be  a  full  shell
-            command  line, including the path name for a program and its
-            arguments.   (Because  of  differences  in  shells  and  the
-            implementation  and  behavior  of  the  same  shell from one
-            system to another, it is specified that the command line  be
-            intended  as  input  to  the  Bourne  shell, i.e. that it is
-            implicitly preceded by "/bin/sh -c " on the command line.)
-
-            The two characters "%s", if used, will be  replaced  by  the
-            name  of  a file for the actual mail body data.  In the case
-            of the edit adn view-command, the body part will  be  passed
-            to  this  command  as  standard  input  unless  one  or more
-            instances of "%s" appear in the view-command, in which  case
-            %s  will  be  replaced  by the name of a file containing the
-            body part, a file which may have to be  created  before  the
-            view-command  program  is  executed.  (Such  files cannot be
-            presumed to continue to exist after the view-command program
-            exits.  Thus a view-command that wishes to exit and continue
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 8]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            processing in the background should take care  to  save  the
-            data  first.)   In  the case of the compose and composetyped
-            commands, %s should be replaced by the name  of  a  file  to
-            which  the  composed  data should be written by the programs
-            named in the compose or composedtyped commands.   Thus,  the
-            calling  program  will  look  in that file later in order to
-            retrieve the composed data. If %s does  not  appear  in  the
-            compose  or  composetyped  commands,  then the composed data
-            will be assumed to be written by the composing  programs  to
-            standard output.
-
-            Furthermore, any occurrence of "%t" will be replaced by  the
-            content-type  and  subtype  specification.  (That is, if the
-            content-type is "text/plain", then %t will  be  replaced  by
-            "text/plain".)   A  literal % character may be quoted as \%.
-            Finally, named parameters from the Content-type field may be
-            placed  in the command execution line using "%{" followed by
-            the parameter name and a closing "}" character.  The  entire
-            parameter  should  appear as a single command line argument,
-            regardless of embedded spaces.  Thus, if the message  has  a
-            Content-type line of:
-
-                 Content-type:  multipart/mixed; boundary=42
-
-            and the mailcap file has a line of:
-
-                 multipart/*; /usr/local/bin/showmulti \
-                   %t %{boundary}
-
-            then the equivalent  of  the  following  command  should  be
-            executed:
-
-                 /usr/local/bin/showmulti multipart/mixed 42
-
-            If the content-type is "multipart" (any subtype),  then  the
-            two  characters  "%n"  will be replaced by an integer giving
-            the number of sub-parts within the multipart  entity.  Also,
-            the  two  characters  "%F"  will  be  replaced  by  a set of
-            arguments, twice as many arguments as  the  number  of  sub-
-            parts,  consisting  of  alternating  content-types  and file
-            names for each part in turn.  Thus if  multipart entity  has
-            three  parts,  "%F"  will  be  replaced by the equivalent of
-            "content-type1 file-name1 content-type2 file-name2  content-
-            type3 file-name3".
-
-
-
-
-
-            Borenstein         DRAFT - expires 8/1/93           [Page 9]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            Semantics of the "test" field
-
-            The "test" field specifies a program  to  be  used  to  test
-            whether  or  not the current mailcap line applies.  This can
-            be used, for example, to  have  a  mailcap  line  that  only
-            applies if the X window system is running, or if the user is
-            running on a SPARCstation with a /dev/audio.  The  value  of
-            the  "test"  field  is  a  program  to  run  to  test such a
-            condition.  The precise program to run and arguments to give
-            it are determined as specified in the previous section.  The
-            test program should return an  exit  code  of  zero  if  the
-            condition is true, and a non-zero code otherwise.
-
-            Semantics of the "compose" field
-
-            On UNIX, the composing program is expected to produce a data
-            stream  for  such  a  body part as its standard output.  The
-            program will be executed with  the  command  line  arguments
-            determined  as  specified  above.  The data returned via its
-            standard output will be given a Content-Type field that  has
-            no  supplementary  parameters.   For  example, the following
-            mailcap entry:
-
-                 audio/basic; /usr/local/bin/showaudio %t
-                  compose = /usr/local/bin/recordaudio
-
-            would  result  in  tagging  the   data   composed   by   the
-            "recordaudio" program as:
-
-                 Content-Type: audio/basic
-
-            If this is unacceptable --  for  example,  in  the  case  of
-            multipart  mail  a  "boundary" parameter is required -- then
-            the  "compose"  field  cannot   be   used.    Instead,   the
-            "composetyped" field should be used in the mailcap file.
-
-            Semantics of the "composetyped" field
-
-            The "composetyped" filed is much like the  "compose"  field,
-            except  that  it  names a composition program that produces,
-            not raw data, but data that includes a MIME-conformant  type
-            specification.   The  program  will  be  executed  with  the
-            command line arguments determined as specified  above.   The
-            data  returned  via  its  standard  output must begin with a
-            Content-Type header, followed optionally by other  Content-*
-            headers,  and  then  by  a  blank  line  and  the data.  For
-
-
-
-            Borenstein         DRAFT - expires 8/1/93          [Page 10]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            example, the following mailcap entry:
-
-                 multipart/mixed; /usr/local/bin/showmulti %t \
-                   %{boundary}; \
-                   composetyped = /usr/local/bin/makemulti
-
-            would result in executing  the  "makemulti"  program,  which
-            would  be  expected  to  begin its output with a line of the
-            form:
-
-                 Content-Type: multipart/mixed; boundary=foobar
-
-            Note that a composition program need not encode binary  data
-            in base64 or quoted-printable. It remains the responsibility
-            of the software calling the composition  program  to  encode
-            such  data  as  necessary.   However, if a composing program
-            does  encode  data,  which  is  not  encouraged,  it  should
-            announce  that fact using a Content-Transfer-Encoding header
-            in the  standard  manner  defined  by  MIME.   Because  such
-            encodings  must  be  announced by such a header, they are an
-            option only  for  composetyped  programs,  not  for  compose
-            programs.
-
-          Appendix B: Sample Mailcap File
-
-            The following is an example of a mailcap file for UNIX  that
-            demonstrates  most  of  the  syntax  above.     It  contains
-            explanatory comments where necessary.
-
-                 # Mailcap file for Bellcore lab 214.
-                 #
-                 # The next line sends "richtext" to the richtext
-                 program
-                 text/richtext; richtext %s; copiousoutput
-                 #
-                 # Next, basic u-law audio
-                 audio/*; showaudio; test=/usr/local/bin/hasaudio
-                 #
-                 # Next, use the xview program to handle several image
-                 formats
-                 image/*; xview %s; test=/usr/local/bin/RunningX
-                 #
-                 # The ATOMICMAIL interpreter uses curses, so needs a
-                 terminal
-
-
-
-
-
-            Borenstein         DRAFT - expires 8/1/93          [Page 11]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-                 application/atomicmail; /usr/local/bin/atomicmail %s; \
-                     needsterminal
-                 #
-                 # The next line handles Andrew format,
-                 #   if ez and ezview are installed
-                 x-be2; /usr/andrew/bin/ezview %s; \
-                    print=/usr/andrew/bin/ezprint %s ; \
-                    compose=/usr/andrew/bin/ez -d %s \;
-                    edit=/usr/andrew/bin/ez -d %s; \;
-                    copiousoutput
-                 #
-                 # The next silly example demonstrates the use of
-                 quoting
-                 application/*; echo "This is \\"%t\\" but \
-                    is 50 \% Greek to me" \; cat %s; copiousoutput
-
-
-          Appendix C:  A Note on Format Translation
-
-            It has been suggested that another function  of  a  mailcap-
-            like  mechanism  might  be  to specify the locally available
-            tools for document format translation.    For  example,  the
-            file could designate a program for translating from format A
-            to format B, another for translating from format B to format
-            C,   and  finally  a  mechanism  for  displaying  format  C.
-            Although this mechanism would be somewhat  richer  than  the
-            current  mailcap  file,  and  might  conceivably  also  have
-            utility at the message  transport  layer,  it  significantly
-            complicates the processing effort necessary for a user agent
-            that simply wants to display a message in format  A.   Using
-            the  current,  simpler,  mailcap scheme, a single line could
-            tell such a user agent to  display  A-format  mail  using  a
-            pipeline  of translators and the C-format viewer.  This memo
-            resists  the  temptation   to   complicate   the   necessary
-            processing  for a user agent to accomplish this task.  Using
-            the mailcap format defined here, it  is  only  necessary  to
-            find  the  correct  single  line  in  a mailcap file, and to
-            execute the command given in that line.
-
-          References
-
-            [RFC 822]  Crocker, D.,  "Standard for the  format  of  ARPA
-            Internet   text  messages", RFC  822,  UDEL, August, 1982.
-
-            [RFC  1341]   Borenstein,   N.,   and   N.   Freed,    "MIME
-            (Multipurpose  Internet  Mail  Extensions):  Mechanisms  for
-
-
-
-            Borenstein         DRAFT - expires 8/1/93          [Page 12]
-
-
-
-
-            MAILCAP        Multimedia Mail Configuration      March 1993
-
-
-            Specifying and Describing the  Format  of  Internet  Message
-            Bodies", RFC 1341, Bellcore, June, 1992.
-
-          Acknowledgements
-
-            The author  wishes  to  thank  Malcolm  Bjorn  Gillies,  Dan
-            Heller,  Olle  Jaernefors, Keith Moore, Luc Rooijakkers, and
-            the other members of the IETF task force on mail  extensions
-            for  their comments on earlier versions of this draft.    If
-            other acknowledgements were neglected, please let  me  know,
-            as it was surely accidental.
-
-          Security Considerations
-
-            Security issues are not  discussed in this memo.    However,
-            the  use  of  the mechanisms described in this memo can make
-            it easier for implementations to  slip  into  the   kind  of
-            security   problems   discussed   in   the   MIME  document.
-            Implementors and mailcap administrators should be  aware  of
-            these  security  considerations,  and  in particular  should
-            exercise caution in the choice of programs to be listed in a
-            mailcap file for  automatic execution.
-
-          Author's Address
-
-            Nathaniel S. Borenstein
-            MRE 2D-296, Bellcore
-            445 South St.
-            Morristown, NJ 07962-1910
-
-            Email: nsb@bellcore.com
-            Phone: +1 201 829 4270
-            Fax:  +1 201 829 7019
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-            Borenstein         DRAFT - expires 8/1/93          [Page 13]
-
-
\ No newline at end of file
diff --git a/SOCKETSHR.announce b/docs/SOCKETSHR.announce
index eda1c739..eda1c739 100644
--- a/SOCKETSHR.announce
+++ b/docs/SOCKETSHR.announce
diff --git a/TCPWARE.announce b/docs/TCPWARE.announce
index 899a460e..899a460e 100644
--- a/TCPWARE.announce
+++ b/docs/TCPWARE.announce
diff --git a/VMSWAIS.announce b/docs/VMSWAIS.announce
index 7253d0db..7253d0db 100644
--- a/VMSWAIS.announce
+++ b/docs/VMSWAIS.announce
diff --git a/lynx.cfg b/lynx.cfg
index 29a9de68..6b4b33a5 100644
--- a/lynx.cfg
+++ b/lynx.cfg
@@ -1266,6 +1266,7 @@ MINIMAL_COMMENTS:TRUE
 # overridden here, or via the global or personal mailcap files (see below).
 # Note that open is used as the default for NeXT, instead of the
 # XLOADIMAGE_COMMAND definition.
+# If you use xli, you may want to add the -quiet flag.
 #
 #XLOADIMAGE_COMMAND:xli %s &
 
@@ -1317,7 +1318,7 @@ MINIMAL_COMMENTS:TRUE
 # The global and personal MAILCAP files allow you to specify external
 # viewers to be spawned when Lynx encounters different MIME types, which
 # will override any of the suffix maps in this (lynx.cfg) configuration
-# file, or in src/HTInit.c.  See RFC-MAILCAP.txt in the docs subdirectory
+# file, or in src/HTInit.c.  See http://www.internic.net/rfc/rfc1524.txt
 # and the example mailcap file in the samples subdirectory.
 #
 #	Unix:
diff --git a/lynx_help/Lynx_users_guide.html b/lynx_help/Lynx_users_guide.html
index fa781d18..ca81d1a2 100644
--- a/lynx_help/Lynx_users_guide.html
+++ b/lynx_help/Lynx_users_guide.html
@@ -263,9 +263,9 @@ are described in <A
 HREF="#18"><em>Scrolling and Other useful commands</em></A>.  Some
 additional commands depend on the fact that Lynx keeps a list of each
 link you visited to reach the current document, called the <a
-href="keystroke_commands/history_help.html">History Page</a>, and a
+href="keystrokes/history_help.html">History Page</a>, and a
 list of all links visited during the current Lynx session, called the <a
-href="keystroke_commands/visited_help.html">Visited Links Page</a>.  The
+href="keystrokes/visited_help.html">Visited Links Page</a>.  The
 HISTORY keystroke command, normally mapped to <em>Backspace</em> or
 <em>Delete</em>, will show you the <em>History Page</em> of links leading to
 your access of the current document.  Any of the previous documents shown in
@@ -477,7 +477,7 @@ An option can be changed by entering the capital letter or character in
 parentheses for the option you wish to change (e.g. '<em>E</em>' for Editor
 or '<em>@</em>' for show cursor).  For fields where text must be entered,
 simply enter the text by typing on the keyboard.  The <a
-href="keystroke_commands/edit_help.html">Line Editor</a> can be used to
+href="keystrokes/edit_help.html">Line Editor</a> can be used to
 correct mistakes, and <em>Control-U</em> can be used to erase the whole
 line.  When you are done entering a change press the <em>Return</em> key
 to get back to the <em>Command?</em> prompt.
@@ -531,7 +531,7 @@ return to Lynx or the '<em>&gt;</em>' command to save the options to a
 	<dd>When multi-bookmarks is OFF, this is the filename and location
 	    of your default personal bookmark file.  Enter '<em>B</em>' to
 	    modify the filename and/or location via the <a
-	    href="keystroke_commands/edit_help.html">Line Editor</a>.
+	    href="keystrokes/edit_help.html">Line Editor</a>.
 	    Bookmark files allow frequently traveled links to be stored in
 	    personal easy to access files.  Using the '<em>a</em>'dd bookmark
 	    link command (see <a href="#15">Lynx bookmarks</a>) you may save
@@ -700,10 +700,10 @@ return to Lynx or the '<em>&gt;</em>' command to save the options to a
 	    selected or made current by numbers as well as using the arrow
 	    keys, or having every link as well as every form field numbered
 	    so that they can be selected or sought by numbers.  See the<br>
-	    &nbsp;&nbsp<a href="keystroke_commands/follow_help.html"
+	    &nbsp;&nbsp<a href="keystrokes/follow_help.html"
 	    >Follow link (or page) number:</a> and<br>
 	    &nbsp;&nbsp<a
-	    href="keystroke_commands/follow_help.html#select-option"
+	    href="keystrokes/follow_help.html#select-option"
 	    >Select option (or page) number:</a><br>
 	    help for more information.
 
@@ -711,7 +711,7 @@ return to Lynx or the '<em>&gt;</em>' command to save the options to a
    	<dd>This option allows you to set alternate key bindings for the
 	    built-in line editor, if your system administrator has installed
 	    alternates.  Otherwise, Lynx uses the <a
-	    href="keystroke_commands/edit_help.html">Default Binding</a>.
+	    href="keystrokes/edit_help.html">Default Binding</a>.
 
    <dt>List directory style
 	<dd>Applies to Directory Editing.  Files and directories can be 
@@ -1117,7 +1117,7 @@ commands.
 	    headers, or treat it as invalid and return an error message. 
    <dt><em>^K</em>
   	<dd><em>Control-K</em> invokes the <a
-	    href="keystroke_commands/cookie_help.html">Cookie Jar Page</a>
+	    href="keystrokes/cookie_help.html">Cookie Jar Page</a>
 	    if it contains cookies.
    <dt><em>z</em>
 	<dd>Lynx supports completely interruptible I/O processes. Press the
@@ -1127,10 +1127,10 @@ commands.
    <dt><em>numbers</em>
 	<dd>Lynx offers other, advanced navigation features when numbers
 	    are used to invoke the <a
-	    href="keystroke_commands/follow_help.html"
+	    href="keystrokes/follow_help.html"
 	    >Follow link (or goto link or page) number:</a> or<br>
 	    &nbsp;&nbsp;<a
-	    href="keystroke_commands/follow_help.html#select-option"
+	    href="keystrokes/follow_help.html#select-option"
 	    >Select option (or page) number:</a><br>
 	    prompts.
 	    [<A HREF="#TOC">ToC</A>]
@@ -1185,7 +1185,7 @@ options from a list, and fields for entering text.
 <dd>Text entry (INPUT) fields are displayed as a row of underscores the
     length of the entry field: <em>_______</em>. You may enter text directly
     by typing at the keyboard.   Use the <a
-    href="keystroke_commands/edit_help.html">Line Editor</a> keys to
+    href="keystrokes/edit_help.html">Line Editor</a> keys to
     correct errors.  If you try to input more text than the field can hold,
     the line editor will not accept the additional characters.  If you fill
     a text field the cursor will not move off the field but remain at the
@@ -1214,7 +1214,7 @@ next page), box, or button.
 
 <p><em>NOTE:</em> If you have a text input field selected you will not
 have access to most of the Lynx keystroke commands, because they are
-interpreted by the <a href="keystroke_commands/edit_help.html"
+interpreted by the <a href="keystrokes/edit_help.html"
 >Line Editor</a> as either text entries or editing commands.  Select a
 button or box when you want to use Lynx keystrokes.
 
@@ -1247,7 +1247,7 @@ resubmitted, even if the content has not changed, when you activate the
 <em>POST</em> as the METHOD if the document returned by the form has links
 which you activated, and then you go back via the PREV_DOC
 (<em>left-arrow</em>) command or via the <a
-href="keystroke_commands/history_help.html">History Page</a>.  Lynx can be
+href="keystrokes/history_help.html">History Page</a>.  Lynx can be
 compiled so that it resubmits the form in those cases as well, and the default
 can be changed via <em>lynx.cfg</em>, and toggled via the
 <em>-resubmit_posts</em> command line switch.
@@ -1765,7 +1765,7 @@ prompts, or ne'<em>V</em>'er to never allow cookies from that
 MIME headers).  All unexpired cookies are held in a hypothetical
 <em>Cookie Jar</em> which can be examined via the COOKIE_JAR keystroke
 command, normally mapped to <em>Ctrl-K</em>, for invoking the <a
-href="keystroke_commands/cookie_help.html">Cookie Jar Page</a>.  The
+href="keystrokes/cookie_help.html">Cookie Jar Page</a>.  The
 <em>Cookie Jar</em>, and any '<em>A</em>'lways or ne'<em>V</em>'er
 'allow' settings, do not presently outlast the Lynx session.
 
@@ -1787,7 +1787,7 @@ which will then apply to all documents visited at that site.
 about how they will be used in subsequent requests to that site, nor can
 infer how they will be used, you can <em>Gobble</em> (delete) the cookies
 and/or change the 'allow' setting for its <em>domain</em> via the <a
-href="keystroke_commands/cookie_help.html">Cookie Jar Page</a>.
+href="keystrokes/cookie_help.html">Cookie Jar Page</a>.
 [<A HREF="#TOC">ToC</A>]
 
 <h2><A NAME="31"><em>The Lynx command line</em></A></h2>
diff --git a/lynx_help/keystroke_commands/bookmark_help.html b/lynx_help/keystrokes/bookmark_help.html
index de08f394..de08f394 100644
--- a/lynx_help/keystroke_commands/bookmark_help.html
+++ b/lynx_help/keystrokes/bookmark_help.html
diff --git a/lynx_help/keystroke_commands/cookie_help.html b/lynx_help/keystrokes/cookie_help.html
index 0fd5b255..0fd5b255 100644
--- a/lynx_help/keystroke_commands/cookie_help.html
+++ b/lynx_help/keystrokes/cookie_help.html
diff --git a/lynx_help/keystroke_commands/dired_help.html b/lynx_help/keystrokes/dired_help.html
index eb1d1ae6..eb1d1ae6 100644
--- a/lynx_help/keystroke_commands/dired_help.html
+++ b/lynx_help/keystrokes/dired_help.html
diff --git a/lynx_help/keystroke_commands/edit_help.html b/lynx_help/keystrokes/edit_help.html
index 4baa7232..4baa7232 100644
--- a/lynx_help/keystroke_commands/edit_help.html
+++ b/lynx_help/keystrokes/edit_help.html
diff --git a/lynx_help/keystroke_commands/follow_help.html b/lynx_help/keystrokes/follow_help.html
index f30fbb77..f30fbb77 100644
--- a/lynx_help/keystroke_commands/follow_help.html
+++ b/lynx_help/keystrokes/follow_help.html
diff --git a/lynx_help/keystroke_commands/gopher_types_help.html b/lynx_help/keystrokes/gopher_types_help.html
index aa134daa..aa134daa 100644
--- a/lynx_help/keystroke_commands/gopher_types_help.html
+++ b/lynx_help/keystrokes/gopher_types_help.html
diff --git a/lynx_help/keystroke_commands/history_help.html b/lynx_help/keystrokes/history_help.html
index c6e3010f..c6e3010f 100644
--- a/lynx_help/keystroke_commands/history_help.html
+++ b/lynx_help/keystrokes/history_help.html
diff --git a/lynx_help/keystroke_commands/keystroke_help.html b/lynx_help/keystrokes/keystroke_help.html
index 77c8bbf2..5011d86e 100644
--- a/lynx_help/keystroke_commands/keystroke_help.html
+++ b/lynx_help/keystrokes/keystroke_help.html
@@ -80,6 +80,7 @@
 	       ]	      - Send a HEAD request for the current doc or link
 	       "	      -	Toggle valid or "soft" double-quote parsing
                CTRL-R         - Reload current file and refresh the screen
+               CTRL-V         - Switch to alternative parsing of HTML documents
                CTRL-W         - Refresh the screen
                CTRL-U         - Erase input line
                CTRL-G         - Cancel input or transfer
diff --git a/lynx_help/keystroke_commands/movement_help.html b/lynx_help/keystrokes/movement_help.html
index 4655db31..4655db31 100644
--- a/lynx_help/keystroke_commands/movement_help.html
+++ b/lynx_help/keystrokes/movement_help.html
diff --git a/lynx_help/keystroke_commands/option_help.html b/lynx_help/keystrokes/option_help.html
index c54b52e0..c54b52e0 100644
--- a/lynx_help/keystroke_commands/option_help.html
+++ b/lynx_help/keystrokes/option_help.html
diff --git a/lynx_help/keystroke_commands/other_help.html b/lynx_help/keystrokes/other_help.html
index 064fe852..1d507968 100644
--- a/lynx_help/keystroke_commands/other_help.html
+++ b/lynx_help/keystrokes/other_help.html
@@ -130,6 +130,10 @@
 
      CTRL-R   -	Reloads the current document and resets the display.
 
+     CTRL-V   -	Switches to an alternative way of parsing HTML documents.
+                This may help to get a more readable rendering of some
+                documents with invalidly placed HTML tags.
+
      CTRL-W   -	Resets or cleans up the display.
 
      CTRL-U   -	Clears text from an input field or prompt.
diff --git a/lynx_help/keystroke_commands/print_help.html b/lynx_help/keystrokes/print_help.html
index 153caa74..153caa74 100644
--- a/lynx_help/keystroke_commands/print_help.html
+++ b/lynx_help/keystrokes/print_help.html
diff --git a/lynx_help/keystroke_commands/scrolling_help.html b/lynx_help/keystrokes/scrolling_help.html
index d1931346..d1931346 100644
--- a/lynx_help/keystroke_commands/scrolling_help.html
+++ b/lynx_help/keystrokes/scrolling_help.html
diff --git a/lynx_help/keystroke_commands/visited_help.html b/lynx_help/keystrokes/visited_help.html
index ebb03a70..ebb03a70 100644
--- a/lynx_help/keystroke_commands/visited_help.html
+++ b/lynx_help/keystrokes/visited_help.html
diff --git a/lynx_help/keystroke_commands/xterm_help.html b/lynx_help/keystrokes/xterm_help.html
index d40ea450..d40ea450 100644
--- a/lynx_help/keystroke_commands/xterm_help.html
+++ b/lynx_help/keystrokes/xterm_help.html
diff --git a/lynx_help/lynx_help_main.html b/lynx_help/lynx_help_main.html
index b6bd6b21..32702484 100644
--- a/lynx_help/lynx_help_main.html
+++ b/lynx_help/lynx_help_main.html
@@ -12,8 +12,8 @@
 <lh><em>Choose a subject:</em></lh>
 <li><a href="Lynx_users_guide.html">Lynx Users Guide</a>
 <ul plain>
-<li><a href="keystroke_commands/keystroke_help.html">Key-stroke Commands</a>
-| <a href="keystroke_commands/edit_help.html">Line Editor</a>
+<li><a href="keystrokes/keystroke_help.html">Key-stroke Commands</a>
+| <a href="keystrokes/edit_help.html">Line Editor</a>
 <li><a href="lynx_url_support.html">Supported URLs</a>
 | <a href="http://www.w3.org/pub/WWW/Addressing/Addressing.html"
 >Help on URLs</a>
diff --git a/lynx_help/lynx_url_support.html b/lynx_help/lynx_url_support.html
index 44fc6f68..d17c5c88 100644
--- a/lynx_help/lynx_url_support.html
+++ b/lynx_help/lynx_url_support.html
@@ -125,7 +125,8 @@ The gopher URL takes the form:<BR>
 where <em>:port</em> is optional and defaults to <em>:70</em>, and the
 <em>/gopher-path</em> is opaque (not fully equivalent to the
 slash-separated series of symbolic elements of http paths) as explained
-in RFC1738.  Typically, the gopher-path consists of a <em>gophertype</em>
+in RFC1738.  Typically, the gopher-path consists of a
+<A HREF="keystrokes/gopher_types_help.html"><em>gophertype</em></A>
 indicating the file or service type (e.g., <em>0</em> or <em>I</em> for
 plain text or an image, respectively, <em>7</em> for a search, or <em>1</em>
 for a directory), followed by a platform-specific <em>selector</em>. Any
@@ -533,12 +534,13 @@ ACTION for a FORM, and if enabled in your Lynx image has the format:<BR>
 <tab indent="12"><em>ly<tab id="lh">
 nxcgi://localhost/path_to_CGI_script</em><BR>
 <tab to="lh">where <em>//localhost/</em> is optional and always implied.
-The output of the script must be text/html and is rendered and displayed
+The output of the script should be text/html and is rendered and displayed
 by Lynx. (Note that restrictions on acceptable paths can be imposed
 by the system administrator.)
 
 <p>This is a Lynxism and should be used only in local documents intended
-solely for Lynx.
+solely for Lynx, or for limited local testing of CGI scripts without a
+http server.
 
 <p>On VMS, you are advised to use the threaded OSU http server, available
 from <a href="ftp://osu.edu"
diff --git a/makefile.in b/makefile.in
index 46e6e071..115fbbcb 100644
--- a/makefile.in
+++ b/makefile.in
@@ -159,7 +159,7 @@ SITE_DEFS = # Your defines here
 # for installation of local execution links, please see the file userdefs.h
 #
 # TESTED: Linux FreeBSD SunOS Solaris IRIX CLIX HP-UX AIX SCO
-all:
+all lynx:
 	cd WWW/Library/unix && $(MAKE) CC="$(CC)" \
 		LYFLAGS="$(SITE_LYDEFS)"
 	cd src && $(MAKE) all CC="$(CC)" \
@@ -229,7 +229,7 @@ save:
 compress: tar
 	cd ..; rm -f $(lynxname).tar.Z; compress -f -v $(lynxname).tar
 
-install: all
+install: lynx
 	-mv -f $(bindir)/lynx $(bindir)/lynx.old
 	-mv -f $(libdir)/lynx.cfg $(libdir)/lynx.oldcfg
 	$(installbin) lynx $(bindir)/lynx
diff --git a/samples/lynx.cfg b/samples/lynx.cfg
index bf2dcade..88dd94a2 100644
--- a/samples/lynx.cfg
+++ b/samples/lynx.cfg
@@ -1266,6 +1266,7 @@ MINIMAL_COMMENTS:TRUE
 # overridden here, or via the global or personal mailcap files (see below).
 # Note that open is used as the default for NeXT, instead of the
 # XLOADIMAGE_COMMAND definition.
+# If you use xli, you may want to add the -quiet flag.
 #
 #XLOADIMAGE_COMMAND:xli %s &
 
diff --git a/styles/lynx.lss b/samples/lynx.lss
index 597a2059..597a2059 100644
--- a/styles/lynx.lss
+++ b/samples/lynx.lss
diff --git a/src/AttrList.h b/src/AttrList.h
index d0a95c3c..bc5710db 100644
--- a/src/AttrList.h
+++ b/src/AttrList.h
@@ -48,10 +48,13 @@ typedef struct {
  int cattr; /* attributes to go with the color */
 } HTCharStyle;
 
+#ifdef NOT_USED
+
 typedef struct _linkedlist {
  char name[64];
  struct _linkedlist *next;
 } linked_list;
+#endif
 
 #define HText_characterStyle if(TRACE)fprintf(stderr,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC
 
diff --git a/src/GridText.c b/src/GridText.c
index fe0d5c73..f7dfd402 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -199,6 +199,7 @@ struct _HText {
 				state;			/* Escape sequence? */
 	char			kanji_buf;		/* Lead multibyte */
 	int			in_sjis;		/* SJIS flag */
+        int			halted;			/* emergency halt */
 
 	BOOL			have_8bit_chars;   /* Any non-ASCII chars? */
 #ifdef EXP_CHARTRANS
@@ -245,6 +246,124 @@ PRIVATE int HText_TrueLineSize PARAMS((
 	HText *		text,
 	BOOL		IgnoreSpaces));
 
+#ifndef VMS			/* VMS has a better way - right? - kw */
+#define CHECK_FREE_MEM
+#endif
+
+#ifdef CHECK_FREE_MEM
+
+/*
+ *  text->halted = 1: have set fake 'Z' and output a message
+ *                 2: next time when HText_appendCharacter is called
+ *		      it will append *** MEMORY EXHAUSTED ***, then set
+ *		      to 3.
+ *		   3: normal text output will be suppressed (but not anchors,
+ *		      form fields etc.)
+ */
+PRIVATE void HText_halt NOARGS
+{
+    if (HTFormNumber > 0)
+	HText_DisableCurrentForm();
+    if (!HTMainText)
+	return;
+    if (HTMainText->halted < 2)
+	HTMainText->halted = 2;
+}
+
+#define MIN_NEEDED_MEM 5000
+
+/*
+ *  Check whether factor*min(bytes,MIN_NEEDED_MEM) is available,
+ *  or bytes if factor is 0.
+ *  MIN_NEEDED_MEM and factor together represent a security margin,
+ *  to take account of all the memory allocations where we don't check
+ *  and of buffers which may be emptied before HTCheckForInterupt()
+ *  is (maybe) called and other things happening, with some chance of
+ *  success.
+ *  This just tries to malloc() the to-be-checked-for amount of memory,
+ *  which might make the situation worse depending how allocation works.
+ *  There should be a better way... - kw
+ */
+PRIVATE BOOL mem_is_avail ARGS2(
+    size_t,	factor,
+    size_t,	bytes)
+{
+    void *p;
+    if (bytes < MIN_NEEDED_MEM && factor > 0)
+	bytes = MIN_NEEDED_MEM;
+    if (factor == 0)
+	factor = 1;
+    p = malloc(factor * bytes);
+    if (p) {
+	FREE(p);
+	return YES;
+    } else {
+	return NO;
+    }
+}
+
+/*
+ *  Replacement for calloc which checks for "enough" free memory
+ *  (with some security margins) and tries various recovery actions
+ *  if deemed necessary. - kw
+ */
+PRIVATE void * LY_check_calloc ARGS2(
+    size_t,	nmemb,
+    size_t,	size)
+{
+    int i, n;
+    if (mem_is_avail(4, nmemb * size)) {
+	return (calloc(nmemb, size));
+    }
+    n = HTList_count(loaded_texts);
+    for (i = n - 1; i > 0; i--) {
+	HText * t = HTList_objectAt(loaded_texts, i);
+	if (t == HTMainText)
+	    t = NULL;		/* shouldn't happen */
+	if (TRACE) {
+	    fprintf(stderr,
+		    "\r *** Emergeny freeing document %d/%d for '%s'%s!\n",
+		    i + 1, n,
+		    ((t && t->node_anchor &&
+		      t->node_anchor->address) ?
+		     t->node_anchor->address : "unknown anchor"),
+		    ((t && t->node_anchor &&
+		      t->node_anchor->post_data) ?	
+		     " with POST data" : ""));
+	}
+	HTList_removeObjectAt(loaded_texts, i);
+        HText_free(t);
+	if (mem_is_avail(4, nmemb * size)) {
+	    return (calloc(nmemb, size));
+	}
+    }
+    LYFakeZap(YES);
+    if (!HTMainText || HTMainText->halted <= 1) {
+	if (!mem_is_avail(2, nmemb * size)) {
+	    HText_halt();
+	    if (mem_is_avail(0, 700)) {
+		HTAlert("Memory exhausted, display interrupted!");
+	    }
+	} else {
+	    if ((!HTMainText || HTMainText->halted == 0) &&
+		mem_is_avail(0, 700)) {
+		HTAlert("Memory exhausted, will interrupt transfer!");
+		if (HTMainText)
+		    HTMainText->halted = 1;
+	    }
+	}
+    }
+    return (calloc(nmemb, size));
+}
+
+#define LY_CALLOC LY_check_calloc
+
+#else
+
+#define LY_CALLOC calloc
+
+#endif /* CHECK_FREE_MEM */
+
 #ifdef EXP_CHARTRANS
 PRIVATE void HText_getChartransInfo ARGS1(
 	HText *,	me)
@@ -369,7 +488,8 @@ PUBLIC HText *	HText_new ARGS1(
      *  Check the kcode setting if the anchor has a charset element. - FM
      */
     if (anchor->charset)
-        HText_setKcode(self, anchor->charset);
+        HText_setKcode(self, anchor->charset,
+		       HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT));
 
     /*
      *	Memory leak fixed.
@@ -487,6 +607,8 @@ PUBLIC void HText_free ARGS1(
             FREE(l->input_field->submit_action);
             FREE(l->input_field->submit_enctype);
             FREE(l->input_field->submit_title);
+
+            FREE(l->input_field->accept_cs);
 		
 	    FREE(l->input_field);
 	}
@@ -506,6 +628,7 @@ PUBLIC void HText_free ARGS1(
 
 	while (NULL != (Tab = (HTTabID *)HTList_nextObject(cur))) {
 	    FREE(Tab->name);
+	    FREE(Tab);
 	}
 	HTList_delete(self->tabs);
 	self->tabs = NULL;
@@ -1499,9 +1622,9 @@ PRIVATE void split_line ARGS2(
     HTLine * previous = text->last_line;
     int ctrl_chars_on_previous_line = 0;
     char * cp;
-    HTLine * line = (HTLine *)calloc(1, LINE_SIZE(MAX_LINE));
+    HTLine * line = (HTLine *)LY_CALLOC(1, LINE_SIZE(MAX_LINE));
     if (line == NULL)
-        outofmem(__FILE__, "split_line");
+        outofmem(__FILE__, "split_line_1");
 
     ctrl_chars_on_this_line = 0; /*reset since we are going to a new line*/
     text->LastChar = ' ';
@@ -1774,9 +1897,9 @@ PRIVATE void split_line ARGS2(
         previous->size--;
 	TailTrim++;
     }
-    temp = (HTLine *)calloc(1, LINE_SIZE(previous->size));
+    temp = (HTLine *)LY_CALLOC(1, LINE_SIZE(previous->size));
     if (temp == NULL)
-        outofmem(__FILE__, "split_line");
+        outofmem(__FILE__, "split_line_2");
     memcpy(temp, previous, LINE_SIZE(previous->size));
     FREE(previous);
     previous = temp;
@@ -1935,6 +2058,15 @@ PUBLIC void HText_appendCharacter ARGS2(
     if (!text)
 	return;
 
+    if (text->halted > 1) {
+	if (text->halted == 2) {
+	    text->halted = 0;
+	    text->kanji_buf = '\0';
+	    HText_appendText(text, " *** MEMORY EXHAUSTED ***");
+	}
+	text->halted = 3;
+	return;
+    }
     /*
      *  Make sure we don't hang on escape sequences.
      */
@@ -2148,6 +2280,12 @@ PUBLIC void HText_appendCharacter ARGS2(
     if (ch == '\n') {
 	    new_line(text);
 	    text->in_line_1 = YES;	/* First line of new paragraph */
+	    /*
+	     *  There are some pages written in
+	     *  different kanji codes. - TA & kw
+	     */
+	    if (HTCJK == JAPANESE)
+		text->kcode = NOKANJI;
 	    return;
     }
 
@@ -2166,6 +2304,12 @@ PUBLIC void HText_appendCharacter ARGS2(
     if (ch == '\r') {
 	new_line(text);
 	text->in_line_1 = NO;
+	/*
+	 *  There are some pages written in
+	 *  different kanji codes. - TA & kw
+	 */
+	if (HTCJK == JAPANESE)
+	    text->kcode = NOKANJI;
 	return;
     }
 
@@ -2238,7 +2382,7 @@ PUBLIC void HText_appendCharacter ARGS2(
     if (ch == ' ') {
         text->permissible_split = (int)line->size;	/* Can split here */
 	/* 
-	 *  There are some pages witten in
+	 *  There are some pages written in
 	 *  different kanji codes. - TA
 	 */
 	if (HTCJK == JAPANESE)
@@ -2928,6 +3072,9 @@ PUBLIC void HText_appendText ARGS2(
     if (str == NULL)
 	return;
 
+    if (text->halted == 3)
+	return;
+
     for (p = str; *p; p++) {
         HText_appendCharacter(text, *p);
     }
@@ -2976,6 +3123,11 @@ PUBLIC void HText_endAppend ARGS1(
      */
     new_line(text);
     
+    if (text->halted) {
+	LYFakeZap(NO);
+	text->halted = 0;
+    }
+
     /*
      *  Get the first line.
      */
@@ -5404,7 +5556,8 @@ PUBLIC void HText_setTabID ARGS2(
 	        return; /* Already set.  Keep the first value. */
 	    last = cur;
 	}
-	cur = last;
+	if (last)
+	    cur = last;
     }
     if (!Tab) { /* New name.  Create a new node */
 	Tab = (HTTabID *)calloc(1, sizeof(HTTabID));
@@ -6290,6 +6443,11 @@ PUBLIC int HText_beginInput ARGS3(
 	f->value_cs = I->value_cs;
     } else if (f->type != F_OPTION_LIST_TYPE) {
 	StrAllocCopy(f->value, "");
+	/*
+	 *  May be an empty INPUT field.  The text entered will then
+	 *  probably be in the current display character set. - kw
+	 */
+	f->value_cs = current_char_set;
     }
 
     /*
@@ -6344,6 +6502,16 @@ PUBLIC int HText_beginInput ARGS3(
     }
 
     /*
+     *  Store accept-charset if present. - kw
+     */
+    if (I->accept_cs) {
+	StrAllocCopy(f->accept_cs, I->accept_cs);
+	collapse_spaces(f->accept_cs);
+	for (i = 0; f->accept_cs[i]; i++)
+	    f->accept_cs[i] = TOLOWER(f->accept_cs[i]);
+    }
+
+    /*
      *  Add numbers to form fields if needed. - LE & FM
      */
     switch (f->type) {
@@ -6494,12 +6662,14 @@ PUBLIC void HText_SubmitForm ARGS4(
     char *Boundary = NULL;
     char *MultipartContentType = NULL;
     int target_cs = -1;
+    CONST char *out_csname;
     CONST char *target_csname = NULL;
     char *name_used;
 #ifdef EXP_CHARTRANS
     BOOL form_has_8bit = NO, form_has_special = NO;
     BOOL field_has_8bit = NO, field_has_special = NO;
     BOOL name_has_8bit = NO, name_has_special = NO;
+    BOOL have_accept_cs = NO;
     BOOL success;
     BOOL had_chartrans_warning = NO;
     char *val_used;
@@ -6558,8 +6728,30 @@ PUBLIC void HText_SubmitForm ARGS4(
 	Boundary = "xnyLAaB03X";
     }
 
+    /*
+     *  Determine in what character encoding (aka. charset) we should
+     *  submit.  We call this target_cs and the MIME name for it
+     *  target_csname.
+     *  TODO:   - actually use ACCEPT-CHARSET stuff from FORM
+     *  TODO:   - deal with list in ACCEPT-CHARSET, find a "best"
+     *		  charset to submit
+     */
 #ifdef EXP_CHARTRANS
-    if (HTMainText->node_anchor->charset &&
+    
+    if (submit_item->accept_cs &&
+	strcasecomp(submit_item->accept_cs, "UNKNOWN"))
+	have_accept_cs = YES;
+    if (submit_item->accept_cs && *submit_item->accept_cs &&
+	strcmp(submit_item->accept_cs, "*") &&
+	strcasecomp(submit_item->accept_cs, "UNKNOWN")) {
+	target_cs = UCGetLYhndl_byMIME(submit_item->accept_cs);
+	if (target_cs >= 0) {
+	    target_csname = submit_item->accept_cs;
+	}
+    }
+
+    if (target_cs < 0 &&
+        HTMainText->node_anchor->charset &&
 	*HTMainText->node_anchor->charset) {
 	target_cs = UCGetLYhndl_byMIME(HTMainText->node_anchor->charset);
 	if (target_cs >= 0) {
@@ -6609,7 +6801,9 @@ PUBLIC void HText_SubmitForm ARGS4(
 	        len += 32; /* plus and ampersand + safety net */
 
 #ifdef EXP_CHARTRANS
-		for (p = val; p && *p && !field_has_8bit; p++)
+		for (p = val;
+		     p && *p && !(field_has_8bit && field_has_special);
+		     p++)
 		    if ((*p == HT_NON_BREAK_SPACE) ||
 			(*p == HT_EM_SPACE) ||
 			(*p == LY_SOFT_HYPHEN)) {
@@ -6617,12 +6811,22 @@ PUBLIC void HText_SubmitForm ARGS4(
 		    } else if ((*p & 0x80) != 0) {
 			field_has_8bit = YES;
 		    }
-		for (p = form_ptr->name; p && *p && !field_has_8bit; p++)
-		    field_has_8bit = ((*p & 0x80) != 0);
-		if (field_has_8bit)
+		for (p = form_ptr->name;
+		     p && *p && !(name_has_8bit && name_has_special);
+		     p++)
+		    if ((*p == HT_NON_BREAK_SPACE) ||
+			(*p == HT_EM_SPACE) ||
+			(*p == LY_SOFT_HYPHEN)) {
+			name_has_special = YES;
+		    } else if ((*p & 0x80) != 0) {
+			name_has_8bit = YES;
+		    }
+
+		if (field_has_8bit || name_has_8bit)
 		    form_has_8bit = YES;
-		if (field_has_special)
+		if (field_has_special || name_has_special)
 		    form_has_special = YES;
+
 		if (!field_has_8bit && !field_has_special) {
 		    /* already ok */
 		} else if (target_cs < 0) {
@@ -6641,6 +6845,26 @@ PUBLIC void HText_SubmitForm ARGS4(
 		} else {
 		    target_cs = -1; /* don't know what to do */
 		}
+
+		/*  Same for name */
+		if (!name_has_8bit && !name_has_special) {
+		    /* already ok */
+		} else if (target_cs < 0) {
+		    /* already confused */
+		} else if (!name_has_8bit &&
+		    (LYCharSet_UC[target_cs].enc == UCT_ENC_8859 ||
+		     (LYCharSet_UC[target_cs].like8859 & UCT_R_8859SPECL))) {
+		    /* those specials will be trivial */
+		} else if (UCNeedNotTranslate(form_ptr->name_cs, target_cs)) {
+		    /* already ok */
+		} else if (UCCanTranslateFromTo(form_ptr->name_cs, target_cs)) {
+		    /* also ok */
+		} else if (UCCanTranslateFromTo(target_cs, form_ptr->name_cs)) {
+		    target_cs = form_ptr->value_cs; 	/* try this */
+		    target_csname = NULL; /* will be set after loop */
+		} else {
+		    target_cs = -1; /* don't know what to do */
+		}
 #endif /* EXP_CHARTRANS */
 
 	    } else if (anchor_ptr->input_field->number > form_number) {
@@ -6707,126 +6931,49 @@ PUBLIC void HText_SubmitForm ARGS4(
 			 "application/x-www-form-urlencoded");
 	}
 
-
-#ifndef EXP_CHARTRANS
 	/*
-	 *  Append the exended charset info if known, and it is not
-	 *  ISO-8859-1 or US-ASCII.  We'll assume the user has the
-	 *  matching character set selected, or a download offer would
-	 *  have been forced and we would not be processing the form
-	 *  here.  We don't yet want to do this unless the server
-	 *  indicated the charset in the original transmission, because
-	 *  otherwise it might be an old server and CGI script which
-	 *  will not parse out the extended charset info, and reject
-	 *  the POST Content-Type as invalid.  If the ENCTYPE is
-	 *  multipart/form-data and the charset is known, set up a
-	 *  Content-Type string for the text fields and append the
-	 *  charset even if it is ISO-8859-1 or US-ASCII, but don't
-	 *  append it to the post_content_type header.  Note that we do
-	 *  not yet have a way to vary the charset among multipart form
-	 *  fields, so this code assumes it is the same for all of the
-	 *  text fields. - FM
+	 *  If the ENCTYPE is not multipart/form-data, append the
+	 *  charset we'll be sending to the post_content_type, IF
+	 *  (1) there was an explicit accept-charset attribute, OR
+	 *  (2) we have 8-bit or special chars, AND the document had
+	 *      an explicit (recognized and accepted) charset parameter,
+	 *	AND it or target_csname is different from iso-8859-1,
+	 *      OR
+	 *  (3) we have 8-bit or special chars, AND the document had
+	 *      no explicit (recognized and accepted) charset parameter,
+	 *	AND target_cs is different from the currently effective
+	 *	assumed charset (which should have been set by the user
+	 *	so that it reflects what the server is sending, if the
+	 *	document is rendered correctly).
+	 *  For multipart/form-data the equivalent will be done later,
+	 *  separately for each form field. - kw
 	 */
-	if (HTMainText->node_anchor->charset != NULL &&
-	    *HTMainText->node_anchor->charset != '\0') {
-	    if (Boundary == NULL &&
-	        strcasecomp(HTMainText->node_anchor->charset, "iso-8859-1") &&
-		strcasecomp(HTMainText->node_anchor->charset, "us-ascii")) {
-		StrAllocCat(doc->post_content_type, "; charset=");
-		StrAllocCat(doc->post_content_type,
-			    HTMainText->node_anchor->charset);
-	    } else if (Boundary != NULL) {
-	        MultipartContentType = (char *)calloc(1,
-			     (40 + strlen(HTMainText->node_anchor->charset)));
-		if (query == NULL)
-		    outofmem(__FILE__, "HText_SubmitForm");
-		sprintf(MultipartContentType,
-			"\r\nContent-Type: text/plain; charset=%s",
-			HTMainText->node_anchor->charset);
-		ct_charset_startpos = strchr(MultipartContentType, ';');
-	    }
-	}
-#else  /* EXP_CHARTRANS */
-	if (target_cs >= 0 && (form_has_8bit || form_has_special)) {
-	    if (Boundary == NULL) {
-		if (target_csname &&
-		    (strcasecomp(target_csname, "iso-8859-1") ||
-		     (HTMainText->node_anchor->charset != NULL &&
-		      strcasecomp(HTMainText->node_anchor->charset,
-				  "iso-8859-1")))) {
-		    StrAllocCat(doc->post_content_type, "; charset=");
-		    StrAllocCat(doc->post_content_type, target_csname);
+	if (have_accept_cs ||
+	    (form_has_8bit || form_has_special)) {
+	    if (target_cs >= 0 && target_csname) {
+		if (Boundary == NULL) {
+		    if ((HTMainText->node_anchor->charset &&
+			 (strcmp(HTMainText->node_anchor->charset,
+				 "iso-8859-1") ||
+			  strcmp(target_csname, "iso-8859-1"))) ||
+			(!HTMainText->node_anchor->charset &&
+			 target_cs != UCLYhndl_for_unspec)) {
+			StrAllocCat(doc->post_content_type, "; charset=");
+			StrAllocCat(doc->post_content_type, target_csname);
+		    }
 		}
+	    } else {
+		had_chartrans_warning = YES;
+		_user_message(
+		    CANNOT_TRANSCODE_FORM,
+		    target_csname ? target_csname : "UNKNOWN");
+		sleep(AlertSecs);
 	    }
 	}
-#endif  /* EXP_CHARTRANS */
     }
 
 
-#if 0				/* 000000 */
-    {
-	if (HTMainText->node_anchor->charset != NULL &&
-	    *HTMainText->node_anchor->charset != '\0') {
-#ifdef EXP_CHARTRANS
-	    /*
-	     *  For now, don't send charset if we may have translated.
-	     *  Although this is when it would be most needed (unless
-	     *  we translate back to the server's charset, which is
-	     *  currently not done).  But currently there aren't many
-	     *  servers or scripts which understand it anyway, so at
-	     *  least we try not to lie. - kw
-	     */
-#if 0
-	    if (!UCNeedNotTranslate(current_char_set,
-				    UCGetLYhndl_byMIME(
-					HTMainText->node_anchor->charset)));
-#endif
-	    if (target_cs < 0) {
-		/*  Do nothing */
-	    } else
-#endif
-	    if (Boundary == NULL &&
-#ifdef EXP_CHARTRANS
-		form_has_8bit &&
-		target_cs >= 0 &&
-#endif
-	        (strcasecomp(HTMainText->node_anchor->charset, "iso-8859-1") ||
-		 strcasecomp(target_csname, "iso-8859-1"))) {
-		StrAllocCat(doc->post_content_type, "; charset=");
-		StrAllocCat(doc->post_content_type,
-			    HTMainText->node_anchor->charset);
-	    } else
-	    if (Boundary == NULL &&
-#ifdef EXP_CHARTRANS
-		target_cs >= 0 &&
-#endif
-	        strcasecomp(HTMainText->node_anchor->charset, "iso-8859-1") &&
-		strcasecomp(HTMainText->node_anchor->charset, "us-ascii")) {
-		StrAllocCat(doc->post_content_type, "; charset=");
-		StrAllocCat(doc->post_content_type,
-			    HTMainText->node_anchor->charset);
-	    } else if (Boundary != NULL) {
-	        MultipartContentType = (char *)calloc(1,
-			     (40 + strlen(HTMainText->node_anchor->charset)));
-		if (query == NULL)
-		    outofmem(__FILE__, "HText_SubmitForm");
-		sprintf(MultipartContentType,
-			"\r\nContent-Type: text/plain; charset=%s",
-			HTMainText->node_anchor->charset);
-		ct_charset_startpos = strchr(MultipartContentType, ';');
-	    }
-	}
-#ifdef EXP_CHARTRANS
-    } else if (Boundary == NULL &&
-	       form_has_8bit &&
-	       target_cs >= 0 &&
-	       strcasecomp(target_csname, "iso-8859-1")) {
-	StrAllocCat(doc->post_content_type, "; charset=");
-	StrAllocCat(doc->post_content_type,
-		    HTMainText->node_anchor->charset);
-#endif /* EXP_CHARTRANS */
-    }
-#endif /* 000000 */
+    out_csname = target_csname;
 
     /*
      *  Reset anchor->ptr.
@@ -6840,7 +6987,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 	    if (anchor_ptr->input_field->number == form_number) {
 		char *p;
 		int out_cs;
-		CONST char * out_csname;
                 form_ptr = anchor_ptr->input_field;
 
 		if (form_ptr->type != F_TEXTAREA_TYPE)
@@ -6890,9 +7036,7 @@ PUBLIC void HText_SubmitForm ARGS4(
 		case F_HIDDEN_TYPE:
 #ifdef EXP_CHARTRANS
 		    /*
-		     *  Charset-translate value now, because we need
-		     *  to know the charset parameter for multipart
-		     *  bodyparts. - kw
+		     *	Be sure to actually look at the option submit value.
 		     */
 		    if (form_ptr->cp_submit_value != NULL) {
 			val_used = form_ptr->cp_submit_value;
@@ -6900,9 +7044,16 @@ PUBLIC void HText_SubmitForm ARGS4(
 			val_used = form_ptr->value;
 		    }
 
+		    /*
+		     *  Charset-translate value now, because we need
+		     *  to know the charset parameter for multipart
+		     *  bodyparts. - kw
+		     */
 		    field_has_8bit = NO;
 		    field_has_special = NO;
-		    for (p = val_used; p && *p && !field_has_8bit; p++) {
+		    for (p = val_used;
+			 p && *p && !(field_has_8bit && field_has_special);
+			 p++) {
 			if ((*p == HT_NON_BREAK_SPACE) ||
 			    (*p == HT_EM_SPACE) ||
 			    (*p == LY_SOFT_HYPHEN)) {
@@ -6933,18 +7084,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			if (success) {
 			    val_used = copied_val_used;
 			}
-			if (Boundary) {
-			    if (!success) {
-				StrAllocCopy(MultipartContentType, "");
-				target_csname = NULL;
-			    } else {
-				if (!target_csname)
-				    target_csname = LYCharSet_UC[target_cs].MIMEname;
-				StrAllocCopy(MultipartContentType,
-					     "\r\nContent-Type: text/plain; charset=");
-				StrAllocCat(MultipartContentType, target_csname);
-			    }
-			}
 		    } else {  /* We can use the value directly. */
 			if (TRACE) {
 			    fprintf(stderr,
@@ -6953,22 +7092,22 @@ PUBLIC void HText_SubmitForm ARGS4(
 				    target_cs,
 				    target_csname ? target_csname : "???");
 			}
-			copied_val_used = NULL;
 			success = YES;
 		    }
 		    if (!success) {
 			if (!had_chartrans_warning) {
 			    had_chartrans_warning = YES;
 			    _user_message(
-				"Cannot convert form data to charset %s!",
+				CANNOT_TRANSCODE_FORM,
 				target_csname ? target_csname : "UNKNOWN");
 			    sleep(AlertSecs);
 			}
 			out_cs = form_ptr->value_cs;
-			out_csname = LYCharSet_UC[out_cs].MIMEname;
 		    } else {
 			out_cs = target_cs;
 		    }
+		    if (out_cs >= 0)
+			out_csname = LYCharSet_UC[out_cs].MIMEname;
 		    if (Boundary) {
 			if (!success && form_ptr->value_cs < 0) {
 			    /*  This is weird. */
@@ -6976,10 +7115,9 @@ PUBLIC void HText_SubmitForm ARGS4(
 					 "\r\nContent-Type: text/plain; charset=");
 			    StrAllocCat(MultipartContentType, "UNKNOWN-8BIT");
 			} else if (!success) {
-			    target_csname = LYCharSet_UC[form_ptr->value_cs].MIMEname;
 			    StrAllocCopy(MultipartContentType,
 					 "\r\nContent-Type: text/plain; charset=");
-			    StrAllocCat(MultipartContentType, target_csname);
+			    StrAllocCat(MultipartContentType, out_csname);
 			    target_csname = NULL;
 			} else {
 			    if (!target_csname) {
@@ -6987,7 +7125,7 @@ PUBLIC void HText_SubmitForm ARGS4(
 			    }
 			    StrAllocCopy(MultipartContentType,
 					 "\r\nContent-Type: text/plain; charset=");
-			    StrAllocCat(MultipartContentType, target_csname);
+			    StrAllocCat(MultipartContentType, out_csname);
 			}
 		    }
 
@@ -7009,7 +7147,9 @@ PUBLIC void HText_SubmitForm ARGS4(
 
 		    name_has_8bit = NO;
 		    name_has_special = NO;
-		    for (p = name_used; p && *p && !name_has_8bit; p++) {
+		    for (p = name_used;
+			 p && *p && !(name_has_8bit && name_has_special);
+			 p++) {
 			if ((*p == HT_NON_BREAK_SPACE) ||
 			    (*p == HT_EM_SPACE) ||
 			    (*p == LY_SOFT_HYPHEN)) {
@@ -7047,9 +7187,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			    } else {
 				if (!target_csname)
 				    target_csname = LYCharSet_UC[target_cs].MIMEname;
-				StrAllocCopy(MultipartContentType,
-					     "\r\nContent-Type: text/plain; charset=");
-				StrAllocCat(MultipartContentType, target_csname);
 			    }
 			}
 		    } else {  /* We can use the name directly. */
@@ -7069,12 +7206,24 @@ PUBLIC void HText_SubmitForm ARGS4(
 			if (!had_chartrans_warning) {
 			    had_chartrans_warning = YES;
 			    _user_message(
-				"Cannot convert form name to charset %s!",
+				CANNOT_TRANSCODE_FORM,
 				target_csname ? target_csname : "UNKNOWN");
 			    sleep(AlertSecs);
 			}
 		    }
 		    if (Boundary) {
+			/*
+			 *  According to RFC 1867, Non-ASCII field names
+			 *  "should be encoded according to the prescriptions
+			 *  of RFC 1522 [...].  I don't think RFC 1522 actually
+			 *  is meant to apply to parameters like this, and it
+			 *  is unknown wheter any server would make sense of
+			 *  it, so for now just use some quoting/escaping and
+			 *  otherwise leave 8-bit values as they are.
+			 *  Non-ASCII characters in form field names submitted
+			 *  as multipart/form-data can only occur if the form
+			 *  provider specifically asked for it anyway. - kw
+			 */
 			HTMake822Word(&copied_name_used);
 			name_used = copied_name_used;
 		    }
@@ -7109,7 +7258,7 @@ PUBLIC void HText_SubmitForm ARGS4(
 		       (form_ptr->type == F_TEXT_SUBMIT_TYPE ||
 			(form_ptr->value && *form_ptr->value != '\0' &&
 			 !strcmp(form_ptr->value, link_value)))) {
-			int cdisp_name_startpos;
+			int cdisp_name_startpos = 0;
 			if (first_one) {
 			    if (Boundary) {
 				sprintf(&query[strlen(query)],
@@ -7143,60 +7292,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			    escaped1 = HTEscapeSP(name_used, URL_XALPHAS);
 			}
 
-#ifndef EXP_CHARTRANS
-			/*
-			 *  Be sure to actually look at
-			 *  the option submit value.
-			 */
-			if (form_ptr->cp_submit_value != NULL) {
-			    for (i = 0; form_ptr->cp_submit_value[i]; i++) {
-				if (form_ptr->cp_submit_value[i] ==
-					HT_NON_BREAK_SPACE ||
-				    form_ptr->cp_submit_value[i] ==
-					HT_EM_SPACE) {
-				    if (PlainText) {
-					form_ptr->cp_submit_value[i] = ' ';
-				    } else {
-					form_ptr->cp_submit_value[i] = 160;
-				    }
-				} else if (form_ptr->cp_submit_value[i] ==
-					LY_SOFT_HYPHEN) {
-				    form_ptr->cp_submit_value[i] = 173;
-				}
-			    }
-			    if (PlainText || Boundary) {
-				StrAllocCopy(escaped2,
-					     (form_ptr->cp_submit_value ?
-					      form_ptr->cp_submit_value : ""));
-			    } else {
-				escaped2 = HTEscapeSP(form_ptr->cp_submit_value,
-						      URL_XALPHAS);
-			    }
-			} else {
-			    for (i = 0; form_ptr->value[i]; i++) {
-				if (form_ptr->value[i] ==
-					HT_NON_BREAK_SPACE ||
-				    form_ptr->value[i] ==
-					HT_EM_SPACE) {
-				    if (PlainText) {
-					form_ptr->value[i] = ' ';
-				    } else {
-					form_ptr->value[i] = 160;
-				    }
-				} else if (form_ptr->value[i] ==
-					LY_SOFT_HYPHEN) {
-				    form_ptr->value[i] = 173;
-				}
-			    }
-			    if (PlainText || Boundary) {
-				StrAllocCopy(escaped2, (form_ptr->value ?
-							form_ptr->value : ""));
-			    } else {
-				escaped2 = HTEscapeSP(form_ptr->value,
-						      URL_XALPHAS);
-			    }
-			}
-#else /* EXP_CHARTRANS */
 			if (PlainText || Boundary) {
 			    StrAllocCopy(escaped2,
 					 (val_used ?
@@ -7204,7 +7299,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			} else {
 			    escaped2 = HTEscapeSP(val_used, URL_XALPHAS);
 			}
-#endif /* EXP_CHARTRANS */
 
 			if (form_ptr->type == F_IMAGE_SUBMIT_TYPE) {
 			    /*
@@ -7293,60 +7387,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			} else {
 			    escaped1 = HTEscapeSP(name_used, URL_XALPHAS);
 			}
-#ifndef EXP_CHARTRANS
-			/*
-			 *  Be sure to use the submit option value.
-			 */
-			if (form_ptr->cp_submit_value != NULL) {
-			    for (i = 0; form_ptr->cp_submit_value[i]; i++) {
-				if (form_ptr->cp_submit_value[i] ==
-					HT_NON_BREAK_SPACE ||
-				    form_ptr->cp_submit_value[i] ==
-					HT_EM_SPACE) {
-				    if (PlainText) {
-					form_ptr->cp_submit_value[i] = ' ';
-				    } else {
-					form_ptr->cp_submit_value[i] = 160;
-				    }
-				 } else if (form_ptr->cp_submit_value[i] ==
-					LY_SOFT_HYPHEN) {
-				    form_ptr->cp_submit_value[i] = 173;
-				 }
-			    }
-			    if (PlainText || Boundary) {
-				StrAllocCopy(escaped2,
-					     (form_ptr->cp_submit_value ?
-					      form_ptr->cp_submit_value : ""));
-			    } else {
-				escaped2 = HTEscapeSP(form_ptr->cp_submit_value,
-						      URL_XALPHAS);
-			    }
-			} else {
-			    for (i = 0; form_ptr->value[i]; i++) {
-				if (form_ptr->value[i] ==
-					HT_NON_BREAK_SPACE ||
-				    form_ptr->value[i] ==
-					HT_EM_SPACE) {
-				    if (PlainText) {
-					form_ptr->value[i] = ' ';
-				    } else {
-					form_ptr->value[i] = 160;
-				    }
-				} else if (form_ptr->value[i] ==
-					LY_SOFT_HYPHEN) {
-				    form_ptr->value[i] = 173;
-
-				}
-			    }
-			    if (PlainText || Boundary) {
-				StrAllocCopy(escaped2, (form_ptr->value ?
-							form_ptr->value : ""));
-			    } else {
-				escaped2 = HTEscapeSP(form_ptr->value,
-						      URL_XALPHAS);
-			    }
-			}
-#else /* EXP_CHARTRANS */
 			if (PlainText || Boundary) {
 			    StrAllocCopy(escaped2,
 					 (val_used ?
@@ -7354,7 +7394,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			} else {
 			    escaped2 = HTEscapeSP(val_used, URL_XALPHAS);
 			}
-#endif /* EXP_CHARTRANS */
 
 			sprintf(&query[strlen(query)],
 				"%s%s%s%s%s",
@@ -7376,26 +7415,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 		    break;
 
 		case F_TEXTAREA_TYPE:
-#ifndef EXP_CHARTRANS
-		    for (i = 0; form_ptr->value[i]; i++) {
-			if (form_ptr->value[i] == HT_NON_BREAK_SPACE ||
-			    form_ptr->value[i] == HT_EM_SPACE) {
-			    if (PlainText) {
-				form_ptr->value[i] = ' ';
-			    } else {
-				form_ptr->value[i] = 160;
-			    }
-			} else if (form_ptr->value[i] == LY_SOFT_HYPHEN) {
-			    form_ptr->value[i] = 173;
-			}
-		    }
-		    if (PlainText || Boundary) {
-			StrAllocCopy(escaped2, (form_ptr->value ? 
-						form_ptr->value : ""));
-		    } else {
-			escaped2 = HTEscapeSP(form_ptr->value, URL_XALPHAS);
-		    }
-#else /* EXP_CHARTRANS */
 		    if (PlainText || Boundary) {
 			StrAllocCopy(escaped2,
 				     (val_used ?
@@ -7403,7 +7422,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 		    } else {
 			escaped2 = HTEscapeSP(val_used, URL_XALPHAS);
 		    }
-#endif /* EXP_CHARTRANS */
 
 		    if (!last_textarea_name || 
 			strcmp(last_textarea_name, form_ptr->name)) {
@@ -7532,59 +7550,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 			escaped1 = HTEscapeSP(name_used, URL_XALPHAS);
 		    }
 
-#ifndef EXP_CHARTRANS
-		    /*
-		     *	Be sure to actually look at the option submit value.
-		     */
-		    if (form_ptr->cp_submit_value != NULL) {
-			for (i = 0; form_ptr->cp_submit_value[i]; i++) {
-			    if (form_ptr->cp_submit_value[i] ==
-					HT_NON_BREAK_SPACE ||
-				form_ptr->cp_submit_value[i] ==
-					HT_EM_SPACE) {
-				if (PlainText) {
-				    form_ptr->cp_submit_value[i] = ' ';
-				} else {
-				    form_ptr->cp_submit_value[i] = 160;
-				}
-			    } else if (form_ptr->cp_submit_value[i] ==
-					LY_SOFT_HYPHEN) {
-				form_ptr->cp_submit_value[i] = 173;
-			    }
-			}
-			if (PlainText || Boundary) {
-			    StrAllocCopy(escaped2,
-					 (form_ptr->cp_submit_value ?
-					  form_ptr->cp_submit_value : ""));
-			} else {
-			    escaped2 = HTEscapeSP(form_ptr->cp_submit_value,
-						  URL_XALPHAS);
-			}
-		    } else {
-			for (i = 0; form_ptr->value[i]; i++) {
-			    if (form_ptr->value[i] ==
-					HT_NON_BREAK_SPACE ||
-				form_ptr->value[i] ==
-					HT_EM_SPACE) {
-				if (PlainText) {
-				    form_ptr->value[i] = ' ';
-				} else {
-				    form_ptr->value[i] = 160;
-				}
-			    } else if (form_ptr->value[i] ==
-					LY_SOFT_HYPHEN) {
-				form_ptr->value[i] = 173;
-			    }
-			}
-			if (PlainText || Boundary) {
-			    StrAllocCopy(escaped2, (form_ptr->value ?
-						    form_ptr->value : ""));
-			} else {
-			    escaped2 = HTEscapeSP(form_ptr->value,
-						  URL_XALPHAS);
-			}
-		    }
-#else /* EXP_CHARTRANS */
 		    if (PlainText || Boundary) {
 			StrAllocCopy(escaped2,
 				     (val_used ?
@@ -7592,7 +7557,6 @@ PUBLIC void HText_SubmitForm ARGS4(
 		    } else {
 			escaped2 = HTEscapeSP(val_used, URL_XALPHAS);
 		    }
-#endif /* EXP_CHARTRANS */
 
 		    sprintf(&query[strlen(query)],
 			    "%s%s%s%s%s",
@@ -7892,16 +7856,36 @@ PUBLIC BOOL HText_hasUTF8OutputSet ARGS1(
 
 /*
 **  Check charset and set the kcode element. - FM
+**  Info on the input charset may be passed in in two forms,
+**  as a string (if given explicitly) and as a pointer to
+**  a LYUCcharset (from chartrans mechanism); either can be NULL.
+**  For Japanes the kcode will be reset at a space or explicit
+**  line or paragraph break, so what we set here may not last for
+**  long.  It's potentially more important not to set HTCJK to
+**  NOCJK unless we are sure. - kw
 */
-PUBLIC void HText_setKcode ARGS2(
+PUBLIC void HText_setKcode ARGS3(
 	HText *,	text,
-	CONST char *,	charset)
+	CONST char *,	charset,
+	LYUCcharset *,	p_in)
 {
     if (!text)
         return;
 
     /*
-    **  Check whether we have a sepecified charset. - FM
+    **  Check whether we have some king of info. - kw
+    */
+    if (!charset && !p_in) {
+	return;
+    }
+    /*
+    **  If no explicit charset string, use the implied one. - kw
+    */
+    if (!charset || *charset == '\0') {
+	charset = p_in->MIMEname;
+    }
+    /*
+    **  Check whether we have a specified charset. - FM
     */
     if (!charset || *charset == '\0') {
 	return;
@@ -7915,7 +7899,9 @@ PUBLIC void HText_setKcode ARGS2(
     */
     if (!strcmp(charset, "shift_jis")) {
 	text->kcode = SJIS;
-    } else if (!strcmp(charset, "euc-jp") ||
+    } else if ((p_in && (p_in->enc == UCT_ENC_CJK)) ||
+	       !strcmp(charset, "euc-jp") ||
+	       !strncmp(charset, "x-euc-", 6) ||
 	       !strcmp(charset, "iso-2022-jp") ||
 	       !strcmp(charset, "iso-2022-jp-2") ||
 	       !strcmp(charset, "euc-kr") ||
@@ -7927,10 +7913,14 @@ PUBLIC void HText_setKcode ARGS2(
 	text->kcode = EUC;
     } else {
         /*
-	**  If we get to here, it's not CJK, so disable that. - FM
+	**  If we get to here, it's not CJK, so disable that if
+	**  it is enabled.  But only if we are quite sure. - FM & kw
 	*/
 	text->kcode = NOKANJI;
-	HTCJK = NOCJK;
+	if (HTCJK != NOCJK) {
+	    if (!p_in || p_in->enc != UCT_ENC_CJK)
+		HTCJK = NOCJK;
+	}
     }
 
     return;
diff --git a/src/GridText.h b/src/GridText.h
index a3fe5fa5..9247e14d 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -192,7 +192,10 @@ extern void HText_setNoCache PARAMS((HText *text));
 extern BOOL HText_hasNoCacheSet PARAMS((HText *text));
 
 extern BOOL HText_hasUTF8OutputSet PARAMS((HText *text));
-extern void HText_setKcode PARAMS((HText *text, CONST char *charset));
+extern void HText_setKcode PARAMS((
+	HText *		text,
+	CONST char *	charset,
+	LYUCcharset *	p_in));
 
 extern void HText_setBreakPoint PARAMS((HText *text));
 
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 719ab8df..a6295ee9 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -1102,7 +1102,7 @@ Compressed_tempname:
     /*
      *  Make command to process file. - FM
      */
-#if USE_ZLIB
+#ifdef USE_ZLIB
     if (compress_suffix[0] == 'g' && /* must be gzip */
 	!me->viewer_command) {
 	/*
diff --git a/src/HTForms.h b/src/HTForms.h
index 7e384cd5..b140f4d7 100644
--- a/src/HTForms.h
+++ b/src/HTForms.h
@@ -78,6 +78,7 @@ typedef struct _FormInfo {
 	int			disabled;  /* If YES, can't change values */
         int 			name_cs;
         int 			value_cs;
+        char *			accept_cs;
 } FormInfo;
 
 #define HYPERTEXT_ANCHOR 1
diff --git a/src/HTInit.c b/src/HTInit.c
index 532f9c5b..540c1c67 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -180,6 +180,11 @@ PUBLIC void HTFormatInit NOARGS
      HTLoadTypesConfigFile(buffer);
  }
 
+ /*
+  *  Put text/html and text/plain at beginning of list. - kw
+  */
+ HTReorderPresentation(WWW_PLAINTEXT, WWW_PRESENT);
+ HTReorderPresentation(WWW_HTML, WWW_PRESENT);
 }
 
 PUBLIC void HTPreparsedFormatInit NOARGS
@@ -232,7 +237,7 @@ PRIVATE int ExitWithError PARAMS((char *txt));
 PRIVATE int PassesTest PARAMS((struct MailcapEntry *mc));
 
 #define LINE_BUF_SIZE       2000
-#define TMPFILE_NAME_SIZE 127
+#define TMPFILE_NAME_SIZE 256
 
 PRIVATE char *GetCommand ARGS2(char *,s, char **,t)
 {
@@ -282,8 +287,8 @@ PRIVATE char *Cleanse ARGS1(char *,s)
         *tmp = TOLOWER ((unsigned char)*tmp);
     }
     /* strip trailing white space */
-    while (*--tmp && isspace((unsigned char) *tmp))
-        *tmp = 0;
+    while ((tmp > news) && *--tmp && isspace((unsigned char) *tmp))
+        *tmp = '\0';
     return(news);
 }
 
@@ -444,13 +449,17 @@ assign_presentation:
     return(1);
 }
 
-PRIVATE void BuildCommand ARGS3(char *,Buf, char *,controlstring, 
-							char *,TmpFileName)
+PRIVATE void BuildCommand ARGS5(
+    char **, 	pBuf,
+    size_t,	Bufsize,
+    char *,	controlstring, 
+    char *,	TmpFileName,
+    size_t,	TmpFileLen)
 {
     char *from, *to;
     int prefixed = 0; 
 
-    for (from = controlstring, to = Buf; *from != '\0'; from++) {
+    for (from = controlstring, to = *pBuf; *from != '\0'; from++) {
         if (prefixed) {
             prefixed = 0;
             switch(*from) {
@@ -465,7 +474,17 @@ PRIVATE void BuildCommand ARGS3(char *,Buf, char *,controlstring,
 				controlstring);
 		    }
 		case 's':
-                    if (TmpFileName) {
+                    if (TmpFileLen && TmpFileName) {
+			if ((to - *pBuf) + TmpFileLen + 1 > Bufsize) {
+			    *to = '\0';
+			    if (TRACE) {
+				fprintf(stderr,
+			"Too long mailcap \"test\" clause, ignoring: %s%s...\n",
+					*pBuf, TmpFileName);
+			    }
+			    **pBuf = '\0';
+			    return;
+			}
                         strcpy(to, TmpFileName);
                         to += strlen(TmpFileName);
                     }
@@ -483,6 +502,16 @@ PRIVATE void BuildCommand ARGS3(char *,Buf, char *,controlstring,
         } else {
             *to++ = *from;
         }
+        if (to >= *pBuf + Bufsize) {
+	    (*pBuf)[Bufsize - 1] = '\0';
+	    if (TRACE) {
+		fprintf(stderr,
+			"Too long mailcap \"test\" clause, ignoring: %s...\n",
+			*pBuf);
+	    }
+            **pBuf = '\0';
+	    return;
+	}
     }
     *to = 0;
 }
@@ -561,7 +590,9 @@ PRIVATE int PassesTest ARGS1(struct MailcapEntry *,mc)
     cmd = (char *)malloc(1024);
     if (!cmd)
         ExitWithError("Out of memory");
-    BuildCommand(cmd, mc->testcommand, TmpFileName);
+    BuildCommand(&cmd, 1024,
+		 mc->testcommand,
+		 TmpFileName, strlen(TmpFileName));
     if (TRACE)
         fprintf(stderr,"Executing test command: %s\n", cmd);
     result = system(cmd);
@@ -882,23 +913,30 @@ PUBLIC void HTFileInit NOARGS
 
 /* The following is lifted from NCSA httpd 1.0a1, by Rob McCool;
    NCSA httpd is in the public domain, as is this code. */
+/* modified Oct 97 - kw */
 
 #define MAX_STRING_LEN 256
 
 PRIVATE int HTGetLine ARGS3(char *,s, int,n, FILE *,f) 
 {
-    register int i = 0;
+    register int i = 0, r;
 
     if (!f)
         return(1);
 
     while (1) {
-	s[i] = (char)fgetc(f);
-
-	if (s[i] == CR)
-	    s[i] = fgetc(f);
+	r = fgetc(f);
+	s[i] = (char)r;
+
+	if (s[i] == CR) {
+	    r = fgetc(f);
+	    if (r == LF)
+		s[i] = r;
+	    else if (r != EOF)
+		ungetc(r, f);
+	}
 
-	if ((s[i] == EOF) || (s[i] == LF) || (i == (n-1))) {
+	if ((r == EOF) || (s[i] == LF) || (s[i] == CR) || (i == (n-1))) {
 	    s[i] = '\0';
 	    return (feof(f) ? 1 : 0);
 	}
diff --git a/src/HTML.c b/src/HTML.c
index f3040bb4..5da10c39 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -528,7 +528,7 @@ char prevailing_class[TEMPSTRINGSIZE];
 	LYUCFullyTranslateString(s, ATTR_CS_IN, current_char_set, YES, p, h, st_HTML)
 
 #define TRANSLATE_AND_UNESCAPE_ENTITIES4(s, cs_to, p, h) \
-	LYUCFullyTranslateString(s, ATTR_CS_IN, cs_to, YES, p, h, st_HTML)
+	LYUCFullyTranslateString(s, ATTR_CS_IN, cs_to, YES, p, h, st_HTML) /* not used */
 
 #define TRANSLATE_AND_UNESCAPE_ENTITIES5(s,cs_from,cs_to,p,h) \
 	LYUCFullyTranslateString(s, cs_from, cs_to, YES, p, h, st_HTML)
@@ -548,11 +548,51 @@ char prevailing_class[TEMPSTRINGSIZE];
 
 #else  /* !EXP_CHARTRANS */
 
+#ifdef OLDSTUFF
 #define ATTR_CS_IN 0
 
+#define TRANSLATE_AND_UNESCAPE_ENTITIES(s, p, h) \
+	if (current_char_set) LYExpandString(s); LYUnEscapeEntities(*(s), p, h)
+/*	if (current_char_set) LYExpandString(s); LYUnEscapeEntities(*(s), p, FALSE) */
+
+#define TRANSLATE_AND_UNESCAPE_ENTITIES5(s,cs_from,cs_to,p,h) \
+	LYUnEscapeEntities(*(s), p, h)
+/*	LYUnEscapeEntities(*(s), TRUE, h) */
+/*	LYUnEscapeEntities(*(s), TRUE, FALSE) */
+
+
+#define TRANSLATE_AND_UNESCAPE_ENTITIES6(s,cs_from,cs_to,spcls,p,h) \
+	if (me->UsePlainSpace && !me->HiddenValue) LYExpandString(me, s);\
+	LYUnEscapeEntities(*(s), me->UsePlainSpace, me->HiddenValue)
+/*	if (current_char_set && (p && !h)) LYExpandString(me, *(s));\
+	LYUnEscapeEntities(*(s), p, h) */
+
 #define TRANSLATE_AND_UNESCAPE_TO_STD(s) \
     			LYUnEscapeToLatinOne(s, TRUE) /* for now */
 #define UNESCAPE_FIELDNAME_TO_STD(s) ; /* no-op */
+#endif /* OLDSTUFF */
+
+#ifdef NOTUSED_FOTEMODS
+/* Roughly (and untested!), the equivalents if one would use the
+ * LYCharUtils.c from FOTEMODS 1997-10-06 instead: */
+#define TRANSLATE_AND_UNESCAPE_ENTITIES(s, p, h) \
+	LYExpandString(me, s); LYUnEscapeEntities(me, s)
+	LYUCFullyTranslateString(s, ATTR_CS_IN, current_char_set, YES, p, h, st_HTML)
+
+#define TRANSLATE_AND_UNESCAPE_ENTITIES5(s,cs_from,cs_to,p,h) \
+	LYUnEscapeEntities(me, s)
+
+#define TRANSLATE_AND_UNESCAPE_ENTITIES6(s,cs_from,cs_to,spcls,p,h) \
+	if (me->UsePlainSpace && !me->HiddenValue) LYExpandString(me, s);\
+	LYUnEscapeEntities(me, s)
+
+#define TRANSLATE_AND_UNESCAPE_TO_STD(s) \
+	LYUnEscapeToLatinOne(me, s, TRUE)
+
+#define UNESCAPE_FIELDNAME_TO_STD(s) ; /* no-op (?) */
+
+#endif /* NOTUSED_FOTEMODS */
+
 #endif  /* !EXP_CHARTRANS */
 
 #define CHECK_ID(code) LYCheckForID(me, present, value, (int)code)
@@ -653,7 +693,7 @@ PRIVATE void HTML_start_element ARGS6(
                         fprintf(stderr, " ca=%d\n", hashStyles[hcode].color);
         }
 
-    if (displayStyles[element_number].color > -1) /* actually set */
+    if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
     {
         if (TRACE)
                 fprintf(stderr, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name);
@@ -1085,7 +1125,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);
-#if USE_COLOR_STYLE
+#ifdef USE_COLOR_STYLE
 	    if (present && present[HTML_LINK_CLASS] &&
 	    value && *value[HTML_LINK_CLASS]!='\0')
 	    {
@@ -1823,6 +1863,7 @@ PRIVATE void HTML_start_element ARGS6(
 		 */
 	        target = ((1.0 * atoi(value[HTML_TAB_INDENT])) / enval) + 0.5;
 	    }
+	    FREE(temp);
 	    /*
 	     *  If we are being directed to a column too far to the left
 	     *  or right, just add a collapsible space, otherwise, add the
@@ -4936,10 +4977,13 @@ PRIVATE void HTML_start_element ARGS6(
 	    StrAllocCopy(me->textarea_name, "");
 	}
 
-	if (present && present[HTML_TEXTAREA_ACCEPT_CHARSET] &&
-	    value[HTML_TEXTAREA_ACCEPT_CHARSET]) {
-	    StrAllocCopy(me->textarea_accept_cs, value[HTML_TEXTAREA_ACCEPT_CHARSET]);
-	    TRANSLATE_AND_UNESCAPE_TO_STD(&me->textarea_accept_cs);
+	if (present && present[HTML_TEXTAREA_ACCEPT_CHARSET]) {
+	    if (value[HTML_TEXTAREA_ACCEPT_CHARSET]) {
+		StrAllocCopy(me->textarea_accept_cs, value[HTML_TEXTAREA_ACCEPT_CHARSET]);
+		TRANSLATE_AND_UNESCAPE_TO_STD(&me->textarea_accept_cs);
+	    } else {
+		StrAllocCopy(me->textarea_accept_cs, "UNKNOWN");
+	    }
 	} else {
 	    FREE(me->textarea_accept_cs);
 	}
@@ -7030,7 +7074,9 @@ End_Object:
         /* reset the prevailing class to the previous one */
         {
                 char *dot=strrchr(Style_className,'.');
-                strcpy (prevailing_class, dot ? (char*)(dot+1) : "");
+                LYstrncpy(prevailing_class,
+			  dot ? (char*)(dot+1) : "",
+			  (TEMPSTRINGSIZE - 1));
         }
 #endif
     }
@@ -7326,7 +7372,7 @@ PRIVATE void get_styles NOARGS
 */
 PUBLIC CONST HTStructuredClass HTMLPresentation = /* As opposed to print etc */
 {		
-	"text/html",
+	"Lynx_HTML_Handler",
 	HTML_free,
 	HTML_abort,
 	HTML_put_character, 	HTML_put_string,  HTML_write,
@@ -7500,6 +7546,12 @@ PUBLIC HTStructured* HTML_new ARGS3(
     me->comment_start = NULL;
     me->comment_end = NULL;
 
+#ifdef USE_COLOR_STYLE
+    Style_className[0] = '\0';
+    class_string[0] = '\0';
+    prevailing_class[0] = '\0';
+#endif
+
 #ifdef EXP_CHARTRANS
     LYGetChartransInfo(me);
     UCTransParams_clear(&me->T);
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index 41b5a138..17fdd3af 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -13,6 +13,7 @@
 #include "HTFont.h"
 #include "GridText.h"
 #include "LYCurses.h"
+#include "LYStrings.h"
 
 #include "LYexit.h"
 #include "LYLeaks.h"
@@ -2314,6 +2315,8 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i)
     }
 #endif /* USE_SLANG */
 
+    ena_csi((LYlowest_eightbit[current_char_set] > 155));
+
     return;
 }
 
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index b25b30ac..25ca634d 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -4,6 +4,7 @@
 */
 #include "HTUtils.h"
 #include "tcp.h"
+#include "SGML.h"
 
 #define Lynx_HTML_Handler
 #include "HTChunk.h"
@@ -351,8 +352,9 @@ PUBLIC void LYFillLocalFileURL ARGS2(
      * directory listing for the current default. - FM
      */
     if (!strcmp(*href, "file://localhost")) {
+	char *temp2;
 #ifdef VMS
-	StrAllocCat(*href, HTVMS_wwwName(getenv("PATH")));
+	temp2 = HTVMS_wwwName(getenv("PATH"));
 #else
 	char curdir[DIRNAMESIZE];
 #if HAVE_GETCWD
@@ -361,11 +363,24 @@ PUBLIC void LYFillLocalFileURL ARGS2(
 	getwd (curdir);
 #endif /* NO_GETCWD */
 #ifdef DOSPATH
-	StrAllocCat(*href, HTDOS_wwwName(curdir));
+	temp2 = HTDOS_wwwName(curdir);
 #else
-	StrAllocCat(*href, curdir);
+	temp2 = curdir;
 #endif /* DOSPATH */
 #endif /* VMS */
+	if (temp2[0] != '/')
+	    StrAllocCat(*href, "/");
+	/*
+	 *  Check for pathological cases - current dir has chars which
+	 *  MUST BE URL-escaped - kw
+	 */
+	if (strchr(temp2, '%') != NULL || strchr(temp2, '#') != NULL) {
+	    FREE(temp);
+	    temp = HTEscape(temp2, URL_PATH);
+	    StrAllocCat(*href, temp);
+	} else {
+	    StrAllocCat(*href, temp2);
+	}
     }
 
 #ifdef VMS
@@ -823,85 +838,6 @@ PUBLIC void LYGetChartransInfo ARGS1(
 
 #endif /* EXP_CHARTRANS */
 
-/*
-**  This function reallocates an allocated string with
-**  8-bit printable Latin characters (>= 160) converted
-**  to their HTML entity names and then translated for
-**  the current character set. - FM
-*/
-PUBLIC void LYExpandString_old ARGS1(
-	char **, str)
-{
-    char *p = *str;
-    char *q = *str;
-    CONST char *name;
-    int i, j, value, high, low, diff = 0;
-
-    /*
-    **  Don't do anything if we have no string
-    **  or are in CJK mode. - FM
-    */
-    if (!p || *p == '\0' ||
-        HTCJK != NOCJK)
-        return;
-
-    /*
-    **  Start a clean copy of the string, without
-    **  invalidating our pointer to the original. - FM
-    */
-    *str = NULL;
-    StrAllocCopy(*str, "");
-
-    /*
-    **  Check each character in the original string,
-    **  and add the characters or substitutions to
-    **  our clean copy. - FM
-    */
-    for (i = 0; p[i]; i++) {
-	/*
-	**  Substitute Lynx special character for
-	**  160 (nbsp) if HTPassHighCtrlRaw is not
-	**  set. - FM
-	*/
-        if (((unsigned char)p[i]) == 160 &&
-	    !HTPassHighCtrlRaw) {
-	    p[i] = HT_NON_BREAK_SPACE;
-	/*
-	**  Substitute Lynx special character for
-	**  173 (shy) if HTPassHighCtrlRaw is not
-	**  set. - FM
-	*/
-        } else if (((unsigned char)p[i]) == 173 &&
-	    !HTPassHighCtrlRaw) {
-	    p[i] = LY_SOFT_HYPHEN;
-	/*
-	**  Substitute other 8-bit characters based on
-	**  the LYCharsets.c tables if HTPassEightBitRaw
-	**  is not set. - FM
-	*/
-	} else if (((unsigned char)p[i]) > 160 &&
-		   !HTPassEightBitRaw) {
-	    value = (int)(((unsigned char)p[i]) - 160);
-	    p[i] = '\0';
-	    StrAllocCat(*str, q);
-	    q = &p[i+1];
-	    name = HTMLGetEntityName(value);
-	    for (low = 0, high = HTML_dtd.number_of_entities;
-		 high > low;
-		 diff < 0 ? (low = j+1) : (high = j)) {
-		/* Binary search */
-		j = (low + (high-low)/2);
-		diff = strcmp(HTML_dtd.entity_names[j], name);
-		if (diff == 0) {
-		    StrAllocCat(*str, p_entity_values[j]);
-		    break;
-		}
-	    }
-	}
-    }
-    StrAllocCat(*str, q);
-    free_and_clear(&p);
-}
 
 /*
 ** Get UCS character code for one character from UTF-8 encoded string. 
@@ -1017,35 +953,83 @@ PRIVATE char * UCPutUtf8ToBuffer ARGS3(char *, q, UCode_t, code, BOOL, terminate
     }
 }
 
+	/* as in HTParse.c, saves some calls - kw */
 PRIVATE char *hex = "0123456789ABCDEF";
 
 /*
-**  This function converts HTML named entities within a string
-**  to their translations in the active LYCharSets.c array.
-**  It also converts numeric entities to their HTML entity names
-**  and then similarly translates those.  The string is converted
-**  in place, on the assumption that the conversion strings will
-**  not be longer than the entity strings, such that the overall
-**  string will never grow.  This assumption is true for the
-**  current LYCharSets arrays.  Make sure it stays true!  If
-**  plain_space is TRUE, nbsp (160) will be treated as an ASCII
+**  This function translates a string from charset
+**  `cs_from' to charset `cs_to', reallocating it if necessary.
+**  If `do_ent' is YES, it also converts HTML named entities
+**  and numeric character references (NCRs) to their `cs_to'
+**  replacements.
+**  If plain_space is TRUE, nbsp (160) will be treated as an ASCII
 **  space (32).  If hidden is TRUE, entities will be translated
-**  but escape sequences will be passed unaltered. - FM
+**  (if `do_ent' is YES) but escape sequences will be passed unaltered.
+**  If `hidden' is FALSE, some characters are converted to Lynx special
+**  codes (160, 173, .. @@ need list @@) (or ASCII space if `plain_space'
+**  applies).  @@ is `use_lynx_specials' needed, does it have any effect? @@
+**  If `use_lynx_specials' is YES, translate byte values 160 and 173
+**  meaning U+00A0 and U+00AD given as or converted from raw char input
+**  are converted to HT_NON_BREAK_SPACE and LY_SOFT_HYPHEN, respectively
+**  (unless input and output charset are both iso-8859-1, for compatibility
+**  with previous usage in HTML.c) even if `hidden' or `plain_space' is set.
+**
+**  If `Back' is YES, the reverse is done instead i.e. Lynx special codes
+**  in the input are translated back to character values.
+**
+**  If `Back' is YES, an attempt is made to use UCReverseTransChar() for
+**  back translation which may be more efficient. (?)
+**
+**  Named entities may be converted to their translations in the
+**  active LYCharSets.c array for `cs_out' or looked up as a Unicode
+**  value which is then passed to the chartrans functions (see UCdomap.c).
+**  @@ order? @@
+**  NCRs with values in the ISO-8859-1 range 160-255 may be converted
+**  to their HTML entity names and then translated according to the
+**  LYCharSets.c array for `cs_out', in general NCRs are translated
+**  by UCdomap.c chartrans functions if necessary.
+**
+**  If `stype' is st_URL, non-ASCII characters are URL-encoded instead.
+**  The sequence of bytes being URL-encoded is the raw input character if
+**  we couldn't transtate it from `cs_in' (CJK etc.); otherwise it is the
+**  UTF-8 representation if either `cs_to' requires this or if the
+**  character's Unicode value is > 255, otherwise it should be the iso-8859-1
+**  representation.
+**  No general URL-encoding occurs for displayable ASCII characters and
+**  spaces and some C0 controls valid in HTML (LF, TAB), it is expected
+**  that other functions will take care of that as appropriate.
+**
+**  Escape characters (0x1B, '\033') are
+**  - URL-encoded       if `stype'  is st_URL,   otherwise
+**  - dropped           if `stype'  is st_other, otherwise (i.e. st_HTML)
+**  - passed            if `hidden' is TRUE or HTCJK is set, otherwise
+**  - dropped.
 */
-PRIVATE char ** LYUnEscapeEntities ARGS5(
+/*
+**  Returns pointer to the char** passed in
+**               if string translated or translation unnecessary, 
+**          NULL otherwise
+**               (in which case something probably went wrong.)
+*/
+
+PRIVATE char ** LYUCFullyTranslateString_1 ARGS9(
 	char **,	str,
+	int,		cs_from,
 	int,		cs_to,
+	BOOLEAN,	do_ent,
+	BOOL,		use_lynx_specials,
 	BOOLEAN,	plain_space,
 	BOOLEAN, 	hidden,
+	BOOL,		Back,
 	CharUtil_st,	stype)
 {
     char * p;
-    char *q, *Str;
+    char *q, *qs;
+    HTChunk *chunk = NULL;
     char * cp;
     char cpe;
     char *esc = NULL;
-    char buf[2];
-    char replace_buf[61];
+    char replace_buf[64];
     int uck;
     int lowest_8;
     UCode_t code;
@@ -1056,6 +1040,10 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
     CONST char ** entities = HTML_dtd.entity_names;
     CONST UC_entity_info * extra_entities = HTML_dtd.extra_entity_info;
     CONST char * name;
+    BOOLEAN no_bytetrans;
+    UCTransParams T;
+    BOOL from_is_utf8;
+    char * puni;
     enum _state
         { S_text, S_esc, S_dollar, S_paren, S_nonascii_text, S_dollar_paren,
 	S_trans_byte, S_check_ent, S_ncr, S_check_uni, S_check_name, S_named,
@@ -1072,40 +1060,92 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
     if (!str || *str == NULL || **str == '\0')
         return str;
     /*
+    **  Don't do byte translation
+    **  if original AND target character sets
+    **  are both iso-8859-1,
+    **  or if we are in CJK mode.
+    */
+    no_bytetrans = ((cs_to <= 0 && cs_from == cs_to) ||
+		    HTCJK != NOCJK);
+
+    /* No need to translate or examine the string any further */
+    if (!no_bytetrans)
+	no_bytetrans = (!use_lynx_specials && !Back &&
+			UCNeedNotTranslate(cs_from, cs_to));
+
+    /*
     **  Save malloc/calloc overhead in simple case - kw
     */
-    if (hidden && (stype != st_URL) && (strchr(*str, '&') == NULL))
+    if (do_ent && hidden && (stype != st_URL) && (strchr(*str, '&') == NULL))
+	do_ent = FALSE;
+
+    /* Can't do, caller should figure out what to do... */
+    if (!UCCanTranslateFromTo(cs_from, cs_to)) {
+	if (cs_to < 0)
+	    return NULL;
+	if (!do_ent && no_bytetrans)
+	    return NULL;
+	no_bytetrans = TRUE;
+    } else if (cs_to < 0) {
+	do_ent = FALSE;
+    }
+
+    if (!do_ent && no_bytetrans)
 	return str;
     p = *str;
 
-    if (cs_to < 0)
-	return NULL;
-    output_utf8 = (LYCharSet_UC[cs_to].enc == UCT_ENC_UTF8 ||
-		   HText_hasUTF8OutputSet(HTMainText));
-#if 0
-    cs_to = current_char_set;	/* for now */
-    lowest_8 = LYlowest_eightbit[HTAnchor_getUCLYhndl(
-					 me->node_anchor,
-					 UCT_STAGE_STRUCTURED)];
-    repl_translated_C0 = me->T.repl_translated_C0;
-#endif
+    if (!no_bytetrans) {
+	UCTransParams_clear(&T);
+	UCSetTransParams(&T, cs_from, &LYCharSet_UC[cs_from],
+			 cs_to, &LYCharSet_UC[cs_to]);
+	from_is_utf8 = (LYCharSet_UC[cs_from].enc == UCT_ENC_UTF8);
+	output_utf8 = T.output_utf8;
+	repl_translated_C0 = T.repl_translated_C0;
+	puni = p;
+    } else if (do_ent) {
+	output_utf8 = (LYCharSet_UC[cs_to].enc == UCT_ENC_UTF8 ||
+		       HText_hasUTF8OutputSet(HTMainText));
+	repl_translated_C0 = (LYCharSet_UC[cs_to].enc == UCT_ENC_8BIT_C0);
+    }
+
     lowest_8 = LYlowest_eightbit[cs_to];
-    repl_translated_C0 = (LYCharSet_UC[cs_to].enc == UCT_ENC_8BIT_C0);
 
     /*
     **  Create a buffer string seven times the length of the original,
     **  so we have plenty of room for expansions. - FM
     */
+#ifdef OLDSTUFF
     len = (strlen(p) * 7) + 1;
     if (len < 16)
 	len = 16;
     if ((Str = (char *)calloc(1, len)) == NULL) {
 	fprintf(stderr,
-		"LYUnEscapeEntities: calloc(1, %lu) failed for '%s'\r\n",
+		"LYUCFullyTranslateString_1: calloc(1, %lu) failed for '%s'\r\n",
 		(unsigned long)len, *str);
-	outofmem(__FILE__, "LYUnEscapeEntities");
+	outofmem(__FILE__, "LYUCFullyTranslateString_1");
     }
     q = Str;
+#else
+    len = strlen(p) + 16;
+    q = p;
+#endif /* OLDSTUFF */
+
+    qs = q;
+
+/*  Create the HTChunk only if we need it */
+#define CHUNK (chunk ? chunk : (chunk = HTChunkCreate2(128, len+1)))
+
+#define REPLACE_STRING(s) \
+		if (q != qs) HTChunkPutb(CHUNK, qs, q-qs); \
+		HTChunkPuts(CHUNK, s); \
+		qs = q = *str
+
+#define REPLACE_CHAR(c) if (q > p) { \
+		HTChunkPutb(CHUNK, qs, q-qs); \
+		qs = q = *str; \
+		*q++ = c; \
+	    } else \
+		*q++ = c
 
     /*
     *  Loop through string, making conversions as needed.
@@ -1123,7 +1163,7 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		if ((HTCJK != NOCJK && !hidden) || stype != st_HTML) {
 		    state = S_esc;
 		    if (stype == st_URL) {
-			*q++ = '%'; *q++ = '1'; *q++ = 'B';
+			REPLACE_STRING("%1B");
 			p++;
 			continue;
 		    } else if (stype != st_HTML) {
@@ -1140,10 +1180,10 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		    */
 		    state = S_next_char;
 		} else {
-		    state = S_check_ent;
+		    state = S_trans_byte;
 		}
 	    } else {
-		state = S_check_ent;
+		state = (do_ent ? S_check_ent : S_trans_byte);
 	    }
 	    break;
 
@@ -1203,7 +1243,7 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		if ((HTCJK != NOCJK && !hidden) || stype != st_HTML) {
 		    state = S_esc;
 		    if (stype == st_URL) {
-			*q++ = '%'; *q++ = '1'; *q++ = 'B';
+			REPLACE_STRING("%1B");
 			p++;
 			continue;
 		    } else if (stype != st_HTML) {
@@ -1216,8 +1256,107 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 	    continue;
 
 	case S_trans_byte:
-	    /*  character translation could go here  */
-	    state = S_got_outchar;
+	    /*  character translation goes here  */
+	    /*
+    **  Don't do anything if we have no string,
+    **  or if original AND target character sets
+    **  are both iso-8859-1,
+    **  or if we are in CJK mode.
+    */
+	    if (*p == '\0' || no_bytetrans) {
+		state = S_got_outchar;
+		break;
+	    }
+
+	    if (Back) {
+		int rev_c;
+		if ((*p) == HT_NON_BREAK_SPACE ||
+		    (*p) == HT_EM_SPACE) {
+		    if (plain_space) {
+			code = *p = ' ';
+			state = S_got_outchar;
+			break;
+		    } else {
+			*p = 160;
+			code = 160;
+			if (LYCharSet_UC[cs_to].enc == UCT_ENC_8859 ||
+			    (LYCharSet_UC[cs_to].like8859 & UCT_R_8859SPECL)) {
+			    state = S_got_outchar;
+			    break;
+			}
+		    }
+		} else if ((*p) == LY_SOFT_HYPHEN) {
+		    *p = 173;
+		    code = 173;
+		    if (LYCharSet_UC[cs_to].enc == UCT_ENC_8859 ||
+			(LYCharSet_UC[cs_to].like8859 & UCT_R_8859SPECL)) {
+			state = S_got_outchar;
+			break;
+		    }
+		} else if (code < 127 || T.transp) {
+		    state = S_got_outchar;
+		    break;
+		}
+		rev_c = UCReverseTransChar(*p, cs_to, cs_from);
+		if (rev_c > 127) {
+		    *p = rev_c;
+		    code = rev_c;
+		    state = S_got_outchar;
+		    break;
+		}
+	    } else if (code < 127) {
+		state = S_got_outchar;
+		break;
+	    }
+	
+	    if (from_is_utf8) {
+		if (((*p)&0xc0)==0xc0) {
+		    puni = p;
+		    code = UCGetUniFromUtf8String(&puni);
+		    if (code <= 0) {
+			code = (unsigned char)(*p);
+		    } else {
+			what = P_utf8;
+		    }
+		}
+	    } else if (use_lynx_specials && !Back &&
+		       (code == 160 || code == 173) &&
+		       (LYCharSet_UC[cs_from].enc == UCT_ENC_8859 ||
+			(LYCharSet_UC[cs_from].like8859 & UCT_R_8859SPECL))) {
+		if (code == 160)
+		    code = *p = HT_NON_BREAK_SPACE;
+		else if (code == 173)
+		    code = *p = LY_SOFT_HYPHEN;
+		state = S_got_outchar;
+		break;
+	    } else if (T.trans_to_uni) {
+		code = UCTransToUni(*p, cs_from);
+		if (code <= 0) {
+		    /* What else can we do? */
+		    code = (unsigned char)(*p);
+		}
+	    } else if (T.strip_raw_char_in &&
+		       (unsigned char)(*p) >= 0xc0 &&
+		       (unsigned char)(*p) < 255) {
+		code = ((*p & 0x7f));
+		state = S_got_outchar;
+		break;
+	    } else if (!T.trans_from_uni) {
+		state = S_got_outchar;
+		break;
+	    }
+	    /*
+		    **  Substitute Lynx special character for
+		    **  160 (nbsp) if use_lynx_specials is set.
+		    */
+	    if (use_lynx_specials && !Back &&
+		(code == 160 || code == 173)) {
+		code = ((code==160 ? HT_NON_BREAK_SPACE : LY_SOFT_HYPHEN));
+		state = S_got_outchar;
+		break;
+	    }
+
+	    state = S_check_uni;
 	    break;
 
 	case S_check_ent:
@@ -1281,11 +1420,13 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		      			sscanf(cp, "%ld", &lcode)) != 1) ||
 		    lcode > 0x7fffffffL || lcode < 0) {
 		    state = S_recover;
+		    break;
 		} else {
 		    code = lcode;
 		    state = S_check_uni;
 		}
 		break;
+
 	case S_check_uni:
 	        /*
 		** Show the numeric entity if the value:
@@ -1503,11 +1644,28 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		    if (cpe != '\0')
 			*(p-1) = cpe;
 		    p = cp;
+		    state = S_done;
 	    } else if (what == P_named) {
 		*cp = cpe;
 		*q++ = '&';
+		state = S_done;
+	    } else {
+		if (T.strip_raw_char_in &&
+		    (unsigned char)(*p) >= 0xc0 &&
+		    (unsigned char)(*p) < 255) {
+		    code = (((*p) & 0x7f));
+		    state = S_got_outchar;
+		} else if (!T.output_utf8 && stype == st_HTML && !hidden &&
+		    !(HTPassEightBitRaw &&
+		      (unsigned char)(*p) >= lowest_8)) {
+		    sprintf(replace_buf, "U%.2lX", code);
+		    state = S_got_outstring;
+		} else {
+		    puni = p;
+		    code = (unsigned char)(*p);
+		    state = S_got_outchar;
+		}
 	    }
-	    state = S_done;
 	    break;
 
 	case S_named:
@@ -1661,16 +1819,9 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 	    } else if (what == P_named) {
 		*cp = cpe;
 		p = (*cp != ';') ? (cp - 1) : cp;
+	    } else if (what == P_utf8) {
+		p = puni;
 	    }
-#if 0
-	    if (what == P_decimal || what == P_hex) {
-		if (cpe != ';' && cpe != '\0')
-		    *(--p) = cpe;
-	    } else if (what == P_named) {
-		*cp = cpe;
-		p = (*cp != ';') ? cp : (cp + 1);
-	    }
-#endif
 	    if (replace_buf[0] == '\0') {
 		state = S_next_char;
 		break;
@@ -1682,14 +1833,12 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 		    state = S_put_urlstring;
 		}
 	    }
-	    for (i = 0; replace_buf[i]; i++)
-		*q++ = replace_buf[i];
+	    REPLACE_STRING(replace_buf);
 	    state = S_next_char;
 	    break;
 	case S_put_urlstring:
 	    esc = HTEscape(replace_buf, URL_XALPHAS);
-	    for (i = 0; esc[i]; i++)
-		*q++ = esc[i];
+	    REPLACE_STRING(esc);
 	    FREE(esc);
 	    state = S_next_char;
 	    break;
@@ -1701,22 +1850,32 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 	    } else if (what == P_named) {
 		*cp = cpe;
 		p = (*cp != ';') ? (cp - 1) : cp;
+	    } else if (what == P_utf8) {
+		p = puni;
 	    }
-	    if (stype == st_URL) {
+	    if (stype == st_URL &&
 	    /*  Not a full HTEscape, only for 8bit and ctrl chars */
-		if (code >= 127 ||
-		    (code < 32 && (code != 9 && code != 10))) {
+		(code >= 127 ||
+		 (code < 32 && (code != 9 && code != 10)))) {
 		    state = S_put_urlchar;
 		    break;
-		}
+	    } else if (!hidden && code == 10 && *p == 10
+		       && q != qs && *(q-1) == 13) {
+		/*
+		**  If this is not a hidden string, and the current char is
+		**  the LF ('\n') of a CRLF pair, drop the CR ('\r'). - KW
+		*/
+	        *(q-1) = *p++;
+		state = S_done;
+		break;
 	    }
 	    *q++ = (char)code;
 	    state = S_next_char;
 	    break;
 	case S_put_urlchar:
 	    *q++ = '%';
-	    *q++ = hex[(code >> 4) & 15];
-	    *q++ = hex[(code & 15)];
+	    REPLACE_CHAR(hex[(code >> 4) & 15]);
+	    REPLACE_CHAR(hex[(code & 15)]);
 	    			/* fall through */
 	case S_next_char:
 	    p++;		/* fall through */
@@ -2644,344 +2803,32 @@ PRIVATE char ** LYUnEscapeEntities ARGS5(
 	}
     }
 #endif /* 0 */
-    
-    *q = '\0';
-    if (stype == st_URL) {
-	LYTrimHead(Str);
-	LYTrimTail(Str);
-    }
-    StrAllocCopy(*str, Str);
-    FREE(Str);
-    return str;
-}
-
-/*
-**  This function converts any named or numeric character
-**  references in allocated strings to their ISO-8858-1
-**  values or to our substitutes if they are not part of
-**  that charset.  If the isURL flag is TRUE, it also
-**  hex escapes ESC and any characters greater than 159,
-**  and trims any leading or trailing blanks.  Otherwise,
-**  it strips out ESC, as would be done when the
-**  "ISO Latin 1" Character Set is selected. - FM
-*/
-PRIVATE void LYUnEscapeToLatinOne_unused ARGS2(
-	char **,	str,
-	CharUtil_st,	stype)
-{
-    char *p = *str;
-    char *q = NULL;
-    char *url = NULL;
-    char *esc = NULL;
-    char buf[2];
-    int e;
-    char *cp;
-    char cpe;
-    int len, value;
-    int high, low, diff = 0, i;
-    enum _state
-        { S_text, S_esc, S_dollar, S_paren,
-	  S_nonascii_text, S_dollar_paren } state = S_text;
 
-    /*
-    **  Make sure we have a non-empty string. - FM
-    */
-    if (!p || *p == '\0')
-        return;
-    buf[0] = buf[1] = '\0';
-
-    /*
-    **  If the isURL flag is TRUE, set up for hex escaping. - FM
-    */
-    if (stype == st_URL) {
-        if ((url = (char *)calloc(1, ((strlen(p) * 3) + 1))) == NULL) {
-	    outofmem(__FILE__, "LYUnEscapeToLatinOne");
+    *q = '\0';
+    if (chunk) {
+	HTChunkPutb(CHUNK, qs, q-qs + 1); /* also terminates */
+	if (stype == st_URL) {
+	    LYTrimHead(chunk->data);
+	    LYTrimTail(chunk->data);
 	}
-	q = url;
+	StrAllocCopy(*str, chunk->data);
+	HTChunkFree(chunk);
     } else {
-        q = p;
-    }
-
-    /*
-    **  Loop through string, making conversions as needed. - FM
-    */
-    while (*p) {
-	/*
-	**  Handle any CJK escape sequences. - FM
-	*/
-	switch(state) {
-	    case S_text:
-		if (*p == '\033') {
-		    state = S_esc;
-		    if (stype == st_URL) {
-		        buf[0] = *p;
-		        esc = HTEscape(buf, URL_XALPHAS);
-			for (e = 0; esc[e]; e++)
-		            *q++ = esc[e];
-			FREE(esc);
-		    }
-		    p++;
-		    continue;
-		}
-		break;
-
-	    case S_esc:
-		if (*p == '$') {
-		    state = S_dollar;
-		    *q++ = *p++;
-		    continue;
-		} else if (*p == '(') {
-		    state = S_paren;
-		   *q++ = *p++;
-		   continue;
-		} else {
-		    state = S_text;
-		}
-
-	    case S_dollar:
-		if (*p == '@' || *p == 'B' || *p == 'A') {
-		    state = S_nonascii_text;
-		    *q++ = *p++;
-		    continue;
-		} else if (*p == '(') {
-		    state = S_dollar_paren;
-		    *q++ = *p++;
-		    continue;
-		} else {
-		    state = S_text;
-		}
-		break;
-
-	   case S_dollar_paren:
-		if (*p == 'C') {
-		    state = S_nonascii_text;
-		    *q++ = *p++;
-		    continue;
-		} else {
-		    state = S_text;
-		}
-		break;
-
-	    case S_paren:
-		if (*p == 'B' || *p == 'J' || *p == 'T')  {
-		    state = S_text;
-		    *q++ = *p++;
-		    continue;
-		} else if (*p == 'I') {
-		    state = S_nonascii_text;
-		    *q++ = *p++;
-		    continue;
-		} else {
-		    state = S_text;
-		}
-		break;
-
-	    case S_nonascii_text:
-		if (*p == '\033') {
-		    state = S_esc;
-		    if (stype == st_URL) {
-		        buf[0] = *p;
-		        esc = HTEscape(buf, URL_XALPHAS);
-			for (e = 0; esc[e]; e++)
-		            *q++ = esc[e];
-			FREE(esc);
-		    }
-		    p++;
-		} else {
-		    *q++ = *p++;
-		}
-		continue;
-		break;
-
-	    default:
-	        p++;
-		continue;
+	if (stype == st_URL) {
+	    LYTrimHead(qs);
+	    LYTrimTail(qs);
 	}
-
-	/*
-	**  Check for a numeric or named entity. - FM
-	*/
-        if (*p == '&') {
-	    p++;
-	    len = strlen(p);
-	    /*
-	    **  Check for a numeric entity. - FM
-	    */
-	    if (*p == '#' && len > 2 &&
-	        (unsigned char)*(p+1) < 127 &&
-		isdigit((unsigned char)*(p+1))) {
-		cp = ++p;
-		while (*p && (unsigned char)*p < 127 &&
-		       isdigit((unsigned char)*p))
-		    p++;
-		cpe = *p;
-		if (*p)
-		    *p++ = '\0';
-	        /*
-		** Show the numeric entity if the value:
-		**  (1) Is greater than 255 (until we support Unicode).
-		**  (2) Is less than 32 and not valid.
-		**  (3) Is 127.
-		**  (4) Is 128 - 159.
-		*/
-		if ((sscanf(cp, "%d", &value) != 1) ||
-		    (value > 255) ||
-		    (value < 32 &&
-		     value != 9 && value != 10 && value != 13) ||
-		    (value == 127) ||
-		    (value > 127 && value < 160)) {
-		    /*
-		    **  Illegal or not yet handled value.
-		    **  Recover the "&#" and continue
-		    **  from there. - FM
-		    */
-		    *q++ = '&';
-		    *q++ = '#';
-		    if (cpe != '\0')
-		       *(p-1) = cpe;
-		    p = cp;
-		    continue;
-		}
-		/*
-		**  Convert the value as an unsigned char,
-		**  hex escaped if isURL is set and it's
-		**  8-bit, and then recycle the terminator
-		**  if it is not a semicolon. - FM
-		*/
-		if (value > 159 && stype == st_URL) {
-		    buf[0] = value;
-		    esc = HTEscape(buf, URL_XALPHAS);
-		    for (e = 0; esc[e]; e++)
-		        *q++ = esc[e];
-		    FREE(esc);
-		} else {
-	            *q++ = (unsigned char)value;
-		}
-		if (cpe != ';' && cpe != '\0') {
-		    p--;
-		    *p = cpe;
-		}
-		continue;
-	    /*
-	    **  Check for a named entity. - FM
-	    */
-	    } else if ((unsigned char)*p < 127 &&
-	    	       isalnum((unsigned char)*p)) {
-		cp = p;
-		while (*cp && (unsigned char)*cp < 127 &&
-		       isalnum((unsigned char)*cp))
-		    cp++;
-		cpe = *cp;
-		*cp = '\0';
-		for (low = 0, high = HTML_dtd.number_of_entities;
-		     high > low ;
-		     diff < 0 ? (low = i+1) : (high = i)) {
-		    /*
-		    **  Binary search.
-		    */
-		    i = (low + (high-low)/2);
-		    diff = strcmp(HTML_dtd.entity_names[i], p);
-		    if (diff == 0) {
-		        /*
-			**  Found the entity. Convert it to
-			**  an ISO-8859-1 character, or our
-			**  substitute for any non-ISO-8859-1
-			**  character, hex escaped if isURL
-			**  is set and it's 8-bit. - FM
-			*/
-			buf[0] = HTMLGetLatinOneValue(i);
-                        if (buf[0] == '\0') {
-                            /*
-                            **  The entity does not have an 8859-1
-			    **  representation of exactly one char length.
-			    **  Try to deal with it anyway - either HTEscape
-			    **  the whole mess, or pass through raw.  So
-			    **  make sure the ISO_Latin1 table, which is the
-			    **  first table in LYCharSets, has reasonable
-			    **  substitution strings! (if it really must
-			    **  have any longer than one char) - KW
-                            */
-			    if (!LYCharSets[0][i][0]) {
-				/*
-				**  Totally empty, skip. - KW
-				*/
-			        ; /* do nothing */
-			    } else if (stype == st_URL) {
-				/*
-				**  All will be HTEscape'd. - KW
-				*/
-				esc = HTEscape(LYCharSets[0][i], URL_XALPHAS);
-				for (e = 0; esc[e]; e++)
-				    *q++ = esc[e];
-				FREE(esc);
-			    } else {
-				/*
-				**  Nothing will be HTEscape'd. - KW 
-				*/
-				for (e = 0; LYCharSets[0][i][e]; e++) {
-				    *q++ =
-					(unsigned char)(LYCharSets[0][i][e]);
-				}
-			    }
-		        } else if ((unsigned char)buf[0] > 159 &&
-				   stype == st_URL) {
-			    esc = HTEscape(buf, URL_XALPHAS);
-			    for (e = 0; esc[e]; e++)
-				*q++ = esc[e];
-			    FREE(esc);
-			} else {
-			    *q++ = buf[0];
-			}
-			/*
-			**  Recycle the terminator if it isn't
-			**  the standard ';' for HTML. - FM
-			*/
-			*cp = cpe;
-			if (*cp != ';')
-			    p = cp;
-			else
-			    p = (cp+1);
-			break;
-		    }
-		}
-		*cp = cpe;
-		if (diff != 0) {
-		    /*
-		    **  Entity not found.  Add the '&' and
-		    **  continue processing from there. - FM
-		    */
-		    *q++ = '&';
-		}
-		continue;
-	    /*
-	    **  If we get to here, it's a raw ampersand. - FM
-	    */
-	    } else {
-		*q++ = '&';
-		continue;
-	    }
-	/*
-	**  Not an entity.  Use the character. - FM
-	*/
-	} else {
-	  *q++ = *p++;
-	}
-    }
-    
-    /*
-    **  Clean up and return. - FM
-    */
-    *q = '\0';
-    if (stype == st_URL) {
-        LYTrimHead(url);
-	LYTrimTail(url);
-        StrAllocCopy(*str, url);
-	FREE(url);
     }
+    return str;
 }
 
+#undef REPLACE_CHAR
+#undef REPLACE_STRING
+
+#ifdef OLDSTUFF
+
 /*
-**  This is a generalized version of LYExpandString.
+**  This is a generalized version of what was previously LYExpandString.
 **
 **  This function translates a string from charset
 **  cs_from to charset cs_to, reallocating it if necessary.
@@ -3208,6 +3055,8 @@ PRIVATE BOOL LYUCTranslateString ARGS7(
     return YES;
 }
 
+#endif /* OLDSTUFF */
+
 PUBLIC BOOL LYUCFullyTranslateString ARGS7(
 	char **, str,
 	int,	cs_from,
@@ -3219,12 +3068,16 @@ PUBLIC BOOL LYUCFullyTranslateString ARGS7(
 {
     BOOL ret = YES;
     /* May reallocate *str even if cs_to == 0 */
+#ifdef OLDSTUFF
     if (!LYUCTranslateString(str, cs_from, cs_to, use_lynx_specials, FALSE, NO, stype)) {
 	LYExpandString_old(str);
 	ret = NO;
     }
+#endif
 
-    if (!LYUnEscapeEntities(str, cs_to, plain_space, hidden, stype)) {
+    if (!LYUCFullyTranslateString_1(str, cs_from, cs_to, TRUE,
+				    use_lynx_specials, plain_space, hidden,
+				    NO, stype)) {
 	ret = NO;
     }
     return ret;
@@ -3236,29 +3089,17 @@ PUBLIC BOOL LYUCTranslateBackFormData ARGS4(
 	int,	cs_to,
 	BOOLEAN,	plain_space)
 {
-    /* May reallocate *str even if cs_to == 0 */
+    char ** ret;
+    /* May reallocate *str */
+#ifdef OLDSTUFF
     return (LYUCTranslateString(str, cs_from, cs_to, NO, plain_space, YES, st_HTML));
-
-}
-
-#ifdef NOTUSED
-PUBLIC BOOL LYUCFullyTranslateString ARGS6(
-	char **, str,
-	int,	cs_from,
-	int,	cs_to,
-	BOOL,	use_lynx_specials,
-	BOOLEAN,	plain_space,
-	BOOLEAN,	hidden)
-{
-    if (cs_to) {
-	if (!LYUCTranslateString(str, cs_from, cs_to, use_lynx_specials))
-	    LYExpandString_old(str);
-    }
-    /* Note that it is guaranteed that *str is not reallocated
-       if cs_to == 0 */
-    LYUnEscapeEntities(*str, plain_space, hidden);
+#else
+    ret = (LYUCFullyTranslateString_1(str, cs_from, cs_to, FALSE,
+				       NO, plain_space, YES,
+				       YES, st_HTML));
+    return (ret != NULL);
+#endif
 }
-#endif /* NOTUSED */
 
 /*
 **  This function processes META tags in HTML streams. - FM
@@ -3478,6 +3319,7 @@ PUBLIC void LYHandleMETA ARGS4(
     } else if (!(me->node_anchor->charset && *me->node_anchor->charset) && 
 	       !strcasecomp((http_equiv ? http_equiv : ""), "Content-Type")) {
 #ifdef EXP_CHARTRANS
+	LYUCcharset * p_in = NULL;
 	LYUCFullyTranslateString(&content, me->tag_charset, me->tag_charset,
 				 NO, NO, YES, st_other);
 #else
@@ -3541,14 +3383,13 @@ PUBLIC void LYHandleMETA ARGS4(
 	    }
 	    FREE(cp3);
 	    if (chartrans_ok) {
-		LYUCcharset * p_in =
-				HTAnchor_getUCInfoStage(me->node_anchor,
-							UCT_STAGE_PARSER);
 		LYUCcharset * p_out =
 				HTAnchor_setUCInfoStage(me->node_anchor,
 							current_char_set,
 							UCT_STAGE_HTEXT,
 							UCT_SETBY_DEFAULT);
+		p_in = HTAnchor_getUCInfoStage(me->node_anchor,
+					       UCT_STAGE_PARSER);
 		if (!p_out) {
 		    /*
 		     *  Try again.
@@ -3658,7 +3499,7 @@ PUBLIC void LYHandleMETA ARGS4(
 	/*
 	 *  Set the kcode element based on the charset. - FM
 	 */
-	HText_setKcode(me->text, me->node_anchor->charset);
+	HText_setKcode(me->text, me->node_anchor->charset, p_in);
 
     /*
      *  Check for a Refresh directive. - FM
@@ -4577,19 +4418,67 @@ PUBLIC void LYResetParagraphAlignment ARGS1(
     return;
 }
 
+/*
+**  This is an example interface for accessing elements of the HTML
+**  parser's HTStructured object by the SGML parser.  The SGML parser
+**  knows the HTML parsers's HTStructured objects as context->target
+**  elements, and, homologously, uses them as an argument in calls to
+**  HTML_start_element() and HTML_end_element(), but should not
+**  manipulate the context->target's elements, itself, because those
+**  are defined in the Lynx_HTML_Handler section of HTML.h, to which
+**  SGML.c is blind.  This *example* function check's whether the
+**  node_anchor element of an HTML parser HTStructured object has
+**  an address with a file scheme, and if so, loads it into the
+**  the SGML parser's context->url element, which was passed as
+**  the second argument.  The handle_comment() calling function in
+**  SGML.c then calls LYDoCSI() in LYUtils.c to insert HTML markup
+**  into the corresponding stream, homologously to an SSI by an
+**  HTTP server. - FM
+**  Since SGML.c is blind to the HTML parsers's HTStructured object
+**  details it may be calling this function inappropriately when
+**  its context->target isn't actually the HTStructured object
+**  implemented in HTML.c but one in HTMLDTD.c.  Therefore this
+**  function checks for the expected HTStructuredClass's signature
+**  in me->isa->name before doing anything else which requires
+**  access to the expected HTStructured object's data fields, and
+**  returns a failure indication if it finds that it has been called
+**  inappropriately. - kw
+**  Functions such as this also could
+**  be used to set the values of elements (existing ones, or any
+**  new ones needed for future development) in the HTML parser's
+**  HTStructured objects, so that they will be accessible to all
+**  Lynx_HTML_Handler utility functions, thus avoiding the need
+**  to increase the number of arguments in the calls to those
+**  functions, and keeping them object-specific via their 'me'
+**  arguments. - FM
+**  But to generalize the SGML.c -> HTStructured calling mechanism
+**  so that it can deal with more than one implementation of what
+**  SGML.c sees as context->target, new functions will either have
+**  to check whether they are called for the expected kind of target
+**  object (such as here), or they have to come in several object-
+**  specific versions to work across all possible target object classes;
+**  in the latter case they should become new member functions of the
+**  Structured Object definition in SGML.h. - kw
+*/
 PUBLIC BOOLEAN LYCheckForCSI ARGS2(
-	HTParentAnchor *, 	anchor,
+	HTStructured *, 	me,
 	char **,		url)
 {
-    if (!(anchor && anchor->address))
+    if (!me)
+        return FALSE;
+
+    if (!me->isa || strcmp(me->isa->name, "Lynx_HTML_Handler"))
+	return FALSE;
+
+    if (!(me->node_anchor && me->node_anchor->address))
         return FALSE;
 
-    if (strncasecomp(anchor->address, "file:", 5))
+    if (strncasecomp(me->node_anchor->address, "file:", 5))
         return FALSE;
 
-    if (!LYisLocalHost(anchor->address))
+    if (!LYisLocalHost(me->node_anchor->address))
         return FALSE;
-     
-    StrAllocCopy(*url, anchor->address);
+
+    StrAllocCopy(*url, me->node_anchor->address);
     return TRUE;
 }
diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h
index c1c58f40..f276ad0a 100644
--- a/src/LYCharUtils.h
+++ b/src/LYCharUtils.h
@@ -109,7 +109,7 @@ extern void LYEnsureSingleSpace PARAMS((
 extern void LYResetParagraphAlignment PARAMS((
 	HTStructured *		me));
 extern BOOLEAN LYCheckForCSI PARAMS((
-	HTParentAnchor *	anchor,
+	HTStructured *		me,
 	char **			url));
 #endif /* Lynx_HTML_Handler */
 
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 284df163..ea1e25b1 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -63,6 +63,8 @@
 #include "LYCharUtils.h"
 #include "LYCookie.h"
 
+#include "LYLeaks.h"
+
 #define FREE(x) if (x) {free(x); x = NULL;}
 
 /*
diff --git a/src/LYCurses.c b/src/LYCurses.c
index c3fc98ae..d134f4b9 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -200,6 +200,7 @@ PUBLIC void setHashStyle ARGS5(int,style,int,color,int,cattr,int,mono,char*,elem
     ds->cattr=cattr;
     ds->mono=mono;
     ds->code=style;
+    FREE(ds->name);
     ds->name=malloc(sizeof(char)*(strlen(element)+2));
     strcpy(ds->name, element);
 }
@@ -766,7 +767,7 @@ PUBLIC void lynx_enable_mouse ARGS1(int,state)
       button 1 is clicked */
 #ifndef _WINDOWS
    if (state)
-     mousemask(BUTTON1_CLICKED, NULL);
+     mousemask(BUTTON1_CLICKED | BUTTON2_CLICKED, NULL);
    else
      mousemask(0, NULL);
 #else
diff --git a/src/LYEditmap.c b/src/LYEditmap.c
index 0ecfcbef..4cba958a 100644
--- a/src/LYEditmap.c
+++ b/src/LYEditmap.c
@@ -63,7 +63,7 @@ LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_CHAR,
 LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_CHAR,
 LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_DELP,
 
-/* 80..99 ISO-8859-1 8-bit escape characters. */
+/* 80..9F ISO-8859-1 8-bit escape characters. */
 LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_CHAR,
 LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_CHAR,
 LYE_CHAR,       LYE_CHAR,       LYE_CHAR,       LYE_CHAR,
diff --git a/src/LYForms.c b/src/LYForms.c
index a92b0918..26f54f74 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -5,6 +5,7 @@
 #include "HTAlert.h"
 #include "LYCurses.h"
 #include "GridText.h"
+#include "LYCharSets.h"
 #include "LYUtils.h"
 #include "LYStructs.h"  /* includes HTForms.h */
 #include "LYStrings.h"
@@ -355,7 +356,8 @@ again:
 	action = EditBinding(ch);
 	if (action == LYE_ENTER)
 	    break;
-	if (action == LYE_AIX && HTCJK == NOCJK)
+	if (action == LYE_AIX &&
+	    (HTCJK == NOCJK && LYlowest_eightbit[current_char_set] > 0x97))
 	    break;
 	if (action == LYE_TAB) {
 	    ch = (int)('\t');
@@ -456,6 +458,18 @@ breakfor:
 	while ((p != form->value) && (p[-1] == ' '))
 	    p--;
 	*p = '\0';
+
+	/*
+	 *  If the field has been changed, assume that it is now in
+	 *  current display character set, even if for some reason
+	 *  it wasn't!  Hopefully a user will only submit the form
+	 *  if the non-ASCII characters are displayed correctly, which
+	 *  means (assuming that the display character set has been set
+	 *  truthfully) the user confirms by changing the field that
+	 *  the character encoding is right. - kw
+	 */
+	if (*p)
+	    form->value_cs = current_char_set;
     }
     return(ch);
 }
diff --git a/src/LYGetFile.c b/src/LYGetFile.c
index b29584aa..e8787cfd 100644
--- a/src/LYGetFile.c
+++ b/src/LYGetFile.c
@@ -106,6 +106,11 @@ PUBLIC BOOLEAN getfile ARGS1(
 	    LYCancelDownload = FALSE;
 	}
 
+	/*
+	 *  Reset fake 'Z' to prevent unwanted delayed effect. - kw
+	 */
+	LYFakeZap(NO);
+
 Try_Redirected_URL:
 	/*
 	 *  Load the WWWDoc struct in case we need to use it.
@@ -824,7 +829,7 @@ Try_Redirected_URL:
 				}
 			        StrAllocCat(use_this_url_instead, pound);
 			    }
-			    if (TRACE)
+			    if (TRACE && LYTraceLogFP == NULL)
 			        sleep(MessageSecs);
 			    _user_message(WWW_USING_MESSAGE,
 			    		  use_this_url_instead);
@@ -963,7 +968,7 @@ Try_Redirected_URL:
                     }
 		}
 	  } else {
-	      if (TRACE)
+	      if (TRACE && LYTraceLogFP == NULL)
 	          sleep(MessageSecs);
 	      _user_message(WWW_BAD_ADDR_MESSAGE, doc->address);
 	      if (TRACE)
@@ -1340,7 +1345,8 @@ PRIVATE int fix_http_urls ARGS1(
 	doc->address[strlen(doc->address)-1] = '\0';
 	if (TRACE) {
 	    fprintf(stderr, "        changed to '%s'\n", doc->address);
-	    sleep(MessageSecs);
+	    if (!LYTraceLogFP)
+		sleep(MessageSecs);
 	}
     }
 
@@ -1357,7 +1363,8 @@ PRIVATE int fix_http_urls ARGS1(
     StrAllocCat(doc->address, "/");
     if (TRACE) {
         fprintf(stderr, "        changed to '%s'\n",doc->address);
-	sleep(MessageSecs);
+	if (!LYTraceLogFP)
+	    sleep(MessageSecs);
     }
 
     return(1);
diff --git a/src/LYHash.c b/src/LYHash.c
index 7fbb55ad..a6eea95f 100644
--- a/src/LYHash.c
+++ b/src/LYHash.c
@@ -10,9 +10,10 @@
 
 #include "LYHash.h"
 
-PUBLIC int hash_table[HASHSIZE]; /* 32K should be big enough */
-
 #ifdef NOT_USED
+
+PUBLIC int hash_table[CSHASHSIZE]; /* 32K should be big enough */
+
 PUBLIC int hash_code_rp ARGS1(char*,string)
 {
 	char* hash_ptr = string;
@@ -23,7 +24,7 @@ PUBLIC int hash_code_rp ARGS1(char*,string)
 		hash_tmp ^= (((*hash_ptr)<<4) ^ ((*hash_ptr)<<12));
 		hash_tmp >>= 1;
 	}
-	return (hash_tmp % HASHSIZE);
+	return (hash_tmp % CSHASHSIZE);
 }
 #endif
 
@@ -32,7 +33,11 @@ PUBLIC int hash_code_rp ARGS1(char*,string)
  *      but with a different value for HASH_SIZE.
  */ 
 
+#ifdef NOT_USED
 #define HASH_SIZE 8193		/* Arbitrary prime. Memory/speed tradeoff */
+#else
+#define HASH_SIZE CSHASHSIZE
+#endif
 
 PUBLIC int hash_code ARGS1 (char*, string)
 {
diff --git a/src/LYHash.h b/src/LYHash.h
index b466f2aa..00f8066c 100644
--- a/src/LYHash.h
+++ b/src/LYHash.h
@@ -11,16 +11,22 @@ struct _hashbucket {
 };
 
 typedef struct _hashbucket bucket;
-	
-#if !defined(HASHSIZE)
-#define HASHSIZE 32768
+
+#if !defined(CSHASHSIZE)
+#ifdef NOT_USED	
+#define CSHASHSIZE 32768
+#else
+#define CSHASHSIZE 8193
+#endif
 #endif
 
 #define NOSTYLE -1
 
-extern bucket hashStyles[HASHSIZE];
+extern bucket hashStyles[CSHASHSIZE];
 extern int hash_code PARAMS((char* string));
-extern int hash_table[HASHSIZE]; /* 32K should be big enough */
+#ifdef NOT_USED
+extern int hash_table[CSHASHSIZE]; /* 32K should be big enough */
+#endif
 
 extern int	s_alink, s_a, s_status,
 		s_label, s_value, s_high,
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index c47c3611..1ceef654 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -462,7 +462,7 @@ PRIVATE struct rmap revmap[] = {
 { "RAW_TOGGLE",		"toggle raw 8-bit translations or CJK mode ON or OFF" },
 { "COOKIE_JAR",		"examine the Cookie Jar" },
 { "F_LINK_NUM",		"invoke the 'Follow link (or page) number:' prompt" },
-{ "SWITCH_DTD",		"switch between old and new parsing of HTML" },
+{ "SWITCH_DTD",		"switch between two ways of parsing HTML" },
 #ifdef USE_EXTERNALS
 { "EXTERN",		"run external program with url" },
 #endif
diff --git a/src/LYLeaks.c b/src/LYLeaks.c
index fed79414..ee69621a 100644
--- a/src/LYLeaks.c
+++ b/src/LYLeaks.c
@@ -25,7 +25,8 @@ PRIVATE void AddToList PARAMS((AllocationList *ALp_new));
 PRIVATE AllocationList *FindInList PARAMS((void *vp_find));
 PRIVATE void RemoveFromList PARAMS((AllocationList *ALp_del));
 
-PUBLIC void LYLeaks NOARGS	{
+PUBLIC void LYLeaks NOARGS
+{
 /*
  *	Purpose:	Print a report of all memory left unallocated by
  *				Lynx code or attempted unallocations on
@@ -173,7 +174,8 @@ PUBLIC void LYLeaks NOARGS	{
 }
 
 PUBLIC void *LYLeakMalloc ARGS3(size_t, st_bytes,  CONST char *, cp_File, CONST
-	short, ssi_Line)	{
+	short, ssi_Line)
+{
 /*
  *	Purpose:	Capture allocations using malloc (stdlib.h) and track
  *				the information in a list.
@@ -230,7 +232,8 @@ PUBLIC void *LYLeakMalloc ARGS3(size_t, st_bytes,  CONST char *, cp_File, CONST
 }
 
 PUBLIC void *LYLeakCalloc ARGS4(size_t, st_number, size_t, st_bytes, CONST char
-	*, cp_File, CONST short, ssi_Line)	{
+	*, cp_File, CONST short, ssi_Line)
+{
 /*
  *	Purpose:	Capture allocations by calloc (stdlib.h) and
  *				save relevant information in a list.
@@ -287,7 +290,8 @@ PUBLIC void *LYLeakCalloc ARGS4(size_t, st_number, size_t, st_bytes, CONST char
 }
 
 PUBLIC void *LYLeakRealloc ARGS4(void *, vp_Alloced, size_t, st_newBytes, CONST
-	char *, cp_File, CONST short, ssi_Line)	{
+	char *, cp_File, CONST short, ssi_Line)
+{
 /*
  *	Purpose:	Capture any realloc (stdlib.h) calls in order to
  *				properly keep track of our run time allocation
@@ -378,7 +382,8 @@ PUBLIC void *LYLeakRealloc ARGS4(void *, vp_Alloced, size_t, st_newBytes, CONST
 }
 
 PUBLIC void LYLeakFree ARGS3(void *, vp_Alloced, CONST char *, cp_File, CONST
-	short, ssi_Line)	{
+	short, ssi_Line)
+{
 /*
  *	Purpose:	Capture all requests to free information and also
  *				remove items from the allocation list.
@@ -441,7 +446,61 @@ PUBLIC void LYLeakFree ARGS3(void *, vp_Alloced, CONST char *, cp_File, CONST
 	}
 }
 
-PRIVATE void AddToList ARGS1(AllocationList *, ALp_new)	{
+/*	Allocates a new copy of a string, and returns it.
+ *	Tracks allocations by using other LYLeakFoo functions.
+ *	Equivalent to HTSACopy in HTUtils.c - kw
+ *	
+*/
+PUBLIC char * LYLeakSACopy ARGS4(
+	char **,	dest,
+	CONST char *,	src,
+	CONST char *, 	cp_File,
+	CONST short,	ssi_Line)
+{
+    if (*dest) {
+	LYLeakFree(*dest, cp_File, ssi_Line);
+	*dest = NULL;
+    }
+    if (src) {
+        *dest = (char *) LYLeakMalloc (strlen(src) + 1, cp_File, ssi_Line);
+	if (*dest == NULL)
+	    outofmem(__FILE__, "LYLeakSACopy");
+	strcpy (*dest, src);
+    }
+    return *dest;
+}
+
+/*	String Allocate and Concatenate.
+ *	Tracks allocations by using other LYLeakFoo functions.
+ *	Equivalent to HTSACat in HTUtils.c - kw
+*/
+PUBLIC char * LYLeakSACat ARGS4(
+	char **,	dest,
+	CONST char *,	src,
+	CONST char *, 	cp_File,
+	CONST short,	ssi_Line)
+{
+    if (src && *src) {
+        if (*dest) {
+	    int length = strlen(*dest);
+	    *dest = (char *)LYLeakRealloc(*dest, length + strlen(src) + 1,
+					  cp_File, ssi_Line);
+	    if (*dest == NULL)
+	        outofmem(__FILE__, "LYLeakSACat");
+	    strcpy (*dest + length, src);
+	} else {
+	    *dest = (char *)LYLeakMalloc(strlen(src) + 1,
+					 cp_File, ssi_Line);
+	    if (*dest == NULL)
+	        outofmem(__FILE__, "LYLeakSACat");
+	    strcpy (*dest, src);
+	}
+    }
+    return *dest;
+}
+
+PRIVATE void AddToList ARGS1(AllocationList *, ALp_new)
+{
 /*
  *	Purpose:	Add a new allocation item to the list.
  *	Arguments:	ALp_new	The new item to add.
@@ -460,7 +519,8 @@ PRIVATE void AddToList ARGS1(AllocationList *, ALp_new)	{
 	ALp_RunTimeAllocations = ALp_new;
 }
 
-PRIVATE AllocationList *FindInList ARGS1(void *, vp_find)	{
+PRIVATE AllocationList *FindInList ARGS1(void *, vp_find)
+{
 /*
  *	Purpose:	Find the place in the list where vp_find is currently
  *				tracked.
@@ -491,7 +551,8 @@ PRIVATE AllocationList *FindInList ARGS1(void *, vp_find)	{
 	return(ALp_find);
 }
 
-PRIVATE void RemoveFromList ARGS1(AllocationList *, ALp_del)	{
+PRIVATE void RemoveFromList ARGS1(AllocationList *, ALp_del)
+{
 /*
  *	Purpose:	Remove the specified item from the list.
  *	Arguments:	ALp_del	The item to remove from the list.
diff --git a/src/LYMain.c b/src/LYMain.c
index 7f9c8800..bcb69040 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -390,6 +390,10 @@ PUBLIC BOOLEAN LYNoCore = NO_FORCED_CORE_DUMP;
 PRIVATE void FatalProblem PARAMS((int sig));
 #endif /* !VMS */
 
+#if defined(USEHASH)
+    char *lynx_lss_file=NULL;
+#endif
+
 PRIVATE void free_lynx_globals NOARGS
 {
     int i;
@@ -470,6 +474,9 @@ PRIVATE void free_lynx_globals NOARGS
     FREE(URLDomainSuffixes);
     FREE(XLoadImageCommand);
     FREE(LYTraceLogPath);
+#if defined(USEHASH)
+    FREE(lynx_lss_file);
+#endif
     for (i = 0; i < nlinks; i++) {
         FREE(links[i].lname);
     }
@@ -478,10 +485,6 @@ PRIVATE void free_lynx_globals NOARGS
     return;
 }
 
-#if defined(USEHASH)
-    char *lynx_lss_file=NULL;
-#endif
-
 
 /*
  *  This function frees the LYStdinArgs list. - FM
@@ -780,7 +783,7 @@ PUBLIC int main ARGS2(
 	    if (!LYValidate)
 	        parse_restrictions("default");
 	    anon_restrictions_set = TRUE;
-	} else if (strcmp(argv[0], "-validate") == 0) {
+	} else if (strcmp(argv[i], "-validate") == 0) {
 	    /*
 	     *  Follow only http URLs.
 	     */
@@ -796,6 +799,18 @@ PUBLIC int main ARGS2(
                 StrAllocCopy(lynx_cfg_file, argv[i+1]);
                 i++;
             }
+
+#if defined(USEHASH)
+	} else if (strncmp(argv[i], "-lss", 4) == 0) {
+	    if ((cp=strchr(argv[i],'=')) != NULL)
+		StrAllocCopy(lynx_lss_file, cp+1);
+	    else {
+		StrAllocCopy(lynx_lss_file, argv[i+1]);
+		i++;
+	    }
+	    fprintf(stderr, "LYMain found -lss flag, lss file is %s\n",
+		    lynx_lss_file ? lynx_lss_file : "<NONE>");
+#endif
 	}
     }
 
@@ -863,6 +878,22 @@ PUBLIC int main ARGS2(
 		    if (*cp)
 			StrAllocCopy(lynx_cfg_file, cp);
 	        }
+ #if defined(USEHASH)
+	    } else if (strncmp(buf, "-lss", 4) == 0) {
+		if ((cp = strchr(buf,'=')) != NULL) {
+		    StrAllocCopy(lynx_lss_file, cp+1);
+		} else {
+		    cp = buf;
+		    while (*cp && !isspace((unsigned char)*cp))
+			cp++;
+		    while (*cp && isspace((unsigned char)*cp))
+			cp++;
+		    if (*cp)
+			StrAllocCopy(lynx_cfg_file, cp);
+	        }
+		fprintf(stderr, "LYMain found -lss flag, lss file is %s\n",
+			lynx_lss_file ? lynx_lss_file : "<NONE>");
+#endif
 	    } else if (strcmp(buf, "-get_data") == 0) {
 		/*
 		 *  User data for GET form.
@@ -1134,9 +1165,6 @@ PUBLIC int main ARGS2(
      *  Convert a '~' in the lynx-style file path to $HOME.
      */
     if ((cp = strchr(lynx_lss_file, '~'))) {
-        char *temp = NULL;
-        int len;
-
         *(cp++) = '\0';
         StrAllocCopy(temp, lynx_lss_file);
         if ((len=strlen(temp)) > 0 && temp[len-1] == '/')
@@ -1663,6 +1691,7 @@ PUBLIC int main ARGS2(
 	    if (display != NULL && *display != '\0') {
 	        LYisConfiguredForX = TRUE;
 	    }
+	    ena_csi((LYlowest_eightbit[current_char_set] > 155));
 	    status = mainloop();
 	    cleanup();
 	}
@@ -2143,17 +2172,6 @@ PRIVATE void parse_arg ARGS3(
     if (strncmp(argv[0], "-link", 5) == 0) {
         if (nextarg)
 	    ccount = atoi(cp);
-#if defined(USEHASH)
-        } else if (strncmp(argv[0], "-lss", 4) == 0) {
-            if ((cp=strchr(argv[0],'=')) != NULL)
-                StrAllocCopy(lynx_lss_file, cp+1);
-            else {
-                StrAllocCopy(lynx_lss_file, argv[1]);
-                i++;
-            }
-	    fprintf(stderr, "LYMain found -lss flag, lss file is %s\n",
-		    lynx_lss_file ? lynx_lss_file : "<NONE>");
-#endif
 
     } else if (strncmp(argv[0], "-localhost", 10) == 0) {
 	local_host_only = TRUE;
@@ -2163,6 +2181,16 @@ PRIVATE void parse_arg ARGS3(
 	local_exec_on_local_files = TRUE;
 #endif /* EXEC_LINKS || EXEC_SCRIPTS */
 
+#if defined(USEHASH)
+    } else if (strncmp(argv[0], "-lss", 4) == 0) {
+        /*
+	 *  Already read the alternate lynx-style file
+         *  so just check whether we need to increment i
+         */
+        if (nextarg)
+            ; /* do nothing */
+#endif
+
     } else {
         goto Output_Error_and_Help_List;
     }
@@ -2497,16 +2525,6 @@ PRIVATE void parse_arg ARGS3(
 	     HTAtom_for("www/download") : HTAtom_for("www/dump"));
 	LYcols=999;
 
-#if defined(USEHASH)
-    } else if (strncmp(argv[0], "-lss", 4) == 0) {
-        /*
-	 *  Already read the alternate lynx-style file
-         *  so just check whether we need to increment i
-         */
-        if (nextarg)
-            ; /* do nothing */
-#endif
-
     } else if (strncmp(argv[0], "-stack_dump", 11) == 0) {
 	stack_dump = TRUE;
 
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 95166360..f541e0ba 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -853,8 +853,10 @@ try_again:
 	  	    break;	
 		}  /* end switch */
 
-	    if (TRACE)
-	        sleep(AlertSecs); /* allow me to look at the results */
+	    if (TRACE) {
+		if (!LYTraceLogFP || trace_mode_flag)
+		    sleep(AlertSecs); /* allow me to look at the results */
+	    }
 
 	    /*
 	     *  Set the files the same.
@@ -1062,7 +1064,8 @@ try_again:
 	    }
 	    if (TRACE) {
 		refresh_screen = TRUE;
-		sleep(AlertSecs);
+		if (!LYTraceLogFP || trace_mode_flag)
+		    sleep(AlertSecs);
 	    }
 	}
 
@@ -1713,6 +1716,7 @@ new_cmd:  /*
 	    } else {
 	        if (HText_getOwner())
 		    StrAllocCopy(ownerS_address, HText_getOwner());
+		LYUCPushAssumed(HTMainAnchor);
 	        HTOutputFormat = WWW_SOURCE;
 	    }
 	    HTuncache_current_document();
@@ -1906,9 +1910,7 @@ new_cmd:  /*
 	    else
 	        New_DTD = YES;
 	    HTSwitchDTD(New_DTD);
-	    _statusline(New_DTD ?
-		"Now using the experimental DTD!" : "Now using the old Lynx DTD.");
-/*		SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF);*/
+	    _statusline(New_DTD ? USING_DTD_0 : USING_DTD_1);
 	    sleep(MessageSecs);
 	    break;
 
@@ -1966,12 +1968,13 @@ new_cmd:  /*
 
 	case  LYK_UP_TWO:
 	    if (Newline > 1) {
-	        Newline -= 2;
+		int scrollamount = (Newline > 2 ? 2 : 1);
+	        Newline -= scrollamount;
 		if (nlinks > 0 && curdoc.link > -1) {
-		    if (links[curdoc.link].ly <= (display_lines - 2)) {
+		    if (links[curdoc.link].ly + scrollamount <= display_lines) {
 		        newdoc.link = curdoc.link +
 				      HText_LinksInLines(HTMainText,
-				      			 Newline, 2);
+				      			 Newline, scrollamount);
 		    } else {
 		        arrowup = TRUE;
 		    }
@@ -2001,13 +2004,16 @@ new_cmd:  /*
 
 	case  LYK_UP_HALF:
 	    if (Newline > 1) {
-	        Newline -= display_lines/2;
+		int scrollamount = display_lines/2;
+		if (Newline - scrollamount < 1)
+		    scrollamount = Newline - 1;
+	        Newline -= scrollamount;
 		if (nlinks > 0 && curdoc.link > -1) {
-		    if (links[curdoc.link].ly <= (display_lines/2)) {
+		    if (links[curdoc.link].ly + scrollamount <= display_lines) {
 		        newdoc.link = curdoc.link +
 				      HText_LinksInLines(HTMainText,
 				      			 Newline,
-							 (display_lines/2));
+							 scrollamount);
 		    } else {
 		        arrowup = TRUE;
 		    }
@@ -2084,8 +2090,18 @@ new_cmd:  /*
 		/*
 		 *  Go back to the previous page.
 		 */
-		Newline -= (display_lines);
-		arrowup = TRUE;
+		int scrollamount = (Newline > display_lines ?
+				    	      display_lines : Newline - 1);
+		Newline -= scrollamount;
+		if (scrollamount < display_lines &&
+		    nlinks > 0 && curdoc.link == 0 &&
+		    links[0].ly - 1 + scrollamount <= display_lines) {
+		        newdoc.link = HText_LinksInLines(HTMainText,
+				      			 1,
+							 scrollamount) - 1;
+		} else {
+		    arrowup = TRUE;
+		}
 
 	    } else if (old_c != real_c) {
 		old_c = real_c;
@@ -2138,7 +2154,11 @@ new_cmd:  /*
 	    break;
 
         case LYK_UP_LINK:
-            if (curdoc.link > 0) {  /* more links above? */
+            if (curdoc.link > 0 &&
+		(links[0].ly != links[curdoc.link].ly ||
+		 !HText_LinksInLines(HTMainText, 1, Newline - 1))) {
+		/* more links before this on screen, and first of them on
+		   a different line or no previous links before this screen? */
                 int newlink = -1;
                 for (i = curdoc.link; i >= 0; i--) {
                     if (links[i].ly < links[curdoc.link].ly) {
@@ -2155,14 +2175,13 @@ new_cmd:  /*
                     curdoc.link = (nlinks-1);
                 } else if (more) {  /* next page */
                         Newline += (display_lines);
-                }
 #else
 		} else if (old_c != real_c) {
 		    old_c = real_c;
 		    _statusline(NO_LINKS_ABOVE);
 		    sleep(MessageSecs);
-		}
 #endif /* NOTDEFINED */
+		}
 
 #ifdef NOTDEFINED
             /*
@@ -2175,8 +2194,18 @@ new_cmd:  /*
 #endif /* NOTDEFINED */
 
             } else if (curdoc.line > 1 && Newline > 1) {  /* previous page */
-                    Newline -= (display_lines);
+		int scrollamount = (Newline > display_lines ?
+				    	      display_lines : Newline - 1);
+		Newline -= scrollamount;
+		if (scrollamount < display_lines &&
+		    nlinks > 0 && curdoc.link > -1 &&
+		    links[0].ly -1 + scrollamount <= display_lines) {
+		        newdoc.link = HText_LinksInLines(HTMainText,
+				      			 1,
+							 scrollamount) - 1;
+		} else {
 		    arrowup = TRUE;
+		}
 
 	    } else if (old_c != real_c) {
 		old_c = real_c;
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 8a03ec78..cbc4912b 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -271,7 +271,8 @@ draw_options:
 	    addstr(UCAssume_MIMEcharset);
 	else
 	    addstr((UCLYhndl_for_unspec >= 0) ?
-		   LYCharSet_UC[UCLYhndl_for_unspec].MIMEname : "NONE");
+		   (char *)LYCharSet_UC[UCLYhndl_for_unspec].MIMEname
+		   			      : "NONE");
     }
 
     move(L_Rawmode, 5);
@@ -813,7 +814,8 @@ draw_options:
 			move(L_ASSUME_CHARSET, COL_OPTION_VALUES);
 			clrtoeol();
 			if (UCLYhndl_for_unspec >= 0)
-			    addstr(LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
+			    addstr((char *)
+				   LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);
 #endif /* VMS || USE_SLANG */
 		    }
 
diff --git a/src/LYStrings.c b/src/LYStrings.c
index dd07fe98..6d9a68c7 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -12,6 +12,7 @@
 #include "LYMail.h"
 #include "LYNews.h"
 #include "LYOptions.h"
+#include "LYCharSets.h"
 
 #include <ctype.h>
 
@@ -261,7 +262,7 @@ PRIVATE int sl_parse_mouse_event ARGS3(int *, x, int *, y, int *, button)
 }
 #endif
 
-#ifdef USE_SLANG_MOUSE
+#if defined(USE_SLANG_MOUSE) || defined(NCURSES_MOUSE_VERSION)
 PRIVATE int map_function_to_key ARGS1(char, keysym)
 {
    int i;
@@ -278,6 +279,12 @@ PRIVATE int map_function_to_key ARGS1(char, keysym)
 }
 #endif
 
+PRIVATE BOOLEAN csi_is_csi = TRUE;
+PUBLIC void ena_csi ARGS1(
+    BOOLEAN,	flag)
+{
+    csi_is_csi = flag;
+}
 /*
  *  LYgetch() translates some escape sequences and may fake noecho.
  */
@@ -371,7 +378,7 @@ re_read:
     }
 #endif /* USE_SLANG */
 
-    if (c == 27 || c == 155) {      /* handle escape sequence */
+    if (c == 27 || (csi_is_csi && c == 155)) {      /* handle escape sequence */
         b = GetChar();
 
         if (b == '[' || b == 'O') {
@@ -499,7 +506,8 @@ re_read:
 	default:
 	   if (TRACE) {
 		fprintf(stderr,"Unknown key sequence: %d:%d:%d\n",c,b,a);
-		sleep(MessageSecs);
+		if (!LYTraceLogFP)
+		    sleep(MessageSecs);
 	   }
         }
 	if (isdigit(a) && (b == '[' || c == 155) && d != -1 && d != '~')
@@ -585,6 +593,8 @@ re_read:
 	   err=getmouse(&event);
 	   if (event.bstate & BUTTON1_CLICKED) {
 	     c = set_clicked_link(event.x, event.y);
+	   } else if (event.bstate & BUTTON2_CLICKED) {
+	     c = map_function_to_key (LYK_PREV_DOC);
 	   }
 #else /* pdcurses version */
               int left,right;
@@ -718,10 +728,11 @@ PUBLIC int LYEdit1 ARGS4(
     case LYE_AIX:
         /*
 	 *  Hex 97.
-	 *  Fall through as a character for CJK.
+	 *  Fall through as a character for CJK, or if this is a valid
+	 *  character in the current display character set.
 	 *  Otherwise, we treat this as LYE_ENTER.
 	 */
-	 if (HTCJK == NOCJK)
+	 if (HTCJK == NOCJK && LYlowest_eightbit[current_char_set] > 0x97)
 	     return(ch);
     case LYE_CHAR:
         /*
@@ -930,7 +941,10 @@ PUBLIC void LYRefreshEdit ARGS1(
         for (i = 0; i < nrdisplayed; i++)
 	    if ((buffer[0] = str[i]) == 1 || buffer[0] == 2 ||
 	        ((unsigned char)buffer[0] == 160 &&
-		 !(HTPassHighCtrlRaw || HTCJK != NOCJK))) {
+		 !(HTPassHighCtrlRaw || HTCJK != NOCJK ||
+		   (LYCharSet_UC[current_char_set].enc != UCT_ENC_8859 &&
+		    !(LYCharSet_UC[current_char_set].like8859
+		      & UCT_R_8859SPECL))))) {
 	        addch(' ');
 	    } else {
 		/* For CJK strings, by Masanobu Kimura */
@@ -1013,10 +1027,13 @@ again:
 	case LYE_AIX:
 	    /*
 	     *  Hex 97.
-	     *  Treat as a character for CJK.
+	     *  Treat as a character for CJK, or if this is a valid
+	     *  character in the current display character set.
 	     *  Otherwise, we treat this as LYE_ENTER.
 	     */
-	    if (HTCJK != NOCJK && ch != '\t') {
+	    if (ch != '\t' &&
+		(HTCJK != NOCJK ||
+		 LYlowest_eightbit[current_char_set] <= 0x97)) {
 	        LYLineEdit(&MyEdit,ch, FALSE);
 		break;
 	    }
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 9d26458c..5dc64c06 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -11,6 +11,7 @@ extern char * LYstrncpy PARAMS((
 	char *		dst,
 	CONST char *	src,
 	int		n));
+extern void ena_csi PARAMS((BOOLEAN flag));
 extern int LYgetch NOPARAMS;
 extern int LYgetstr PARAMS((
 	char *		inputline,
diff --git a/src/LYStyle.c b/src/LYStyle.c
index 8e36c09d..3f529264 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,6 +1,6 @@
 /* character level styles for Lynx
  * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
- * $Id: LYStyle.c,v 1.3 1997/09/19 01:14:00 klaus Exp $
+ * @Id: LYStyle.c 1.7 Wed, 17 Sep 1997 17:34:13 -0600 dickey @
  */
 #include "HTUtils.h"
 #include "HTML.h"
@@ -20,10 +20,11 @@
 #include "LYStyle.h"
 
 #include "LYexit.h"
+#include "LYLeaks.h"
 
 #ifdef USE_COLOR_STYLE
 
-PUBLIC bucket hashStyles[HASHSIZE];
+PUBLIC bucket hashStyles[CSHASHSIZE];
 
 /* definitions for the mono attributes we can use */
 static int ncursesMono[7] = {
@@ -62,6 +63,8 @@ PUBLIC int	s_alink=NOSTYLE, s_a=NOSTYLE, s_status=NOSTYLE,
 
 /* start somewhere safe */ 
 PRIVATE int colorPairs=0;
+PRIVATE int last_fA=COLOR_WHITE, last_bA=COLOR_BLACK;
+
 
 #define FREE(x) if (x) {free(x); x = NULL;}
 
@@ -125,15 +128,21 @@ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char*
   */
  if (lynx_has_color && colorPairs < COLOR_PAIRS-1 && fA!=-1)
  {
-	colorPairs++;
-	init_pair(colorPairs, fA, bA);
-	setStyle(style, COLOR_PAIR(colorPairs)|cA, cA, mA);
+     if (colorPairs <= 0 || fA != last_fA || bA != last_bA) {
+	 colorPairs++;
+	 init_pair(colorPairs, fA, bA);
+	 last_fA = fA;
+	 last_bA = bA;
+     }
+	if (style < DSTYLE_ELEMENTS)
+	    setStyle(style, COLOR_PAIR(colorPairs)|cA, cA, mA);
 	setHashStyle(newstyle, COLOR_PAIR(colorPairs)|cA, cA, mA, element);
  }
  else
  {
 	/* only mono is set */
-	setStyle(style, -1, -1, mA);
+	if (style < DSTYLE_ELEMENTS)
+	    setStyle(style, -1, -1, mA);
 	setHashStyle(newstyle, -1, -1, mA, element);
  }
 }
@@ -251,11 +260,26 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer);
 	 }
 	}
 #else
-	parse_attributes(mono,fg,bg,hash_code(element),element);
+	int element_number = -1;
+	HTTag * t = SGMLFindTag(&HTML_dtd, element);
+	if (t && t->name) {
+	    element_number = t - HTML_dtd.tags;
+	}
+	if (element_number >= HTML_A &&
+	    element_number < HTML_ELEMENTS)
+	    parse_attributes(mono,fg,bg, element_number+STARTAT,element);
+	else
+	    parse_attributes(mono,fg,bg, DSTYLE_ELEMENTS,element);
 #endif
  }
 }
 
+PRIVATE void free_colorstylestuff NOARGS
+{
+    style_initialiseHashTable();
+    style_deleteStyleList();
+}
+
 /*
  * initialise the default style sheet
  * This should be able to be read from a file in CSS format :-)
@@ -268,13 +292,21 @@ PRIVATE void initialise_default_stylesheet NOARGS
 PUBLIC void style_initialiseHashTable NOARGS
 {
 	int i;
+	static int firsttime = 1;
 	
-	for (i=0; i<HASHSIZE; i++)
+	for (i=0; i<CSHASHSIZE; i++)
 	{
+	    if (firsttime)
 		hashStyles[i].name=NULL;
-		hashStyles[i].color=-1;
-		hashStyles[i].cattr=-1;
-		hashStyles[i].mono=-1;
+	    else
+		FREE(hashStyles[i].name);
+	    hashStyles[i].color=-1;
+	    hashStyles[i].cattr=-1;
+	    hashStyles[i].mono=-1;
+	}
+	if (firsttime) {
+	    firsttime = 0;
+	    atexit(free_colorstylestuff);
 	}
 	s_high=hash_code("high");
 	s_alink=hash_code("alink");
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 58005020..117d44b3 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1987,6 +1987,30 @@ PUBLIC void noviceline ARGS1(
     return;
 }
 
+PRIVATE int fake_zap = 0;
+
+PUBLIC void LYFakeZap ARGS1(
+    BOOL,	set)
+{
+    if (set && fake_zap < 1) {
+	if (TRACE) {
+	    fprintf(stderr, "\r *** Set simulated 'Z'");
+	    if (fake_zap)
+		fprintf(stderr, ", %d pending", fake_zap);
+	    fprintf(stderr, " ***\n");
+	}
+	fake_zap++;
+    } else if (!set && fake_zap) {
+	if (TRACE) {
+	    fprintf(stderr, "\r *** Unset simulated 'Z'");
+	    fprintf(stderr, ", %d pending", fake_zap);
+	    fprintf(stderr, " ***\n");
+	}
+	fake_zap = 0;
+    }
+    
+}
+
 PUBLIC int HTCheckForInterrupt NOARGS
 {
 #ifndef VMS /* UNIX stuff: */
@@ -1997,6 +2021,17 @@ PUBLIC int HTCheckForInterrupt NOARGS
     fd_set readfds;
 #endif /* !USE_SLANG */
 
+    if (fake_zap > 0) {
+	fake_zap--;
+	if (TRACE) {
+	    fprintf(stderr, "\r *** Got simulated 'Z' ***\n");
+	    fflush(stderr);
+	    if (!LYTraceLogFP)
+		sleep(AlertSecs);
+	}
+	return((int)TRUE);
+    }
+	
     /** Curses or slang setup was not invoked **/
     if (dump_output_immediately)
 	return((int)FALSE);
@@ -2053,6 +2088,17 @@ PUBLIC int HTCheckForInterrupt NOARGS
     extern BOOLEAN HadVMSInterrupt;
     extern int typeahead();
 
+    if (fake_zap > 0) {
+	fake_zap--;
+	if (TRACE) {
+	    fprintf(stderr, "\r *** Got simulated 'Z' ***\n");
+	    fflush(stderr);
+	    if (!LYTraceLogFP)
+		sleep(AlertSecs);
+	}
+	return((int)TRUE);
+    }
+	
     /** Curses or slang setup was not invoked **/
     if (dump_output_immediately)
 	  return((int)FALSE);
@@ -4121,8 +4167,8 @@ have_VMS_URL:
 	    }
 	} else {
 	    /*
-	     *  Normal absolute path.  Simplify, trim any
-	     *  residual relative elements, and append it. - FM
+	     *  Normal absolute path in URL syntax.  Simplify, trim
+	     *  any residual relative elements, and append it. - FM
 	     */
 	    StrAllocCopy(temp, old_string);
 	    LYTrimRelFromAbsPath(temp);
@@ -4137,7 +4183,8 @@ have_VMS_URL:
     FREE(old_string);
     if (TRACE) {
 	/* Pause so we can read the messages before invoking curses */
-	sleep(AlertSecs);
+	if (!LYTraceLogFP)
+	    sleep(AlertSecs);
     }
 }
 
diff --git a/src/LYUtils.h b/src/LYUtils.h
index 3896624e..7af31349 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -16,6 +16,7 @@ extern char * strip_trailing_slash PARAMS((char * dirname));
 extern void statusline PARAMS((CONST char *text));
 extern void toggle_novice_line NOPARAMS;
 extern void noviceline PARAMS((int more_flag));
+extern void LYFakeZap PARAMS((BOOL set));
 extern int HTCheckForInterrupt NOPARAMS;
 extern BOOLEAN LYisLocalFile PARAMS((char *filename));
 extern BOOLEAN LYisLocalHost PARAMS((char *filename));
diff --git a/src/LYexit.c b/src/LYexit.c
index 027b1549..625c05e3 100644
--- a/src/LYexit.c
+++ b/src/LYexit.c
@@ -137,6 +137,8 @@ void (*function)();
      *  Check for available space.
      */
     if (topOfStack == ATEXITSIZE) {
+	if (TRACE)
+	    fprintf(stderr, "(LY)atexit: Too many functions, ignoring one!\n");
 	return(-1);
     }
 
diff --git a/src/UCAux.c b/src/UCAux.c
index 3ee93929..d63e04e0 100644
--- a/src/UCAux.c
+++ b/src/UCAux.c
@@ -9,62 +9,68 @@
 extern HTCJKlang HTCJK;
 extern LYUCcharset LYCharSet_UC[];
 
-PUBLIC BOOL UCCanUniTranslateFrom ARGS1(
+PUBLIC UCTQ_t UCCanUniTranslateFrom ARGS1(
 	int,		from)
 {
     if (from < 0)
-	return NO;
+	return TQ_NO;
     if (LYCharSet_UC[from].enc == UCT_ENC_7BIT ||
 	LYCharSet_UC[from].enc == UCT_ENC_UTF8)
-	return YES;
+	return TQ_EXCELLENT;
     if (LYCharSet_UC[from].codepoints & (UCT_CP_SUBSETOF_LAT1))
-	return YES;
-    return (LYCharSet_UC[from].UChndl >= 0);
+	return TQ_EXCELLENT;
+    return ((LYCharSet_UC[from].UChndl >= 0) ? TQ_GOOD : TQ_NO);
 }
-PUBLIC BOOL UCCanTranslateUniTo ARGS1(
+PUBLIC UCTQ_t UCCanTranslateUniTo ARGS1(
 	int,		to)
 {
     if (to < 0)
-	return NO;
-    return YES;			/* well at least some characters... */
+	return TQ_NO;
+    if (LYCharSet_UC[to].enc == UCT_ENC_7BIT)
+	return TQ_POOR;
+    if (LYCharSet_UC[to].enc == UCT_ENC_UTF8)
+	return TQ_EXCELLENT;
+    if (LYCharSet_UC[to].enc == UCT_ENC_CJK)
+	return TQ_POOR;
+    if (LYCharSet_UC[to].UChndl >= 0)
+	return TQ_GOOD;
+    return TQ_GOOD;	/* at least some characters, we don't know more */
 }
-PUBLIC BOOL UCCanTranslateFromTo ARGS2(
+PUBLIC UCTQ_t UCCanTranslateFromTo ARGS2(
 	int,		from,
 	int,		to)
 {
     if (from == to)
-	return YES;
+	return TQ_EXCELLENT;
     if (from < 0 || to < 0)
-	return NO;
+	return TQ_NO;
     if (from == 0)
 	return UCCanTranslateUniTo(to);
-    if (to == 0)
+    if (to == 0 || LYCharSet_UC[to].enc == UCT_ENC_UTF8)
 	return UCCanUniTranslateFrom(from);
-    if (LYCharSet_UC[to].enc == UCT_ENC_UTF8) {
-	return (LYCharSet_UC[from].UChndl >= 0);
-    }
     {
 	CONST char * fromname = LYCharSet_UC[from].MIMEname;
 	CONST char * toname = LYCharSet_UC[to].MIMEname;
+	UCTQ_t tqmin = TQ_NO, tqmax = TQ_GOOD;
 	if (!strcmp(fromname, "x-transparent") ||
 	    !strcmp(toname, "x-transparent")) {
-	    return YES;
+	    return TQ_GOOD;
 	}
 	if (LYCharSet_UC[from].enc == UCT_ENC_CJK) {
 	    if (HTCJK == NOCJK)	/* use that global flag, for now */
-		return NO;
+		return TQ_NO;
 	    if (HTCJK == JAPANESE &&
 		(!strcmp(fromname, "euc-jp") ||
 		 !strncmp(fromname, "iso-2022-jp",11) ||
 		 !strcmp(fromname, "shift_jis")))
-		return YES;
-	    return NO;	/* if not handled by (from == to) above */
+		return TQ_GOOD;
+	    return TQ_NO;	/* if not handled by (from == to) above */
 	}
 	if (!strcmp(fromname, "koi8-r")) {
 	    /*
 	     *  Will try to use stripping of high bit...
 	     */
-	    return YES;
+	    tqmin = TQ_POOR;
 	}
 
 	if (!strcmp(fromname, "koi8-r") || /* from cyrillic */
@@ -76,10 +82,10 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2(
 		strcmp(toname, "koi8-r") &&
 		strcmp(toname, "cp866") &&
 		strcmp(toname, "windows-1251"))
-		return NO;
+		tqmax = TQ_POOR;
 	}
+	return ((LYCharSet_UC[from].UChndl >= 0) ? tqmax : tqmin);
     }
-    return (LYCharSet_UC[from].UChndl >= 0);
 }
 
 /* Returns YES if no tranlation necessary (because charsets
diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl
index 0f6b6030..dcbb2f01 100644
--- a/src/chrtrans/def7_uni.tbl
+++ b/src/chrtrans/def7_uni.tbl
@@ -414,7 +414,7 @@ U+03e1:p3
 U+03f4:'%
 U+03f5:j3
 # Cyrillic capital letters
-0x6e	U+0401
+0x65	U+0401
 U+0402:D%
 U+0403:G%
 U+0404:IE
@@ -1301,10 +1301,14 @@ U+208b:_-
 U+208c:_=
 U+208d:(
 U+208e:)
+# Old euro currency sign glyph:
+U+20A0:CE
 U+20a3:Ff
 U+20a4:Li
 U+20a7:Pt
 U+20a9:W=
+# New euro currency sign glyph ?
+# U+20AC:EUR
 U+2103:oC
 U+2105:c/o
 U+2109:oF
@@ -1314,6 +1318,7 @@ U+211e:Rx
 U+2120:(SM)
 U+2122:(TM)
 U+2126:Ohm
+U+212E:est.
 0x4b	U+212A	# Kelvin sign - K
 U+212b:Ang.
 U+2153: 1/3
@@ -2067,6 +2072,7 @@ U+fef9:lh-
 U+fefa:lh.
 U+fefb:la-
 U+fefc:la.
+# Symbols for C0 and C1 control characters, in case they get through...
 U+0000:NU
 U+0001:SH
 U+0002:SX
@@ -2132,6 +2138,7 @@ U+009c:ST
 U+009d:OC
 U+009e:PM
 U+009f:AC
+# Unassigned stuff in private zone (?)
 U+e000:"3
 U+e001:"1
 U+e002:"!
diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos
new file mode 100644
index 00000000..6a99e87f
--- /dev/null
+++ b/src/chrtrans/makefile.dos
@@ -0,0 +1,92 @@
+#
+# Makefile for the makeuctb and unicode tables
+# for use with DJGPP.
+#
+# Type make to build makeuctb  and all character translation maps.
+# Type make fontmap to build makeuctb and translation map iso8859-1.
+# Type make makeuctb.exe to build makeuctb only.
+# Type make clean to remove makeuctb and character translation maps.
+# Type make distclean to remove makeuctb, character translation maps
+# and .bak files.
+#
+CFLAGS = $(MCFLAGS)
+
+CC = gcc
+MCFLAGS = -O3 -DEXP_CHARTRANS -DDOSPATH -DNO_TTYTYP \
+-I../../WWW/library/implement -I../../djgpp/tcplib/include \
+-I../../djgpp/tcplib/include/tcp
+
+.SUFFIXES: .tbl
+#
+# This file contains the font map for the default (hardware) font
+#
+
+FONTMAP_INC = iso01_un.h
+
+CHRTR=
+
+TABLES= $(CHRTR)iso01_un.h \
+ $(CHRTR)iso02_un.h \
+ $(CHRTR)def7_uni.h \
+ $(CHRTR)iso03_un.h \
+ $(CHRTR)iso04_un.h \
+ $(CHRTR)iso05_un.h \
+ $(CHRTR)iso06_un.h \
+ $(CHRTR)iso07_un.h \
+ $(CHRTR)iso08_un.h \
+ $(CHRTR)iso09_un.h \
+ $(CHRTR)iso10_un.h \
+ $(CHRTR)koi8r_un.h \
+ $(CHRTR)cp437_un.h \
+ $(CHRTR)cp850_un.h \
+ $(CHRTR)cp852_un.h \
+ $(CHRTR)cp866_un.h \
+ $(CHRTR)cp1250_u.h \
+ $(CHRTR)cp1251_u.h \
+ $(CHRTR)cp1252_u.h \
+ $(CHRTR)viscii_u.h \
+ $(CHRTR)utf8_uni.h \
+ $(CHRTR)rfc_suni.h \
+ $(CHRTR)mnemonic.h \
+ $(CHRTR)mnem_sun.h
+
+default: $(TABLES)
+
+fontmap: $(FONTMAP_INC)
+
+makeuctb.exe: makeuctb.c UCkd.h
+	$(CC) $(CFLAGS) -o makeuctb.exe makeuctb.c
+	strip makeuctb.exe
+
+.tbl.h:
+	./makeuctb $*.tbl > $@
+
+iso01_un.h: iso01_un.tbl makeuctb.exe
+iso02_un.h: iso02_un.tbl makeuctb.exe
+def7_uni.h: def7_uni.tbl makeuctb.exe
+iso03_un.h: iso03_un.tbl makeuctb.exe
+iso04_un.h: iso04_un.tbl makeuctb.exe
+iso05_un.h: iso05_un.tbl makeuctb.exe
+iso06_un.h: iso06_un.tbl makeuctb.exe
+iso07_un.h: iso07_un.tbl makeuctb.exe
+iso08_un.h: iso08_un.tbl makeuctb.exe
+iso09_un.h: iso09_un.tbl makeuctb.exe
+iso10_un.h: iso10_un.tbl makeuctb.exe
+koi8r_un.h: koi8r_un.tbl makeuctb.exe
+cp437_un.h: cp437_un.tbl makeuctb.exe
+cp850_un.h: cp850_un.tbl makeuctb.exe
+cp852_un.h: cp852_un.tbl makeuctb.exe
+cp1250_u.h: cp1250_u.tbl makeuctb.exe
+cp1251_u.h: cp1251_u.tbl makeuctb.exe
+cp1252_u.h: cp1252_u.tbl makeuctb.exe
+utf8_uni.h: utf8_uni.tbl makeuctb.exe
+mnemonic.h: mnemonic.tbl makeuctb.exe
+mnem_sun.h: mnem_sun.tbl makeuctb.exe
+rfc_suni.h: rfc_suni.tbl makeuctb.exe
+
+clean:
+	rm -f makeuctb.exe makeuctb *.o *un.h *u.h *c.h *i.h
+
+distclean: clean
+	-rm -f *.bak
+
diff --git a/test/ALT88592.html b/test/ALT88592.html
new file mode 100644
index 00000000..8a8d8d1a
--- /dev/null
+++ b/test/ALT88592.html
@@ -0,0 +1,170 @@
+<HTML>
+<HEAD>
+<TITLE>Character table modified and enhanced for iso8859-2 - ALT test</TITLE>
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">
+<LINK REV="made" HREF="mailto:kweide@tezcat.com">
+<LINK REV="owner" HREF="http://www.flora.org/lynx-dev/">
+<!-- A BASE tag for the SRC attributes of dummy images.
+     They should be inaccessible so that the ALT text will be shown in graphical browsers.
+     Use file: to save network resources. -->
+<BASE HREF="file://localhost/this.path.intentionally.invalid/">
+</HEAD>
+
+<BODY> 
+
+<H1 ALIGN=center>iso8859-2 plus table - ALT test</H1> 
+
+<PRE>
+Description                               Code            Entity name   
+===================================       ============    ==============
+quotation mark                           <IMG SRC=X ALT=" &amp;#34;  --> &#34;     &amp;quot;   --> &quot;">
+ampersand                                <IMG SRC=X ALT=" &amp;#38;  --> &#38;     &amp;amp;    --> &amp;">
+less-than sign                           <IMG SRC=X ALT=" &amp;#60;  --> &#60;     &amp;lt;     --> &lt;">
+greater-than sign                        <IMG SRC=X ALT=" &amp;#62;  --> &#62;     &amp;gt;     --> &gt;">
+
+Description                          Char Code            Entity name   
+===================================  ==== ============    ==============
+non-breaking space                  <IMG SRC=X ALT="      &amp;#160; --> &#160;    &amp;nbsp;   --> &nbsp;">
+capital A, ogonek                   <IMG SRC=X ALT=" ¡    &amp;#260; --> &#260;    &amp;Aogon;  --> &Aogon;">
+breve                              <IMG SRC=X ALT=" {¢}  {&amp;#728;}-->{&#728;}  {&amp;breve;} -->{&breve;}">
+capital L, stroke                   <IMG SRC=X ALT=" £    &amp;#321; --> &#321;    &amp;Lstrok; --> &Lstrok;">
+general currency sign               <IMG SRC=X ALT=" ¤    &amp;#164; --> &#164;    &amp;curren; --> &curren;">
+capital L, caron                    <IMG SRC=X ALT=" ¥    &amp;#317; --> &#317;    &amp;Lcaron; --> &Lcaron;">
+capital S, acute accent             <IMG SRC=X ALT=" ¦    &amp;#346; --> &#346;    &amp;Sacute; --> &Sacute;">
+section sign                        <IMG SRC=X ALT=" §    &amp;#167; --> &#167;    &amp;sect;   --> &sect;">
+umlaut (dieresis)                   <IMG SRC=X ALT=" ¨    &amp;#168; --> &#168;    &amp;uml;    --> &uml;">
+                                                         <IMG SRC=X ALT=" &amp;die;    --> &die;">
+capital S, caron                    <IMG SRC=X ALT=" ©    &amp;#352; --> &#352;    &amp;Scaron; --> &Scaron;">
+capital S, cedilla                  <IMG SRC=X ALT=" ª    &amp;#350; --> &#350;    &amp;Scedil; --> &Scedil;">
+capital T, caron                    <IMG SRC=X ALT=" «    &amp;#356; --> &#356;    &amp;Tcaron; --> &Tcaron;">
+capital Z, acute accent             <IMG SRC=X ALT=" ¬    &amp;#377; --> &#377;    &amp;Zacute; --> &Zacute;">
+soft hyphen                        <IMG SRC=X ALT=" [­]  [&amp;#173;]-->[&#173;]  [&amp;shy;]   -->[&shy;]">
+capital Z, caron                    <IMG SRC=X ALT=" ®    &amp;#381; --> &#381;    &amp;Zcaron; --> &Zcaron;">
+capital Z, dot above                <IMG SRC=X ALT=" ¯    &amp;#379; --> &#379;    &amp;Zdot;   --> &Zdot;">
+degree sign                         <IMG SRC=X ALT=" °    &amp;#176; --> &#176;    &amp;deg;    --> &deg;">
+small a, ogonek                     <IMG SRC=X ALT=" ±    &amp;#261; --> &#261;    &amp;aogon;  --> &aogon;">
+ogonek                             <IMG SRC=X ALT=" {²}  {&amp;#731;}-->{&#731;}  {&amp;ogon;}  -->{&ogon;}">
+small l, stroke                     <IMG SRC=X ALT=" ³    &amp;#322; --> &#322;    &amp;lstrok; --> &lstrok;">
+acute accent                        <IMG SRC=X ALT=" ´    &amp;#180; --> &#180;    &amp;acute;  --> &acute;">
+small l, caron                      <IMG SRC=X ALT=" µ    &amp;#318; --> &#318;    &amp;lcaron; --> &lcaron;">
+small s, acute accent               <IMG SRC=X ALT=" ¶    &amp;#347; --> &#347;    &amp;sacute; --> &sacute;">
+caron                              <IMG SRC=X ALT=" {·}  {&amp;#711;}-->{&#711;}  {&amp;caron;} -->{&caron;}">
+cedilla                             <IMG SRC=X ALT=" ¸    &amp;#184; --> &#184;    &amp;cedil;  --> &cedil;">
+small s, caron                      <IMG SRC=X ALT=" ¹    &amp;#353; --> &#353;    &amp;scaron; --> &scaron;">
+small s, cedilla                    <IMG SRC=X ALT=" º    &amp;#351; --> &#351;    &amp;scedil; --> &scedil;">
+small t, caron                      <IMG SRC=X ALT=" »    &amp;#357; --> &#357;    &amp;tcaron; --> &tcaron;">
+small z, acute accent               <IMG SRC=X ALT=" ¼    &amp;#378; --> &#378;    &amp;zacute; --> &zacute;">
+double acute accent                <IMG SRC=X ALT=" {½}  {&amp;#733;}-->{&#733;}  {&amp;dblac;} -->{&dblac;}">
+small z, caron                      <IMG SRC=X ALT=" ¾    &amp;#382; --> &#382;    &amp;zcaron; --> &zcaron;">
+small z, dot above                  <IMG SRC=X ALT=" ¿    &amp;#380; --> &#380;    &amp;zdot;   --> &zdot;  ">
+capital R, acute accent             <IMG SRC=X ALT=" À    &amp;#340; --> &#340;    &amp;Racute; --> &Racute;">
+capital A, acute accent             <IMG SRC=X ALT=" Á    &amp;#193; --> &#193;    &amp;Aacute; --> &Aacute;">
+capital A, circumflex accent        <IMG SRC=X ALT=" Â    &amp;#194; --> &#194;    &amp;Acirc;  --> &Acirc;">
+capital A, breve                    <IMG SRC=X ALT=" Ã    &amp;#258; --> &#258;    &amp;Abreve; --> &Abreve;">
+capital A, dieresis or umlaut mark  <IMG SRC=X ALT=" Ä    &amp;#196; --> &#196;    &amp;Auml;   --> &Auml;">
+capital L, acute accent             <IMG SRC=X ALT=" Å    &amp;#313; --> &#313;    &amp;Lacute; --> &Lacute;">
+capital C, acute accent             <IMG SRC=X ALT=" Æ    &amp;#262; --> &#262;    &amp;Cacute; --> &Cacute;">
+capital C, cedilla                  <IMG SRC=X ALT=" Ç    &amp;#199; --> &#199;    &amp;Ccedil; --> &Ccedil;">
+capital C, caron                    <IMG SRC=X ALT=" È    &amp;#268; --> &#268;    &amp;Ccaron; --> &Ccaron;">
+capital E, acute accent             <IMG SRC=X ALT=" É    &amp;#201; --> &#201;    &amp;Eacute; --> &Eacute;">
+capital E, ogonek                   <IMG SRC=X ALT=" Ê    &amp;#280; --> &#280;    &amp;Eogon;  --> &Eogon;">
+capital E, dieresis or umlaut mark  <IMG SRC=X ALT=" Ë    &amp;#203; --> &#203;    &amp;Euml;   --> &Euml;">
+capital E, caron                    <IMG SRC=X ALT=" Ì    &amp;#282; --> &#282;    &amp;Ecaron; --> &Ecaron;">
+capital I, acute accent             <IMG SRC=X ALT=" Í    &amp;#205; --> &#205;    &amp;Iacute; --> &Iacute;">
+capital I, circumflex accent        <IMG SRC=X ALT=" Î    &amp;#206; --> &#206;    &amp;Icirc;  --> &Icirc;">
+capital D, caron                    <IMG SRC=X ALT=" Ï    &amp;#270; --> &#270;    &amp;Dcaron; --> &Dcaron;">
+capital D, stroke                   <IMG SRC=X ALT=" Ð    &amp;#272; --> &#272;    &amp;Dstrok; --> &Dstrok;">
+capital Eth, Icelandic              <IMG SRC=X ALT=" N/A  &amp;#208; --> &#208;    &amp;ETH;    --> &ETH;">
+capital N, acute accent             <IMG SRC=X ALT=" Ñ    &amp;#323; --> &#323;    &amp;Nacute; --> &Nacute;">
+capital N, caron                    <IMG SRC=X ALT=" Ò    &amp;#327; --> &#327;    &amp;Ncaron; --> &Ncaron;">
+capital O, acute accent             <IMG SRC=X ALT=" Ó    &amp;#211; --> &#211;    &amp;Oacute; --> &Oacute;">
+capital O, circumflex accent        <IMG SRC=X ALT=" Ô    &amp;#212; --> &#212;    &amp;Ocirc;  --> &Ocirc;">
+capital O, double acute accent      <IMG SRC=X ALT=" Õ    &amp;#368; --> &#368;    &amp;Odblac; --> &Odblac;">
+capital O, dieresis or umlaut mark  <IMG SRC=X ALT=" Ö    &amp;#214; --> &#214;    &amp;Ouml;   --> &Ouml;">
+multiply sign                       <IMG SRC=X ALT=" ×    &amp;#215; --> &#215;    &amp;times;  --> &times;">
+capital R, caron                    <IMG SRC=X ALT=" Ø    &amp;#344; --> &#344;    &amp;Rcaron; --> &Rcaron;">
+capital U, ring                     <IMG SRC=X ALT=" Ù    &amp;#366; --> &#366;    &amp;Uring;  --> &Uring;">
+capital U, acute accent             <IMG SRC=X ALT=" Ú    &amp;#218; --> &#218;    &amp;Uacute; --> &Uacute;">
+capital U, double acute accent      <IMG SRC=X ALT=" Û    &amp;#368; --> &#368;    &amp;Udblac; --> &Udblac;">
+capital U, dieresis or umlaut mark  <IMG SRC=X ALT=" Ü    &amp;#220; --> &#220;    &amp;Uuml;   --> &Uuml;">
+capital Y, acute accent             <IMG SRC=X ALT=" Ý    &amp;#221; --> &#221;    &amp;Yacute; --> &Yacute;">
+capital T, cedilla                  <IMG SRC=X ALT=" Þ    &amp;#354; --> &#354;    &amp;Tcedil; --> &Tcedil;">
+small sharp s, German (sz ligature) <IMG SRC=X ALT=" ß    &amp;#223; --> &#223;    &amp;szlig;  --> &szlig;">
+small r, acute accent               <IMG SRC=X ALT=" à    &amp;#341; --> &#341;    &amp;racute; --> &racute;">
+small a, acute accent               <IMG SRC=X ALT=" á    &amp;#225; --> &#225;    &amp;aacute; --> &aacute;">
+small a, circumflex accent          <IMG SRC=X ALT=" â    &amp;#226; --> &#226;    &amp;acirc;  --> &acirc;">
+small a, breve                      <IMG SRC=X ALT=" ã    &amp;#259; --> &#259;    &amp;abreve; --> &abreve;">
+small a, dieresis or umlaut mark    <IMG SRC=X ALT=" ä    &amp;#228; --> &#228;    &amp;auml;   --> &auml;">
+small l, acute accent               <IMG SRC=X ALT=" å    &amp;#314; --> &#314;    &amp;lacute; --> &lacute;">
+small c, acute accent               <IMG SRC=X ALT=" æ    &amp;#263; --> &#263;    &amp;cacute; --> &cacute;">
+small c, cedilla                    <IMG SRC=X ALT=" ç    &amp;#231; --> &#231;    &amp;ccedil; --> &ccedil;">
+small c, caron                      <IMG SRC=X ALT=" è    &amp;#269; --> &#269;    &amp;ccaron; --> &ccaron;">
+small e, acute accent               <IMG SRC=X ALT=" é    &amp;#233; --> &#233;    &amp;eacute; --> &eacute;">
+small e, ogonek                     <IMG SRC=X ALT=" ê    &amp;#281; --> &#281;    &amp;eogon;  --> &eogon;">
+small e, dieresis or umlaut mark    <IMG SRC=X ALT=" ë    &amp;#235; --> &#235;    &amp;euml;   --> &euml;">
+small e, caron                      <IMG SRC=X ALT=" ì    &amp;#283; --> &#283;    &amp;ecaron; --> &ecaron;">
+small i, acute accent               <IMG SRC=X ALT=" í    &amp;#237; --> &#237;    &amp;iacute; --> &iacute;">
+small i, circumflex accent          <IMG SRC=X ALT=" î    &amp;#238; --> &#238;    &amp;icirc;  --> &icirc;">
+small d, caron                      <IMG SRC=X ALT=" ï    &amp;#271; --> &#271;    &amp;dcaron; --> &dcaron;">
+small d, stroke                     <IMG SRC=X ALT=" ð    &amp;#273; --> &#273;    &amp;dstrok; --> &dstrok;">
+small eth, Icelandic                <IMG SRC=X ALT=" N/A  &amp;#240; --> &#240;    &amp;eth;    --> &eth;">
+small n, acute accent               <IMG SRC=X ALT=" ñ    &amp;#324; --> &#324;    &amp;nacute; --> &nacute;">
+small n, caron                      <IMG SRC=X ALT=" ò    &amp;#328; --> &#328;    &amp;ncaron; --> &ncaron;">
+small o, acute accent               <IMG SRC=X ALT=" ó    &amp;#243; --> &#243;    &amp;oacute; --> &oacute;">
+small o, circumflex accent          <IMG SRC=X ALT=" ô    &amp;#244; --> &#244;    &amp;ocirc;  --> &ocirc;">
+small o, double acute accent        <IMG SRC=X ALT=" õ    &amp;#369; --> &#369;    &amp;odblac; --> &odblac;">
+small o, dieresis or umlaut mark    <IMG SRC=X ALT=" ö    &amp;#246; --> &#246;    &amp;ouml;   --> &ouml;">
+division sign                       <IMG SRC=X ALT=" ÷    &amp;#247; --> &#247;    &amp;divide; --> &divide;">
+small r, caron                      <IMG SRC=X ALT=" ø    &amp;#345; --> &#345;    &amp;rcaron; --> &rcaron;">
+small u, ring                       <IMG SRC=X ALT=" ù    &amp;#367; --> &#367;    &amp;uring;  --> &uring;">
+small u, acute accent               <IMG SRC=X ALT=" ú    &amp;#250; --> &#250;    &amp;uacute; --> &uacute;">
+small u, double acute accent        <IMG SRC=X ALT=" û    &amp;#369; --> &#369;    &amp;udblac; --> &udblac;">
+small u, dieresis or umlaut mark    <IMG SRC=X ALT=" ü    &amp;#252; --> &#252;    &amp;uuml;   --> &uuml;">
+small y, acute accent               <IMG SRC=X ALT=" ý    &amp;#253; --> &#253;    &amp;yacute; --> &yacute;">
+small t, cedilla                    <IMG SRC=X ALT=" þ    &amp;#355; --> &#355;    &amp;tcedil; --> &tcedil;">
+dot above                          <IMG SRC=X ALT=" {ÿ}  {&amp;#729;}-->{&#729;}  {&amp;dot;}   -->{&dot;}">
+
+Some other characters of interest    Char Code            Entity name   
+===================================  ==== ============    ==============
+capital AE diphthong (ligature)     <IMG SRC=X ALT=" N/A  &amp;#198; --> &#198;    &amp;AElig;  --> &AElig;">
+small ae diphthong (ligature)       <IMG SRC=X ALT=" N/A  &amp;#230; --> &#230;    &amp;aelig;  --> &aelig;">
+capital OE ligature                 <IMG SRC=X ALT=" N/A {&amp;#338;}-->{&#338;}  {&amp;OElig;} -->{&OElig;}">
+small oe ligature                   <IMG SRC=X ALT=" N/A {&amp;#339;}-->{&#339;}  {&amp;oelig;} -->{&oelig;}">
+copyright                           <IMG SRC=X ALT=" N/A  &amp;#169; --> &#169;    &amp;copy;   --> &copy;">
+registered trademark                <IMG SRC=X ALT=" N/A  &amp;#174; --> &#174;    &amp;reg;    --> &reg;">
+trademark sign                      <IMG SRC=X ALT=" N/A  &amp;#8482;--> &#8482;   &amp;trade;  --> &trade;">
+em space                            <IMG SRC=X ALT=" N/A [&amp;#8195;]->[&#8195;] [&amp;emsp;]  -->[&emsp;]">
+en space                            <IMG SRC=X ALT=" N/A [&amp;#8194;]->[&#8194;] [&amp;ensp;]  -->[&ensp;]">
+1/3-em space                        <IMG SRC=X ALT=" N/A [&amp;#8196;]->[&#8196;] [&amp;emsp3;] -->[&emsp3;]">
+1/4-em space                        <IMG SRC=X ALT=" N/A [&amp;#8197;]->[&#8197;] [&amp;emsp4;] -->[&emsp4;]">
+thin space                          <IMG SRC=X ALT=" N/A [&amp;#8201;]->[&#8201;] [&amp;thinsp;]-->[&thinsp;]">
+hair space                          <IMG SRC=X ALT=" N/A [&amp;#8202;]->[&#8202;] [&amp;hairsp;]-->[&hairsp;]">
+em dash                             <IMG SRC=X ALT=" N/A [&amp;#8212;]->[&#8212;] [&amp;mdash;] -->[&mdash;]">
+en dash                             <IMG SRC=X ALT=" N/A [&amp;#8211;]->[&#8211;] [&amp;ndash;] -->[&ndash;]">
+
+</PRE><!-- </PRE> no HotJava preBeta hackx - kw -->
+<!-- second /PRE is a hack for HotJava 1.0 preBeta 1 -->
+<HR>
+<P>
+Characters not found in ISO-8859-2 have "N/A" in the <TT>Char</TT> column.
+Some characters for which I could not find entity names in either 
+<A HREF="http://www.internic.net/rfc/rfc2070.txt">RFC 2070</A>
+or the 
+<A HREF="ftp://www.ucc.ie/pub/sgml/">ISOlat1, ISOlat2, ISOnum, ISOpub and ISOtech</A> 
+sets (the ones included by Peter Flynn's
+<A HREF="http://www.ucc.ie/doc/www/html/dtds/htmlpro.html">HTML Pro DTD</A>)
+are shown enclosed in <TT>{</TT>braces<TT>}</TT>.
+</P>
+<P>
+See Martin Ramsch's original
+<A CHARSET="iso-8859-1" HREF="http://www.uni-passau.de/~ramsch/iso8859-1.html">ISO-8859-1 Table</A>
+for related info and links, and for some notes on entity names.  
+This file is mostly just an adaptation of his table 
+to the ISO-8859-2 character set.
+
+<HR>
+
+<ADDRESS>kweide@tezcat.com 1997-03-09</ADDRESS>
+
+</BODY>
+</HTML>
diff --git a/test/iso88592.html b/test/iso88592.html
new file mode 100644
index 00000000..c25749eb
--- /dev/null
+++ b/test/iso88592.html
@@ -0,0 +1,173 @@
+<!-- X-URL: http://www.uni-passau.de/~ramsch/iso8859-1.html -->
+<HTML>
+<HEAD>
+<TITLE>Martin Ramsch's character table modified and enhanced for iso8859-2</TITLE>
+<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">
+<LINK REV="made" HREF="mailto:kweide@tezcat.com">
+<LINK REV="owner" HREF="http://www.flora.org/lynx-dev/">
+<LINK REL="sibling" HREF="iso8859-1.html" TITLE="iso-8859-1 test">
+<LINK REL="sibling" HREF="ALT88592.html"  TITLE="iso-8859-2 ALT test">
+</HEAD>
+
+<BODY> 
+
+<H1 ALIGN=center>iso8859-2 plus table</H1> 
+
+<PRE>
+Description                               Code            Entity name   
+===================================       ============    ==============
+quotation mark                            &amp;#34;  --> &#34;     &amp;quot;   --> &quot;
+ampersand                                 &amp;#38;  --> &#38;     &amp;amp;    --> &amp;
+less-than sign                            &amp;#60;  --> &#60;     &amp;lt;     --> &lt;
+greater-than sign                         &amp;#62;  --> &#62;     &amp;gt;     --> &gt;
+
+Description                          Char Code            Entity name   
+===================================  ==== ============    ==============
+non-breaking space                        &amp;#160; --> &#160;    &amp;nbsp;   --> &nbsp;
+capital A, ogonek                    ¡    &amp;#260; --> &#260;    &amp;Aogon;  --> &Aogon;
+breve                               {¢}  {&amp;#728;}-->{&#728;}  {&amp;breve;} -->{&breve;}
+capital L, stroke                    £    &amp;#321; --> &#321;    &amp;Lstrok; --> &Lstrok;
+general currency sign                ¤    &amp;#164; --> &#164;    &amp;curren; --> &curren;
+capital L, caron                     ¥    &amp;#317; --> &#317;    &amp;Lcaron; --> &Lcaron;
+capital S, acute accent              ¦    &amp;#346; --> &#346;    &amp;Sacute; --> &Sacute;
+section sign                         §    &amp;#167; --> &#167;    &amp;sect;   --> &sect;
+umlaut (dieresis)                    ¨    &amp;#168; --> &#168;    &amp;uml;    --> &uml;
+                                                          &amp;die;    --> &die;
+capital S, caron                     ©    &amp;#352; --> &#352;    &amp;Scaron; --> &Scaron;
+capital S, cedilla                   ª    &amp;#350; --> &#350;    &amp;Scedil; --> &Scedil;
+capital T, caron                     «    &amp;#356; --> &#356;    &amp;Tcaron; --> &Tcaron;
+capital Z, acute accent              ¬    &amp;#377; --> &#377;    &amp;Zacute; --> &Zacute;
+soft hyphen                         [­]  [&amp;#173;]-->[&#173;]  [&amp;shy;]   -->[&shy;]
+capital Z, caron                     ®    &amp;#381; --> &#381;    &amp;Zcaron; --> &Zcaron;
+capital Z, dot above                 ¯    &amp;#379; --> &#379;    &amp;Zdot;   --> &Zdot;
+degree sign                          °    &amp;#176; --> &#176;    &amp;deg;    --> &deg;
+small a, ogonek                      ±    &amp;#261; --> &#261;    &amp;aogon;  --> &aogon;
+ogonek                              {²}  {&amp;#731;}-->{&#731;}  {&amp;ogon;}  -->{&ogon;}
+small l, stroke                      ³    &amp;#322; --> &#322;    &amp;lstrok; --> &lstrok;
+acute accent                         ´    &amp;#180; --> &#180;    &amp;acute;  --> &acute;
+small l, caron                       µ    &amp;#318; --> &#318;    &amp;lcaron; --> &lcaron;
+small s, acute accent                ¶    &amp;#347; --> &#347;    &amp;sacute; --> &sacute;
+caron                               {·}  {&amp;#711;}-->{&#711;}  {&amp;caron;} -->{&caron;}
+cedilla                              ¸    &amp;#184; --> &#184;    &amp;cedil;  --> &cedil;
+small s, caron                       ¹    &amp;#353; --> &#353;    &amp;scaron; --> &scaron;
+small s, cedilla                     º    &amp;#351; --> &#351;    &amp;scedil; --> &scedil;
+small t, caron                       »    &amp;#357; --> &#357;    &amp;tcaron; --> &tcaron;
+small z, acute accent                ¼    &amp;#378; --> &#378;    &amp;zacute; --> &zacute;
+double acute accent                 {½}  {&amp;#733;}-->{&#733;}  {&amp;dblac;} -->{&dblac;}
+small z, caron                       ¾    &amp;#382; --> &#382;    &amp;zcaron; --> &zcaron;
+small z, dot above                   ¿    &amp;#380; --> &#380;    &amp;zdot;   --> &zdot;  
+capital R, acute accent              À    &amp;#340; --> &#340;    &amp;Racute; --> &Racute;
+capital A, acute accent              Á    &amp;#193; --> &#193;    &amp;Aacute; --> &Aacute;
+capital A, circumflex accent         Â    &amp;#194; --> &#194;    &amp;Acirc;  --> &Acirc;
+capital A, breve                     Ã    &amp;#258; --> &#258;    &amp;Abreve; --> &Abreve;
+capital A, dieresis or umlaut mark   Ä    &amp;#196; --> &#196;    &amp;Auml;   --> &Auml;
+capital L, acute accent              Å    &amp;#313; --> &#313;    &amp;Lacute; --> &Lacute;
+capital C, acute accent              Æ    &amp;#262; --> &#262;    &amp;Cacute; --> &Cacute;
+capital C, cedilla                   Ç    &amp;#199; --> &#199;    &amp;Ccedil; --> &Ccedil;
+capital C, caron                     È    &amp;#268; --> &#268;    &amp;Ccaron; --> &Ccaron;
+capital E, acute accent              É    &amp;#201; --> &#201;    &amp;Eacute; --> &Eacute;
+capital E, ogonek                    Ê    &amp;#280; --> &#280;    &amp;Eogon;  --> &Eogon;
+capital E, dieresis or umlaut mark   Ë    &amp;#203; --> &#203;    &amp;Euml;   --> &Euml;
+capital E, caron                     Ì    &amp;#282; --> &#282;    &amp;Ecaron; --> &Ecaron;
+capital I, acute accent              Í    &amp;#205; --> &#205;    &amp;Iacute; --> &Iacute;
+capital I, circumflex accent         Î    &amp;#206; --> &#206;    &amp;Icirc;  --> &Icirc;
+capital D, caron                     Ï    &amp;#270; --> &#270;    &amp;Dcaron; --> &Dcaron;
+capital D, stroke                    Ð    &amp;#272; --> &#272;    &amp;Dstrok; --> &Dstrok;
+capital Eth, Icelandic               N/A  &amp;#208; --> &#208;    &amp;ETH;    --> &ETH;
+capital N, acute accent              Ñ    &amp;#323; --> &#323;    &amp;Nacute; --> &Nacute;
+capital N, caron                     Ò    &amp;#327; --> &#327;    &amp;Ncaron; --> &Ncaron;
+capital O, acute accent              Ó    &amp;#211; --> &#211;    &amp;Oacute; --> &Oacute;
+capital O, circumflex accent         Ô    &amp;#212; --> &#212;    &amp;Ocirc;  --> &Ocirc;
+capital O, double acute accent       Õ    &amp;#368; --> &#368;    &amp;Odblac; --> &Odblac;
+capital O, dieresis or umlaut mark   Ö    &amp;#214; --> &#214;    &amp;Ouml;   --> &Ouml;
+multiply sign                        ×    &amp;#215; --> &#215;    &amp;times;  --> &times;
+capital R, caron                     Ø    &amp;#344; --> &#344;    &amp;Rcaron; --> &Rcaron;
+capital U, ring                      Ù    &amp;#366; --> &#366;    &amp;Uring;  --> &Uring;
+capital U, acute accent              Ú    &amp;#218; --> &#218;    &amp;Uacute; --> &Uacute;
+capital U, double acute accent       Û    &amp;#368; --> &#368;    &amp;Udblac; --> &Udblac;
+capital U, dieresis or umlaut mark   Ü    &amp;#220; --> &#220;    &amp;Uuml;   --> &Uuml;
+capital Y, acute accent              Ý    &amp;#221; --> &#221;    &amp;Yacute; --> &Yacute;
+capital T, cedilla                   Þ    &amp;#354; --> &#354;    &amp;Tcedil; --> &Tcedil;
+small sharp s, German (sz ligature)  ß    &amp;#223; --> &#223;    &amp;szlig;  --> &szlig;
+small r, acute accent                à    &amp;#341; --> &#341;    &amp;racute; --> &racute;
+small a, acute accent                á    &amp;#225; --> &#225;    &amp;aacute; --> &aacute;
+small a, circumflex accent           â    &amp;#226; --> &#226;    &amp;acirc;  --> &acirc;
+small a, breve                       ã    &amp;#259; --> &#259;    &amp;abreve; --> &abreve;
+small a, dieresis or umlaut mark     ä    &amp;#228; --> &#228;    &amp;auml;   --> &auml;
+small l, acute accent                å    &amp;#314; --> &#314;    &amp;lacute; --> &lacute;
+small c, acute accent                æ    &amp;#263; --> &#263;    &amp;cacute; --> &cacute;
+small c, cedilla                     ç    &amp;#231; --> &#231;    &amp;ccedil; --> &ccedil;
+small c, caron                       è    &amp;#269; --> &#269;    &amp;ccaron; --> &ccaron;
+small e, acute accent                é    &amp;#233; --> &#233;    &amp;eacute; --> &eacute;
+small e, ogonek                      ê    &amp;#281; --> &#281;    &amp;eogon;  --> &eogon;
+small e, dieresis or umlaut mark     ë    &amp;#235; --> &#235;    &amp;euml;   --> &euml;
+small e, caron                       ì    &amp;#283; --> &#283;    &amp;ecaron; --> &ecaron;
+small i, acute accent                í    &amp;#237; --> &#237;    &amp;iacute; --> &iacute;
+small i, circumflex accent           î    &amp;#238; --> &#238;    &amp;icirc;  --> &icirc;
+small d, caron                       ï    &amp;#271; --> &#271;    &amp;dcaron; --> &dcaron;
+small d, stroke                      ð    &amp;#273; --> &#273;    &amp;dstrok; --> &dstrok;
+small eth, Icelandic                 N/A  &amp;#240; --> &#240;    &amp;eth;    --> &eth;
+small n, acute accent                ñ    &amp;#324; --> &#324;    &amp;nacute; --> &nacute;
+small n, caron                       ò    &amp;#328; --> &#328;    &amp;ncaron; --> &ncaron;
+small o, acute accent                ó    &amp;#243; --> &#243;    &amp;oacute; --> &oacute;
+small o, circumflex accent           ô    &amp;#244; --> &#244;    &amp;ocirc;  --> &ocirc;
+small o, double acute accent         õ    &amp;#369; --> &#369;    &amp;odblac; --> &odblac;
+small o, dieresis or umlaut mark     ö    &amp;#246; --> &#246;    &amp;ouml;   --> &ouml;
+division sign                        ÷    &amp;#247; --> &#247;    &amp;divide; --> &divide;
+small r, caron                       ø    &amp;#345; --> &#345;    &amp;rcaron; --> &rcaron;
+small u, ring                        ù    &amp;#367; --> &#367;    &amp;uring;  --> &uring;
+small u, acute accent                ú    &amp;#250; --> &#250;    &amp;uacute; --> &uacute;
+small u, double acute accent         û    &amp;#369; --> &#369;    &amp;udblac; --> &udblac;
+small u, dieresis or umlaut mark     ü    &amp;#252; --> &#252;    &amp;uuml;   --> &uuml;
+small y, acute accent                ý    &amp;#253; --> &#253;    &amp;yacute; --> &yacute;
+small t, cedilla                     þ    &amp;#355; --> &#355;    &amp;tcedil; --> &tcedil;
+dot above                           {ÿ}  {&amp;#729;}-->{&#729;}  {&amp;dot;}   -->{&dot;}
+
+Some other characters of interest    Char Code            Entity name   
+===================================  ==== ============    ==============
+capital AE diphthong (ligature)      N/A  &amp;#198; --> &#198;    &amp;AElig;  --> &AElig;
+small ae diphthong (ligature)        N/A  &amp;#230; --> &#230;    &amp;aelig;  --> &aelig;
+capital OE ligature                  N/A {&amp;#338;}-->{&#338;}  {&amp;OElig;} -->{&OElig;}
+small oe ligature                    N/A {&amp;#339;}-->{&#339;}  {&amp;oelig;} -->{&oelig;}
+copyright                            N/A  &amp;#169; --> &#169;    &amp;copy;   --> &copy;
+registered trademark                 N/A  &amp;#174; --> &#174;    &amp;reg;    --> &reg;
+trademark sign                       N/A  &amp;#8482;--> &#8482;   &amp;trade;  --> &trade;
+em space                             N/A [&amp;#8195;]->[&#8195;] [&amp;emsp;]  -->[&emsp;]
+en space                             N/A [&amp;#8194;]->[&#8194;] [&amp;ensp;]  -->[&ensp;]
+1/3-em space                         N/A [&amp;#8196;]->[&#8196;] [&amp;emsp3;] -->[&emsp3;]
+1/4-em space                         N/A [&amp;#8197;]->[&#8197;] [&amp;emsp4;] -->[&emsp4;]
+thin space                           N/A [&amp;#8201;]->[&#8201;] [&amp;thinsp;]-->[&thinsp;]
+hair space                           N/A [&amp;#8202;]->[&#8202;] [&amp;hairsp;]-->[&hairsp;]
+em dash                              N/A [&amp;#8212;]->[&#8212;] [&amp;mdash;] -->[&mdash;]
+en dash                              N/A [&amp;#8211;]->[&#8211;] [&amp;ndash;] -->[&ndash;]
+
+</PRE><!-- </PRE> no HotJava preBeta hackx - kw -->
+<!-- second /PRE is a hack for HotJava 1.0 preBeta 1 -->
+<HR>
+<P>
+Characters not found in ISO-8859-2 have "N/A" in the <TT>Char</TT> column.
+Some characters for which I could not find entity names in either 
+<A HREF="http://www.internic.net/rfc/rfc2070.txt">RFC 2070</A>
+or the 
+<A HREF="ftp://www.ucc.ie/pub/sgml/">ISOlat1, ISOlat2, ISOnum, ISOpub and ISOtech</A> 
+sets (the ones included by Peter Flynn's
+<A HREF="http://www.ucc.ie/doc/www/html/dtds/htmlpro.html">HTML Pro DTD</A>)
+are shown enclosed in <TT>{</TT>braces<TT>}</TT>.
+</P>
+<P>
+There also is a variation of this table which tests
+<A HREF="ALT88592.html">ISO-8859-2 characters and entities in ALT attributes</A>.
+</P>
+<P>
+See Martin Ramsch's original
+<A CHARSET="iso-8859-1" HREF="http://www.uni-passau.de/~ramsch/iso8859-1.html">ISO-8859-1 Table</A>
+for related info and links, and for some notes on entity names.  
+This file is mostly just an adaptation of his table 
+to the ISO-8859-2 character set.
+</P>
+<HR>
+
+<ADDRESS>kweide@tezcat.com 1997-03-09</ADDRESS>
+
+</BODY>
+</HTML>
diff --git a/utils/inews/Makefile b/utils/inews/Makefile
deleted file mode 100644
index 0380e783..00000000
--- a/utils/inews/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-# Makefile for NN version of mini inews.
-#
-# @RCSfile: Makefile,v @	@Revision: 1.3 @
-#
-# @Author: news @	@Date: 89/12/21 17:59:52 @
-#
-# @State: Exp @	@Locker:  @
-#
-# @Log:	Makefile,v @
-# Revision 1.3  89/12/21  17:59:52  news
-# Added kit processing, cleanups.
-#
-
-TARGET	= inews
-
-BINDIR	= /usr/lib/news/
-SHELL	= /bin/sh
-
-CC	= cc
-# General definitions here which apply to all -- form -DDEF
-DEFS	= -DFOR_NN
-# Link libraries -- form -lLIB
-LIBS	= -lsocket -lnsl -lucb
-# Lint definitions -- same as DEFS, but form -D DEF
-LDEFS	= -D lint -D FOR_NN
-# Lint libraries -- same as LIBS, but form -l LIB
-LLIBS	=
-# Set to -g for debugging, -O for optimise, or both if compiler handles it
-DEBUG	= -O
-CFLAGS	= $(DEBUG) $(DEFS) -I.. -I../conf -L/usr/ucblib
-
-SRCS	= inews.c clientlib.c version.c
-OBJS	= inews.o clientlib.o version.o
-CLUDES	= clientlib.h conf.h nntp.h
-KIT	= Makefile README README.NN $(SRCS) $(CLUDES)
-
-$(TARGET): $(OBJS)
-	$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
-
-$(OBJS):	$(CLUDES)
-
-all:	$(TARGET)
-
-Manifest:	$(KIT)
-	touch Manifest
-	rm -f foo
-	ls -ls Manifest $(KIT) > foo
-	mv foo Manifest
-	ls -ls Manifest $(KIT) > foo
-	mv foo Manifest
-
-kit:	Manifest
-	shar Manifest $(KIT) > inews.shar
-
-clean:
-	rm -f $(OBJS) core lint tags
-
-clobber:	clean
-	rm -f $(TARGET) Make.Log Manifest $(KIT)
-
-lint:	$(SRCS)
-	lint -D lint $(LLIBES) $(LDEFS) $(SRCS) > lint
-
-tags:	$(SRCS)
-	ctags $(SRCS)
-
-install:	$(TARGET)
-	../inst inews $(TARGET)
-#	install -o news -g news -m 511 -s -c $(TARGET) $(BINDIR)
diff --git a/utils/inews/Manifest b/utils/inews/Manifest
deleted file mode 100644
index c3d99bcf..00000000
--- a/utils/inews/Manifest
+++ /dev/null
@@ -1,11 +0,0 @@
-   2 -r--r--r--  1 news         1406 Dec 21 18:00 Makefile
-   1 -rw-r--r--  1 news          649 Dec 21 18:00 Manifest
-   3 -r--r--r--  1 news         2391 Dec 21 18:00 README
-   2 -r--r--r--  1 news         1863 Dec 21 18:00 README.NN
-  11 -r--r--r--  1 news        11154 Dec 21 18:00 clientlib.c
-   1 -r--r--r--  1 news          230 Dec 21 18:00 clientlib.h
-   4 -r--r--r--  1 news         3106 Dec 21 18:00 conf.h
-   8 -r--r--r--  1 news         7983 Dec 21 18:00 inews.c
-   3 -r--r--r--  1 news         2530 Dec 21 18:00 nntp.h
-   3 -r--r--r--  1 news         2167 Dec 21 18:00 uname.c
-   1 -r--r--r--  1 news          103 Dec 21 18:00 version.c
diff --git a/utils/inews/README b/utils/inews/README
deleted file mode 100644
index 1ce496d6..00000000
--- a/utils/inews/README
+++ /dev/null
@@ -1,55 +0,0 @@
-
-     This is a "pseudo" inews which allows remote posting using
-the NNTP server.  Essentially it takes a bunch of arguments and ignores
-ones starting with "-", expecting to find at least one which is
-a file name.  If no files are specified, it uses standard input
-as the input file.
-
-     It then opens a connection to the NNTP server on the remote
-machine and blasts the article across.  It then closes the connection.
-If it doesn't find a From: or Path: line, it inserts them, in the
-default format
-
-	From: login@hostname.DOMAIN (Full_name)
-	Path: hostname!login
-
-where DOMAIN is a #define in ./conf.h, and should be changed to reflect
-your system.  A good choice is "UUCP" if you are not a member of the
-Internet.  "Full_name" understands the & hack in password files. If
-"HIDDENNET" is defined in ./conf.h, DOMAIN is used as the complete host
-name, and the format used is
-
-	From: login@DOMAIN (Full_name)
-	Path: login
-
-     "hostname" is figured out by what you've #defined in ../config.h.
-If you have defined GHNAME, it uses the gethostname() call.
-If you've defined UUNAME, it figured it out from the file
-/etc/uucpname.  Finally, if neither is defined it gets it from
-/usr/include/whoami.h.  If you have GHNAME defined and your
-gethostname() returns your fully-qualified Internet name,
-undefine DOMAIN.
-
-     The point here is that the thing looks like inews to any program
-which would care to post something (e.g., Pnews, postnews, what have
-you).  The difference is that the article will look like it was posted
-on the remote end, not on the local end.  Please note that "postnews"
-(nor any of the other standard news programs) is not required for
-rrn/nntp on client machines.
-
-     The "test*" files in this directory provide some good test
-material for inews; you can just redirect inews to take input from
-them or whatever.
-
-     Thanks to Steven Grady <grady@postgres.berkeley.edu> for
-writing this, and for wasting a lot of his valuable time dealing
-with the can-o'-worms that is the real inews.
-
-BUGS:
-
-     This version of inews doesn't handle real inews options.  As
-a result, some posting programs (notably the Gnumacs front end) will
-fail if they use this program.  In the interests of simplicity, I
-have no plans for modifying mini-inews to handle real-inews options.
-However, if you'd like to send me diffs I'll be more than happy to
-install them for the next release.
diff --git a/utils/inews/README.NN b/utils/inews/README.NN
deleted file mode 100644
index dea4036f..00000000
--- a/utils/inews/README.NN
+++ /dev/null
@@ -1,83 +0,0 @@
-From: Steve Simmons <scs%itivax@relay.EU.net>
-To: storm@texas.dk (Kim F. Storm)
-Date: Thu, 21 Dec 89 18:02:03 EDT
-Subject: Inews Kit For NN
-
-What Is This:
-
-This is a mini-inews, suitable for building client-only versions of NN
-that use NNTP for remote reading.  Some unknown (to me) person patched
-it to be driven on NNs config.h file.  I have taken those changes, reversed
-most of them and upgraded to NNTP release version 1.5.7.  This inews was
-a co-operative venture when Stan released it, and it's kind of fitting
-that it continues to be worked on by many hands.
-
-If you have a full installation of news where you're installing NN,
-you could care less about this.
-
-Copyrights:
-
-See individual files for authors.  I wrote conf.h and the
-Makefile, and explicitly put them in the public domain.  Other parts
-may have other copyrights, see the individual files.
-
-Maintenance:
-
-My less-than-humble opinion is that as Stan releases nntp patches, you will
-be able to apply them to this code with no changes whatsoever.  As Stan
-releases patches I will attempt to apply them and upgrade this source,
-but no guarantees.
-
-Why A Separate Release From NNTP:
-
-NN and NNTP both use configuration files to let you fit the software
-for your system.  Unfortunately, they used rather different methods.
-This release specificly reconciles NNs 'config.h' and NNTPs '../common/conf.h'
-by creating a local "conf.h" which maps 'config.h' to what NNTP inews needs.
-Result -- once you build the config.h for NN you're 98% done with NNTP inews.
-
-INSTALLATION:
-
-Ideally you went to your nn source directory and created a subdir
-named inews.  Then you unpacked this in that directory (I have already
-done that, ++Kim).
-
-All you should need to do is read conf.h, make any changes you feel
-like, and then type 'make'.  If things work, type 'make install'.  For
-more data on the inews itself, read the file README.  It's slightly
-edited from the NNTP version to reflect its separation from the rest
-of NNTP.
-
-For more data on the inews itself, read the file README.  It's
-slightly edited from the NNTP version to reflect its separation from
-the rest of NNTP.
-
-Steve Simmons
-scs@lokkur.dexter.mi.us
-December 21, 1989
-
-
---- Changes by Kim Storm, storm@texas.dk
-
-I have edited what Steve sent me a bit further to simplify the
-configuration and installation even more: It now uses nn's code to get
-the hostname, so this is now got for free, and it gets the location of
-the inews program from config.h as well.
-
-Makefile:
-	Added -I../conf to CFLAGS
-	nn's hostname.o is used instead of uname.o to get the hostname.
-	Installation uses nn's inst script (which will use the possible
-	definition of INEWS or NEWS_LIB_DIRECTORY in config.h).
-
-conf.h:
-	#defines to set the proper hostname removed.
-	#include "../config.h" line moved to start of file.
-	Documents optional #define USG to get bcopy function.
-
-clientlib.c, inews.c
-	Added tweaks using a FOR_NN #define to include/exclude
-	code to co-exist with nn's config.h file.
-
-uname.c:
-	Not used (so it is omitted from this distribution).
diff --git a/utils/inews/clientlib.c b/utils/inews/clientlib.c
deleted file mode 100644
index c06c3b6f..00000000
--- a/utils/inews/clientlib.c
+++ /dev/null
@@ -1,525 +0,0 @@
-#ifndef lint
-static char	*sccsid = "@(#)clientlib.c	1.11	(Berkeley) 10/27/89";
-#endif
-
-/*
- * NNTP client routines.
- */
-
-/*
- * Include configuration parameters only if we're made in the nntp tree.
- */
-
-#ifdef FOR_NN
-#include "conf.h"
-#endif
-
-#ifdef NNTPSRC
-#include "../config.h"
-#endif NNTPSRC
-
-#include <stdio.h>
-#ifndef FOR_NN
-#include <sys/types.h>
-#endif
-#ifdef FOR_NN
-#if !defined(NETWORK_DATABASE) || defined(NETWORK_BYTE_ORDER)
-#include <netinet/in.h>
-#endif
-#else
-#include <netinet/in.h>
-#endif
-#include <sys/socket.h>
-#ifndef EXCELAN
-# include <netdb.h>
-#endif /* !EXCELAN */
-
-#include <string.h>
-
-#ifdef EXCELAN
-# define	IPPORT_NNTP	119
-#endif
-
-#ifdef DECNET
-#include <netdnet/dn.h>
-#include <netdnet/dnetdb.h>
-#endif /* DECNET */
-
-#include "nntp.h"
-
-FILE	*ser_rd_fp = NULL;
-FILE	*ser_wr_fp = NULL;
-
-/*
- * getserverbyfile	Get the name of a server from a named file.
- *			Handle white space and comments.
- *			Use NNTPSERVER environment variable if set.
- *
- *	Parameters:	"file" is the name of the file to read.
- *
- *	Returns:	Pointer to static data area containing the
- *			first non-ws/comment line in the file.
- *			NULL on error (or lack of entry in file).
- *
- *	Side effects:	None.
- */
-
-char *
-getserverbyfile(file)
-char	*file;
-{
-	register FILE	*fp;
-	register char	*cp;
-	static char	buf[256];
-	char		*getenv();
-
-	if (cp = getenv("NNTPSERVER")) {
-		(void) strcpy(buf, cp);
-		return (buf);
-	}
-
-	if (file == NULL)
-		return (NULL);
-
-	fp = fopen(file, "r");
-	if (fp == NULL)
-		return (NULL);
-
-	while (fgets(buf, sizeof (buf), fp) != NULL) {
-		if (*buf == '\n' || *buf == '#')
-			continue;
-		cp = strchr(buf, '\n');
-		if (cp)
-			*cp = '\0';
-		(void) fclose(fp);
-		return (buf);
-	}
-
-	(void) fclose(fp);
-	return (NULL);			 /* No entry */
-}
-
-
-/*
- * server_init  Get a connection to the remote news server.
- *
- *	Parameters:	"machine" is the machine to connect to.
- *
- *	Returns:	-1 on error
- *			server's initial response code on success.
- *
- *	Side effects:	Connects to server.
- *			"ser_rd_fp" and "ser_wr_fp" are fp's
- *			for reading and writing to server.
- */
-
-server_init(machine)
-char	*machine;
-{
-	int	sockt_rd, sockt_wr;
-	char	line[256];
-#ifdef DECNET
-	char	*cp;
-
-	cp = strchr(machine, ':');
-
-	if (cp && cp[1] == ':') {
-		*cp = '\0';
-		sockt_rd = get_dnet_socket(machine);
-	} else
-		sockt_rd = get_tcp_socket(machine);
-#else
-	sockt_rd = get_tcp_socket(machine);
-#endif
-
-	if (sockt_rd < 0)
-		return (-1);
-
-	/*
-	 * Now we'll make file pointers (i.e., buffered I/O) out of
-	 * the socket file descriptor.  Note that we can't just
-	 * open a fp for reading and writing -- we have to open
-	 * up two separate fp's, one for reading, one for writing.
-	 */
-
-	if ((ser_rd_fp = fdopen(sockt_rd, "r")) == NULL) {
-		perror("server_init: fdopen #1");
-		return (-1);
-	}
-
-	sockt_wr = dup(sockt_rd);
-	if ((ser_wr_fp = fdopen(sockt_wr, "w")) == NULL) {
-		perror("server_init: fdopen #2");
-		ser_rd_fp = NULL;		/* from above */
-		return (-1);
-	}
-
-	/* Now get the server's signon message */
-
-	(void) get_server(line, sizeof(line));
-	return (atoi(line));
-}
-
-
-/*
- * get_tcp_socket -- get us a socket connected to the news server.
- *
- *	Parameters:	"machine" is the machine the server is running on.
- *
- *	Returns:	Socket connected to the news server if
- *			all is ok, else -1 on error.
- *
- *	Side effects:	Connects to server.
- *
- *	Errors:		Printed via perror.
- */
-
-get_tcp_socket(machine)
-char	*machine;
-{
-	int	s;
-	struct	sockaddr_in sin;
-#ifndef EXCELAN
-	struct	servent *getservbyname(), *sp;
-	struct	hostent *gethostbyname(), *hp;
-#ifdef h_addr
-	int	x = 0;
-	register char **cp;
-#endif h_addr
-
-	if ((sp = getservbyname("nntp", "tcp")) ==  NULL) {
-		fprintf(stderr, "nntp/tcp: Unknown service.\n");
-		return (-1);
-	}
-
-       /*
-        * Name resolution doesn't quite go as far as it should.  Take things
-        * one stage further to allow nnn.nnn.nnn.nnn addresses if all else
-        * fails.
-        */
-       if( (hp = gethostbyname( machine ) ) == NULL ) {
-               unsigned long inet_addr();
-               static struct hostent def;
-               static struct in_addr defaddr;
-               static char *alist[1];
-               static char namebuf[ 256 ];
-               defaddr.s_addr = inet_addr( machine );
-               if( defaddr.s_addr != -1 ) {
-                       strcpy( namebuf, machine );
-                       def.h_name = namebuf;
-#ifdef h_addr
-                       def.h_addr_list = alist;
-#endif
-                       def.h_addr = (char *)&defaddr;
-                       def.h_length = sizeof( struct in_addr );
-                       def.h_addrtype = AF_INET;
-                       def.h_aliases = 0;
-                       hp = &def;
-               }
-       }
-       if (hp == NULL) {
-		fprintf(stderr, "%s: Unknown host.\n", machine);
-		return (-1);
-	}
-
-	memset((char *) &sin, '\0', sizeof(sin));
-	sin.sin_family = hp->h_addrtype;
-	sin.sin_port = sp->s_port;
-#else
-	memset((char *) &sin, '\0', sizeof(sin));
-	sin.sin_family = AF_INET;
-	sin.sin_port = htons(IPPORT_NNTP);
-#endif /* !EXCELAN */
-
-	/*
-	 * The following is kinda gross.  The name server under 4.3
-	 * returns a list of addresses, each of which should be tried
-	 * in turn if the previous one fails.  However, 4.2 hostent
-	 * structure doesn't have this list of addresses.
-	 * Under 4.3, h_addr is a #define to h_addr_list[0].
-	 * We use this to figure out whether to include the NS specific
-	 * code...
-	 */
-
-#ifdef	h_addr
-
-	/* get a socket and initiate connection -- use multiple addresses */
-
-	for (cp = hp->h_addr_list; cp && *cp; cp++) {
-		s = socket(hp->h_addrtype, SOCK_STREAM, 0);
-		if (s < 0) {
-			perror("socket");
-			return (-1);
-		}
-	        memcpy(*cp, (char *)&sin.sin_addr, hp->h_length);
-
-		if (x < 0)
-			fprintf(stderr, "trying %s\n", inet_ntoa(sin.sin_addr));
-		x = connect(s, (struct sockaddr *)&sin, sizeof (sin));
-		if (x == 0)
-			break;
-                fprintf(stderr, "connection to %s: ", inet_ntoa(sin.sin_addr));
-		perror("");
-		(void) close(s);
-	}
-	if (x < 0) {
-		fprintf(stderr, "giving up...\n");
-		return (-1);
-	}
-#else	/* no name server */
-#ifdef EXCELAN
-	if ((s = rresvport(SO_KEEPALIVE)) < 0)
-	{
-		/* Get the socket */
-		perror("socket");
-		return (-1);
-	}
-	/* set up addr for the connect */
-	sin.sin_addr.s_addr = rhost(machine);
-	if (sin.sin_addr.s_addr < 0){
-		fprintf(stderr, "%s: Unknown host.\n", machine);
-		return (-1);
-	}
-	/* And then connect */
-
-	if (connect(s, &sin) < 0) {
-		perror("connect");
-		(void) close(s);
-		return (-1);
-	}
-#else
-	if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		perror("socket");
-		return (-1);
-	}
-
-	/* And then connect */
-
-	memcpy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
-	if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
-		perror("connect");
-		(void) close(s);
-		return (-1);
-	}
-
-#endif /* !EXCELAN */
-#endif
-
-	return (s);
-}
-
-#ifdef DECNET
-/*
- * get_dnet_socket -- get us a socket connected to the news server.
- *
- *	Parameters:	"machine" is the machine the server is running on.
- *
- *	Returns:	Socket connected to the news server if
- *			all is ok, else -1 on error.
- *
- *	Side effects:	Connects to server.
- *
- *	Errors:		Printed via nerror.
- */
-
-get_dnet_socket(machine)
-char	*machine;
-{
-	int	s, area, node;
-	struct	sockaddr_dn sdn;
-	struct	nodeent *getnodebyname(), *np;
-
-	memset((char *) &sdn, '\0', sizeof(sdn));
-
-	switch (s = sscanf( machine, "%d%*[.]%d", &area, &node )) {
-		case 1:
-			node = area;
-			area = 0;
-		case 2:
-			node += area*1024;
-			sdn.sdn_add.a_len = 2;
-			sdn.sdn_family = AF_DECnet;
-			sdn.sdn_add.a_addr[0] = node % 256;
-			sdn.sdn_add.a_addr[1] = node / 256;
-			break;
-		default:
-			if ((np = getnodebyname(machine)) == NULL) {
-				fprintf(stderr,
-					"%s: Unknown host.\n", machine);
-				return (-1);
-			} else {
-				memcpy(np->n_addr,
-					(char *) sdn.sdn_add.a_addr,
-					np->n_length);
-				sdn.sdn_add.a_len = np->n_length;
-				sdn.sdn_family = np->n_addrtype;
-			}
-			break;
-	}
-	sdn.sdn_objnum = 0;
-	sdn.sdn_flags = 0;
-	sdn.sdn_objnamel = strlen("NNTP");
-	memcpy("NNTP", &sdn.sdn_objname[0], sdn.sdn_objnamel);
-
-	if ((s = socket(AF_DECnet, SOCK_STREAM, 0)) < 0) {
-		nerror("socket");
-		return (-1);
-	}
-
-	/* And then connect */
-
-	if (connect(s, (struct sockaddr *) &sdn, sizeof(sdn)) < 0) {
-		nerror("connect");
-		close(s);
-		return (-1);
-	}
-
-	return (s);
-}
-#endif
-
-
-
-/*
- * handle_server_response
- *
- *	Print some informative messages based on the server's initial
- *	response code.  This is here so inews, rn, etc. can share
- *	the code.
- *
- *	Parameters:	"response" is the response code which the
- *			server sent us, presumably from "server_init",
- *			above.
- *			"server" is the news server we got the
- *			response code from.
- *
- *	Returns:	-1 if the error is fatal (and we should exit).
- *			0 otherwise.
- *
- *	Side effects:	None.
- */
-
-handle_server_response(response, server)
-int	response;
-char	*server;
-{
-    switch (response) {
-	case OK_NOPOST:		/* fall through */
-    		printf(
-	"NOTE: This machine does not have permission to post articles.\n");
-		printf(
-	"      Please don't waste your time trying.\n\n");
-
-	case OK_CANPOST:
-		return (0);
-		break;
-
-	case ERR_ACCESS:
-		printf(
-   "This machine does not have permission to use the %s news server.\n",
-		server);
-		return (-1);
-		break;
-
-	default:
-		printf("Unexpected response code from %s news server: %d\n",
-			server, response);
-		return (-1);
-		break;
-    }
-	/*NOTREACHED*/
-}
-
-
-/*
- * put_server -- send a line of text to the server, terminating it
- * with CR and LF, as per ARPA standard.
- *
- *	Parameters:	"string" is the string to be sent to the
- *			server.
- *
- *	Returns:	Nothing.
- *
- *	Side effects:	Talks to the server.
- *
- *	Note:		This routine flushes the buffer each time
- *			it is called.  For large transmissions
- *			(i.e., posting news) don't use it.  Instead,
- *			do the fprintf's yourself, and then a final
- *			fflush.
- */
-
-void
-put_server(string)
-char *string;
-{
-#ifdef DEBUG
-	fprintf(stderr, ">>> %s\n", string);
-#endif
-	fprintf(ser_wr_fp, "%s\r\n", string);
-	(void) fflush(ser_wr_fp);
-}
-
-
-/*
- * get_server -- get a line of text from the server.  Strips
- * CR's and LF's.
- *
- *	Parameters:	"string" has the buffer space for the
- *			line received.
- *			"size" is the size of the buffer.
- *
- *	Returns:	-1 on error, 0 otherwise.
- *
- *	Side effects:	Talks to server, changes contents of "string".
- */
-
-get_server(string, size)
-char	*string;
-int	size;
-{
-	register char *cp;
-
-	if (fgets(string, size, ser_rd_fp) == NULL)
-		return (-1);
-
-	if ((cp = strchr(string, '\r')) != NULL)
-		*cp = '\0';
-	else if ((cp = strchr(string, '\n')) != NULL)
-		*cp = '\0';
-#ifdef DEBUG
-	fprintf(stderr, "<<< %s\n", string);
-#endif
-
-	return (0);
-}
-
-
-/*
- * close_server -- close the connection to the server, after sending
- *		the "quit" command.
- *
- *	Parameters:	None.
- *
- *	Returns:	Nothing.
- *
- *	Side effects:	Closes the connection with the server.
- *			You can't use "put_server" or "get_server"
- *			after this routine is called.
- */
-
-void
-close_server()
-{
-	char	ser_line[256];
-
-	if (ser_wr_fp == NULL || ser_rd_fp == NULL)
-		return;
-
-	put_server("QUIT");
-	(void) get_server(ser_line, sizeof(ser_line));
-
-	(void) fclose(ser_wr_fp);
-	(void) fclose(ser_rd_fp);
-}
-
diff --git a/utils/inews/clientlib.h b/utils/inews/clientlib.h
deleted file mode 100644
index 0c1137f7..00000000
--- a/utils/inews/clientlib.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Definitions for NNTP client routines.
- *
- * @(#)clientlib.h	1.1	(Berkeley) 1/9/88
- */
-
-extern	char	*getserverbyfile();
-extern	int	server_init();
-extern	void	put_server();
-extern	int	get_server();
-extern	void	close_server();
diff --git a/utils/inews/conf.h b/utils/inews/conf.h
deleted file mode 100644
index 0e6849dc..00000000
--- a/utils/inews/conf.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Configuration file for nn version of nntp inews.  Written by
- * Steve Simmons (scs@lokkur.dexter.mi.us), Dec 19, 1989.  Placed
- * in the public domain by the author.  This file rationalizes
- * the stock NNTP release of inews with the definitions for NN.
- * The rationalization was done as of NN version 6.3.10 and NNTP
- * version 1.5.7.
- *
- * You must edit this file to reflect your local configuration
- * and environment.
- *
- * Follow the instructions given in the comments.  See the file
- * README for more comments.
- *
- * $RCSfile: conf.h,v $	$Revision: 1.2 $
- *
- * $Author: tom $	$Date: 1997/07/28 00:39:05 $
- *
- * $State: Exp $	$Locker:  $
- *
- * $Log: conf.h,v $
- * Revision 1.2  1997/07/28 00:39:05  tom
- * 2.7.1ac-0.43
- *
- * Revision 1.1  1989/12/20 17:43:03  news
- * v2_6
- *
- * Revision 1.1  89/12/20  17:43:03  news
- * Initial revision
- *
- * May 1st, 1990, Kim Storm
- * Modifications to get hostname for free (see README.NN)
- */
-
-#ifndef	NNINEWSCONF_H
-#define	NNINEWSCONF_H
-
-/* #include	"config.h" */
-/*
- *  added by Montulli@ukanaix.cc.ukans.edu
- *  to replace the need for config.h
- */
-
-#include <stdio.h>
-#include <ctype.h>
-
-
-/*
- *      Define NNTP_SERVER to the name of a file containing the name of the
- *      nntp server.
- *
- *      It is vital that both the nnmaster and all nn users on a machine
- *      uses the same nntp server, because the nn database is synchronized
- *      with a specific news active file.
- *
- *      If the file name does not start with a slash, it is relative to
- *      LIB_DIRECTORY defined below.
- *      NOTE: If you plan to use the included inews, it MUST be a full pathname
- */
-
-#define NNTP_SERVER     "/usr/local/etc/nntpserver"
-/* #define NNTP_SERVER     "/usr/lib/nntp_server" */
-
-
-#ifndef NNTP
-/* WHY DO YOU WANT TO MAKE MINI-INEWS WHEN YOU DONT USE NNTP */
-#endif
-
-/*
- *  Define your local domain name.  You *must* define something, either
- *  here, in config.h, or elsewhere according to your local standards.
- *  See comment below on HIDDENNET.
- *
- *  You are not strictly *required* to have a domain name; nonetheless
- *  it's a good idea.  If you are on the Internet or otherwise have a
- *  valid domain name, use it (except see HIDDENNET below).  If you're
- *  a uucp-only site, use ".uucp" for now and go get a real name.
- *
- *  Note that if you imbed your domain name in the hostname and you don't
- *  use HIDDENNET, you may get a period on the end of your fully qualified
- *  domian name (FQDN) in postings.  In that case, use HIDDENNET and
- *  define DOMAIN to be your FQDN.
- */
-
-#define	DOMAIN	"cc.ukans.edu" 
-
-/*
- *  If you define this, the hostname will not appear in the posting
- *  data except on the path.  Items will be from user@DOMAIN (with
- *  DOMAIN as defined above).  If you don't want this, comment it out.
- */
-
-/* #define	HIDDENNET */
-
-/*
- *  There are a number of ways that inews will try to figure out the
- *  host name.  When used with nn, the definitions in ../config.h
- *  will specify this, so you don't have to do anything special here.
- */
-
-/*
- *  If you don't have bcopy, the following define will make one...
- */
-
-/* #define USG			/* */
-
-/*
- *  You shouldn't need to touch anything below this line.
- */
-
-/*
- *  This is the code needed to get the proper hostname.
- *
- *	nn provides a gethostname function for generic use.
- *	we fake uname() for inews.c using this:
- */
-
-#define	uname(str) gethostname(str, sizeof(str))
-
-/*
- *  Stock nntp inews and nn use some different #define names for the
- *  same general functions.  This synchronises them.
- */
-
-#define	SERVER_FILE	NNTP_SERVER
-
-/*
- *	Reverse engineering (nn got this the other way around)....
- */
-
-#ifdef HAVE_STRCHR
-#define	rindex strrchr
-#define index strchr
-#endif
-
-/*
- *  Sanity checks (You know.  Checks you get from Sanity Claus)
- */
-
-#ifdef	HIDDENNET
-#ifndef	DOMAIN
-YOU_BLEW_IT READ_THE_INSTRUCTIONS_AGAIN
-#endif
-#endif
-
-#endif	/* of ifdef NNINEWSCONF_H */
diff --git a/utils/inews/config.h b/utils/inews/config.h
deleted file mode 100644
index eacc4361..00000000
--- a/utils/inews/config.h
+++ /dev/null
@@ -1,392 +0,0 @@
-
-/**************************** NN CONFIGURATION ***************************
- *
- *      Configuration file for nn.
- *
- *      You must edit this file to reflect your local configuration
- *      and environment.
- *
- *      Before editing this file, read the licence terms in the README
- *      file and the installation guidelines in the INSTALLATION file.
- *
- *      (c) Copyright 1990, Kim F. Storm.  All rights reserved.
- */
-
-#define RELEASE         "6.4"
-
-#include <stdio.h>
-#include <ctype.h>
-
-
-/*********************** NETWORK DEPENDENT DEFINITIONS **********************
- *
- *      Define NETWORK_DATABASE if you share the database through NFS on
- *      a network with different, non-compatible machines, e.g. SUNs and
- *      VAXen, or SUN-3 and SUN-4, or if you are using different compilers
- *      on the same architecture.
- *
- *      In a homogenous network, you can leave it undefined for higher
- *      performance (no data conversion is needed).
- */
-
-/* #define NETWORK_DATABASE     /* */
-
-
-/********************************** NNTP *********************************
- *
- *      Define NNTP to enable nntp support.  If you are not using NNTP,
- *      just leave the following NNTP_* definitions as they are - they
- *      will be ignored anyway.
- *
- *      With NNTP, the nnmaster still maintains a local database of
- *      all article headers for fast access (and because NNTP does not
- *      support nn - yet), while the articles are fetched from the
- *      nntp server when they are read or saved.
- *
- *      You may still share this database through NFS locally (see the
- *      description of NETWORK_DATABASE above) if you don't want to
- *      have separate nn databases on all your local systems.
- *
- *      Consult the file NNTP for further information on the use of NNTP.
- */
-
-/* #define NNTP                 /* */
-
-/*
- *      Define NNTP_SERVER to the name of a file containing the name of the
- *      nntp server.
- *
- *      It is vital that both the nnmaster and all nn users on a machine
- *      uses the same nntp server, because the nn database is synchronized
- *      with a specific news active file.
- *
- *      If the file name does not start with a slash, it is relative to
- *      LIB_DIRECTORY defined below.
- *      NOTE: If you plan to use the included inews, it MUST be a full pathname
- */
-
-#define NNTP_SERVER     "/usr/lib/nntp_server"
-
-/*
- *      Define NNTP_POST if you want nn to reject attempts to post via
- *      NNTP to a server, that disallows postings.
- *
- *      You should define this, if you use the NNTP based mini-inews for
- *      postings from NNTP clients.  If you use another mechanism, that
- *      does not involve NNTP, you should leave it undefined.
- */
-
-#define NNTP_POST             /* */
-
-/*
- *      NNTP's mini-inews seems to require that messages contain a complete
- *      header with Message-ID, Path, and Date fields which the normal inews
- *      generates itself.  If your mini-inews requires these headers to
- *      be present, define NNTP_MINI_INEWS_HEADER below.
- */
-
-#define NNTP_MINI_INEWS_HEADER  /* uses "broken" mini-inews */
-
-/*
- *      Define NNTP_PATH_HOSTNAME to force a specific hostname into the
- *      Path: header generated when NNTP_MINI_INEWS_HEADER is defined.
- *      This is useful for multi-machine sites with one mail/news gateway.
- *
- *      If the string starts with a '/' it is taken as the name of a file
- *      from which the outgoing hostname should be read (at runtime).
- */
-
-/* #define NNTP_PATH_HOSTNAME   "puthostnamehere"       /* */
-
-
-/***************** OPERATING SYSTEM DEPENDENT DEFINITIONS *******************
- *
- *      Include the appropriate s- file for your system below.
- *
- *      If a file does not exist for your system, you can use
- *      conf/s-template.h as a starting point for writing you own.
- */
-
-#include "s-sys5.h"
-
-/*
- *      Define DEFAULT_PAGER as the initial value of the 'pager' variable.
- *      nnadmin pipes shell command output though this command.
- */
-
-#define DEFAULT_PAGER           "pg -n -s"      /* system V */
-/* #define DEFAULT_PAGER        "more"                  /* bsd */
-
-/*
- *      DEFAULT_PRINTER is the initial value of the 'printer' variable.
- *      nn's :print command pipes text into this command.
- */
-
-#define DEFAULT_PRINTER         "lp -s"         /* System V */
-/* #define DEFAULT_PRINTER      "lpr -p -JNEWS" /* bsd */
-
-/*
- *      Define RESIZING to make nn understand dynamic window-resizing.
- *      (It uses the TIOCGWINSZ ioctl found on most 4.3BSD systems)
- */
-
-/* #define RESIZING             /* */
-
-
-/********************** MACHINE DEPENDENT DEFINITIONS **********************
- *
- *      Include the appropriate m- file for your system below.
- *
- *      If a file does not exist for your system, you can use
- *      conf/m-template.h as a starting point for writing you own.
- */
-
-#include "m-m680x0.h"
-
-
-/***************************** OWNERSHIP ***************************
- *
- *      Specify owner and group for installed files and programs.
- *
- *      The nnmaster will run suid/sgid to this owner and group.
- *
- *      The only requirements are that the ownership allows the
- *      nnmaster to READ the news related files and directories, and
- *      the ordinary users to read the database and execute the nn*
- *      programs.
- *
- *      Common choices are:  (news, news)  and   (your uid, your gid)
- */
-
-#define OWNER   "news"
-#define GROUP   "news"
-
-
-/**************************** LOCALIZATION ****************************
- *
- *      Specify where programs and files are installed.
- *
- *      BIN_DIRECTORY    - the location of the user programs (mandatory)
- *
- *      LIB_DIRECTORY    - the location of auxiliary programs and files.
- *                         (mandatory UNLESS ALL of the following are defined).
- *
- *      MASTER_DIRECTORY - the location of the master program (on server)
- *                         (= LIB_DIRECTORY if undefined)
- *
- *      CLIENT_DIRECTORY - the location of auxiliary programs (on clients)
- *                         (= LIB_DIRECTORY if undefined)
- *
- *      HELP_DIRECTORY   - the location of help files, online manual, etc.
- *                         (= CLIENT_DIRECTORY/help if undefined)
- *
- *      CACHE_DIRECTORY  - if NNTP is used, nn uses this central directory
- *                         to store working copies of articles on the local
- *                         system.  If not defined, it stores the articles
- *                         in each user's ~/.nn directory.
- *
- *      TMP_DIRECTORY    - temporary file storage.  Overriden by $TMPDIR.
- *                         (= /usr/tmp if undefined).
- *
- *      LOG_FILE         - the location of nn's log file.
- *                         (= LIB_DIRECTORY/Log if undefined).
- */
-
-#define BIN_DIRECTORY   "/usr/local/bin"
-#define LIB_DIRECTORY   "/usr/local/lib/nn"
-
-
-/**************************** DATABASE LOCATION **************************
- *
- *      Specify where the nn database should be installed.
- *
- *      If none of the following symbols are defined, the database will
- *      be contained in the NEWS_DIRECTORY in a separate .nn directory for
- *      master files and in files named .nnx and .nnd in each group's
- *      spool directory.  To use this scheme, the OWNER specified above
- *      must have write permission on the news spool directories.
- *
- *      If you access news via NNTP, you will probably always have to
- *      give the database directory explicitly through DB_DIRECTORY
- *      (and DB_DATA_DIRECTORY), since the normal news spool directories
- *      are probably not available on the local system.
- *      The exception may be if nnmaster runs directly on the nntp server.
- *
- *      To change the default behaviour, you can define the following
- *      symbols:
- *
- *      DB_DIRECTORY       - the directory containing the master files.
- *
- *      DB_DATA_DIRECTORY  - the directory containing the per-group files
- *                           (default is DB_DIRECTORY/DATA if undefined).
- *
- *      DB_LONG_NAMES      - use group's name rather than number when
- *                           building file names in DB_DATA_DIRECTORY.
- *           (The file system must support long file names!!)
- */
-
-#define DB_DIRECTORY    "/usr/spool/nn"
-
-
-/*************************** NEWS TRANSPORT **************************
- *
- *      Specify the location of your news programs and files
- *      You only need to specify these if you are not
- *      satisfied with the default settings.
- *
- *      NEWS_DIRECTORY          - The news spool directory.
- *                                Default: /usr/spool/news
- *
- *      NEWS_LIB_DIRECTORY      - The news lib directory.
- *                                Default: /usr/lib/news
- *
- *      INEWS_PATH              - The location of the inews program.
- *                                Default: NEWS_LIB_DIR/inews
- *
- *      RMGROUP_PATH            - The location of the rmgroup program.
- *                                Default: NEWS_LIB_DIR/{rm,del}group
- */
-
-#define NEWS_DIRECTORY          "/usr/spool/news"       /* */
-#define NEWS_LIB_DIRECTORY      "/usr/lib/news"         /* */
-
-/* #define INEWS_PATH           "/usr/lib/news/inews"   /* */
-
-
-/*************************** MAIL INTERFACE *************************
- *
- *      Specify a mailer that accepts a letter WITH a header IN THE TEXT.
- *
- *      A program named 'recmail' program is normally delivered with
- *      the Bnews system, or you can use sendmail -t if you have it.
- *
- *      The contrib/ directory contains two programs which you might
- *      be able to use with a little tweaking.
- */
-
-#define REC_MAIL        "/usr/lib/news/recmail" /* non-sendmail */
-/* #define REC_MAIL     "/usr/lib/sendmail -t"  /* sendmail */
-
-
-/*
- *      Define HAVE_ROUTING if your mailer understands domain based
- *      adresses (...@...) and performs the necessary rerouting (e.g.
- *      Sendmail or Smail).
- *
- *      Otherwise, nn will provide a simple routing facility using
- *      routing information specified in the file LIB_DIRECTORY/routes.
- */
-
-#define HAVE_ROUTING                    /* */
-
-/*
- *      If HAVE_ROUTING is NOT defined, nn needs to know the name of
- *      your host.  To obtain the host name it will use either of the
- *      'uname' or 'gethostname' system calls as specified in the s-
- *      file included above.
- *
- *      If neither 'uname' nor 'gethostname' is available, you must
- *      define HOSTNAME to be the name of your host.  Otherwise, leave
- *      it undefined (it will not be used anyway).
- */
-
-/* #define HOSTNAME     "myhost"        /* Not used if HAVE_ROUTING */
-
-/*
- *      Define APPEND_SIGNATURE if you want nn to ask users to append
- *      ~/.signature to mail messages (reply/forward/mail).
- *
- *      If the mailer defined in REC_MAIL automatically includes .signature
- *      you should not define this (it will fool people to include it twice).
- *
- *      I think 'recmail' includes .signature, but 'sendmail -t' doesn't.
- */
-
-/* #define APPEND_SIGNATURE             /* */
-
-/*
- *      BUG_REPORT_ADDRESS is the initial value of the bug-report-address
- *      variable which is used by the :bug command to report bugs in
- *      the nn software.
- */
-
-#define BUG_REPORT_ADDRESS      "nn-bugs@dkuug.dk"
-
-
-/*************************** DOCUMENTATION ***************************
- *
- *      Specify directories for the user and system manuals
- *
- *      Adapt this to your local standards; the manuals will be named
- *              $(MAN_DIR)/program.$(MAN_SECTION)
- *
- *      USER_MAN        - nn, nntidy, nngrep, etc.
- *      SYS_MAN         - nnadmin
- *      DAEMON_MAN      - nnmaster
- */
-
-#define USER_MAN_DIR    "/usr/man/man1"
-#define USER_MAN_SECTION        "1"
-
-#define SYS_MAN_DIR     "/usr/man/man1"
-#define SYS_MAN_SECTION         "1m"
-
-#define DAEMON_MAN_DIR  "/usr/man/man8"
-#define DAEMON_MAN_SECTION      "8"
-
-
-/************************** LOCAL POLICY *****************************
- *
- *      Define STATISTICS if you want to keep a record of how much
- *      time the users spend on news reading.
- *
- *      Sessions shorter than the specified number of minutes are not
- *      recorded (don't clutter up the log file).
- *
- *      Usage statistics is entered into the $LOG_FILE with code U
- */
-
-/* #define STATISTICS   5 /* minutes */
-
-/*
- *      Define ACCOUNTING if you want to keep accumulated accounting
- *      based on the statistics in a separate 'acct' file.  In this
- *      case, the accounting figures will be secret, and not be
- *      written to the Log file.  And the users will not be able to
- *      "decrease" their own account.
- *
- *      See account.c for optional cost calculation parameters.
- */
-
-/* #define ACCOUNTING           /* */
-
-/*
- *      Define AUTHORIZE if you want to restrict the use of nn to
- *      certain users or certain periods of the day.  Define both
- *      this and ACCOUNTING if you want to impose a usage quota
- *
- *      See account.c for implementing various access policies.
- */
-
-/* #define AUTHORIZE    /* */
-
-/*
- *      Default folder directory
- */
-
-#define FOLDER_DIRECTORY        "~/News"
-
-/*
- *      Max length of authors name (in "edited" format).
- *      Also size of "Name" field on the article menus.
- *      You may want to increase this if your terminals are wider than
- *      80 columns.
- */
-
-#define NAME_LENGTH             16
-
-
-/************************ CONFIGURATION COMPLETED ************************/
-
-#include "global.h"
-
diff --git a/utils/inews/config.h-dist b/utils/inews/config.h-dist
deleted file mode 100644
index eacc4361..00000000
--- a/utils/inews/config.h-dist
+++ /dev/null
@@ -1,392 +0,0 @@
-
-/**************************** NN CONFIGURATION ***************************
- *
- *      Configuration file for nn.
- *
- *      You must edit this file to reflect your local configuration
- *      and environment.
- *
- *      Before editing this file, read the licence terms in the README
- *      file and the installation guidelines in the INSTALLATION file.
- *
- *      (c) Copyright 1990, Kim F. Storm.  All rights reserved.
- */
-
-#define RELEASE         "6.4"
-
-#include <stdio.h>
-#include <ctype.h>
-
-
-/*********************** NETWORK DEPENDENT DEFINITIONS **********************
- *
- *      Define NETWORK_DATABASE if you share the database through NFS on
- *      a network with different, non-compatible machines, e.g. SUNs and
- *      VAXen, or SUN-3 and SUN-4, or if you are using different compilers
- *      on the same architecture.
- *
- *      In a homogenous network, you can leave it undefined for higher
- *      performance (no data conversion is needed).
- */
-
-/* #define NETWORK_DATABASE     /* */
-
-
-/********************************** NNTP *********************************
- *
- *      Define NNTP to enable nntp support.  If you are not using NNTP,
- *      just leave the following NNTP_* definitions as they are - they
- *      will be ignored anyway.
- *
- *      With NNTP, the nnmaster still maintains a local database of
- *      all article headers for fast access (and because NNTP does not
- *      support nn - yet), while the articles are fetched from the
- *      nntp server when they are read or saved.
- *
- *      You may still share this database through NFS locally (see the
- *      description of NETWORK_DATABASE above) if you don't want to
- *      have separate nn databases on all your local systems.
- *
- *      Consult the file NNTP for further information on the use of NNTP.
- */
-
-/* #define NNTP                 /* */
-
-/*
- *      Define NNTP_SERVER to the name of a file containing the name of the
- *      nntp server.
- *
- *      It is vital that both the nnmaster and all nn users on a machine
- *      uses the same nntp server, because the nn database is synchronized
- *      with a specific news active file.
- *
- *      If the file name does not start with a slash, it is relative to
- *      LIB_DIRECTORY defined below.
- *      NOTE: If you plan to use the included inews, it MUST be a full pathname
- */
-
-#define NNTP_SERVER     "/usr/lib/nntp_server"
-
-/*
- *      Define NNTP_POST if you want nn to reject attempts to post via
- *      NNTP to a server, that disallows postings.
- *
- *      You should define this, if you use the NNTP based mini-inews for
- *      postings from NNTP clients.  If you use another mechanism, that
- *      does not involve NNTP, you should leave it undefined.
- */
-
-#define NNTP_POST             /* */
-
-/*
- *      NNTP's mini-inews seems to require that messages contain a complete
- *      header with Message-ID, Path, and Date fields which the normal inews
- *      generates itself.  If your mini-inews requires these headers to
- *      be present, define NNTP_MINI_INEWS_HEADER below.
- */
-
-#define NNTP_MINI_INEWS_HEADER  /* uses "broken" mini-inews */
-
-/*
- *      Define NNTP_PATH_HOSTNAME to force a specific hostname into the
- *      Path: header generated when NNTP_MINI_INEWS_HEADER is defined.
- *      This is useful for multi-machine sites with one mail/news gateway.
- *
- *      If the string starts with a '/' it is taken as the name of a file
- *      from which the outgoing hostname should be read (at runtime).
- */
-
-/* #define NNTP_PATH_HOSTNAME   "puthostnamehere"       /* */
-
-
-/***************** OPERATING SYSTEM DEPENDENT DEFINITIONS *******************
- *
- *      Include the appropriate s- file for your system below.
- *
- *      If a file does not exist for your system, you can use
- *      conf/s-template.h as a starting point for writing you own.
- */
-
-#include "s-sys5.h"
-
-/*
- *      Define DEFAULT_PAGER as the initial value of the 'pager' variable.
- *      nnadmin pipes shell command output though this command.
- */
-
-#define DEFAULT_PAGER           "pg -n -s"      /* system V */
-/* #define DEFAULT_PAGER        "more"                  /* bsd */
-
-/*
- *      DEFAULT_PRINTER is the initial value of the 'printer' variable.
- *      nn's :print command pipes text into this command.
- */
-
-#define DEFAULT_PRINTER         "lp -s"         /* System V */
-/* #define DEFAULT_PRINTER      "lpr -p -JNEWS" /* bsd */
-
-/*
- *      Define RESIZING to make nn understand dynamic window-resizing.
- *      (It uses the TIOCGWINSZ ioctl found on most 4.3BSD systems)
- */
-
-/* #define RESIZING             /* */
-
-
-/********************** MACHINE DEPENDENT DEFINITIONS **********************
- *
- *      Include the appropriate m- file for your system below.
- *
- *      If a file does not exist for your system, you can use
- *      conf/m-template.h as a starting point for writing you own.
- */
-
-#include "m-m680x0.h"
-
-
-/***************************** OWNERSHIP ***************************
- *
- *      Specify owner and group for installed files and programs.
- *
- *      The nnmaster will run suid/sgid to this owner and group.
- *
- *      The only requirements are that the ownership allows the
- *      nnmaster to READ the news related files and directories, and
- *      the ordinary users to read the database and execute the nn*
- *      programs.
- *
- *      Common choices are:  (news, news)  and   (your uid, your gid)
- */
-
-#define OWNER   "news"
-#define GROUP   "news"
-
-
-/**************************** LOCALIZATION ****************************
- *
- *      Specify where programs and files are installed.
- *
- *      BIN_DIRECTORY    - the location of the user programs (mandatory)
- *
- *      LIB_DIRECTORY    - the location of auxiliary programs and files.
- *                         (mandatory UNLESS ALL of the following are defined).
- *
- *      MASTER_DIRECTORY - the location of the master program (on server)
- *                         (= LIB_DIRECTORY if undefined)
- *
- *      CLIENT_DIRECTORY - the location of auxiliary programs (on clients)
- *                         (= LIB_DIRECTORY if undefined)
- *
- *      HELP_DIRECTORY   - the location of help files, online manual, etc.
- *                         (= CLIENT_DIRECTORY/help if undefined)
- *
- *      CACHE_DIRECTORY  - if NNTP is used, nn uses this central directory
- *                         to store working copies of articles on the local
- *                         system.  If not defined, it stores the articles
- *                         in each user's ~/.nn directory.
- *
- *      TMP_DIRECTORY    - temporary file storage.  Overriden by $TMPDIR.
- *                         (= /usr/tmp if undefined).
- *
- *      LOG_FILE         - the location of nn's log file.
- *                         (= LIB_DIRECTORY/Log if undefined).
- */
-
-#define BIN_DIRECTORY   "/usr/local/bin"
-#define LIB_DIRECTORY   "/usr/local/lib/nn"
-
-
-/**************************** DATABASE LOCATION **************************
- *
- *      Specify where the nn database should be installed.
- *
- *      If none of the following symbols are defined, the database will
- *      be contained in the NEWS_DIRECTORY in a separate .nn directory for
- *      master files and in files named .nnx and .nnd in each group's
- *      spool directory.  To use this scheme, the OWNER specified above
- *      must have write permission on the news spool directories.
- *
- *      If you access news via NNTP, you will probably always have to
- *      give the database directory explicitly through DB_DIRECTORY
- *      (and DB_DATA_DIRECTORY), since the normal news spool directories
- *      are probably not available on the local system.
- *      The exception may be if nnmaster runs directly on the nntp server.
- *
- *      To change the default behaviour, you can define the following
- *      symbols:
- *
- *      DB_DIRECTORY       - the directory containing the master files.
- *
- *      DB_DATA_DIRECTORY  - the directory containing the per-group files
- *                           (default is DB_DIRECTORY/DATA if undefined).
- *
- *      DB_LONG_NAMES      - use group's name rather than number when
- *                           building file names in DB_DATA_DIRECTORY.
- *           (The file system must support long file names!!)
- */
-
-#define DB_DIRECTORY    "/usr/spool/nn"
-
-
-/*************************** NEWS TRANSPORT **************************
- *
- *      Specify the location of your news programs and files
- *      You only need to specify these if you are not
- *      satisfied with the default settings.
- *
- *      NEWS_DIRECTORY          - The news spool directory.
- *                                Default: /usr/spool/news
- *
- *      NEWS_LIB_DIRECTORY      - The news lib directory.
- *                                Default: /usr/lib/news
- *
- *      INEWS_PATH              - The location of the inews program.
- *                                Default: NEWS_LIB_DIR/inews
- *
- *      RMGROUP_PATH            - The location of the rmgroup program.
- *                                Default: NEWS_LIB_DIR/{rm,del}group
- */
-
-#define NEWS_DIRECTORY          "/usr/spool/news"       /* */
-#define NEWS_LIB_DIRECTORY      "/usr/lib/news"         /* */
-
-/* #define INEWS_PATH           "/usr/lib/news/inews"   /* */
-
-
-/*************************** MAIL INTERFACE *************************
- *
- *      Specify a mailer that accepts a letter WITH a header IN THE TEXT.
- *
- *      A program named 'recmail' program is normally delivered with
- *      the Bnews system, or you can use sendmail -t if you have it.
- *
- *      The contrib/ directory contains two programs which you might
- *      be able to use with a little tweaking.
- */
-
-#define REC_MAIL        "/usr/lib/news/recmail" /* non-sendmail */
-/* #define REC_MAIL     "/usr/lib/sendmail -t"  /* sendmail */
-
-
-/*
- *      Define HAVE_ROUTING if your mailer understands domain based
- *      adresses (...@...) and performs the necessary rerouting (e.g.
- *      Sendmail or Smail).
- *
- *      Otherwise, nn will provide a simple routing facility using
- *      routing information specified in the file LIB_DIRECTORY/routes.
- */
-
-#define HAVE_ROUTING                    /* */
-
-/*
- *      If HAVE_ROUTING is NOT defined, nn needs to know the name of
- *      your host.  To obtain the host name it will use either of the
- *      'uname' or 'gethostname' system calls as specified in the s-
- *      file included above.
- *
- *      If neither 'uname' nor 'gethostname' is available, you must
- *      define HOSTNAME to be the name of your host.  Otherwise, leave
- *      it undefined (it will not be used anyway).
- */
-
-/* #define HOSTNAME     "myhost"        /* Not used if HAVE_ROUTING */
-
-/*
- *      Define APPEND_SIGNATURE if you want nn to ask users to append
- *      ~/.signature to mail messages (reply/forward/mail).
- *
- *      If the mailer defined in REC_MAIL automatically includes .signature
- *      you should not define this (it will fool people to include it twice).
- *
- *      I think 'recmail' includes .signature, but 'sendmail -t' doesn't.
- */
-
-/* #define APPEND_SIGNATURE             /* */
-
-/*
- *      BUG_REPORT_ADDRESS is the initial value of the bug-report-address
- *      variable which is used by the :bug command to report bugs in
- *      the nn software.
- */
-
-#define BUG_REPORT_ADDRESS      "nn-bugs@dkuug.dk"
-
-
-/*************************** DOCUMENTATION ***************************
- *
- *      Specify directories for the user and system manuals
- *
- *      Adapt this to your local standards; the manuals will be named
- *              $(MAN_DIR)/program.$(MAN_SECTION)
- *
- *      USER_MAN        - nn, nntidy, nngrep, etc.
- *      SYS_MAN         - nnadmin
- *      DAEMON_MAN      - nnmaster
- */
-
-#define USER_MAN_DIR    "/usr/man/man1"
-#define USER_MAN_SECTION        "1"
-
-#define SYS_MAN_DIR     "/usr/man/man1"
-#define SYS_MAN_SECTION         "1m"
-
-#define DAEMON_MAN_DIR  "/usr/man/man8"
-#define DAEMON_MAN_SECTION      "8"
-
-
-/************************** LOCAL POLICY *****************************
- *
- *      Define STATISTICS if you want to keep a record of how much
- *      time the users spend on news reading.
- *
- *      Sessions shorter than the specified number of minutes are not
- *      recorded (don't clutter up the log file).
- *
- *      Usage statistics is entered into the $LOG_FILE with code U
- */
-
-/* #define STATISTICS   5 /* minutes */
-
-/*
- *      Define ACCOUNTING if you want to keep accumulated accounting
- *      based on the statistics in a separate 'acct' file.  In this
- *      case, the accounting figures will be secret, and not be
- *      written to the Log file.  And the users will not be able to
- *      "decrease" their own account.
- *
- *      See account.c for optional cost calculation parameters.
- */
-
-/* #define ACCOUNTING           /* */
-
-/*
- *      Define AUTHORIZE if you want to restrict the use of nn to
- *      certain users or certain periods of the day.  Define both
- *      this and ACCOUNTING if you want to impose a usage quota
- *
- *      See account.c for implementing various access policies.
- */
-
-/* #define AUTHORIZE    /* */
-
-/*
- *      Default folder directory
- */
-
-#define FOLDER_DIRECTORY        "~/News"
-
-/*
- *      Max length of authors name (in "edited" format).
- *      Also size of "Name" field on the article menus.
- *      You may want to increase this if your terminals are wider than
- *      80 columns.
- */
-
-#define NAME_LENGTH             16
-
-
-/************************ CONFIGURATION COMPLETED ************************/
-
-#include "global.h"
-
diff --git a/utils/inews/inews.c b/utils/inews/inews.c
deleted file mode 100644
index 134dc460..00000000
--- a/utils/inews/inews.c
+++ /dev/null
@@ -1,392 +0,0 @@
-#ifndef lint
-static char *sccsid = "@(#)inews.c	1.16	(Berkeley) 8/27/89";
-#endif
-
-/*
- * Itty-bitty inews for talking to remote server.
- * Simply accept input on stdin (or via a named file) and dump this
- * to the server; add a From: and Path: line if missing in the original.
- * Print meaningful errors from the server.
- * Limit .signature files to MAX_SIGNATURE lines.
- * No processing of command line options.
- *
- * Original by Steven Grady <grady@ucbvax.Berkeley.EDU>, with thanks from
- * Phil Lapsley <phil@ucbvax.berkeley.edu>
- * Send bug reports to Stan Barber <sob@bcm.tmc.edu>
- */
-
-#include <stdio.h>
-#include <pwd.h>
-#include <ctype.h>
-#include "conf.h"
-#include "nntp.h"
-#include "clientlib.h"
-#include <string.h>
-
-#define	MAX_SIGNATURE	4
-
-extern	FILE	*ser_wr_fp;
-
-char	host_name[256];
-
-main(argc, argv)
-int	argc;
-char	*argv[];
-{
-	char	line[NNTP_STRLEN], s[NNTP_STRLEN];
-	int	seen_fromline, in_header, seen_header;
-	int	response;
-	char	*server;
-	char	*getserverbyfile();
-	register char	*cp;
-
-	++argv;
-	while (argc > 1)
-		if (*argv[0] == '-') {
-			++argv;
-			--argc;
-		} else
-			break;
-
-	if (argc > 1) {
-		if (freopen(*argv, "r", stdin) == NULL) {
-			perror(*argv);
-			exit(1);
-		}
-	}
-
-	uname(host_name);
-
-	server = getserverbyfile(SERVER_FILE);
-	if (server == NULL) {
-		fprintf(stderr,
-			"Can't get the name of the news server from %s.\n",
-			SERVER_FILE);
-		fprintf(stderr,
-	       "Either fix this file, or put NNTPSERVER in your enviroment.\n");
-		exit(1);
-	}
-
-	response = server_init(server);
-	if (response < 0) {
-		printf("Couldn't connect to %s news server, try again later.\n",
-			server);
-		exit(1);
-	}
-
-	if (handle_server_response(response, server) < 0
-	    || response == OK_NOPOST) {
-		close_server();
-		exit(1);
-	}
-
-	put_server("POST");
-	(void) get_server(line, sizeof(line));
-	if (*line != CHAR_CONT) {
-		if (atoi(line) == ERR_NOPOST) {
-			close_server();
-			fprintf(stderr,
-				"Sorry, you can't post from this machine.\n");
-			exit(1);
-		} else {
-			close_server();
-		        fprintf(stderr, "Remote error: %s\n", line);
-			exit(1);
-		}
-	}
-
-	in_header = 1;
-	seen_header = 0;
-	seen_fromline = 0;
-
-	while (fgets(s, sizeof(s), stdin) != NULL) {
-		if ((cp = strchr(s, '\n')) != NULL)
-		    *cp = '\0';
-		if (s[0] == '.')    /* Single . is eof, so put in extra one */
-			(void) fputc('.', ser_wr_fp);
-		if (in_header && strneql(s, "From:", sizeof("From:")-1)) {
-	                seen_header = 1;
-			seen_fromline = 1;
-		}
-		if (in_header && s[0] == '\0') {
-	                if (seen_header) {
-		                in_header = 0;
-			        if (!seen_fromline)
-				        gen_frompath();
-			} else {
-			        continue;
-			}
-		} else if (in_header) {
-		        if (valid_header(s))
-			        seen_header = 1;
-	                else
-                                continue;
-		}
-		fprintf(ser_wr_fp, "%s\r\n", s);
-	}
-
-	append_signature();
-
-	fprintf(ser_wr_fp, ".\r\n");
-	(void) fflush(ser_wr_fp);
-	(void) get_server(line, sizeof(line));
-	if (*line != CHAR_OK) {
-		if (atoi(line) == ERR_POSTFAIL) {
-			close_server();
-			printf("Article not accepted by server; not posted.\n");
-			for (cp = line + 4; *cp && *cp != '\r'; cp++)
-				if (*cp == '\\')
-					putchar('\n');
-				else
-					putchar(*cp);
-			exit(1);
-		} else {
-			close_server();
-			fprintf(stderr, "Remote error: %s\n", line);
-			exit(1);
-		}
-	}
-
-	/*
-	 * Close server sends the server a
-	 * "quit" command for us, which is why we don't send it.
-	 */
-
-	close_server();
-
-	exit(0);
-	return(0);
-}
-
-/*
- * append_signature -- append the person's .signature file if
- * they have one.  Limit .signature to MAX_SIGNATURE lines.
- * The rn-style DOTDIR environmental variable is used if present.
- */
-
-append_signature()
-{
-	char	line[256], sigfile[256];
-	char	*cp;
-	struct	passwd	*passwd;
-	FILE	*fp;
-	char	*getenv();
-	int	count = 0;
-	char	*dotdir;
-
-	passwd = getpwuid(getuid());
-	if (passwd == NULL)
-	  return;
-#ifdef DO_DOTDIR
-	if ((dotdir = getenv("DOTDIR")) == NULL)
-#endif
-	{
-	  dotdir = passwd->pw_dir;
-	}
-
-	if (dotdir[0] == '~') {
-	  (void) strcpy(sigfile, passwd->pw_dir);
-	  (void) strcat(sigfile, &dotdir[1]);
-	} else {
-	  (void) strcpy(sigfile, dotdir);
-	}
-	(void) strcat(sigfile, "/");
-	(void) strcat(sigfile, ".signature");
-
-#ifdef DEBUG
-  fprintf(stderr,"sigfile = '%s'\n", sigfile);
-#endif
-
-	fp = fopen(sigfile, "r");
-	if (fp == NULL)
-		return;
-
-#ifdef DEBUG
-  fprintf(stderr,"sigfile opened OK\n");
-#endif
-
-	fprintf(ser_wr_fp, "--\r\n");
-	while (fgets(line, sizeof (line), fp)) {
-		count++;
-		if (count > MAX_SIGNATURE) {
-			fprintf(stderr,
-	      "Warning: .signature files should be no longer than %d lines.\n",
-			MAX_SIGNATURE);
-			fprintf(stderr,
-			"(Only %d lines of your .signature were posted.)\n",
-			MAX_SIGNATURE);
-			break;
-		}
-		if (cp = strchr(line, '\n'))
-			*cp = '\0';
-		fprintf(ser_wr_fp, "%s\r\n", line);
-	}
-	(void) fclose(fp);
-#ifdef DEBUG
-	printf(".signature appended (from %s)\n", sigfile);
-#endif
-}
-
-
-/*
- * gen_frompath -- generate From: and Path: lines, in the form
- *
- *	From: user@host.domain (full_name)
- *	Path: host!user
- *
- * This routine should only be called if the message doesn't have
- * a From: line in it.
- */
-
-gen_frompath()
-{
-	char	*full_name;
-	char	*cp;
-	struct	passwd *passwd;
-	char	*getenv();
-
-	passwd = getpwuid(getuid());
-
-	full_name = getenv("NAME");
-	if (full_name == NULL) {
-		full_name = passwd->pw_gecos;
-		if ((cp = strchr(full_name, ',')))
-			*cp = '\0';
-	}
-
-#ifdef DOMAIN
-#ifdef HIDDENNET
-		fprintf(ser_wr_fp, "From: %s@%s (",
-			passwd->pw_name,
-			DOMAIN);
-#else /* HIDDENNET */
-
-	/* A heuristic to see if we should tack on a domain */
-
-	cp = strchr(host_name, '.');
-	if (cp)
-		fprintf(ser_wr_fp, "From: %s@%s (",
-			passwd->pw_name,
-			host_name);
-	else
-		fprintf(ser_wr_fp, "From: %s@%s.%s (",
-			passwd->pw_name,
-			host_name,
-			DOMAIN);
-#endif /* HIDDENNET */
-#else
-	fprintf(ser_wr_fp, "From: %s@%s (",
-		passwd->pw_name,
-		host_name);
-#endif
-
-	for (cp = full_name; *cp != '\0'; ++cp)
-		if (*cp != '&')
-			putc(*cp, ser_wr_fp);
-		else {		/* Stupid & hack.  God damn it. */
-			putc(toupper(passwd->pw_name[0]), ser_wr_fp);
-			fprintf(ser_wr_fp, passwd->pw_name+1);
-		}
-
-	fprintf(ser_wr_fp, ")\r\n");
-
-#ifdef HIDDENNET
-	/* Only the login name - nntp server will add uucp name */
-	fprintf(ser_wr_fp, "Path: %s\r\n", passwd->pw_name);
-#else /* HIDDENNET */
-	fprintf(ser_wr_fp, "Path: %s!%s\r\n", host_name, passwd->pw_name);
-#endif /* HIDDENNET */
-}
-
-
-/*
- * strneql -- determine if two strings are equal in the first n
- * characters, ignoring case.
- *
- *	Parameters:	"a" and "b" are the pointers
- *			to characters to be compared.
- *			"n" is the number of characters to compare.
- *
- *	Returns:	1 if the strings are equal, 0 otherwise.
- *
- *	Side effects:	None.
- */
-
-strneql(a, b, n)
-register char *a, *b;
-int	n;
-{
-	char	lower();
-
-	while (n && lower(*a) == lower(*b)) {
-		if (*a == '\0')
-			return (1);
-		a++;
-		b++;
-		n--;
-	}
-	if (n)
-		return (0);
-	else
-		return (1);
-}
-
-/*
- * lower -- convert a character to lower case, if it's
- *	upper case.
- *
- *	Parameters:	"c" is the character to be
- *			converted.
- *
- *	Returns:	"c" if the character is not
- *			upper case, otherwise the lower
- *			case eqivalent of "c".
- *
- *	Side effects:	None.
- */
-
-char lower(c)
-register char c;
-{
-	if (isascii(c) && isupper(c))
-		c = c - 'A' + 'a';
-	return(c);
-}
-
-
-/*
- * valid_header -- determine if a line is a valid header line
- *
- *	Parameters:	"h" is the header line to be checked.
- *
- *	Returns: 	1 if valid, 0 otherwise
- *
- *	Side Effects:	none
- *
- */
-
-int valid_header(h)
-register char *h;
-{
-  char *colon, *space;
-
-  /*
-   * blank or tab in first position implies this is a continuation header
-   */
-  if (h[0] == ' ' || h[0] == '\t')
-    return (1);
-
-  /*
-   * just check for initial letter, colon, and space to make
-   * sure we discard only invalid headers
-   */
-  colon = strchr(h, ':');
-  space = strchr(h, ' ');
-  if (isalpha(h[0]) && colon && space == colon + 1)
-    return (1);
-
-  /*
-   * anything else is a bad header -- it should be ignored
-   */
-  return (0);
-}
diff --git a/utils/inews/nntp.h b/utils/inews/nntp.h
deleted file mode 100644
index 4ec2f35b..00000000
--- a/utils/inews/nntp.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Response codes for NNTP server
- *
- * @(#)nntp.h	1.7	(Berkeley) 1/11/88
- *
- * First digit:
- *
- *	1xx	Informative message
- *	2xx	Command ok
- *	3xx	Command ok so far, continue
- *	4xx	Command was correct, but couldn't be performed
- *		for some specified reason.
- *	5xx	Command unimplemented, incorrect, or a
- *		program error has occured.
- *
- * Second digit:
- *
- *	x0x	Connection, setup, miscellaneous
- *	x1x	Newsgroup selection
- *	x2x	Article selection
- *	x3x	Distribution
- *	x4x	Posting
- */
-
-#define	CHAR_INF	'1'
-#define	CHAR_OK		'2'
-#define	CHAR_CONT	'3'
-#define	CHAR_ERR	'4'
-#define	CHAR_FATAL	'5'
-
-#define	INF_HELP	100	/* Help text on way */
-#define	INF_DEBUG	199	/* Debug output */
-
-#define	OK_CANPOST	200	/* Hello; you can post */
-#define	OK_NOPOST	201	/* Hello; you can't post */
-#define	OK_SLAVE	202	/* Slave status noted */
-#define	OK_GOODBYE	205	/* Closing connection */
-#define	OK_GROUP	211	/* Group selected */
-#define	OK_GROUPS	215	/* Newsgroups follow */
-#define	OK_ARTICLE	220	/* Article (head & body) follows */
-#define	OK_HEAD		221	/* Head follows */
-#define	OK_BODY		222	/* Body follows */
-#define	OK_NOTEXT	223	/* No text sent -- stat, next, last */
-#define	OK_NEWNEWS	230	/* New articles by message-id follow */
-#define	OK_NEWGROUPS	231	/* New newsgroups follow */
-#define	OK_XFERED	235	/* Article transferred successfully */
-#define	OK_POSTED	240	/* Article posted successfully */
-
-#define CONT_XFER	335	/* Continue to send article */
-#define	CONT_POST	340	/* Continue to post article */
-
-#define	ERR_GOODBYE	400	/* Have to hang up for some reason */
-#define	ERR_NOGROUP	411	/* No such newsgroup */
-#define	ERR_NCING	412	/* Not currently in newsgroup */
-#define	ERR_NOCRNT	420	/* No current article selected */
-#define	ERR_NONEXT	421	/* No next article in this group */
-#define	ERR_NOPREV	422	/* No previous article in this group */
-#define	ERR_NOARTIG	423	/* No such article in this group */
-#define ERR_NOART	430	/* No such article at all */
-#define ERR_GOTIT	435	/* Already got that article, don't send */
-#define ERR_XFERFAIL	436	/* Transfer failed */
-#define	ERR_XFERRJCT	437	/* Article rejected, don't resend */
-#define	ERR_NOPOST	440	/* Posting not allowed */
-#define	ERR_POSTFAIL	441	/* Posting failed */
-
-#define	ERR_COMMAND	500	/* Command not recognized */
-#define	ERR_CMDSYN	501	/* Command syntax error */
-#define	ERR_ACCESS	502	/* Access to server denied */
-#define ERR_FAULT	503	/* Program fault, command not performed */
-
-/* RFC 977 defines this; don't change it. */
-
-#define	NNTP_STRLEN	512
diff --git a/utils/inews/version.c b/utils/inews/version.c
deleted file mode 100644
index 0b9d4167..00000000
--- a/utils/inews/version.c
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- * Provide the version number of this release.
- */
-
-char	nntp_version[] = "1.5.8 (11 March 90)";