about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c14
-rw-r--r--src/HTFWriter.c5
-rw-r--r--src/LYCharSets.c4
-rw-r--r--src/LYCurses.c134
-rw-r--r--src/LYCurses.h10
-rw-r--r--src/LYExtern.c89
-rw-r--r--src/LYForms.c8
-rw-r--r--src/LYGetFile.c14
-rw-r--r--src/LYGlobalDefs.h18
-rw-r--r--src/LYKeymap.c57
-rw-r--r--src/LYMain.c63
-rw-r--r--src/LYMainLoop.c52
-rw-r--r--src/LYOptions.c8
-rw-r--r--src/LYPrint.c4
-rw-r--r--src/LYReadCFG.c101
-rw-r--r--src/LYStrings.c28
-rw-r--r--src/LYStrings.h2
-rw-r--r--src/LYUtils.c83
-rw-r--r--src/LYUtils.h18
-rw-r--r--src/LYexit.c12
-rw-r--r--src/UCdomap.c70
-rw-r--r--src/UCdomap.h82
-rw-r--r--src/Xsystem.c17
-rw-r--r--src/chrtrans/build-chrtrans.com91
-rw-r--r--src/chrtrans/build-header.com1
-rw-r--r--src/chrtrans/make-msc.bat83
-rw-r--r--src/chrtrans/makefile.dos2
-rw-r--r--src/chrtrans/makefile.in2
-rw-r--r--src/chrtrans/makeuctb.c183
-rw-r--r--src/chrtrans/makew32.bat83
-rw-r--r--src/makefile.in6
31 files changed, 795 insertions, 549 deletions
diff --git a/src/GridText.c b/src/GridText.c
index 456b850c..76f57635 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -16,12 +16,6 @@
 
 #include <assert.h>
 
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-#include <syslog.h>
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
-
 #include <GridText.h>
 #include <LYCurses.h>
 #include <LYUtils.h>
@@ -6281,11 +6275,9 @@ get_query:
     StrAllocCat(tmpaddress, "?");
     StrAllocCat(tmpaddress, searchstring);
     user_message(WWW_WAIT_MESSAGE, tmpaddress);
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-    syslog(LOG_INFO|LOG_LOCAL5, "%s", tmpaddress);
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+    LYSyslog(tmpaddress);
+#endif /* !VMS && SYSLOG_REQUESTED_URLS */
     FREE(tmpaddress);
     if (cp)
 	*cp = '?';
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 7252b4d2..d55d53de 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -530,11 +530,12 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
 	    HTAlert(EXECUTION_DISABLED);
 	    return HTPlainPresent(pres, anchor, sink);
 	}
-	if (!local_exec)
+	if (!local_exec) {
 	    if (local_exec_on_local_files &&
 		(LYJumpFileURL ||
 		 !strncmp(anchor->address,"file://localhost",16))) {
 		/* allow it to continue */
+		;
 	    } else {
 		char *buf = 0;
 
@@ -544,6 +545,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
 		FREE(buf);
 		return HTPlainPresent(pres, anchor, sink);
 	    }
+	}
     }
 #endif /* EXEC_LINKS || EXEC_SCRIPTS */
 
