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.c38
-rw-r--r--src/HTML.c25
-rw-r--r--src/LYCharUtils.c15
-rw-r--r--src/LYCookie.c4
-rw-r--r--src/LYCurses.c38
-rw-r--r--src/LYForms.c3
-rw-r--r--src/LYJump.c2
-rw-r--r--src/LYMain.c21
-rw-r--r--src/LYMainLoop.c6
-rw-r--r--src/LYOptions.c4
-rw-r--r--src/LYReadCFG.c6
-rw-r--r--src/LYStrings.c40
-rw-r--r--src/LYUtils.c97
-rw-r--r--src/LYUtils.h1
-rw-r--r--src/LYrcFile.h2
-rw-r--r--src/TRSTable.c4
-rw-r--r--src/UCAux.c4
-rw-r--r--src/UCdomap.c86
18 files changed, 276 insertions, 120 deletions
diff --git a/src/GridText.c b/src/GridText.c
index e1d2c335..c2175b02 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -2809,14 +2809,14 @@ static void split_line(HText *text, unsigned split)
     }
     if (split > previous->size) {
 	CTRACE((tfp,
-		"*** split_line: split==%d greater than last_line->size==%d !\n",
+		"*** split_line: split==%u greater than last_line->size==%d !\n",
 		split, previous->size));
 	if (split > MAX_LINE) {
 	    split = previous->size;
 	    if ((cp = strrchr(previous->data, ' ')) &&
 		cp - previous->data > 1)
 		split = cp - previous->data;
-	    CTRACE((tfp, "                split adjusted to %d.\n", split));
+	    CTRACE((tfp, "                split adjusted to %u.\n", split));
 	}
     }
 
@@ -2965,7 +2965,7 @@ static void split_line(HText *text, unsigned split)
 #ifdef DEBUG_APPCH
     if (s != (int) split)
 #endif
-	CTRACE((tfp, "GridText: split_line(%d [now:%d]) called\n", split, s));
+	CTRACE((tfp, "GridText: split_line(%u [now:%d]) called\n", split, s));
 #endif
 
 #if defined(USE_COLOR_STYLE)
@@ -4253,7 +4253,7 @@ void HText_appendCharacter(HText *text, int ch)
 	 + (int) style->rightIndent
 	 - ctrl_chars_on_this_line
 	 + (((HTCJK != NOCJK) && text->kanji_buf) ? 1 : 0)
-	) >= (WRAP_COLS(text) - 1)
+	) >= WRAP_COLS(text)
 	|| (text->T.output_utf8
 	    && ((actual
 		 + UTFXTRA_ON_THIS_LINE
@@ -9696,7 +9696,7 @@ int HText_beginInput(HText *text, BOOL underline,
 
     f->select_list = 0;
     f->number = HTFormNumber;
-    f->disabled = (HTFormDisabled ? TRUE : I->disabled);
+    f->disabled = HTFormDisabled;
     f->no_cache = NO;
 
     HTFormFields++;
@@ -9983,14 +9983,13 @@ int HText_beginInput(HText *text, BOOL underline,
     }
     if (fields_are_numbered() && (a->number > 0)) {
 	sprintf(marker, "[%d]", a->number);
+	adjust_marker = strlen(marker);
 	if (number_fields_on_left) {
 	    BOOL had_bracket = (f->type == F_OPTION_LIST_TYPE);
 
 	    HText_appendText(text, had_bracket ? (marker + 1) : marker);
 	    if (had_bracket)
 		HText_appendCharacter(text, '[');
-	} else {
-	    adjust_marker = strlen(marker);
 	}
 	a->line_num = text->Lines;
 	a->line_pos = text->last_line->size;
@@ -10049,6 +10048,10 @@ int HText_beginInput(HText *text, BOOL underline,
 	MaximumSize -= 10;
 	break;
     }
+
+    if (MaximumSize < 1)
+	MaximumSize = 1;
+
     if (f->size > MaximumSize)
 	f->size = MaximumSize;
 
@@ -10099,6 +10102,9 @@ int HText_beginInput(HText *text, BOOL underline,
     /*
      * Return the SIZE of the input field.
      */
+    if (I->size && f->size > adjust_marker) {
+	f->size -= adjust_marker;
+    }
     return (f->size);
 }
 
@@ -10654,9 +10660,9 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name,
 	    !anchor_ptr->input_field->disabled) {
 
 	    FormInfo *form_ptr = anchor_ptr->input_field;
-	    char *val = form_ptr->cp_submit_value != NULL
-	    ? form_ptr->cp_submit_value
-	    : form_ptr->value;
+	    char *val = (form_ptr->cp_submit_value != NULL
+			 ? form_ptr->cp_submit_value
+			 : form_ptr->value);
 
 	    unsigned field_is_special = check_form_specialchars(val);
 	    unsigned name_is_special = check_form_specialchars(form_ptr->name);
@@ -10897,9 +10903,9 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name,
 		    CTRACE((tfp, "field \"%s\" %d %s -> %d %s %s\n",
 			    NonNull(form_ptr->name),
 			    form_ptr->value_cs,
-			    form_ptr->value_cs >= 0
-			    ? LYCharSet_UC[form_ptr->value_cs].MIMEname
-			    : "???",
+			    ((form_ptr->value_cs >= 0)
+			     ? LYCharSet_UC[form_ptr->value_cs].MIMEname
+			     : "???"),
 			    target_cs,
 			    target_csname ? target_csname : "???",
 			    success ? "OK" : "FAILED"));
@@ -10960,9 +10966,9 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name,
 		    CTRACE((tfp, "name \"%s\" %d %s -> %d %s %s\n",
 			    NonNull(form_ptr->name),
 			    form_ptr->name_cs,
-			    form_ptr->name_cs >= 0
-			    ? LYCharSet_UC[form_ptr->name_cs].MIMEname
-			    : "???",
+			    ((form_ptr->name_cs >= 0)
+			     ? LYCharSet_UC[form_ptr->name_cs].MIMEname
+			     : "???"),
 			    target_cs,
 			    target_csname ? target_csname : "???",
 			    success ? "OK" : "FAILED"));
diff --git a/src/HTML.c b/src/HTML.c
index b0c1d47f..03efce72 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -3037,9 +3037,10 @@ static int HTML_start_element(HTStructured * me, int element_number,
 	     * set, we'll use the current document's URL for resolving. 
 	     * Otherwise use the BASE.  - kw
 	     */
-	    Base = (me->inBASE &&
-		    !(*map_href == '#' && LYSeekFragMAPinCur == TRUE)) ?
-		me->base_href : me->node_anchor->address;
+	    Base = ((me->inBASE &&
+		     !(*map_href == '#' && LYSeekFragMAPinCur == TRUE))
+		    ? me->base_href
+		    : me->node_anchor->address);
 	    HTParseALL(&map_href, Base);
 
 	    /*
@@ -3511,9 +3512,10 @@ static int HTML_start_element(HTStructured * me, int element_number,
 	     * itself, unless the HREF is a lone fragment and
 	     * LYSeekFragAREAinCur is set.  - FM
 	     */
-	    Base = ((me->inBASE && *href != '\0') &&
-		    !(*href == '#' && LYSeekFragAREAinCur == TRUE)) ?
-		me->base_href : me->node_anchor->address;
+	    Base = (((me->inBASE && *href != '\0') &&
+		     !(*href == '#' && LYSeekFragAREAinCur == TRUE))
+		    ? me->base_href
+		    : me->node_anchor->address);
 	    HTParseALL(&href, Base);
 
 	    /*
@@ -4442,8 +4444,9 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		 */
 		for (i = 0; I.value[i]; i++) {
 		    HTML_put_character(me,
-				       (char) (I.value[i] == ' ' ?
-					       HT_NON_BREAK_SPACE : I.value[i]));
+				       (I.value[i] == ' ')
+				       ? HT_NON_BREAK_SPACE
+				       : I.value[i]);
 		}
 		while (i++ < chars) {
 		    HTML_put_character(me, HT_NON_BREAK_SPACE);
@@ -4628,6 +4631,7 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		UNESCAPE_FIELDNAME_TO_STD(&I_name);
 		I.name = I_name;
 	    }
+
 	    if ((present && present[HTML_INPUT_ALT] &&
 		 non_empty(value[HTML_INPUT_ALT]) &&
 		 I.type && !strcasecomp(I.type, "image")) &&
@@ -4815,12 +4819,10 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		I.md = value[HTML_INPUT_MD];
 
 	    chars = HText_beginInput(me->text, me->inUnderline, &I);
-#ifndef USE_FILE_UPLOAD
 	    CTRACE((tfp,
 		    "I.%s have %d chars, or something\n",
 		    NONNULL(I.type),
 		    chars));
-#endif
 	    /*
 	     * Submit and reset buttons have values which don't change, so
 	     * HText_beginInput() sets I.value to the string which should be
@@ -4890,9 +4892,7 @@ static int HTML_start_element(HTStructured * me, int element_number,
 		}
 		HText_setIgnoreExcess(me->text, TRUE);
 	    }
-#ifndef USE_FILE_UPLOAD
 	    CTRACE((tfp, "I.%s, %d\n", NONNULL(I.type), IsSubmitOrReset));
-#endif
 	    if (IsSubmitOrReset == FALSE) {
 		/*
 		 * This is not a submit or reset button, so output the rest of
@@ -6163,6 +6163,7 @@ static int HTML_end_element(HTStructured * me, int element_number,
 	/*
 	 * Set to know that we are no longer in a PRE block.
 	 */
+	HText_appendCharacter(me->text, '\n');
 	me->inPRE = FALSE;
 	/* FALLTHRU */
     case HTML_LISTING:		/* Literal text */
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index e3c42602..defd13e3 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -1145,6 +1145,7 @@ char **LYUCFullyTranslateString(char **str,
     if ((HTCJK != NOCJK)
 #ifdef EXP_JAPANESEUTF8_SUPPORT
 	&& (strcmp(LYCharSet_UC[cs_from].MIMEname, "utf-8") != 0)
+	&& (strcmp(LYCharSet_UC[cs_to].MIMEname, "utf-8") != 0)
 #endif
 	) {
 	no_bytetrans = TRUE;
@@ -1392,6 +1393,20 @@ char **LYUCFullyTranslateString(char **str,
 		    } else {
 			*(unsigned char *) p = UCH(173);
 		    }
+#ifdef EXP_JAPANESEUTF8_SUPPORT
+		} else if (output_utf8) {
+		    if ((!strcmp(LYCharSet_UC[cs_from].MIMEname, "euc-jp") &&
+			 (IS_EUC((unsigned char) (*p),
+				 (unsigned char) (*(p + 1))))) ||
+			(!strcmp(LYCharSet_UC[cs_from].MIMEname, "shift_jis") &&
+			 (IS_SJIS_2BYTE((unsigned char) (*p),
+					(unsigned char) (*(p + 1)))))) {
+			code = UCTransJPToUni(p, 2, cs_from);
+			p++;
+			state = S_check_uni;
+			break;
+		    }
+#endif
 		} else if (code < 127 || T.transp) {
 		    state = S_got_outchar;
 		    break;
diff --git a/src/LYCookie.c b/src/LYCookie.c
index f54f7db0..561f3676 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -305,7 +305,7 @@ static domain_entry *find_domain_entry(const char *name)
 	    if (de != NULL && de->domain != NULL) {
 		CTRACE2(TRACE_CFG,
 			(tfp,
-			 "...test_domain_entry(%s) bv:%d, invcheck_bv:%d\n",
+			 "...test_domain_entry(%s) bv:%u, invcheck_bv:%u\n",
 			 de->domain,
 			 de->bv,
 			 de->invcheck_bv));
@@ -2643,7 +2643,7 @@ static void cookie_domain_flag_set(char *domainstr,
 	    break;
 	}
 	CTRACE((tfp,
-		"cookie_domain_flag_set (%s, bv=%d, invcheck_bv=%d)\n",
+		"cookie_domain_flag_set (%s, bv=%u, invcheck_bv=%u)\n",
 		strsmall, de->bv, de->invcheck_bv));
     }
 
diff --git a/src/LYCurses.c b/src/LYCurses.c
index e608520b..7b68dbda 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -570,6 +570,10 @@ int lynx_default_colors(void)
 	    default_fg = DEFAULT_COLOR;
 	    default_bg = DEFAULT_COLOR;
 	    code = 1;
+	} else {
+	    default_fg = COLOR_WHITE;
+	    default_bg = COLOR_BLACK;
+	    default_color_reset = TRUE;
 	}
     }
     return code;
@@ -859,6 +863,12 @@ void start_curses(void)
     }
 
     if (slinit == 0) {
+#if defined(HAVE_TTYNAME)
+	if (isatty(fileno(stdout)) && LYReopenInput() < 0) {
+	    fprintf(stderr, "Cannot open tty input\n");
+	    exit_immediately(EXIT_FAILURE);
+	}
+#endif
 #if defined(USE_KEYMAPS)
 	if (-1 == lynx_initialize_keymaps())
 	    exit_immediately(EXIT_FAILURE);
@@ -967,6 +977,13 @@ void start_curses(void)
     initscr();			/* start curses */
 #else /* Unix: */
 
+#if defined(HAVE_TTYNAME)
+    if (isatty(fileno(stdout)) && LYReopenInput() < 0) {
+	fprintf(stderr, "Cannot open tty input\n");
+	exit_immediately(EXIT_FAILURE);
+    }
+#endif
+
 #ifdef __CYGWIN__
     /*
      * Workaround for buggy Cygwin, which breaks subprocesses of a
@@ -1110,7 +1127,7 @@ void start_curses(void)
 			lynx_color_cfg[n].fg = default_fg;
 		    if (default_bg >= 0 && lynx_color_cfg[n].bg < 0)
 			lynx_color_cfg[n].bg = default_bg;
-		    CTRACE((tfp, "color_cfg[%d] = %d/%d\n", n,
+		    CTRACE((tfp, "color_cfg[%u] = %d/%d\n", n,
 			    lynx_color_cfg[n].fg,
 			    lynx_color_cfg[n].bg));
 		}
@@ -1673,8 +1690,13 @@ WINDOW *LYstartPopup(int *top_y,
     if (*left_x > 0 && (*left_x + *width + 4) < LYcolLimit)
 	form_window = newwin(*height, *width + 4, *top_y, *left_x - 1);
     if (form_window == 0) {
-	*width = LYcolLimit - 4;
-	form_window = newwin(*height, LYcolLimit, *top_y, 0);
+	if (*width > LYcolLimit - 4) {
+	    *width = LYcolLimit - 4;
+	    *left_x = 1;
+	} else {
+	    *left_x = LYcolLimit - 4 - *width;
+	}
+	form_window = newwin(*height, *width + 4, *top_y, *left_x - 1);
     }
     if (form_window == 0) {
 	HTAlert(POPUP_FAILED);
@@ -1772,9 +1794,9 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
 	int start = 0;
 	int piece = (LYcolLimit - x0);
 
-	CTRACE((tfp, "LYwaddnstr wrapping src:%s, len:%d:%d\n", src, len, LYcolLimit));
+	CTRACE((tfp, "LYwaddnstr wrapping src:%s, len:%u:%d\n", src, len, LYcolLimit));
 	LYwideLines = TRUE;	/* prevent recursion */
-	for (;;) {
+	while (piece > 0) {
 	    int y, x;
 
 	    getyx(LYwin, y, x);
@@ -1801,15 +1823,15 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
 	int y, x;
 
 	LYGetYX(y, x);
-	CTRACE2(TRACE_STYLE, (tfp, "[%2d,%2d] LYwaddnstr(%.*s)\n",
-			      y, x, (int) len, src));
+	CTRACE2(TRACE_STYLE, (tfp, "[%2d,%2d] LYwaddnstr(%.*s, %u)\n",
+			      y, x, (int) len, src, (unsigned) len));
     }
 #endif
     /*
      * There's no guarantee that a library won't temporarily write on its input.
      * Be safe and copy it when we have const-data.
      */
-    while (len > 0) {
+    while ((int) len > 0) {
 	char temp[MAX_LINE];
 	size_t use = (len >= MAX_LINE) ? MAX_LINE - 1 : len;
 
diff --git a/src/LYForms.c b/src/LYForms.c
index e5695db6..80fafbc5 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -69,6 +69,7 @@ int change_form_link_ex(int cur,
     int newdoc_changed = 0;
     int c = DO_NOTHING;
     int OrigNumValue;
+    int title_adjust = (no_title ? -TITLE_LINES : 0);
     char **my_data = 0;
 
     /*
@@ -82,7 +83,7 @@ int change_form_link_ex(int cur,
     /*
      * Move to the link position.
      */
-    LYmove(links[cur].ly, links[cur].lx);
+    LYmove(links[cur].ly + title_adjust, links[cur].lx);
 
     switch (form->type) {
     case F_CHECKBOX_TYPE:
diff --git a/src/LYJump.c b/src/LYJump.c
index 903c2ee2..f3af593f 100644
--- a/src/LYJump.c
+++ b/src/LYJump.c
@@ -475,7 +475,7 @@ static unsigned LYRead_Jumpfile(struct JumpTable *jtp)
 	if (cp == NULL)
 	    break;
 	cp++;
-	CTRACE((tfp, "Read jumpfile[%d] key='%s', url='%s'\n",
+	CTRACE((tfp, "Read jumpfile[%u] key='%s', url='%s'\n",
 		i, jtp->table[i].key, jtp->table[i].url));
 	i++;
 	if (!cp)
diff --git a/src/LYMain.c b/src/LYMain.c
index f5e8b353..0aa29e71 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1620,19 +1620,13 @@ int main(int argc,
     /*
      * If we are told to read the startfile from standard input, do it now,
      * after we have read all of the option data from standard input.
+     * Later we'll use LYReopenInput().
      */
     if (startfile_stdin) {
 	char result[LY_MAXPATH];
 	char *buf = NULL;
-	const char *tty = NULL;
 
-# ifdef HAVE_TTYNAME
-	tty = ttyname(fileno(stderr));
-# endif
-	if (tty == NULL)
-	    tty = isatty(fileno(stdin)) ? TTY_DEVICE : NUL_DEVICE;
-
-	CTRACE((tfp, "processing stdin startfile, tty=%s\n", tty));
+	CTRACE((tfp, "processing stdin startfile\n"));
 	if ((fp = LYOpenTemp(result, HTML_SUFFIX, "w")) != 0) {
 	    StrAllocCopy(startfile, result);
 	    while (GetStdin(&buf, FALSE)) {
@@ -1643,13 +1637,6 @@ int main(int argc,
 	    LYCloseTempFP(fp);
 	}
 	CTRACE((tfp, "...done stdin startfile\n"));
-	if ((freopen(tty, "r", stdin)) == 0) {
-	    CTRACE((tfp, "cannot open a terminal (%s)\n", tty));
-	    if (!dump_output_immediately) {
-		fprintf(stderr, "cannot open a terminal (%s)\n", tty);
-		exit_immediately(1);
-	    }
-	}
     }
 #endif
 
@@ -4080,7 +4067,7 @@ static BOOL parse_arg(char **argv,
 #endif
 
     arg_name = argv[0];
-    CTRACE((tfp, "parse_arg(arg_name=%s, mask=%d, count=%d)\n",
+    CTRACE((tfp, "parse_arg(arg_name=%s, mask=%u, count=%d)\n",
 	    arg_name, mask, countp ? *countp : -1));
 
 #if EXTENDED_STARTFILE_RECALL
@@ -4178,7 +4165,7 @@ static BOOL parse_arg(char **argv,
 
 	/* ignore option if it's not our turn */
 	if ((p->type & mask) == 0) {
-	    CTRACE((tfp, "...skip (mask %d/%d)\n", mask, p->type & 7));
+	    CTRACE((tfp, "...skip (mask %u/%d)\n", mask, p->type & 7));
 	    return FALSE;
 	}
 
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 38eedf3c..1de98d5b 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -5235,9 +5235,9 @@ int mainloop(void)
     char cfile[128];
     FILE *cfp;
     char *cp;
-    int ch;
-    RecallType recall;
-    int URLTotal;
+    int ch = 0;
+    RecallType recall = NORECALL;
+    int URLTotal = 0;
     int URLNum;
     BOOLEAN FirstURLRecall = TRUE;
     char *temp = NULL;
diff --git a/src/LYOptions.c b/src/LYOptions.c
index dd5b5c07..fffa9011 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -2589,7 +2589,7 @@ int postoptions(DocInfo *newdoc)
     PostPair *data = 0;
     DocAddress WWWDoc;		/* need on exit */
     int i;
-    int code;
+    int code = 0;
     BOOLEAN save_all = FALSE;
     int display_char_set_old = current_char_set;
     int old_media_value = LYAcceptMedia;
@@ -2748,7 +2748,7 @@ int postoptions(DocInfo *newdoc)
 
 	/* Keypad Mode: SELECT */
 	if (!strcmp(data[i].tag, keypad_mode_string)) {
-	    int newval;
+	    int newval = 0;
 
 	    if (GetOptValues(keypad_mode_values, data[i].value, &newval)
 		&& keypad_mode != newval) {
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index a6a8f384..e8e21d55 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1272,7 +1272,7 @@ static Config_Type Config_Table [] =
      PARSE_STR(RC_COOKIE_SAVE_FILE,     LYCookieSaveFile),
 #endif /* USE_PERSISTENT_COOKIES */
      PARSE_STR(RC_COOKIE_STRICT_INVALID_DOMAIN, LYCookieSStrictCheckDomains),
-     PARSE_Env(RC_CSO_PROXY,		0),
+     PARSE_Env(RC_CSO_PROXY,            0),
 #ifdef VMS
      PARSE_PRG(RC_CSWING_PATH,          ppCSWING),
 #endif
@@ -1406,9 +1406,11 @@ static Config_Type Config_Table [] =
 #endif
      PARSE_SET(RC_NO_FROM_HEADER,       LYNoFromHeader),
      PARSE_SET(RC_NO_ISMAP_IF_USEMAP,   LYNoISMAPifUSEMAP),
+     PARSE_SET(RC_NO_MARGINS,           no_margins),
      PARSE_Env(RC_NO_PROXY,             0),
      PARSE_SET(RC_NO_REFERER_HEADER,    LYNoRefererHeader),
      PARSE_SET(RC_NO_TABLE_CENTER,      no_table_center),
+     PARSE_SET(RC_NO_TITLE,             no_title),
      PARSE_FUN(RC_NONRESTARTING_SIGWINCH, nonrest_sigwinch_fun),
      PARSE_FUN(RC_OUTGOING_MAIL_CHARSET, outgoing_mail_charset_fun),
 #ifdef DISP_PARTIAL
@@ -1474,7 +1476,7 @@ static Config_Type Config_Table [] =
      PARSE_FUN(RC_SUFFIX_ORDER,         suffix_order_fun),
 #ifdef SYSLOG_REQUESTED_URLS
      PARSE_SET(RC_SYSLOG_REQUESTED_URLS, syslog_requested_urls),
-     PARSE_SET(RC_SYSLOG_TEXT,		syslog_txt),
+     PARSE_SET(RC_SYSLOG_TEXT,          syslog_txt),
 #endif
      PARSE_FUN(RC_SYSTEM_EDITOR,        system_editor_fun),
      PARSE_STR(RC_SYSTEM_MAIL,          system_mail),
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 4fe7be02..92eaf1bd 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1062,7 +1062,7 @@ static BOOLEAN unescape_string(char *src, char *dst, char *final)
     BOOLEAN ok = FALSE;
 
     if (*src == SQUOTE) {
-	int keysym;
+	int keysym = -1;
 
 	unescaped_char(src, &keysym);
 	if (keysym >= 0) {
@@ -1677,42 +1677,18 @@ static int LYgetch_for(int code)
 	 || (c == 0xFFFF)
 #endif
 	)) {
-	int fd, kbd_fd;
 
 	CTRACE((tfp,
 		"nozap: Got EOF, curses %s, stdin is %p, LYNoZapKey reduced from %d to 0.\n",
 		LYCursesON ? "on" : "off", stdin, LYNoZapKey));
 	LYNoZapKey = 0;		/* 2 -> 0 */
-	if ((fd = fileno(stdin)) == 0 && !isatty(fd) &&
-	    (kbd_fd = LYConsoleInputFD(FALSE)) == fd) {
-	    char *term_name;
-	    int new_fd = INVSOC;
-
-	    if ((term_name = ttyname(fileno(stdout))) != NULL)
-		new_fd = open(term_name, O_RDONLY);
-	    if (new_fd == INVSOC &&
-		(term_name = ttyname(fileno(stderr))) != NULL)
-		new_fd = open(term_name, O_RDONLY);
-	    if (new_fd == INVSOC) {
-		term_name = ctermid(NULL);
-		new_fd = open(term_name, O_RDONLY);
-	    }
-	    CTRACE((tfp, "nozap: open(%s) returned %d.\n", term_name, new_fd));
-	    if (new_fd >= 0) {
-		FILE *frp;
-
-		close(new_fd);
-		frp = freopen(term_name, "r", stdin);
-		CTRACE((tfp,
-			"nozap: freopen(%s,\"r\",stdin) returned %p, stdin is now %p with fd %d.\n",
-			term_name, frp, stdin, fileno(stdin)));
-		if (LYCursesON) {
-		    stop_curses();
-		    start_curses();
-		    LYrefresh();
-		}
-		goto re_read;
+	if (LYReopenInput() > 0) {
+	    if (LYCursesON) {
+		stop_curses();
+		start_curses();
+		LYrefresh();
 	    }
+	    goto re_read;
 	}
     }
 #endif /* MISC_EXP */
@@ -2864,7 +2840,7 @@ static int map_active = 0;
 
 int LYEditInsert(EDREC * edit, unsigned const char *s,
 		 int len,
-		 int map,
+		 int map GCC_UNUSED,
 		 BOOL maxMessage)
 {
     int length = strlen(Buf);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 4fde7d96..ca4a3741 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -970,7 +970,7 @@ static int find_cached_style(int cur,
 			    s = cached_styles[LYP][x];
 			    cached_styles[LYP][LXP] = s;
 			}
-			CTRACE((tfp, "found %d, x_offset=%d.\n",
+			CTRACE((tfp, "found %u, x_offset=%d.\n",
 				cached_styles[LYP][x], (int) x - LXP));
 			break;
 		    }
@@ -1496,7 +1496,68 @@ void noviceline(int more_flag GCC_UNUSED)
     return;
 }
 
-#if defined(NSL_FORK) || defined(MISC_EXP)
+#if defined(MISC_EXP) || defined(TTY_DEVICE) || defined(HAVE_TTYNAME)
+/*
+ * If the standard input is not a tty, and Lynx is really reading from the
+ * standard input, attempt to reopen it, pointing to a real tty.  Normally
+ * this would happen if the user pipes data to Lynx and wants to run
+ * interactively after that.
+ *
+ * Returns:
+ *     1  if successfully reopened
+ *    -1  if we cannot reopen
+ *     0  if we do not have to reopen
+ */
+int LYReopenInput(void)
+{
+    int result = 0;
+    int fd;
+
+    if ((fd = fileno(stdin)) == 0
+	&& !isatty(fd)
+	&& LYConsoleInputFD(FALSE) == fd) {
+	char *term_name = NULL;
+	int new_fd = -1;
+
+#ifdef HAVE_TTYNAME
+	if (isatty(fileno(stdout)) &&
+	    (term_name = ttyname(fileno(stdout))) != NULL)
+	    new_fd = open(term_name, O_RDONLY);
+
+	if (new_fd == -1 &&
+	    isatty(fileno(stderr)) &&
+	    (term_name = ttyname(fileno(stderr))) != NULL)
+	    new_fd = open(term_name, O_RDONLY);
+
+	if (new_fd == -1 &&
+	    (term_name = ctermid(NULL)) != NULL)
+	    new_fd = open(term_name, O_RDONLY);
+#endif
+
+#ifdef TTY_DEVICE
+	if (new_fd == -1)
+	    new_fd = open(term_name = TTY_DEVICE, O_RDONLY);
+#endif
+
+	CTRACE((tfp, "LYReopenInput open(%s) returned %d.\n", term_name, new_fd));
+	if (new_fd >= 0) {
+	    FILE *frp;
+
+	    close(new_fd);
+	    frp = freopen(term_name, "r", stdin);
+	    CTRACE((tfp,
+		    "LYReopenInput freopen(%s,\"r\",stdin) returned %p, stdin is now %p with fd %d.\n",
+		    term_name, frp, stdin, fileno(stdin)));
+	    result = 1;
+	} else {
+	    result = -1;
+	}
+    }
+    return result;
+}
+#endif
+
+#if defined(NSL_FORK) || defined(MISC_EXP) || defined (TTY_DEVICE) || defined(HAVE_TTYNAME)
 /*
  * Returns the file descriptor from which keyboard input is expected, or INVSOC
  * (-1) if not available.  If need_selectable is true, returns non-INVSOC fd
@@ -4365,9 +4426,9 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
 			   char *prefix_list,
 			   char *suffix_list)
 {
-    char DomainPrefix[80];
+    char *DomainPrefix = NULL;
     const char *StartP, *EndP;
-    char DomainSuffix[80];
+    char *DomainSuffix = NULL;
     const char *StartS, *EndS;
     char *Str = NULL, *StrColon = NULL, *MsgStr = NULL;
     char *Host = NULL, *HostColon = NULL, *host = NULL;
@@ -4425,8 +4486,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
     if ((StrColon = strrchr(Str, ':')) != NULL &&
 	isdigit(UCH(StrColon[1]))) {
 	if (StrColon == Str) {
-	    FREE(Str);
-	    return GotHost;
+	    goto cleanup;
 	}
 	*StrColon = '\0';
     }
@@ -4468,10 +4528,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
 	 * Return success.  - FM
 	 */
 	GotHost = TRUE;
-	FREE(host);
-	FREE(Str);
-	FREE(MsgStr);
-	return GotHost;
+	goto cleanup;
     } else if (LYCursesON && (lynx_nsl_status == HT_INTERRUPTED)) {
 	/*
 	 * Give the user chance to interrupt lookup cycles.  - KW & FM
@@ -4483,10 +4540,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
 	/*
 	 * Return failure.  - FM
 	 */
-	FREE(host);
-	FREE(Str);
-	FREE(MsgStr);
-	return FALSE;
+	goto cleanup;
     }
 
     /*
@@ -4521,7 +4575,8 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
     while (*EndP && !WHITE(*EndP) && *EndP != ',') {
 	EndP++;			/* Find separator */
     }
-    LYstrncpy(DomainPrefix, StartP, (EndP - StartP));
+    StrAllocCopy(DomainPrefix, StartP);
+    DomainPrefix[EndP - StartP] = '\0';
 
     /*
      * Test each prefix with each suffix.  - FM
@@ -4541,7 +4596,8 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
 	while (*EndS && !WHITE(*EndS) && *EndS != ',') {
 	    EndS++;		/* Find separator */
 	}
-	LYstrncpy(DomainSuffix, StartS, (EndS - StartS));
+	StrAllocCopy(DomainSuffix, StartS);
+	DomainSuffix[EndS - StartS] = '\0';
 
 	/*
 	 * Create domain names and do DNS tests.  - FM
@@ -4579,11 +4635,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
 		    CTRACE((tfp,
 			    "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n",
 			    host));
-		    FREE(Str);
-		    FREE(MsgStr);
-		    FREE(Host);
-		    FREE(host);
-		    return FALSE;	/* We didn't find a valid name. */
+		    goto cleanup;	/* We didn't find a valid name. */
 		}
 
 		/*
@@ -4651,6 +4703,9 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
     /*
      * Clean up and return the last test result.  - FM
      */
+  cleanup:
+    FREE(DomainPrefix);
+    FREE(DomainSuffix);
     FREE(Str);
     FREE(MsgStr);
     FREE(Host);
diff --git a/src/LYUtils.h b/src/LYUtils.h
index d9e26567..9844d728 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -144,6 +144,7 @@ extern "C" {
     extern int LYCopyFile(char *src, char *dst);
     extern int LYGetHilitePos(int cur, int count);
     extern int LYRemoveTemp(char *name);
+    extern int LYReopenInput(void);
     extern int LYSystem(char *command);
     extern int LYValidateOutput(char *filename);
     extern int find_restriction(const char *name, int len);
diff --git a/src/LYrcFile.h b/src/LYrcFile.h
index 7c6f28ee..16db1647 100644
--- a/src/LYrcFile.h
+++ b/src/LYrcFile.h
@@ -146,9 +146,11 @@
 #define RC_NO_FORCED_CORE_DUMP          "no_forced_core_dump"
 #define RC_NO_FROM_HEADER               "no_from_header"
 #define RC_NO_ISMAP_IF_USEMAP           "no_ismap_if_usemap"
+#define RC_NO_MARGINS                   "no_margins"
 #define RC_NO_PROXY                     "no_proxy"
 #define RC_NO_REFERER_HEADER            "no_referer_header"
 #define RC_NO_TABLE_CENTER              "no_table_center"
+#define RC_NO_TITLE                     "no_title"
 #define RC_NUMBER_FIELDS_ON_LEFT        "number_fields_on_left"
 #define RC_NUMBER_LINKS_ON_LEFT         "number_links_on_left"
 #define RC_OUTGOING_MAIL_CHARSET        "outgoing_mail_charset"
diff --git a/src/TRSTable.c b/src/TRSTable.c
index aedb56a7..f8ec81b8 100644
--- a/src/TRSTable.c
+++ b/src/TRSTable.c
@@ -1755,7 +1755,7 @@ int Stbl_finishTABLE(STable_info *me)
 	    continue;		/* Not a continuation line */
 	minoffset = nextrow[-1].offset;		/* Line before first continuation */
 	CTRACE2(TRACE_TRST, (tfp,
-			     "TRST:Stbl_finishTABLE, l=%d, offset=%d, ended=%d.\n",
+			     "TRST:Stbl_finishTABLE, l=%d, offset=%d, ended=%u.\n",
 			     i, nextrow[-1].offset, nextrow[-1].ended));
 
 	/* Find the common part of the requested offsets */
@@ -1769,7 +1769,7 @@ int Stbl_finishTABLE(STable_info *me)
 		minoffset = nextrow->offset;
 	    CTRACE2(TRACE_TRST,
 		    (tfp,
-		     "TRST:Stbl_finishTABLE, l=%d, offset=%d, ended=%d.\n",
+		     "TRST:Stbl_finishTABLE, l=%d, offset=%d, ended=%u.\n",
 		     j, nextrow->offset, nextrow[-1].ended));
 	    nextrow++;
 	    j++;
diff --git a/src/UCAux.c b/src/UCAux.c
index 24976426..e5d01147 100644
--- a/src/UCAux.c
+++ b/src/UCAux.c
@@ -11,8 +11,10 @@ BOOL UCCanUniTranslateFrom(int from)
 {
     if (from < 0)
 	return NO;
+#ifndef EXP_JAPANESEUTF8_SUPPORT
     if (LYCharSet_UC[from].enc == UCT_ENC_CJK)
 	return NO;
+#endif
     if (!strcmp(LYCharSet_UC[from].MIMEname, "x-transparent"))
 	return NO;
 
@@ -313,7 +315,7 @@ void UCTransParams_clear(UCTransParams * pT)
  *  chars to displayable ASCII chars if '0' was requested.  They'll
  *  stay as they are otherwise. - kw
  */
-void UCSetBoxChars(int cset,
+void UCSetBoxChars(int cset GCC_UNUSED,
 		   int *pvert_out,
 		   int *phori_out,
 		   int vert_in,
diff --git a/src/UCdomap.c b/src/UCdomap.c
index 11ec31bd..a03a4b92 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -1098,6 +1098,30 @@ int UCTransChar(char ch_in,
     return rc;
 }
 
+#ifdef EXP_JAPANESEUTF8_SUPPORT
+long int UCTransJPToUni(char *inbuf,
+			int buflen,
+			int charset_in)
+{
+    char outbuf[3], *pin, *pout;
+    size_t rc, ilen, olen;
+    iconv_t cd;
+
+    pin = inbuf;
+    pout = outbuf;
+    ilen = 2;
+    olen = buflen;
+
+    cd = iconv_open("UTF-16BE", LYCharSet_UC[charset_in].MIMEname);
+    rc = iconv(cd, &pin, &ilen, &pout, &olen);
+    iconv_close(cd);
+    if ((ilen == 0) && (olen == 0)) {
+	return (((unsigned char) outbuf[0]) << 8) + (unsigned char) outbuf[1];
+    }
+    return -11;
+}
+#endif
+
 long int UCTransToUni(char ch_in,
 		      int charset_in)
 {
@@ -1109,6 +1133,68 @@ long int UCTransToUni(char ch_in,
 #ifndef UC_NO_SHORTCUTS
     if (charset_in == LATIN1)
 	return ch_iu;
+#ifdef EXP_JAPANESEUTF8_SUPPORT
+    if ((strcmp(LYCharSet_UC[charset_in].MIMEname, "shift_jis") == 0) ||
+	(strcmp(LYCharSet_UC[charset_in].MIMEname, "euc-jp") == 0)) {
+	static char buffer[3];
+	char obuffer[3], *pin, *pout;
+	static int inx = 0;
+	size_t rc, ilen, olen;
+	iconv_t cd;
+
+	pin = buffer;
+	pout = obuffer;
+	ilen = olen = 2;
+	if (strcmp(LYCharSet_UC[charset_in].MIMEname, "shift_jis") == 0) {
+	    if (inx == 0) {
+		if (IS_SJIS_HI1((unsigned char) ch_in) ||
+		    IS_SJIS_HI2((unsigned char) ch_in)) {
+		    buffer[0] = ch_in;
+		    inx = 1;
+		    return -11;
+		}
+	    } else {
+		if (IS_SJIS_LO((unsigned char) ch_in)) {
+		    buffer[1] = ch_in;
+		    buffer[2] = 0;
+
+		    cd = iconv_open("UTF-16BE", "Shift_JIS");
+		    rc = iconv(cd, &pin, &ilen, &pout, &olen);
+		    iconv_close(cd);
+		    inx = 0;
+		    if ((ilen == 0) && (olen == 0)) {
+			return (((unsigned char) obuffer[0]) << 8)
+			    + (unsigned char) obuffer[1];
+		    }
+		}
+	    }
+	}
+	if (strcmp(LYCharSet_UC[charset_in].MIMEname, "euc-jp") == 0) {
+	    if (inx == 0) {
+		if (IS_EUC_HI((unsigned char) ch_in)) {
+		    buffer[0] = ch_in;
+		    inx = 1;
+		    return -11;
+		}
+	    } else {
+		if (IS_EUC_LOX((unsigned char) ch_in)) {
+		    buffer[1] = ch_in;
+		    buffer[2] = 0;
+
+		    cd = iconv_open("UTF-16BE", "EUC-JP");
+		    rc = iconv(cd, &pin, &ilen, &pout, &olen);
+		    iconv_close(cd);
+		    inx = 0;
+		    if ((ilen == 0) && (olen == 0)) {
+			return (((unsigned char) obuffer[0]) << 8)
+			    + (unsigned char) obuffer[1];
+		    }
+		}
+	    }
+	}
+	inx = 0;
+    }
+#endif
     if (UCH(ch_in) < 128 && UCH(ch_in) >= 32)
 	return ch_iu;
 #endif /* UC_NO_SHORTCUTS */