@@ -567,7 +569,6 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
 	if (!strncmp(anchor->address,"file://localhost",16)) {
 
 	    /* 1998/01/23 (Fri) 17:38:26 */
-	    extern char windows_drive[];
 	    unsigned char *cp, *view_fname;
 
 #define IS_SJIS_HI1(hi) ((0x81<=hi)&&(hi<=0x9F))	/* 1st lev. */
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index 592c8ddb..64effdde 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -842,7 +842,7 @@ PUBLIC CONST char * HTMLGetEntityName ARGS1(
 	UCode_t,	code)
 {
 #define IntValue code
-    int MaxValue = ((sizeof(LYEntityNames)/sizeof(char **)) - 1);
+    int MaxValue = (TABLESIZE(LYEntityNames) - 1);
 
     if (IntValue < 0 || IntValue > MaxValue) {
 	return "";
@@ -872,7 +872,7 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1(
     UCode_t value = 0;
     size_t i, high, low;
     int diff = 0;
-    size_t number_of_unicode_entities = sizeof(unicode_entities)/sizeof(unicode_entities[0]);
+    size_t number_of_unicode_entities = TABLESIZE(unicode_entities);
 
     /*
      *	Make sure we have a non-zero length name. - FM
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 0562d962..762bb6f6 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -50,6 +50,7 @@ BOOLEAN LYCursesON = FALSE;
 
 #if USE_COLOR_TABLE || defined(USE_SLANG)
 PRIVATE int Current_Attr;
+PRIVATE int Masked_Attr;
 #endif
 
 #define OMIT_SCN_KEEPING 0 /* whether to omit keeping of Style_className
@@ -106,18 +107,37 @@ PUBLIC void LYaddAttr ARGS1(
 	int,		a)
 {
     Current_Attr |= a;
-    SLsmg_set_color(Current_Attr);
+    SLsmg_set_color(Current_Attr & ~Masked_Attr);
 }
 
 PUBLIC void LYsubAttr ARGS1(
 	int,		a)
 {
     Current_Attr &= ~a;
-    SLsmg_set_color(Current_Attr);
+    SLsmg_set_color(Current_Attr & ~Masked_Attr);
+}
+
+PRIVATE void lynx_setup_attrs NOARGS
+{
+    static int monoattr[] = {
+	0,
+	SLTT_BOLD_MASK,
+	SLTT_REV_MASK,
+	SLTT_REV_MASK | SLTT_BOLD_MASK,
+	SLTT_ULINE_MASK,
+	SLTT_ULINE_MASK | SLTT_BOLD_MASK,
+	SLTT_ULINE_MASK | SLTT_REV_MASK,
+	SLTT_ULINE_MASK | SLTT_BOLD_MASK | SLTT_REV_MASK
+    };
+    int n;
+
+    for (n = 1; n <= 7; n++)
+	SLtt_set_mono(n, NULL, (monoattr[n] & ~Masked_Attr));
 }
 
 PUBLIC void lynx_setup_colors NOARGS
 {
+    CTRACE(tfp, "lynx_setup_colors\n");
     SLtt_set_color(0, NULL, DEFAULT_FG, DEFAULT_BG);
     SLtt_set_color(1, NULL, "blue",	DEFAULT_BG); /* bold */
     SLtt_set_color(2, NULL, "yellow",	"blue");     /* reverse */
@@ -129,17 +149,10 @@ PUBLIC void lynx_setup_colors NOARGS
     SLtt_set_color(5, NULL, "blue",	DEFAULT_BG); /* bold-underline */
     SLtt_set_color(6, NULL, "red",	DEFAULT_BG); /* reverse-underline */
     SLtt_set_color(7, NULL, "magenta",	"cyan");     /* reverse-underline-bold */
-
     /*
      *	Now set monochrome attributes.
      */
-    SLtt_set_mono(1, NULL, SLTT_BOLD_MASK);
-    SLtt_set_mono(2, NULL, SLTT_REV_MASK);
-    SLtt_set_mono(3, NULL, SLTT_REV_MASK | SLTT_BOLD_MASK);
-    SLtt_set_mono(4, NULL, SLTT_ULINE_MASK);
-    SLtt_set_mono(5, NULL, SLTT_ULINE_MASK | SLTT_BOLD_MASK);
-    SLtt_set_mono(6, NULL, SLTT_ULINE_MASK | SLTT_REV_MASK);
-    SLtt_set_mono(7, NULL, SLTT_ULINE_MASK | SLTT_BOLD_MASK | SLTT_REV_MASK);
+    lynx_setup_attrs();
 }
 
 PRIVATE void sl_suspend ARGS1(
@@ -160,7 +173,7 @@ PRIVATE void sl_suspend ARGS1(
     SLang_init_tty(3, 0, 1);
 #endif /* SLANG_VERSION > 9929 */
     signal(SIGTSTP, sl_suspend);
-#ifdef UNIX
+#if defined(UNIX) && !defined(__CYGWIN__)
     SLtty_set_suspend_state(1);
 #endif
     if (sig == SIGTSTP)
@@ -522,9 +535,9 @@ PRIVATE void LYsetWAttr ARGS1(WINDOW *, win)
 		attr |= COLOR_PAIR(code+offs);
 	}
 
-	wattrset(win, attr);
+	wattrset(win, attr & ~Masked_Attr);
     } else {
-	wattrset(win, Current_Attr);
+	wattrset(win, Current_Attr & ~Masked_Attr);
     }
 }
 
@@ -598,7 +611,7 @@ PRIVATE void lynx_init_colors NOARGS
 	lynx_color_cfg[0].fg = default_fg;
 	lynx_color_cfg[0].bg = default_bg;
 
-	for (n = 0; n < sizeof(lynx_color_cfg)/sizeof(lynx_color_cfg[0]); n++) {
+	for (n = 0; n < TABLESIZE(lynx_color_cfg); n++) {
 	    for (m = 0; m <= 16; m += 8) {
 		int pair = n + m + 1;
 		if (pair < COLOR_PAIRS)
@@ -622,49 +635,23 @@ PUBLIC void lynx_setup_colors NOARGS
 }
 #endif /* USE_COLOR_TABLE */
 
-#ifdef NOTUSED
-#if defined (DJGPP) && !defined (USE_SLANG)
-/*
- * Sorry about making a completely new function,
- * but the real one is messy! WB
- */
-PUBLIC void start_curses NOARGS
+PUBLIC void LYnoVideo ARGS1(
+	int,		a)
 {
-    static BOOLEAN first_time = TRUE;
-
-    if(first_time)
-    {
-	initscr();		/* start curses */
-	first_time = FALSE;
-	cbreak();
-	keypad(stdscr, TRUE);
-	fflush(stdin);
-	fflush(stdout);
-	if (has_colors()) {
-	    lynx_has_color = TRUE;
-	    start_color();
-	}
-	lynx_init_colors();
-	lynx_called_initscr = TRUE;
-
-	/* Inform pdcurses that we're interested in knowing when mouse buttons
-	 * are clicked.  Maybe someday pdcurses will support it.
-	 */
-	if (LYUseMouse)
-	    lynx_enable_mouse (1);
-
-    } else {
-	sock_init();
-    }
-    LYCursesON = TRUE;
-    CTRACE(tfp, "start_curses: done.\n");
-    clear();
-    noecho();
-}
+    CTRACE(tfp, "LYnoVideo(%d)\n", a);
+#if USE_SLANG
+    if (a & 1) Masked_Attr |= SLTT_BOLD_MASK;
+    if (a & 2) Masked_Attr |= SLTT_REV_MASK;
+    if (a & 4) Masked_Attr |= SLTT_ULINE_MASK;
+    lynx_setup_attrs();
 #else
-#endif /* defined (DJGPP) && !defined (USE_SLANG) */
-#endif /* NOTUSED */
-
+#if USE_COLOR_TABLE
+    if (a & 1) Masked_Attr |= A_BOLD;
+    if (a & 2) Masked_Attr |= A_REVERSE;
+    if (a & 4) Masked_Attr |= A_UNDERLINE;
+#endif
+#endif
+}
 
 PUBLIC void start_curses NOARGS
 {
@@ -684,11 +671,11 @@ PUBLIC void start_curses NOARGS
 	SLkp_init ();
 #endif /* __DJGPP__ && !DJGPP_KEYHANDLER */
 
-#ifdef UNIX
+#if defined(UNIX) && !defined(__CYGWIN__)
 #if SLANG_VERSION >= 9935
 	SLang_TT_Read_FD = fileno(stdin);
 #endif /* SLANG_VERSION >= 9935 */
-#endif /* UNIX */
+#endif /* UNIX && !__CYGWIN__ */
 
 #if !defined(USE_KEYMAPS) && defined(ENHANCED_LINEEDIT) && defined(ESCDELAY)
 	/* way to get ESC that's not part of a recognized sequence through */
@@ -724,7 +711,7 @@ PUBLIC void start_curses NOARGS
 	}
 	size_change(0);
 
-#if defined(VMS) || defined(UNIX)
+#if (defined(VMS) || defined(UNIX)) && !defined(__CYGWIN__)
 	SLtt_add_color_attribute(4, SLTT_ULINE_MASK);
 	SLtt_add_color_attribute(5, SLTT_ULINE_MASK);
 	/*
@@ -736,7 +723,7 @@ PUBLIC void start_curses NOARGS
 	} else {
 	    SLtt_Blink_Mode = 0;
 	}
-#endif /* VMS || UNIX */
+#endif /* (VMS || UNIX) && !__CYGWIN__  */
     }
 #ifdef __DJGPP__
 #ifdef WATT32
@@ -762,9 +749,9 @@ PUBLIC void start_curses NOARGS
     scrollok(0,0);
     SLsmg_Backspace_Moves = 1;
 #ifndef VMS
-#ifdef UNIX
+#if defined(UNIX) && !defined(__CYGWIN__)
     SLtty_set_suspend_state(1);
-#endif /* UNIX */
+#endif /* UNIX && !__CYGWIN__ */
 #ifdef SIGTSTP
     if (!no_suspend)
 	signal(SIGTSTP, sl_suspend);
@@ -1176,6 +1163,18 @@ PUBLIC BOOLEAN setup ARGS1(
     if (strncmp((CONST char*)ttytype, "dec-vt", 6) == 0) {
 	(void) setterm(ttytype + 4);
     }
+
+    /*
+     *  Account for lossage on the 'sun' terminal type (80x24) Sun text
+     *  console driver. It only supports reverse video, but all SGR
+     *  sequences produce that same reverse video, and the terminfo
+     *  entry lists different SGRs for 'bold' and 'rev'. As a result,
+     *  the current link is indistinguishable from all other links.
+     *  The workaround here is to disable the 'rev' capability.
+     */
+    if ((strncmp(ttytype, "sun", 3) == 0)) {
+	LYnoVideo(2);
+    }
 #endif /* HAVE_TTYTYPE */
 
 #if defined(HAVE_SIZECHANGE) && !defined(USE_SLANG) && defined(NOTDEFINED)
@@ -1201,7 +1200,7 @@ PUBLIC BOOLEAN setup ARGS1(
     LYlines = LINES;
     LYcols = COLS;
 #endif /* HAVE_SIZECHANGE && !USE_SLANG && USE_NOTDEFINED */
-#if defined(WIN_EX) && defined(NOTDEFINED)
+#if defined(WIN_EX) && defined(CJK_EX) /* 1999/08/26 (Thu) 17:53:38 */
     {
 	extern int current_codepage;	/* PDCurses lib. */
 
@@ -1306,7 +1305,8 @@ PUBLIC void LYstopTargetEmphasis NOARGS
  * There's no guarantee that a library won't temporarily write on its input.
  * Be safe and copy it when we have const-data.
  */
-PUBLIC void LYaddnstr ARGS2(
+PUBLIC void LYwaddnstr ARGS3(
+	WINDOW *,	w,
 	CONST char *,	s,
 	size_t,		len)
 {
@@ -1314,16 +1314,10 @@ PUBLIC void LYaddnstr ARGS2(
 	char temp[MAX_LINE];
 	memcpy(temp, s, len);
 	temp[len] = 0;
-	addstr(temp);
+	waddstr(w, temp);
     }
 }
 
-PUBLIC void LYaddstr ARGS1(
-	CONST char *,	s)
-{
-    LYaddnstr(s, strlen(s));
-}
-
 #ifdef VMS
 /*
  *	Cut-down termio --
diff --git a/src/LYCurses.h b/src/LYCurses.h
index 7ae71e94..58725ff3 100644
--- a/src/LYCurses.h
+++ b/src/LYCurses.h
@@ -26,6 +26,8 @@
 
 #ifdef USE_SLANG
 #include <slang.h>
+#define WINDOW void
+#define waddstr(w,s) addstr(s)
 
 #else /* Using curses: */
 
@@ -161,10 +163,14 @@ extern int LYcols;   /* replaces COLS */
 extern void start_curses NOPARAMS;
 extern void stop_curses NOPARAMS;
 extern BOOLEAN setup PARAMS((char *terminal));
+extern void LYnoVideo PARAMS((int mask));
 extern void LYstartTargetEmphasis NOPARAMS;
 extern void LYstopTargetEmphasis NOPARAMS;
-extern void LYaddnstr PARAMS((CONST char *s, size_t len));
-extern void LYaddstr PARAMS((CONST char *s));
+extern void LYwaddnstr PARAMS((WINDOW *w, CONST char *s, size_t len));
+
+#define LYaddstr(s)      LYwaddnstr(stdscr, s, strlen(s))
+#define LYaddnstr(s,len) LYwaddnstr(stdscr, s, len)
+#define LYwaddstr(w,s)   LYwaddnstr(w, s, strlen(s))
 
 #ifdef VMS
 extern int DCLsystem (char *command);
diff --git a/src/LYExtern.c b/src/LYExtern.c
index 05e5d71c..5750bc2f 100644
--- a/src/LYExtern.c
+++ b/src/LYExtern.c
@@ -176,12 +176,13 @@ void run_external ARGS1(char *, c)
 {
 #ifdef WIN_EX
     HANDLE handle;
-    int stat;
+    int status;
+    int confirmed;
     char pram_string[PATH_MAX];
     int redraw_flag;
     extern int xsystem(char *cmd);
 #endif
-    char command[1024];
+    char *cmdbuf = NULL;
     lynx_html_item_type *externals2 = 0;
 
     if (externals == NULL)
@@ -189,7 +190,7 @@ void run_external ARGS1(char *, c)
 
 #ifdef WIN_EX			/* 1998/01/26 (Mon) 09:16:13 */
     if (c == NULL) {
-	HTInfoMsg("Not exist external command");
+	HTInfoMsg("Not external command exists");
 	return;
     }
 #endif
@@ -206,7 +207,7 @@ void run_external ARGS1(char *, c)
 	{
 	    if (no_externals && !externals2->always_enabled) {
 		HTUserMsg(EXTERNALS_DISABLED);
-		return;
+		break;
 	    }
 	    /*  Too dangerous to leave any URL that may come along unquoted.
 	     *  They often contain '&', ';', and '?' chars, and who knows
@@ -215,25 +216,22 @@ void run_external ARGS1(char *, c)
 	     *  Dunno how this needs to be modified for VMS or DOS. - kw
 	     */
 #if (defined(VMS) || defined(DOSPATH) || defined(__EMX__)) && !defined(WIN_EX)
-	    sprintf(command, externals2->command, c);
+	    HTSprintf0(&cmdbuf, externals2->command, c);
 #else	/* Unix or DOS/Win: */
 #if defined(WIN_EX)
 	    if (*c != '\"' && strchr(c, ' ') != NULL) {
 		char *cp = quote_pathname(c);
-		sprintf(command, externals2->command, cp);
+		HTSprintf0(&cmdbuf, externals2->command, cp);
 		FREE(cp);
 	    } else {
-		strcpy(pram_string, c);
+		LYstrncpy(pram_string, c, sizeof(pram_string)-1);
 		decode_string(pram_string);
 		c = pram_string;
 
-		/* mailto: */
 		if (strnicmp("mailto:", c, 7) == 0) {
-		    sprintf(command, externals2->command, c + 7);
-		}
-		/* telnet:// */
-		else if (strnicmp("telnet://", c, 9) == 0) {
-		    char host[STRING_MAX];
+		    HTSprintf0(&cmdbuf, externals2->command, c + 7);
+		} else if (strnicmp("telnet://", c, 9) == 0) {
+		    char host[sizeof(pram_string)];
 		    int last_pos;
 
 		    strcpy(host, c + 9);
@@ -241,11 +239,8 @@ void run_external ARGS1(char *, c)
 		    if (last_pos > 1 && host[last_pos] == '/')
 			host[last_pos] = '\0';
 
-		    sprintf(command, externals2->command, host);
-		}
-		/* file:// */
-		else if (strnicmp("file://localhost/", c, 17) == 0) {
-		    extern char windows_drive[];
+		    HTSprintf0(&cmdbuf, externals2->command, host);
+		} else if (strnicmp("file://localhost/", c, 17) == 0) {
 		    char e_buff[PATH_MAX], *p;
 
 		    p = c + 17;
@@ -271,45 +266,42 @@ void run_external ARGS1(char *, c)
 		     * less ==> long filename
 		     */
 		    if (isupper(externals2->command[0])) {
-			sprintf(command,
+			HTSprintf0(&cmdbuf,
 				externals2->command, HTDOS_short_name(e_buff));
 		    } else {
-			sprintf(command, externals2->command, e_buff);
+			HTSprintf0(&cmdbuf, externals2->command, e_buff);
 		    }
 		} else {
-		    sprintf(command, externals2->command, c);
+		    HTSprintf0(&cmdbuf, externals2->command, c);
 		}
 	    }
 #else	/* Unix */
 	    {
 		char *cp = HTQuoteParameter(c);
-		sprintf(command, externals2->command, cp);
+		HTSprintf0(&cmdbuf, externals2->command, cp);
 		FREE(cp);
 	    }
 #endif
 #endif	/* VMS */
 
-	    if (*command != '\0') {
+	    if (cmdbuf != 0 && *cmdbuf != '\0') {
 #ifdef WIN_EX			/* 1997/10/17 (Fri) 14:07:50 */
 		int len;
 		char buff[PATH_MAX];
 
-		CTRACE(tfp, "Lynx EXTERNAL: '%s'\n", command);
+		CTRACE(tfp, "Lynx EXTERNAL: '%s'\n", cmdbuf);
 #ifdef WIN_GUI			/* 1997/11/06 (Thu) 14:17:15 */
-		stat = MessageBox(handle, command,
+		confirmed = MessageBox(handle, cmdbuf,
 				  "Lynx (EXTERNAL COMMAND EXEC)",
-		       MB_ICONQUESTION | MB_SETFOREGROUND | MB_OKCANCEL);
-		if (stat == IDCANCEL) {
-		    return;
-		}
+		       MB_ICONQUESTION | MB_SETFOREGROUND | MB_OKCANCEL)
+			    == IDCANCEL;
 #else
-		stat = HTConfirm(string_short(command, 40));
-		if (stat == NO) {
-		    return;
-		}
+		confirmed = HTConfirm(string_short(cmdbuf, 40)) == NO;
 #endif
+		if (confirmed)
+		    break;
 
-		len = strlen(command);
+		len = strlen(cmdbuf);
 		if (len > 255) {
 		    sprintf(buff, "Lynx: command line too long (%d > 255)", len);
 #ifdef WIN_GUI			/* 1997/11/06 (Thu) 14:17:02 */
@@ -318,16 +310,14 @@ void run_external ARGS1(char *, c)
 			  MB_ICONEXCLAMATION | MB_SETFOREGROUND | MB_OK);
 		    SetConsoleTitle("Lynx for Win32");
 #else
-		    stat = HTConfirm(string_short(buff, 40));
+		    HTConfirm(string_short(buff, 40));
 #endif
-		    return;
+		    break;
 		} else {
-		    SetConsoleTitle(command);
+		    SetConsoleTitle(cmdbuf);
 		}
-#endif
 
-#ifdef WIN_EX
-		if (strnicmp(command, "start ", 6) == 0)
+		if (strnicmp(cmdbuf, "start ", 6) == 0)
 		    redraw_flag = FALSE;
 		else
 		    redraw_flag = TRUE;
@@ -337,33 +327,33 @@ void run_external ARGS1(char *, c)
 		    fflush(stdout);
 		}
 #else
-		HTUserMsg(command);
+		HTUserMsg(cmdbuf);
 		stop_curses();
 #endif
 
 		/* command running. */
 #ifdef WIN_EX			/* 1997/10/17 (Fri) 14:07:50 */
 #ifdef __CYGWIN__
-		stat = system(command);
+		status = system(cmdbuf);
 #else
-		stat = xsystem(command);
+		status = xsystem(cmdbuf);
 #endif
-		if (stat != 0) {
+		if (status != 0) {
 		    sprintf(buff,
 			    "EXEC code = %04x (%2d, %2d)\r\n"
 			    "'%s'",
-			    stat, (stat / 256), (stat & 0xff),
-			    command);
+			    status, (status / 256), (status & 0xff),
+			    cmdbuf);
 #ifdef SH_EX	/* WIN_GUI for ERROR only */
 		    MessageBox(handle, buff,
 			       "Lynx (EXTERNAL COMMAND EXEC)",
 			       MB_ICONSTOP | MB_SETFOREGROUND | MB_OK);
 #else
-		    stat = HTConfirm(string_short(buff, 40));
+		    HTConfirm(string_short(buff, 40));
 #endif		/* 1 */
 		}
 #else	/* Not WIN_EX */
-		LYSystem(command);
+		LYSystem(cmdbuf);
 #endif	/* WIN_EX */
 
 #if defined(WIN_EX)
@@ -380,10 +370,11 @@ void run_external ARGS1(char *, c)
 		start_curses();
 #endif
 	    }
-	    return;
+	    break;
 	} /* end if */
     } /* end-for */
 
+    FREE(cmdbuf);
     return;
 }
 #endif	/* USE_EXTERNALS */
diff --git a/src/LYForms.c b/src/LYForms.c
index 7c437509..d4aadd52 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -623,10 +623,18 @@ again:
 	    case LTARROW:	/* 1999/04/14 (Wed) 15:01:33 */
 		if (MyEdit.pos == 0 && repeat == -1) {
 		    int c = YES;    /* Go back immediately if no changes */
+#ifndef NO_NONSTICKY_INPUTS
+		    if (sticky_inputs
+		     && !textfield_stop_at_left_edge)
+#endif
 		    if (strcmp(MyEdit.buffer, value)) {
 			c = HTConfirmDefault(PREV_DOC_QUERY, NO);
 		    }
 		    if (c == YES) {
+#ifndef NO_NONSTICKY_INPUTS
+			if (textfield_stop_at_left_edge)
+			    goto again;
+#endif
 			return(ch);
 		    } else {
 			if (form->disabled == YES)
diff --git a/src/LYGetFile.c b/src/LYGetFile.c
index 370bf41f..ef8c051c 100644
--- a/src/LYGetFile.c
+++ b/src/LYGetFile.c
@@ -32,12 +32,6 @@
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-#include <syslog.h>
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
-
 PRIVATE int fix_httplike_urls PARAMS((document *doc, UrlTypes type));
 extern char * WWW_Download_File;
 #ifdef VMS
@@ -286,11 +280,9 @@ Try_Redirected_URL:
 		    WWWDoc.post_data = NULL;
 		    WWWDoc.post_content_type = NULL;
 		}
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-		syslog(LOG_INFO|LOG_LOCAL5, "%s", doc->address);
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+		LYSyslog (doc->address);
+#endif
 		if (url_type == UNKNOWN_URL_TYPE ||
 		    url_type == AFS_URL_TYPE ||
 		    url_type == PROSPERO_URL_TYPE) {
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 81c391e0..586c5a7d 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -402,6 +402,7 @@ extern BOOL force_empty_hrefless_a;
 #ifndef NO_NONSTICKY_INPUTS
 extern BOOL sticky_inputs;
 extern BOOL textinput_drawn;
+extern BOOL textfield_stop_at_left_edge;
 #endif
 
 
@@ -414,9 +415,10 @@ extern int HTNoDataOK;		/* HT_NO_DATA-is-ok hack */
 
 #ifdef WIN_EX
 /* LYMain.c */
-extern int lynx_timeout;
-extern BOOLEAN system_is_NT;
 extern BOOLEAN focus_window;
+extern BOOLEAN system_is_NT;
+extern char windows_drive[];
+extern int lynx_timeout;
 #endif /* _WINDOWS */
 
 #ifdef SH_EX
@@ -428,6 +430,12 @@ extern int     debug_delay;
 extern BOOLEAN no_table_center;
 #endif
 
+#if defined(__CYGWIN__)
+extern void cygwin_conv_to_full_win32_path(char *posix, char *dos);
+extern void cygwin_conv_to_full_posix_path(char *dos, char *posix);
+extern int setmode(int handle, int amode);
+#endif
+
 #if !defined(__CYGWIN__) && defined(__CYGWIN32__)
 #define __CYGWIN__
 
@@ -438,12 +446,6 @@ extern BOOLEAN no_table_center;
 	cygwin32_conv_to_full_posix_path(p, q)
 #endif
 
-#if defined(__CYGWIN__)
-extern void cygwin_conv_to_full_win32_path(char *posix, char *dos);
-extern void cygwin_conv_to_full_posix_path(char *dos, char *posix);
-extern int setmode(int handle, int amode);
-#endif
-
 #ifdef USE_SCROLLBAR
 /* GridText.c */
 extern int LYsb;
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index 72f6ebe2..c381c081 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -185,17 +185,9 @@ LYK_TAG_LINK,     LYK_PREV_DOC,   LYK_VIEW_BOOKMARK,   0,
 LYK_NOCACHE,            0,          LYK_INTERRUPT,     0,
 /* x */              /* y */          /* z */       /* { */
 
-#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__))
-
-LYK_PIPE,               0,              0,             0,
-/* | */               /* } */         /* ~ */
-
-#else
-
 LYK_PIPE,               0,              0,          LYK_HISTORY,
 /* | */               /* } */         /* ~ */       /* del */
 
-#endif /* _WINDOWS || __DJGPP__ || __CYGWIN__ */
 
 /* 80..9F (illegal ISO-8859-1) 8-bit characters. */
    0,                  0,              0,             0,
@@ -256,12 +248,7 @@ LYK_UP_TWO,       LYK_DOWN_TWO,     LYK_DO_NOTHING, LYK_FASTBACKW_LINK,
 
 /* 110..18F */
 
-#if (defined(_WINDOWS) || defined(__DJGPP__) || defined(__CYGWIN__)) && defined(USE_SLANG) && !defined(DJGPP_KEYHANDLER)
-   LYK_HISTORY,        LYK_ACTIVATE,   0,             0,
-   /* Backspace */     /* Enter */
-#else
    0,                  0,              0,             0,
-#endif /* USE_SLANG &&(_WINDOWS || __DJGPP || __CYGWIN__) && !DJGPP_KEYHANDLER */
    0,                  0,              0,             0,
    0,             LYK_DO_NOTHING,      0,             0,
                /* 0x11d: MOUSE_KEY */
@@ -889,32 +876,32 @@ PUBLIC int lacname_to_lac ARGS1(
 PUBLIC int lkcstring_to_lkc ARGS1(
 	CONST char *,	src)
 {
-       int c = -1;
-
-       if (strlen(src) == 1)
-               c = *src;
-       else if (strlen(src) == 2 && *src == '^')
-               c = src[1] & 037;
-       else if (strlen(src) >= 2 && isdigit(*src)) {
-               if (sscanf(src, "%i", &c) != 1)
-                       return (-1);
+    int c = -1;
+
+    if (strlen(src) == 1)
+	c = *src;
+    else if (strlen(src) == 2 && *src == '^')
+	c = src[1] & 037;
+    else if (strlen(src) >= 2 && isdigit(*src)) {
+	if (sscanf(src, "%i", &c) != 1)
+	    return (-1);
 #ifdef USE_KEYMAPS
-       } else {
-	   map_string_to_keysym((char *)src, &c);
+    } else {
+	map_string_to_keysym(src, &c);
 #ifndef USE_SLANG
-	   if (c >= 0) {
-	       if ((c&LKC_MASK) > 255 && !(c & LKC_ISLKC))
-		   return (-1);	/* Don't accept untranslated curses KEY_* */
-	       else
-		   c &= ~LKC_ISLKC;
-	   }
+	if (c >= 0) {
+	    if ((c&LKC_MASK) > 255 && !(c & LKC_ISLKC))
+		return (-1);	/* Don't accept untranslated curses KEY_* */
+	    else
+		c &= ~LKC_ISLKC;
+	}
 #endif
 #endif
-	}
-	if (c < -1)
-	    return (-1);
-	else
-	    return c;
+    }
+    if (c < -1)
+	return (-1);
+    else
+	return c;
 }
 
 PRIVATE int LYLoadKeymap ARGS4 (
diff --git a/src/LYMain.c b/src/LYMain.c
index b58cef3c..f4aa9c40 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -38,12 +38,6 @@
 #include <io.h>
 #endif
 
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-#include <syslog.h>
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
-
 #ifdef LOCALE
 #undef gettext		/* Solaris locale.h prototypes gettext() */
 #include <locale.h>
@@ -457,6 +451,8 @@ PUBLIC BOOL force_empty_hrefless_a = FALSE;
 PUBLIC BOOL sticky_inputs = TRUE;
 #endif
 
+PUBLIC BOOL textfield_stop_at_left_edge=TRUE;
+
 #ifdef DISP_PARTIAL
 PUBLIC BOOLEAN display_partial_flag = TRUE; /* Display document during download */
 PUBLIC BOOLEAN debug_display_partial = FALSE; /* Show with MessageSecs delay */
@@ -930,9 +926,6 @@ PUBLIC int main ARGS2(
     memset((void *)MBM_A_subbookmark, 0, sizeof(char)*(MBM_V_MAXFILES+1));
     memset((void *)MBM_A_subdescript, 0, sizeof(char)*(MBM_V_MAXFILES+1));
 #ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-    openlog("lynx", LOG_PID, LOG_LOCAL5);
-#endif /* SYSLOG_REQUESTED_URLS */
     StrAllocCopy(list_format, LIST_FORMAT);
 #endif /* !VMS */
     InfoSecs	= (int)INFOSECS;
@@ -1671,16 +1664,6 @@ PUBLIC int main ARGS2(
     HTFormatInit();
     HTFileInit();
 
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-    if (syslog_txt) {
-	syslog(LOG_INFO, "Session start:%s", syslog_txt);
-    } else {
-	syslog(LOG_INFO, "Session start");
-    }
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
-
 #ifdef SH_EX
     if (show_cfg) {
 	cleanup();
@@ -1972,6 +1955,10 @@ PUBLIC int main ARGS2(
        __system_redirect;               /* redirect internally */
 #endif  /* __DJGPP__ */
 
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+    LYOpenlog (syslog_txt);
+#endif
+
     /*
      *	Here's where we do all the work.
      */
@@ -2608,6 +2595,14 @@ static int newsmaxchunk_fun ARGS1(
 }
 #endif /* not DISABLE_NEWS */
 
+/* -nobold */
+static int nobold_fun ARGS1(
+	char *,			next_arg GCC_UNUSED)
+{
+   LYnoVideo(1);
+   return 0;
+}
+
 /* -nobrowse */
 static int nobrowse_fun ARGS1(
 	char *,			next_arg GCC_UNUSED)
@@ -2638,6 +2633,22 @@ static int nopause_fun ARGS1(
     return 0;
 }
 
+/* -noreverse */
+static int noreverse_fun ARGS1(
+	char *,			next_arg GCC_UNUSED)
+{
+   LYnoVideo(2);
+   return 0;
+}
+
+/* -nounderline */
+static int nounderline_fun ARGS1(
+	char *,			next_arg GCC_UNUSED)
+{
+   LYnoVideo(4);
+   return 0;
+}
+
 /* -pauth */
 static int pauth_fun ARGS1(
 	char *,			next_arg)
@@ -2783,7 +2794,7 @@ static int restrictions_fun ARGS1(
 
     if (next_arg == 0 || *next_arg == '\0') {
 	SetOutputMode( O_TEXT );
-	for (n = 0; n < sizeof(Usage)/sizeof(Usage[0]); n++)
+	for (n = 0; n < TABLESIZE(Usage); n++)
 	    printf("%s\n", Usage[n]);
 	SetOutputMode( O_BINARY );
 	exit(0);
@@ -3169,6 +3180,10 @@ keys (may be incompatible with some curses packages)"
    ),
 #endif
    PARSE_FUN(
+      "nobold",		FUNCTION_ARG,		nobold_fun,
+      "disable bold video-attribute"
+   ),
+   PARSE_FUN(
       "nobrowse",	FUNCTION_ARG,		nobrowse_fun,
       "disable directory browsing"
    ),
@@ -3214,6 +3229,10 @@ keys (may be incompatible with some curses packages)"
       "noreferer",	SET_ARG,		&LYNoRefererHeader,
       "disable transmissions of Referer headers"
    ),
+   PARSE_FUN(
+      "noreverse",	FUNCTION_ARG,		noreverse_fun,
+      "disable reverse video-attribute"
+   ),
 #ifdef SOCKS
    PARSE_SET(
       "nosocks",	UNSET_ARG,		&socks_flag,
@@ -3224,6 +3243,10 @@ keys (may be incompatible with some curses packages)"
       "nostatus",	SET_ARG,		&no_statusline,
       "disable the miscellaneous information messages"
    ),
+   PARSE_FUN(
+      "nounderline",	FUNCTION_ARG,		nounderline_fun,
+      "disable underline video-attribute"
+   ),
    PARSE_SET(
       "number_fields",	SET_ARG,		&number_fields,
       "force numbering of links as well as form input fields"
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index fe5242c0..bde21255 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -368,31 +368,31 @@ PRIVATE int do_change_link ARGS1(
 }
 
 PRIVATE int find_link_near_col ARGS2(
-    	int,	col,
+	int,	col,
 	int,	delta)
 {
     int i;
 
     for (i = curdoc.link; delta > 0 ? (i < nlinks) : (i >= 0); i += delta) {
-       if ( (links[i].ly - links[curdoc.link].ly) * delta > 0 ) {
-            int cy = links[i].ly, best = -1, dist = 1000000;
-
-            while ((delta > 0 ? (i < nlinks) : (i >= 0)) && cy == links[i].ly) {
-                int cx = links[i].lx;
-
-                if (links[i].hightext)
-                    cx += strlen(links[i].hightext)/2;
-                cx -= col;
-                if (cx < 0)
-                    cx = -cx;
-                if (cx < dist) {
-                    dist = cx;
-                    best = i;
-                }
-                i += delta;
-            }
-            return(best);
-       }
+	if ( (links[i].ly - links[curdoc.link].ly) * delta > 0 ) {
+	    int cy = links[i].ly, best = -1, dist = 1000000;
+
+	    while ((delta > 0 ? (i < nlinks) : (i >= 0)) && cy == links[i].ly) {
+		int cx = links[i].lx;
+
+		if (links[i].hightext)
+		    cx += strlen(links[i].hightext)/2;
+		cx -= col;
+		if (cx < 0)
+		    cx = -cx;
+		if (cx < dist) {
+		    dist = cx;
+		    best = i;
+		}
+		i += delta;
+	    }
+	    return(best);
+	}
     }
     return(-1);
 }
@@ -1828,7 +1828,7 @@ try_again:
 #ifndef NO_NONSTICKY_INPUTS
 		if (!sticky_inputs && !textinput_activated) {
 		    /*draw the text entry, but don't activate it*/
-    		    change_form_link_ex(&links[curdoc.link],
+		    change_form_link_ex(&links[curdoc.link],
 				     &newdoc, &refresh_screen,
 				     links[curdoc.link].form->name,
 				      links[curdoc.link].form->value,
@@ -2010,7 +2010,7 @@ new_keyboard_input:
 	 */
 	if (traversal) {
 	    if ((c = DoTraversal(c, &crawl_ok)) < 0)
-	    	return (-1);
+		return (-1);
 	} /* traversal */
 
 #ifdef WIN_EX
@@ -2332,7 +2332,7 @@ new_cmd:  /*
 		psrc_view = FALSE;
 #endif
 		FREE(ownerS_address);   /* not used with source_cache */
-		LYUCPopAssumed();  	/* probably a right place here */
+		LYUCPopAssumed();	/* probably a right place here */
 		HTMLSetCharacterHandling(current_char_set);  /* restore now */
 
 		break;
@@ -4103,7 +4103,7 @@ check_recall:
 			    LYAddHtmlSep0(user_input_buffer);
 			else {
 			    HTUserMsg2(WWW_ILLEGAL_URL_MESSAGE,
-			    			user_input_buffer);
+						user_input_buffer);
 			    strcpy(user_input_buffer, temp);
 			    FREE(temp);
 			    break;
@@ -5805,7 +5805,7 @@ check_add_bookmark_to_self:
 	    if (!no_shell) {
 		stop_curses();
 		printf("%s\r\n", SPAWNING_MSG);
-#if defined(__CYGWIN_) && defined(DOSPATH)
+#if defined(__CYGWIN__)
 		Cygwin_Shell();
 #else
 		LYSystem(LYSysShell());
@@ -6933,7 +6933,7 @@ PRIVATE void status_link ARGS3(
 	    /*
 	     *  Replace some leaves to '...', if possible, and put the
 	     *  final leaf at the end. We assume that one can recognize
-	     * 	the link from at least MIN_STATUS characters.
+	     *  the link from at least MIN_STATUS characters.
 	     */
 	    if (cut_from_pos > MIN_STATUS) {
 		for (n = 1; n <= 3; n++)
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 575fe13d..d199eea6 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -912,7 +912,7 @@ draw_options:
 			    addstr(LYRawMode ? "ON " : "OFF");
 			}
 		    }
-		    FREE(TYPECAST(char *,assume_list));
+		    FREE(assume_list);
 		    response = ' ';
 		    if (LYSelectPopups) {
 #if !defined(VMS) || defined(USE_SLANG)
@@ -2487,7 +2487,7 @@ redraw:
 	    wmove(form_window, ((i + 1) - window_offset), 2);
 	    wclrtoeol(form_window);
 	    waddstr(form_window, Cnum);
-	    waddstr(form_window, Cptr[i]);
+	    LYwaddstr(form_window, Cptr[i]);
 #endif /* USE_SLANG */
 	}
     }
@@ -2522,7 +2522,7 @@ redraw:
 #else
 	    wmove(form_window, ((i + 1) - window_offset), 2);
 	    waddstr(form_window, Cnum);
-	    waddstr(form_window, Cptr[i]);
+	    LYwaddstr(form_window, Cptr[i]);
 #endif /* USE_SLANG */
 	}
 	Cptr = choices;
@@ -2562,7 +2562,7 @@ redraw:
 #else
 	wstart_reverse(form_window);
 #endif
-	waddstr(form_window, Cptr[i]);
+	LYwaddstr(form_window, Cptr[i]);
 #if defined(WIN_EX)	/* 1997/10/18 (Sat) 00:10:58 */
 	wattroff(form_window, A_REVERSE);
 #else
diff --git a/src/LYPrint.c b/src/LYPrint.c
index ed3a63d9..d775e43a 100644
--- a/src/LYPrint.c
+++ b/src/LYPrint.c
@@ -366,7 +366,7 @@ check_recall:
      */
     CTRACE(tfp, "LYPrint: filename is %s, action is `%c'\n", buffer, c);
 
-#if HAVE_POPEN || !defined(__CYGWIN__)
+#if HAVE_POPEN
     if (*buffer == '|') {
 	if (no_shell) {
 	    HTUserMsg(SPAWNING_DISABLED);
@@ -443,7 +443,7 @@ check_recall:
     if (keypad_mode)
 	printlist(outfile_fp,FALSE);
 
-#if HAVE_POPEN || !defined(__CYGWIN__)
+#if HAVE_POPEN
     if (LYIsPipeCommand(buffer))
 	pclose(outfile_fp);
     else
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 98525546..21671223 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -908,55 +908,6 @@ static int nonrest_sigwinch_fun ARGS1(
     return 0;
 }
 
-#ifdef USE_PSRC
-
-static void html_src_bad_syntax ARGS2(
-	    char*, value,
-	    char*, option_name)
-{
-    char *buf = 0;
-
-    HTSprintf0(&buf,"HTMLSRC_%s", option_name);
-    LYUpperCase(buf);
-    fprintf(stderr,"Bad syntax in TAGSPEC %s:%s\n", buf, value);
-    exit_immediately(-1);
-}
-
-
-static int parse_html_src_spec ARGS3(
-	    HTlexem, lexem_code,
-	    char*, value,
-	    char*, option_name)
-{
-   /* Now checking the value for being correct.  Since HTML_dtd is not
-    * initialized completely (member tags points to non-initiailized data), we
-    * use tags_old.  If the syntax is incorrect, then lynx will exit with error
-    * message.
-    */
-    char* ts2;
-    if ( !value || !*value) return 0; /* silently ignoring*/
-
-#define BS() html_src_bad_syntax(value,option_name)
-
-    ts2 = strchr(value,':');
-    if (!ts2)
-	BS();
-    *ts2 = '\0';
-
-    if ( html_src_parse_tagspec(value, lexem_code, TRUE, TRUE)
-	|| html_src_parse_tagspec(ts2, lexem_code, TRUE, TRUE) )
-    {
-	*ts2 = ':';
-	BS();
-    }
-
-    *ts2 = ':';
-    HTL_tagspecs[lexem_code] = NULL;
-    StrAllocCopy(HTL_tagspecs[lexem_code],value);
-#undef BS
-    return 0;
-}
-
 #ifdef EXP_CHARSET_CHOICE
 PRIVATE void matched_charset_choice ARGS2(
 	BOOL,	display_charset,
@@ -1042,6 +993,55 @@ PRIVATE int parse_assumed_doc_charset_choice ARGS1(char*,p)
 
 #endif /* EXP_CHARSET_CHOICE */
 
+#ifdef USE_PSRC
+
+static void html_src_bad_syntax ARGS2(
+	    char*, value,
+	    char*, option_name)
+{
+    char *buf = 0;
+
+    HTSprintf0(&buf,"HTMLSRC_%s", option_name);
+    LYUpperCase(buf);
+    fprintf(stderr,"Bad syntax in TAGSPEC %s:%s\n", buf, value);
+    exit_immediately(-1);
+}
+
+
+static int parse_html_src_spec ARGS3(
+	    HTlexem, lexem_code,
+	    char*, value,
+	    char*, option_name)
+{
+   /* Now checking the value for being correct.  Since HTML_dtd is not
+    * initialized completely (member tags points to non-initiailized data), we
+    * use tags_old.  If the syntax is incorrect, then lynx will exit with error
+    * message.
+    */
+    char* ts2;
+    if ( !value || !*value) return 0; /* silently ignoring*/
+
+#define BS() html_src_bad_syntax(value,option_name)
+
+    ts2 = strchr(value,':');
+    if (!ts2)
+	BS();
+    *ts2 = '\0';
+
+    if ( html_src_parse_tagspec(value, lexem_code, TRUE, TRUE)
+	|| html_src_parse_tagspec(ts2, lexem_code, TRUE, TRUE) )
+    {
+	*ts2 = ':';
+	BS();
+    }
+
+    *ts2 = ':';
+    HTL_tagspecs[lexem_code] = NULL;
+    StrAllocCopy(HTL_tagspecs[lexem_code],value);
+#undef BS
+    return 0;
+}
+
 #if defined(__STDC__) || defined(_WIN_CC)
 #define defHTSRC_parse_fun(x) static int html_src_set_##x ARGS1( char*,str) \
  { parse_html_src_spec(HTL_##x,str,#x); return 0; }
@@ -1323,6 +1323,7 @@ static Config_Type Config_Table [] =
 #endif
      PARSE_STR("startfile", CONF_STR, &startfile),
 #ifndef NO_NONSTICKY_INPUTS
+     PARSE_SET("sticky_fields", CONF_BOOL, &textfield_stop_at_left_edge),
      PARSE_SET("sticky_inputs", CONF_BOOL, &sticky_inputs),
 #endif
      PARSE_SET("strip_dotdot_urls", CONF_BOOL, &LYStripDotDotURLs),
@@ -1426,7 +1427,7 @@ PRIVATE Config_Type *lookup_config ARGS1(
     return tbl;
 }
 
-#define NOPTS_ ( (sizeof Config_Table)/(sizeof Config_Table[0]) - 1 )
+#define NOPTS_ ( TABLESIZE(Config_Table) - 1 )
 typedef BOOL (optidx_set_t) [ NOPTS_ ];
  /* if element is FALSE, then it's allowed in the current file*/
 
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 51d3df31..7e7e4ddf 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -686,7 +686,7 @@ PUBLIC void ena_csi ARGS1(
 #define define_key(string, code) \
 	SLkm_define_keysym (string, code, Keymap_List)
 #define expand_substring(dst, first, last) \
-	SLexpand_escaped_string(dst, first, last)
+	SLexpand_escaped_string(dst, (char *)first, (char *)last)
 static SLKeyMap_List_Type *Keymap_List;
 /* This value should be larger than anything in LYStrings.h */
 #define MOUSE_KEYSYM 0x0400
@@ -758,7 +758,7 @@ PRIVATE int lookup_tiname (char *name, NCURSES_CONST char *CONST *names)
     return -1;
 }
 
-PRIVATE char *expand_tiname (char *first, size_t len, char **result)
+PRIVATE CONST char *expand_tiname (CONST char *first, size_t len, char **result)
 {
     char name[BUFSIZ];
     int code;
@@ -775,7 +775,7 @@ PRIVATE char *expand_tiname (char *first, size_t len, char **result)
     return first + len;
 }
 
-PRIVATE char *expand_tichar (char *first, char **result)
+PRIVATE CONST char *expand_tichar (CONST char *first, char **result)
 {
     int ch;
     int limit = 0;
@@ -806,12 +806,12 @@ PRIVATE char *expand_tichar (char *first, char **result)
     }
 
     if (radix != 0) {
-	char *last;
-	int save = first[limit];
-	first[limit] = '\0';
-	value = strtol(first, &last, radix);
-	first[limit] = save;
-	first = last;
+	char *last = 0;
+	char tmp[80];
+	LYstrncpy(tmp, first, limit);
+	value = strtol(tmp, &last, radix);
+	if (last != 0 && last != tmp)
+	    first += (last - tmp);
     }
 
     if (name != 0) {
@@ -824,7 +824,7 @@ PRIVATE char *expand_tichar (char *first, char **result)
     return first;
 }
 
-PRIVATE void expand_substring (char* dst, char* first, char* last)
+PRIVATE void expand_substring (char* dst, CONST char* first, CONST char* last)
 {
     int ch;
     while (first < last) {
@@ -835,7 +835,7 @@ PRIVATE void expand_substring (char* dst, char* first, char* last)
 	case '^':
 	    ch = *first++;
 	    if (ch == LPAREN) {
-		char *s = strchr(first, RPAREN);
+		CONST char *s = strchr(first, RPAREN);
 		if (s == 0)
 		    s = first + strlen(first);
 		first = expand_tiname(first, s-first, &dst);
@@ -862,7 +862,7 @@ PRIVATE void expand_substring (char* dst, char* first, char* last)
 }
 #endif
 
-PRIVATE void unescaped_char ARGS2(char*, parse, int*,keysym)
+PRIVATE void unescaped_char ARGS2(CONST char*, parse, int*,keysym)
 {
     size_t len = strlen(parse);
     char buf[BUFSIZ];
@@ -893,7 +893,7 @@ PRIVATE BOOLEAN unescape_string ARGS2(char*, src, char *, dst)
     return ok;
 }
 
-PUBLIC int map_string_to_keysym ARGS2(char*, str, int*,keysym)
+PUBLIC int map_string_to_keysym ARGS2(CONST char*, str, int*,keysym)
 {
     int modifier = 0;
     *keysym = -1;
@@ -3812,7 +3812,7 @@ PRIVATE long UniToLowerCase ARGS1(long, upper)
      *	Try unicode_to_lower_case[].
      */
     low = 0;
-    high = sizeof(unicode_to_lower_case)/sizeof(unicode_to_lower_case[0]);
+    high = TABLESIZE(unicode_to_lower_case);
     while (low < high) {
 	/*
 	**  Binary search.
diff --git a/src/LYStrings.h b/src/LYStrings.h
index e6bf1ac0..550c4096 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -243,7 +243,7 @@ typedef struct _EditFieldData {
 
 #if defined(USE_KEYMAPS)
 extern int lynx_initialize_keymaps NOPARAMS;
-extern int map_string_to_keysym PARAMS((char * src, int *lec));
+extern int map_string_to_keysym PARAMS((CONST char * src, int *lec));
 #endif
 
 extern void LYLowerCase PARAMS((
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 1501c80b..24651c95 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2102,7 +2102,7 @@ PUBLIC int LYConsoleInputFD ARGS1(
 #ifdef USE_SLANG
     if (!LYCursesON)
 	fd = fileno(stdin);
-#if ((SLANG_VERSION >= 9919) && defined(UNIX))
+#if ((SLANG_VERSION >= 9919) && defined(UNIX) && !defined(__CYGWIN__))
     /* SLang_TT_Read_FD introduced in slang 0.99.19, from its changelog:
      *   SLang_TT_Read_FD variable is now available for unix.  This is the file
      *   descriptor used by SLang_getkey. */
@@ -7236,7 +7236,7 @@ PUBLIC int LYSystem ARGS1(
 /*
  * Return a string which can be used in LYSystem() for spawning a subshell
  */
-#if defined(__CYGWIN__) && defined(DOSPATH)	/* 1999/02/26 (Fri) */
+#if defined(__CYGWIN__)	/* 1999/02/26 (Fri) */
 PUBLIC int Cygwin_Shell NOARGS
 {
     char *shell;
@@ -7555,3 +7555,82 @@ PUBLIC char * w32_strerror(DWORD ercode)
 }
 
 #endif
+
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+/*
+ * syslog() interface
+ */
+PUBLIC void LYOpenlog ARGS1(
+       CONST char *, banner)
+{
+#if defined(WATT32)
+    openlog("lynx", LOG_PID|LOG_NDELAY, LOG_LOCAL5);
+#else
+    openlog("lynx", LOG_PID, LOG_LOCAL5);
+#endif
+
+    if (banner) {
+	syslog(LOG_INFO, "Session start:%s", banner);
+    } else {
+	syslog(LOG_INFO, "Session start");
+    }
+}
+
+PRIVATE BOOLEAN looks_like_password ARGS2(
+	char *,		first,
+	char *,		last)
+{
+    BOOLEAN result = FALSE;
+
+    while (first <= last) {
+	if (*first == '/'
+	 || *first == ':') {
+	    result = FALSE;
+	    break;
+	}
+	result = TRUE;
+	first++;
+    }
+    return result;
+}
+
+PUBLIC void LYSyslog ARGS1(
+       char *,		arg)
+{
+    char *colon1;
+    char *colon2;
+    char *atsign;
+
+    CTRACE(tfp, "LYSyslog %s\n", arg);
+
+    if (is_url(arg)) {	/* proto://user:password@host/path:port */
+			/*	^this colon		    */
+	if ((colon1 = strchr(arg, ':')) != 0
+	 && !strncmp(colon1, "://", 3)
+	 && (colon2 = strchr(colon1+3, ':')) != 0
+	 && (atsign = strchr(colon1, '@')) != 0
+	 && (colon2 < atsign)
+	 && looks_like_password(colon2 + 1, atsign - 1)) {
+	    char *buf = NULL;
+
+	    StrAllocCopy(buf, arg);
+	    buf[colon2 - arg + 1] = 0;
+	    StrAllocCat(buf, "******");
+	    StrAllocCat(buf, atsign);
+	    syslog (LOG_INFO|LOG_LOCAL5, buf);
+	    CTRACE(tfp, "...alter %s\n", buf);
+	    FREE(buf);
+	    return;
+        }
+    }
+    syslog (LOG_INFO|LOG_LOCAL5, arg);
+}
+
+PUBLIC void LYCloselog NOARGS
+{
+  syslog(LOG_INFO, "Session over");
+  closelog();
+}
+
+#endif /* !VMS && SYSLOG_REQUESTED_URLS */
+
diff --git a/src/LYUtils.h b/src/LYUtils.h
index 6c07b971..a7072fcd 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -50,8 +50,6 @@
 
 #define LYIsHtmlSep(ch) ((ch) == '/')
 
-#define TABLESIZE(v) (sizeof(v)/sizeof(v[0]))
-
 extern BOOLEAN LYAddSchemeForURL PARAMS((char **AllocatedString, char *default_scheme));
 extern BOOLEAN LYCachedTemp PARAMS((char *result, char **cached));
 extern BOOLEAN LYCanDoHEAD PARAMS((CONST char *address));
@@ -219,6 +217,22 @@ typedef enum {
 extern HTList *sug_filenames;
 
 /*
+ * syslog() facility
+ */
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+#ifdef WATT32
+#include <sys/syslog.h>
+#else
+#include <syslog.h>
+#endif
+
+extern void LYOpenlog  PARAMS((CONST char *banner));
+extern void LYSyslog   PARAMS((char *arg));
+extern void LYCloselog NOPARAMS;
+
+#endif /* !VMS && SYSLOG_REQUESTED_URLS */
+
+/*
  *  Miscellaneous.
  */
 #define ON      1
diff --git a/src/LYexit.c b/src/LYexit.c
index 75046338..3fd90cac 100644
--- a/src/LYexit.c
+++ b/src/LYexit.c
@@ -9,9 +9,6 @@
 #include <LYSignal.h>
 #include <LYClean.h>
 #include <LYMainLoop.h>
-#ifdef SYSLOG_REQUESTED_URLS
-#include <syslog.h>
-#endif /* SYSLOG_REQUESTED_URLS */
 #endif /* !VMS */
 
 /*
@@ -145,12 +142,9 @@ PUBLIC void LYexit ARGS1(
      */
     LYCompleteExit();
 
-#ifndef VMS
-#ifdef SYSLOG_REQUESTED_URLS
-    syslog(LOG_INFO, "Session over");
-    closelog();
-#endif /* SYSLOG_REQUESTED_URLS */
-#endif /* !VMS */
+#if !defined(VMS) && defined(SYSLOG_REQUESTED_URLS)
+    LYCloselog();
+#endif /* !VMS && SYSLOG_REQUESTED_URLS */
 
 #ifdef exit
 /*  Make sure we use stdlib exit and not LYexit. - GAB
diff --git a/src/UCdomap.c b/src/UCdomap.c
index 73b89bcd..35e3e027 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -20,7 +20,6 @@
 #include <HTMLDTD.h>
 
 #include <LYGlobalDefs.h>
-#include <UCkd.h>
 #include <UCdomap.h>
 #include <UCMap.h>
 #include <UCDefs.h>
@@ -1522,6 +1521,29 @@ PUBLIC int UCGetRawUniMode_byLYhndl ARGS1(
 }
 
 /*
+ * Construct a new charset name, given prefix and codepage.  This introduces
+ * potentially unchecked recursion into UCGetLYhntl_byMIME if neither the "cp"
+ * nor "windows-" prefixes are configured, so we check it here.
+ */
+PRIVATE int getLYhndl_byCP ARGS2(
+	CONST char *,	prefix,
+	CONST char *,	codepage)
+{
+    static int nested;
+    int result = -1;
+
+    if (!nested++) {
+	char *cptmp = NULL;
+	StrAllocCopy(cptmp, prefix);
+	StrAllocCat(cptmp, codepage);
+	result = UCGetLYhndl_byMIME(cptmp);
+	FREE(cptmp);
+    }
+    nested--;
+    return result;
+}
+
+/*
  *  Get Lynx internal charset handler from MIME name,
  *  return -1 if we got NULL or did not recognize value.
  *  According to RFC, MIME headers should match case-insensitively.
@@ -1549,6 +1571,7 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
     /*
      * Not yet found, try synonyms.  - FM
      */
+#if !NO_CHARSET_utf_8
     if (!strcasecomp(value, "unicode-1-1-utf-8") ||
 	!strcasecomp(value, "utf8")) {
 	/*
@@ -1556,33 +1579,49 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
 	 */
 	return UCGetLYhndl_byMIME("utf-8");
     }
+#endif
+#if !NO_CHARSET_euc_jp
     if (!strncasecomp(value, "iso-2022-jp", 11) ||
 	!strcasecomp(value, "x-euc-jp")) {
 	return UCGetLYhndl_byMIME("euc-jp");
     }
+#endif
+#if !NO_CHARSET_shift_jis
     if (!strcasecomp(value, "x-shift-jis")) {
 	return UCGetLYhndl_byMIME("shift_jis");
     }
+#endif
+#if !NO_CHARSET_euc_kr
     if (!strcasecomp(value, "iso-2022-kr")) {
 	return UCGetLYhndl_byMIME("euc-kr");
     }
+#endif
+#if !NO_CHARSET_euc_cn
     if (!strcasecomp(value, "gb2312") ||
 	!strncasecomp(value, "cn-gb", 5) ||
 	!strcasecomp(value, "iso-2022-cn")) {
 	return UCGetLYhndl_byMIME("euc-cn");
     }
+#endif
+#if !NO_CHARSET_big5
     if (!strcasecomp(value, "cn-big5")) {
 	return UCGetLYhndl_byMIME("big5");
     }
+#endif
+#if !NO_CHARSET_macintosh
     if (!strcasecomp(value, "x-mac-roman") ||
 	!strcasecomp(value, "mac-roman")) {
 	return UCGetLYhndl_byMIME("macintosh");
     }
+#endif
+#if !NO_CHARSET_next
     if (!strcasecomp(value, "x-next") ||
 	!strcasecomp(value, "nextstep") ||
 	!strcasecomp(value, "x-nextstep")) {
 	return UCGetLYhndl_byMIME("next");
     }
+#endif
+#if !NO_CHARSET_windows_1252
     if (!strcasecomp(value, "iso-8859-1-windows-3.1-latin-1") ||
 	!strcasecomp(value, "cp1252") ||
 	!strcasecomp(value, "cp-1252") ||
@@ -1594,6 +1633,8 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
 	 */
 	return UCGetLYhndl_byMIME("windows-1252");
     }
+#endif
+#if !NO_CHARSET_windows_1250
     if (!strcasecomp(value, "iso-8859-2-windows-latin-2") ||
 	!strcasecomp(value, "cp1250") ||
 	!strcasecomp(value, "cp-1250") ||
@@ -1603,6 +1644,7 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
 	 */
 	return UCGetLYhndl_byMIME("windows-1250");
     }
+#endif
     if ((!strncasecomp(value, "ibm", 3) ||
 	 !strncasecomp(value, "cp-", 3)) &&
 	isdigit((unsigned char)value[3]) &&
@@ -1612,23 +1654,12 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
 	 * For "ibmNNN<...>" or "cp-NNN", try "cpNNN<...>"
 	 * if not yet found.  - KW & FM
 	 */
-	char * cptmp = NULL;
-
-	StrAllocCopy(cptmp, (value + 1));
-	cptmp[0] = 'c';
-	cptmp[1] = 'p';
-	if ((LYhndl = UCGetLYhndl_byMIME(cptmp)) >= 0) {
-	    FREE(cptmp);
+	if ((LYhndl = getLYhndl_byCP("cp", value+3)) >= 0)
 	    return LYhndl;
-	}
 	/*
 	 * Try windows-NNN<...> if not yet found.  - FM
 	 */
-	StrAllocCopy(cptmp, "windows-");
-	StrAllocCat(cptmp, (value + 3));
-	LYhndl = UCGetLYhndl_byMIME(cptmp);
-	FREE(cptmp);
-	return LYhndl;
+	return getLYhndl_byCP("windows-", value + 3);
     }
     if (!strncasecomp(value, "windows-", 8) &&
 	isdigit((unsigned char)value[8]) &&
@@ -1637,18 +1668,13 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1(
 	/*
 	 * For "windows-NNN<...>", try "cpNNN<...>" - FM
 	 */
-	char * cptmp = NULL;
-
-	StrAllocCopy(cptmp, (value + 6));
-	cptmp[0] = 'c';
-	cptmp[1] = 'p';
-	LYhndl = UCGetLYhndl_byMIME(cptmp);
-	FREE(cptmp);
-	return LYhndl;
+	return getLYhndl_byCP("cp", value + 8);
     }
+#if !NO_CHARSET_koi8_r
     if (!strcasecomp(value, "koi-8")) { /* accentsoft bugosity */
       return UCGetLYhndl_byMIME("koi8-r");
     }
+#endif
     /* no more synonyms if come here... */
 
     CTRACE(tfp, "UCGetLYhndl_byMIME: unrecognized MIME name \"%s\"\n", value);
diff --git a/src/UCdomap.h b/src/UCdomap.h
index 18c8e3d6..71cbc696 100644
--- a/src/UCdomap.h
+++ b/src/UCdomap.h
@@ -5,6 +5,10 @@
 #include <HTUtils.h>
 #endif
 
+#ifndef ALL_CHARSETS
+#define ALL_CHARSETS 1
+#endif
+
 #include <UCkd.h>
 
 /*
@@ -66,7 +70,7 @@ extern void UCInit NOARGS;
  *
  *  Several #defines below are declarations for charsets which need no
  *  tables for mapping to Unicode - CJK multibytes, x-transparent, UTF8 -
- *  Lynx care of them internally.
+ *  Lynx takes care of them internally.
  *
  *  The declaration's format is kept in chrtrans/XXX_uni.h -
  *  keep this in mind when changing ucmaketbl.c,
@@ -80,24 +84,100 @@ extern void UCInit NOARGS;
    *  what is output to the terminal. - KW
    */
 
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_euc_cn
+#define NO_CHARSET_euc_cn !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_euc_cn
+#define UC_CHARSET_SETUP_euc_cn /*nothing*/
+#else
 #define UC_CHARSET_SETUP_euc_cn UC_Charset_NoUctb_Setup("euc-cn","Chinese",\
        1, 128,UCT_ENC_CJK,0)
+#endif
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_euc_jp
+#define NO_CHARSET_euc_jp !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_euc_jp
+#define UC_CHARSET_SETUP_euc_jp /*nothing*/
+#else
 #define UC_CHARSET_SETUP_euc_jp UC_Charset_NoUctb_Setup("euc-jp","Japanese (EUC-JP)",\
        1, 128,UCT_ENC_CJK,0)
+#endif
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_shift_jis
+#define NO_CHARSET_shift_jis !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_shift_jis
+#define UC_CHARSET_SETUP_shift_jis /*nothing*/
+#else
 #define UC_CHARSET_SETUP_shift_jis UC_Charset_NoUctb_Setup("shift_jis","Japanese (Shift_JIS)",\
        1, 128,UCT_ENC_CJK,0)
+#endif
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_euc_kr
+#define NO_CHARSET_euc_kr !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_euc_kr
+#define UC_CHARSET_SETUP_euc_kr /*nothing*/
+#else
 #define UC_CHARSET_SETUP_euc_kr UC_Charset_NoUctb_Setup("euc-kr","Korean",\
        1, 128,UCT_ENC_CJK,0)
+#endif
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_big5
+#define NO_CHARSET_big5 !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_big5
+#define UC_CHARSET_SETUP_big5 /*nothing*/
+#else
 #define UC_CHARSET_SETUP_big5 UC_Charset_NoUctb_Setup("big5","Taipei (Big5)",\
        1, 128,UCT_ENC_CJK,0)
+#endif
+
+/*----------------------------------------------------------------------------*/
+
   /*
    *  Placeholder for non-translation mode. - FM
    */
+
+#ifndef NO_CHARSET_x_transparent
+#define NO_CHARSET_x_transparent !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_x_transparent
+#define UC_CHARSET_SETUP_x_transparent /*nothing*/
+#else
 #define UC_CHARSET_SETUP_x_transparent UC_Charset_NoUctb_Setup("x-transparent","Transparent",\
        0, 128,UCT_ENC_8BIT,0)
+#endif
 
+/*----------------------------------------------------------------------------*/
+
+#ifndef NO_CHARSET_utf_8
+#define NO_CHARSET_utf_8 !ALL_CHARSETS
+#endif
+
+#if NO_CHARSET_utf_8
+#define UC_CHARSET_SETUP_utf_8 /*nothing*/
+#else
 #define UC_CHARSET_SETUP_utf_8 UC_Charset_NoUctb_Setup("utf-8","UNICODE (UTF-8)",\
        0, 128,UCT_ENC_UTF8,-4)
+#endif
 
 
 #endif /* UCDOMAP_H */
diff --git a/src/Xsystem.c b/src/Xsystem.c
index cc66aff0..e112ab6a 100644
--- a/src/Xsystem.c
+++ b/src/Xsystem.c
@@ -1,12 +1,9 @@
-/* @Id: Xsystem.c 1.3 Thu, 26 Aug 1999 05:31:19 -0600 dickey @
+/* @Id: Xsystem.c 1.4 Sat, 28 Aug 1999 15:04:13 -0600 dickey @
  *	like system("cmd") but return with exit code of "cmd"
  *	for Turbo-C/MS-C/LSI-C
  *  This code is in the public domain.
  *
- * @Log: Xsystem.c,v @
- * Revision 1.1  1999/07/14 16:44:55  tom
- * Initial revision
- *
+ * @Log: xsystem.c,v @
  *
  * Revision 1.14  1997/10/17 (Fri) 16:28:24  senshu
  * *** for Win32 version ***
@@ -46,6 +43,8 @@
 #define FALSE	0
 #endif
 
+#define	TABLESIZE(v)	(sizeof(v)/sizeof(v[0]))
+
 #define STR_MAX 512	/* MAX command line */
 
 extern char *mktemp(char *);
@@ -122,7 +121,7 @@ is_builtin_command(char *s)
     int i, l, lc, count;
 
     l = strlen(s);
-    count = sizeof(cmdtab) / sizeof(cmdtab[0]);
+    count = TABLESIZE(cmdtab);
     count--;
 #ifdef WIN_EX
     if (system_is_NT)
@@ -178,7 +177,7 @@ pars1c(char *s)
     int q;
 
     pp = (PRO *) xmalloc(sizeof(PRO));
-    for (q = 0; q < sizeof(pp->ored) / sizeof(pp->ored[0]); q++)
+    for (q = 0; q < TABLESIZE(pp->ored); q++)
 	pp->ored[q] = q;
     while (isspc(*s))
 	s++;
@@ -442,7 +441,7 @@ redswitch(PRO * p)
 {
     int d;
 
-    for (d = 0; d < sizeof(p->ored) / sizeof(p->ored[0]); d++) {
+    for (d = 0; d < TABLESIZE(p->ored); d++) {
 	if (d != p->ored[d]) {
 	    p->sred[d] = dup(d);
 	    dup2(p->ored[d], d);
@@ -455,7 +454,7 @@ redunswitch(PRO * p)
 {
     int d;
 
-    for (d = 0; d < sizeof(p->ored) / sizeof(p->ored[0]); d++) {
+    for (d = 0; d < TABLESIZE(p->ored); d++) {
 	if (d != p->ored[d]) {
 	    dup2(p->sred[d], d);
 	    close(p->sred[d]);
diff --git a/src/chrtrans/build-chrtrans.com b/src/chrtrans/build-chrtrans.com
index 42aebf86..0ba35058 100644
--- a/src/chrtrans/build-chrtrans.com
+++ b/src/chrtrans/build-chrtrans.com
@@ -76,86 +76,47 @@ $!
 $!	Create the Lynx [.SRC.CHRTRANS] header files.
 $!
 $ makeuctb := $'CHRwhere'makeuctb
-$ define/user sys$output 'CHRwhere'iso01_uni.h	!ISO Latin 1
-$ makeuctb iso01_uni.tbl
-$ define/user sys$output 'CHRwhere'cp850_uni.h	!DosLatin1 (cp850)
-$ makeuctb cp850_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1252_uni.h	!WinLatin1 (cp1252)
+$ makeuctb cp1250_uni.tbl
+$ makeuctb cp1251_uni.tbl
 $ makeuctb cp1252_uni.tbl
-$ define/user sys$output 'CHRwhere'cp437_uni.h	!DosLatinUS (cp437)
+$ makeuctb cp1253_uni.tbl
+$ makeuctb cp1255_uni.tbl
+$ makeuctb cp1256_uni.tbl
+$ makeuctb cp1257_uni.tbl
 $ makeuctb cp437_uni.tbl
-$ define/user sys$output 'CHRwhere'hp_uni.h	!HP Roman8
-$ makeuctb hp_uni.tbl
-$ define/user sys$output 'CHRwhere'dmcs_uni.h	!DEC Multinational
-$ makeuctb dmcs_uni.tbl
-$ define/user sys$output 'CHRwhere'mac_uni.h	!Macintosh (8 bit)
-$ makeuctb mac_uni.tbl
-$ define/user sys$output 'CHRwhere'next_uni.h	!NeXT character set
-$ makeuctb next_uni.tbl
-$ define/user sys$output 'CHRwhere'viscii_uni.h	!Vietnamese (VISCII)
-$ makeuctb viscii_uni.tbl
-$ define/user sys$output 'CHRwhere'def7_uni.h	!7 bit approximations
+$ makeuctb cp737_uni.tbl
+$ makeuctb cp775_uni.tbl
+$ makeuctb cp850_uni.tbl
+$ makeuctb cp852_uni.tbl
+$ makeuctb cp862_uni.tbl
+$ makeuctb cp864_uni.tbl
+$ makeuctb cp866_uni.tbl
+$ makeuctb cp866u_uni.tbl
+$ makeuctb cp869_uni.tbl
 $ makeuctb def7_uni.tbl
-$ define/user sys$output 'CHRwhere'iso02_uni.h	!ISO Latin 2
+$ makeuctb dmcs_uni.tbl
+$ makeuctb hp_uni.tbl
+$ makeuctb iso01_uni.tbl
 $ makeuctb iso02_uni.tbl
-$ define/user sys$output 'CHRwhere'cp852_uni.h	!DosLatin2 (cp852)
-$ makeuctb cp852_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1250_uni.h	!WinLatin2 (cp1250)
-$ makeuctb cp1250_uni.tbl
-$ define/user sys$output 'CHRwhere'iso03_uni.h	!ISO Latin 3
 $ makeuctb iso03_uni.tbl
-$ define/user sys$output 'CHRwhere'iso04_uni.h	!ISO Latin 4
 $ makeuctb iso04_uni.tbl
-$ define/user sys$output 'CHRwhere'cp775_uni.h	!DosBlatRim (cp775)
-$ makeuctb cp775_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1257_uni.h	!WinBlatRim (cp1257)
-$ makeuctb cp1257_uni.tbl
-$ define/user sys$output 'CHRwhere'iso05_uni.h	!ISO 8859-5 Cyrillic
 $ makeuctb iso05_uni.tbl
-$ define/user sys$output 'CHRwhere'cp866_uni.h	!DosCyrillic (cp866)
-$ makeuctb cp866_uni.tbl
-$ define/user sys$output 'CHRwhere'cp866u_uni.h	!Ukrainian Cyrillic
-$ makeuctb cp866u_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1251_uni.h	!WinCyrillic (cp1251)
-$ makeuctb cp1251_uni.tbl
-$ define/user sys$output 'CHRwhere'koi8r_uni.h	!KOI8-R Cyrillic
-$ makeuctb koi8r_uni.tbl
-$ define/user sys$output 'CHRwhere'koi8u_uni.h	!KOI8-U Ukranian Cyrillic
-$ makeuctb koi8u_uni.tbl
-$ define/user sys$output 'CHRwhere'iso06_uni.h	!ISO 8859-6 Arabic
 $ makeuctb iso06_uni.tbl
-$ define/user sys$output 'CHRwhere'cp864_uni.h	!DosArabic (cp864)
-$ makeuctb cp864_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1256_uni.h	!WinArabic (cp1256)
-$ makeuctb cp1256_uni.tbl
-$ define/user sys$output 'CHRwhere'iso07_uni.h	!ISO 8859-7 Greek
 $ makeuctb iso07_uni.tbl
-$ define/user sys$output 'CHRwhere'cp737_uni.h	!DosGreek (cp737)
-$ makeuctb cp737_uni.tbl
-$ define/user sys$output 'CHRwhere'cp869_uni.h	!DosGreek2 (cp869)
-$ makeuctb cp869_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1253_uni.h	!WinGreek (cp1253)
-$ makeuctb cp1253_uni.tbl
-$ define/user sys$output 'CHRwhere'iso08_uni.h	!ISO 8859-8 Hebrew
 $ makeuctb iso08_uni.tbl
-$ define/user sys$output 'CHRwhere'cp862_uni.h	!DosHebrew (cp862)
-$ makeuctb cp862_uni.tbl
-$ define/user sys$output 'CHRwhere'cp1255_uni.h	!WinHebrew (cp1255)
-$ makeuctb cp1255_uni.tbl
-$ define/user sys$output 'CHRwhere'iso09_uni.h	!ISO 8859-9 (Latin 5)
 $ makeuctb iso09_uni.tbl
-$ define/user sys$output 'CHRwhere'iso10_uni.h	!ISO 8859-10
 $ makeuctb iso10_uni.tbl
-$ define/user sys$output 'CHRwhere'iso15_uni.h	!ISO 8859-15
 $ makeuctb iso15_uni.tbl
-$ define/user sys$output 'CHRwhere'utf8_uni.h	!UNICODE UTF-8
-$ makeuctb utf8_uni.tbl
-$ define/user sys$output 'CHRwhere'rfc_suni.h	!RFC 1345 w/o Intro
-$ makeuctb rfc_suni.tbl
-$ define/user sys$output 'CHRwhere'mnem2_suni.h !RFC 1345 Mnemonic
+$ makeuctb koi8r_uni.tbl
+$ makeuctb koi8u_uni.tbl
+$ makeuctb mac_uni.tbl
+$ makeuctb mnem_suni.tbl
 $ makeuctb mnem2_suni.tbl
-$ define/user sys$output 'CHRwhere'mnem_suni.h	!(not used)
 $ makeuctb mnem_suni.tbl
+$ makeuctb next_uni.tbl
+$ makeuctb rfc_suni.tbl
+$ makeuctb utf8_uni.tbl
+$ makeuctb viscii_uni.tbl
 $ v1 = 'f$verify(0)'
 $ exit
 $!
diff --git a/src/chrtrans/build-header.com b/src/chrtrans/build-header.com
index 963825dd..c1e9d087 100644
--- a/src/chrtrans/build-header.com
+++ b/src/chrtrans/build-header.com
@@ -24,7 +24,6 @@ $!
 $!	Create a Lynx [.SRC.CHRTRANS] header file.
 $!
 $ makeuctb := $'CHRwhere'makeuctb
-$ define/user sys$output 'CHRwhere''P1'.h
 $ makeuctb 'P1'.tbl
 $ v1 = 'f$verify(0)'
 $ exit
diff --git a/src/chrtrans/make-msc.bat b/src/chrtrans/make-msc.bat
index 7e69d642..e17389cb 100644
--- a/src/chrtrans/make-msc.bat
+++ b/src/chrtrans/make-msc.bat
@@ -2,48 +2,47 @@
 @echo this batch file.

 @echo .

 @echo off

-REM make -f makefile.w32

 

 nmake -f makefile.msc

 

-makeuctb cp1250_uni.tbl > cp1250_uni.h

-makeuctb cp1251_uni.tbl > cp1251_uni.h

-makeuctb cp1252_uni.tbl > cp1252_uni.h

-makeuctb cp1253_uni.tbl > cp1253_uni.h

-makeuctb cp1255_uni.tbl > cp1255_uni.h

-makeuctb cp1256_uni.tbl > cp1256_uni.h

-makeuctb cp1257_uni.tbl > cp1257_uni.h

-makeuctb cp437_uni.tbl > cp437_uni.h

-makeuctb cp737_uni.tbl > cp737_uni.h

-makeuctb cp775_uni.tbl > cp775_uni.h

-makeuctb cp850_uni.tbl > cp850_uni.h

-makeuctb cp852_uni.tbl > cp852_uni.h

-makeuctb cp862_uni.tbl > cp862_uni.h

-makeuctb cp864_uni.tbl > cp864_uni.h

-makeuctb cp866_uni.tbl > cp866_uni.h

-makeuctb cp866u_uni.tbl > cp866u_uni.h

-makeuctb cp869_uni.tbl > cp869_uni.h

-makeuctb def7_uni.tbl  > def7_uni.h

-makeuctb dmcs_uni.tbl > dmcs_uni.h

-makeuctb hp_uni.tbl > hp_uni.h

-makeuctb iso01_uni.tbl > iso01_uni.h

-makeuctb iso02_uni.tbl > iso02_uni.h

-makeuctb iso03_uni.tbl > iso03_uni.h

-makeuctb iso04_uni.tbl > iso04_uni.h

-makeuctb iso05_uni.tbl > iso05_uni.h

-makeuctb iso06_uni.tbl > iso06_uni.h

-makeuctb iso07_uni.tbl > iso07_uni.h

-makeuctb iso08_uni.tbl > iso08_uni.h

-makeuctb iso09_uni.tbl > iso09_uni.h

-makeuctb iso10_uni.tbl > iso10_uni.h

-makeuctb iso15_uni.tbl > iso15_uni.h

-makeuctb koi8r_uni.tbl > koi8r_uni.h

-makeuctb koi8u_uni.tbl > koi8u_uni.h

-makeuctb mac_uni.tbl > mac_uni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb mnem2_suni.tbl > mnem2_suni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb next_uni.tbl > next_uni.h

-makeuctb rfc_suni.tbl > rfc_suni.h

-makeuctb utf8_uni.tbl > utf8_uni.h

-makeuctb viscii_uni.tbl > viscii_uni.h

+makeuctb cp1250_uni.tbl

+makeuctb cp1251_uni.tbl

+makeuctb cp1252_uni.tbl

+makeuctb cp1253_uni.tbl

+makeuctb cp1255_uni.tbl

+makeuctb cp1256_uni.tbl

+makeuctb cp1257_uni.tbl

+makeuctb cp437_uni.tbl

+makeuctb cp737_uni.tbl

+makeuctb cp775_uni.tbl

+makeuctb cp850_uni.tbl

+makeuctb cp852_uni.tbl

+makeuctb cp862_uni.tbl

+makeuctb cp864_uni.tbl

+makeuctb cp866_uni.tbl

+makeuctb cp866u_uni.tbl

+makeuctb cp869_uni.tbl

+makeuctb def7_uni.tbl

+makeuctb dmcs_uni.tbl

+makeuctb hp_uni.tbl

+makeuctb iso01_uni.tbl

+makeuctb iso02_uni.tbl

+makeuctb iso03_uni.tbl

+makeuctb iso04_uni.tbl

+makeuctb iso05_uni.tbl

+makeuctb iso06_uni.tbl

+makeuctb iso07_uni.tbl

+makeuctb iso08_uni.tbl

+makeuctb iso09_uni.tbl

+makeuctb iso10_uni.tbl

+makeuctb iso15_uni.tbl

+makeuctb koi8r_uni.tbl

+makeuctb koi8u_uni.tbl

+makeuctb mac_uni.tbl

+makeuctb mnem_suni.tbl

+makeuctb mnem2_suni.tbl

+makeuctb mnem_suni.tbl

+makeuctb next_uni.tbl

+makeuctb rfc_suni.tbl

+makeuctb utf8_uni.tbl

+makeuctb viscii_uni.tbl

diff --git a/src/chrtrans/makefile.dos b/src/chrtrans/makefile.dos
index cc9884cf..369246ac 100644
--- a/src/chrtrans/makefile.dos
+++ b/src/chrtrans/makefile.dos
@@ -77,7 +77,7 @@ makeuctb.exe: makeuctb.c UCkd.h
 	strip makeuctb.exe
 
 .tbl.h:
-	./makeuctb $*.tbl > $@
+	./makeuctb $*.tbl
 
 cp1250_uni.h:		cp1250_uni.tbl		makeuctb.exe
 cp1251_uni.h:		cp1251_uni.tbl		makeuctb.exe
diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in
index 87a39825..52cf5524 100644
--- a/src/chrtrans/makefile.in
+++ b/src/chrtrans/makefile.in
@@ -109,7 +109,7 @@ makeuctb.o: $(srcdir)/UCkd.h $(srcdir)/makeuctb.c
 	@ECHO_CC@$(CPP) -C $(CPP_OPTS) $(srcdir)/$*.c >$@
 
 .tbl.h:
-	./makeuctb$x $(srcdir)/$*.tbl > $@
+	./makeuctb$x $(srcdir)/$*.tbl $*.h
 
 # table files listed here once again to get the make dependencies
 # right, in case makeuctb was recompiled.
diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c
index 4a940b7e..305a9abf 100644
--- a/src/chrtrans/makeuctb.c
+++ b/src/chrtrans/makeuctb.c
@@ -25,6 +25,10 @@
 #undef exit
 #endif /* exit */
 
+#ifndef TOUPPER
+#define TOUPPER(c) (islower((unsigned char)c) ? toupper((unsigned char)c) : (c))
+#endif /* !TOLOWER */
+
 #ifndef TOLOWER
 #define TOLOWER(c) (isupper((unsigned char)c) ? tolower((unsigned char)c) : (c))
 #endif /* !TOLOWER */
@@ -39,25 +43,39 @@
  */
 typedef u16 unicode;
 
+static FILE *chdr = 0;
+
 /*
- * Since we're writing the formatted file to stdout, ensure that we flush
+ * Since we may be writing the formatted file to stdout, ensure that we flush
  * everything before leaving, since some old (and a few not-so-old) platforms
  * that do not implement POSIX 'exit()'.
  */
-#define done(code)  \
-    fflush(stdout); \
-    fflush(stderr); \
-    exit(code)
+PRIVATE void done PARAMS((int code)) GCC_NORETURN;
+PRIVATE void done ARGS1(int, code)
+{
+    fflush(chdr);
+    fclose(chdr);
+    fflush(stderr);
+    exit(code);
+}
 
-PRIVATE void usage ARGS1(
-	char *,		argv0)
+PRIVATE void usage NOARGS
 {
-    fprintf(stderr, "Usage: \n");
-    fprintf(stderr,
-	    "        %s chartable [charsetmimename] [charsetdisplayname]\n",
-	    argv0);
-    fprintf(stderr,
-	    "Utility to convert .tbl into .h files for Lynx compilation.\n");
+    static CONST char *tbl[] = {
+	"Usage: makeuctb [parameters]"
+	"",
+	"Utility to convert .tbl into .h files for Lynx compilation.",
+	""
+	"Parameters (all are optional):",
+	"  1: the input file (normally {filename}.tbl, but \"-\" for stdin",
+	"  2: the output file (normally {filename}.tbl but \"-\" for stdout",
+	"  3: charset mime name",
+	"  4: charset display name"
+    };
+    unsigned n;
+    for (n = 0; n < TABLESIZE(tbl); n++) {
+	fprintf(stderr, "%s\n", tbl[n]);
+    };
     done(EX_USAGE);
 }
 
@@ -110,7 +128,8 @@ int unicount[MAX_FONTLEN];
 
 struct unimapdesc_str themap_str = {0, NULL, 0, 0};
 
-char *tblname;
+PRIVATE char *tblname;
+PRIVATE char *hdrname;
 
 PRIVATE int RawOrEnc = 0;
 PRIVATE int Raw_found = 0;		/* whether explicit R directive found */
@@ -218,16 +237,55 @@ PUBLIC int main ARGS2(
 	int,		argc,
 	char **,	argv)
 {
+    static char *first_ifdefs[] = {
+	"/*",
+	" * Compile-in this chunk of code unless we've turned it off specifically",
+	" * or in general (id=%s).",
+	" */",
+	"",
+	"#ifndef INCL_CHARSET%s",
+	"#define INCL_CHARSET%s 1",
+	"",
+	"/*ifdef NO_CHARSET*/",
+	"#ifdef  NO_CHARSET",
+	"#undef  NO_CHARSET",
+	"#endif",
+	"#define NO_CHARSET 0 /* force default to always be active */",
+	"",
+	"/*ifndef NO_CHARSET%s*/",
+	"#ifndef NO_CHARSET%s",
+	"",
+	"#if    ALL_CHARSETS",
+	"#define NO_CHARSET%s 0",
+	"#else",
+	"#define NO_CHARSET%s 1",
+	"#endif",
+	"",
+	"#endif /* ndef(NO_CHARSET%s) */",
+	"",
+	"#if NO_CHARSET%s",
+	"#define UC_CHARSET_SETUP%s /*nothing*/",
+	"#else"
+    };
+    static char *last_ifdefs[] = {
+	"",
+	"#endif /* NO_CHARSET%s */"
+	"",
+	"#endif /* INCL_CHARSET%s */"
+    };
+
     FILE *ctbl;
     char buffer[65536];
+    char outname[256];
+    unsigned n;
     int fontlen;
     int i, nuni, nent;
-    int fp0, fp1, un0, un1;
+    int fp0 = 0, fp1 = 0, un0, un1;
     char *p, *p1;
     char *tbuf, ch;
 
-    if (argc < 2 || argc > 4) {
-	usage(argv[0]);
+    if (argc < 2 || argc > 5) {
+	usage();
     }
 
     if (!strcmp(argv[1], "-")) {
@@ -241,6 +299,31 @@ PUBLIC int main ARGS2(
 	}
     }
 
+    if (argc > 2) {
+	if (!strcmp(argv[2], "-")) {
+	    chdr = stdout;
+	    hdrname = "stdout";
+	} else {
+	    hdrname = argv[2];
+	}
+    } else if (ctbl == stdin) {
+	chdr = stdout;
+	hdrname = "stdout";
+    } else {
+	strcpy(hdrname = outname, tblname);
+	if ((p = strrchr(outname, '.')) == 0)
+	    p = outname + strlen(outname);
+	strcpy(p, ".h");
+    }
+
+    if (chdr == 0) {
+	chdr = fopen(hdrname, "w");
+	if (!chdr) {
+	    perror(hdrname);
+	    done(EX_NOINPUT);
+	}
+    }
+
     /*
      *  For now we assume the default font is always 256 characters.
      */
@@ -488,7 +571,7 @@ PUBLIC int main ARGS2(
 	    *p1 = '\0';
 	    for (i = un0; i <= un1; i++) {
 #ifdef NOTDEFINED
-		printf("U+0x%x:%s\n", i, tbuf); */
+		fprintf(chdr, "U+0x%x:%s\n", i, tbuf); */
 #endif /* NOTDEFINED */
 		addpair_str(tbuf,i);
 	    }
@@ -637,8 +720,8 @@ PUBLIC int main ARGS2(
 	nuni += unicount[i];
     }
 
-    if (argc >= 3) {
-	strncpy(this_MIMEcharset,argv[2],UC_MAXLEN_MIMECSNAME);
+    if (argc > 3) {
+	strncpy(this_MIMEcharset,argv[3],UC_MAXLEN_MIMECSNAME);
     } else if (this_MIMEcharset[0] == '\0') {
 	strncpy(this_MIMEcharset,tblname,UC_MAXLEN_MIMECSNAME);
 	if ((p = strchr(this_MIMEcharset,'.')) != 0) {
@@ -648,8 +731,8 @@ PUBLIC int main ARGS2(
     for (p = this_MIMEcharset; *p; p++) {
 	*p = TOLOWER(*p);
     }
-    if (argc >= 4) {
-	strncpy(this_LYNXcharset,argv[3],UC_MAXLEN_LYNXCSNAME);
+    if (argc > 4) {
+	strncpy(this_LYNXcharset,argv[4],UC_MAXLEN_LYNXCSNAME);
     } else if (this_LYNXcharset[0] == '\0') {
 	strncpy(this_LYNXcharset,this_MIMEcharset,UC_MAXLEN_LYNXCSNAME);
     }
@@ -683,7 +766,12 @@ PUBLIC int main ARGS2(
     }
     fprintf(stderr, " (%s).\n", id_append);
 
-    printf("\
+    for (n = 0; n < TABLESIZE(first_ifdefs); n++) {
+	fprintf(chdr, first_ifdefs[n], id_append);
+	fprintf(chdr, "\n");
+    }
+
+    fprintf(chdr, "\n\
 /*\n\
  *  uni_hash.tbl\n\
  *\n\
@@ -700,13 +788,13 @@ static CONST u8 dfont_unicount%s[%d] = \n\
 	if (i >= 128 && unicount[i] > 0 && i < lowest_eight) {
 	    lowest_eight = i;
 	}
-	printf("%3d", unicount[i]);
+	fprintf(chdr, "%3d", unicount[i]);
 	if (i == (fontlen - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 8) == 7) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
 
@@ -719,10 +807,10 @@ static CONST u8 dfont_unicount%s[%d] = \n\
     }
 
     if (nuni) {
-	printf("\nstatic CONST u16 dfont_unitable%s[%d] = \n{\n\t",
+	fprintf(chdr, "\nstatic CONST u16 dfont_unitable%s[%d] = \n{\n\t",
 	       id_append, nuni);
     } else {
-	printf("\nstatic CONST u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
+	fprintf(chdr, "\nstatic CONST u16 dfont_unitable%s[1]; /* dummy */\n", id_append);
     }
 
     fp0 = 0;
@@ -732,57 +820,62 @@ static CONST u8 dfont_unicount%s[%d] = \n\
 	    fp0++;
 	    nent = 0;
 	}
-	printf("0x%04x", unitable[fp0][nent++]);
+	fprintf(chdr, "0x%04x", unitable[fp0][nent++]);
 	if (i == (nuni - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 8) == 7) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
 
     if (themap_str.entry_ct) {
-	printf("\n\
+	fprintf(chdr, "\n\
 static struct unipair_str repl_map%s[%d] = \n\
 {\n\t", id_append, themap_str.entry_ct);
     } else {
-	printf("\n\
+	fprintf(chdr, "\n\
 /* static struct unipair_str repl_map%s[]; */\n", id_append);
     }
 
     for (i = 0; i < themap_str.entry_ct; i++) {
-	printf("{0x%x,\"%s\"}",
+	fprintf(chdr, "{0x%x,\"%s\"}",
 	       themap_str.entries[i].unicode,
 	       themap_str.entries[i].replace_str);
 	if (i == (themap_str.entry_ct - 1)) {
-	    printf("\n};\n");
+	    fprintf(chdr, "\n};\n");
 	} else if ((i % 4) == 3) {
-	    printf(",\n\t");
+	    fprintf(chdr, ",\n\t");
 	} else {
-	    printf(", ");
+	    fprintf(chdr, ", ");
 	}
     }
     if (themap_str.entry_ct) {
-	printf("\n\
+	fprintf(chdr, "\n\
 static CONST struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s,",
 id_append, themap_str.entry_ct, id_append);
     } else {
-	printf("\n\
+	fprintf(chdr, "\n\
 static CONST struct unimapdesc_str dfont_replacedesc%s = {0,NULL,",id_append);
     }
-    printf("%d,%d};\n",
-    this_isDefaultMap ? 1 : 0,
-    (useDefaultMap && !this_isDefaultMap) ? 1 : 0
+    fprintf(chdr, "%d,%d};\n",
+	    this_isDefaultMap ? 1 : 0,
+	    (useDefaultMap && !this_isDefaultMap) ? 1 : 0
     );
 
 
-    printf("#define UC_CHARSET_SETUP%s UC_Charset_Setup(\
+    fprintf(chdr, "#define UC_CHARSET_SETUP%s UC_Charset_Setup(\
 \"%s\",\\\n\"%s\",\\\n\
 dfont_unicount%s,dfont_unitable%s,%d,\\\n\
 dfont_replacedesc%s,%d,%d,%d)\n",
 id_append, this_MIMEcharset, this_LYNXcharset,
 id_append, id_append, nuni, id_append, lowest_eight, RawOrEnc, CodePage);
 
+    for (n = 0; n < TABLESIZE(last_ifdefs); n++) {
+	fprintf(chdr, last_ifdefs[n], id_append);
+	fprintf(chdr, "\n");
+    }
+
     done(EX_OK);
 }
diff --git a/src/chrtrans/makew32.bat b/src/chrtrans/makew32.bat
index e0e28bc4..6339101d 100644
--- a/src/chrtrans/makew32.bat
+++ b/src/chrtrans/makew32.bat
@@ -1,44 +1,47 @@
 @echo If .tbl files are added or removed you will need to hand edit

 @echo this batch file.

+@echo .

 @echo off

+

 make -l -f makefile.bcb

-makeuctb cp1250_uni.tbl > cp1250_uni.h

-makeuctb cp1251_uni.tbl > cp1251_uni.h

-makeuctb cp1252_uni.tbl > cp1252_uni.h

-makeuctb cp1253_uni.tbl > cp1253_uni.h

-makeuctb cp1255_uni.tbl > cp1255_uni.h

-makeuctb cp1256_uni.tbl > cp1256_uni.h

-makeuctb cp1257_uni.tbl > cp1257_uni.h

-makeuctb cp437_uni.tbl > cp437_uni.h

-makeuctb cp737_uni.tbl > cp737_uni.h

-makeuctb cp775_uni.tbl > cp775_uni.h

-makeuctb cp850_uni.tbl > cp850_uni.h

-makeuctb cp852_uni.tbl > cp852_uni.h

-makeuctb cp862_uni.tbl > cp862_uni.h

-makeuctb cp864_uni.tbl > cp864_uni.h

-makeuctb cp866_uni.tbl > cp866_uni.h

-makeuctb cp866u_uni.tbl > cp866u_uni.h

-makeuctb cp869_uni.tbl > cp869_uni.h

-makeuctb def7_uni.tbl  > def7_uni.h

-makeuctb dmcs_uni.tbl > dmcs_uni.h

-makeuctb hp_uni.tbl > hp_uni.h

-makeuctb iso01_uni.tbl > iso01_uni.h

-makeuctb iso02_uni.tbl > iso02_uni.h

-makeuctb iso03_uni.tbl > iso03_uni.h

-makeuctb iso04_uni.tbl > iso04_uni.h

-makeuctb iso05_uni.tbl > iso05_uni.h

-makeuctb iso06_uni.tbl > iso06_uni.h

-makeuctb iso07_uni.tbl > iso07_uni.h

-makeuctb iso08_uni.tbl > iso08_uni.h

-makeuctb iso09_uni.tbl > iso09_uni.h

-makeuctb iso10_uni.tbl > iso10_uni.h

-makeuctb iso15_uni.tbl > iso15_uni.h

-makeuctb koi8r_uni.tbl > koi8r_uni.h

-makeuctb koi8u_uni.tbl > koi8u_uni.h

-makeuctb mac_uni.tbl > mac_uni.h

-makeuctb mnem2_suni.tbl > mnem2_suni.h

-makeuctb mnem_suni.tbl > mnem_suni.h

-makeuctb next_uni.tbl > next_uni.h

-makeuctb rfc_suni.tbl > rfc_suni.h

-makeuctb utf8_uni.tbl > utf8_uni.h

-makeuctb viscii_uni.tbl > viscii_uni.h

+

+makeuctb cp1250_uni.tbl

+makeuctb cp1251_uni.tbl

+makeuctb cp1252_uni.tbl

+makeuctb cp1253_uni.tbl

+makeuctb cp1255_uni.tbl

+makeuctb cp1256_uni.tbl

+makeuctb cp1257_uni.tbl

+makeuctb cp437_uni.tbl

+makeuctb cp737_uni.tbl

+makeuctb cp775_uni.tbl

+makeuctb cp850_uni.tbl

+makeuctb cp852_uni.tbl

+makeuctb cp862_uni.tbl

+makeuctb cp864_uni.tbl

+makeuctb cp866_uni.tbl

+makeuctb cp866u_uni.tbl

+makeuctb cp869_uni.tbl

+makeuctb def7_uni.tbl

+makeuctb dmcs_uni.tbl

+makeuctb hp_uni.tbl

+makeuctb iso01_uni.tbl

+makeuctb iso02_uni.tbl

+makeuctb iso03_uni.tbl

+makeuctb iso04_uni.tbl

+makeuctb iso05_uni.tbl

+makeuctb iso06_uni.tbl

+makeuctb iso07_uni.tbl

+makeuctb iso08_uni.tbl

+makeuctb iso09_uni.tbl

+makeuctb iso10_uni.tbl

+makeuctb iso15_uni.tbl

+makeuctb koi8r_uni.tbl

+makeuctb koi8u_uni.tbl

+makeuctb mac_uni.tbl

+makeuctb mnem2_suni.tbl

+makeuctb mnem_suni.tbl

+makeuctb next_uni.tbl

+makeuctb rfc_suni.tbl

+makeuctb utf8_uni.tbl

+makeuctb viscii_uni.tbl

diff --git a/src/makefile.in b/src/makefile.in
index ba451262..233e043c 100644
--- a/src/makefile.in
+++ b/src/makefile.in
@@ -21,6 +21,7 @@ CC		= @CC@
 CPP		= @CPP@
 CFLAGS		= @CFLAGS@
 DEFS		= @DEFS@
+CHARSET_DEFS	= @CHARSET_DEFS@
 CPPFLAGS	= @CPPFLAGS@
 
 LIBS		= @LIBS@ $(RESOLVLIB) $(WAISLIB) $(SITE_LIBS)
@@ -38,7 +39,7 @@ WWWLIB		= $(top_builddir)/WWW/Library/Implementation/libwww.a
 INTLLIB		= @INTLDIR_MAKE@@INTLLIBS@
 INTLDIR_CPPFLAGS= @INTLDIR_CPPFLAGS@-I$(top_srcdir)/intl
 
-CPP_OPTS	= $(DEFS) $(CPPFLAGS) \
+CPP_OPTS	= $(CHARSET_DEFS) $(DEFS) $(CPPFLAGS) \
 		-DLOCALEDIR=\"$(localedir)\" \
 		-I. \
 		-I$(top_builddir) \
@@ -85,7 +86,8 @@ lynx$x:   message do_chartrans_stuff $(top_builddir)/LYHelp.h $(OBJS) $(WWWLIB)
 	@echo "Linking and creating Lynx executable"
 	$(CC) $(CC_OPTS) $(LDFLAGS) -o $@  $(OBJS) $(WWWLIB) $(INTLLIB) $(LIBS)
 	@echo "Copying Lynx executable into top-level directory"
-	cp $@ $(top_builddir)
+	rm -f $(top_builddir)/$@
+	cp $@ $(top_builddir)/
 	@echo "Welcome to Lynx!"
 
 message: