about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--WWW/Library/Implementation/HTAccess.c5
-rw-r--r--WWW/Library/Implementation/HTPlain.c10
-rw-r--r--WWW/Library/Implementation/HTWAIS.c7
-rw-r--r--WWW/Library/Implementation/SGML.c36
-rw-r--r--src/AttrList.h3
-rw-r--r--src/GridText.c65
-rw-r--r--src/HTAlert.c4
-rw-r--r--src/HTForms.h34
-rw-r--r--src/HTML.c4
-rw-r--r--src/LYCharSets.c7
-rw-r--r--src/LYCharUtils.c14
-rw-r--r--src/LYCookie.c6
-rw-r--r--src/LYForms.c12
-rw-r--r--src/LYStrings.c87
-rw-r--r--src/LYStrings.h5
-rw-r--r--src/LYUtils.c24
-rw-r--r--src/UCAux.c12
17 files changed, 191 insertions, 144 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index ebcf0863..f92df3a0 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAccess.c,v 1.66 2008/08/31 22:38:38 tom Exp $
+ * $LynxId: HTAccess.c,v 1.67 2008/09/06 14:44:37 tom Exp $
  *
  *		Access Manager					HTAccess.c
  *		==============
@@ -64,6 +64,7 @@
 
 #include <LYGlobalDefs.h>
 #include <LYexit.h>
+#include <LYStrings.h>
 #include <LYUtils.h>
 #include <LYLeaks.h>
 
@@ -1287,7 +1288,7 @@ BOOL HTSearch(const char *keywords,
 
 	if (WHITE(*p)) {
 	    *q++ = '+';
-	} else if (HTCJK != NOCJK) {
+	} else if (IS_CJK_TTY) {
 	    *q++ = *p;
 	} else if (c >= 32 && c <= UCH(127) && isAcceptable[c - 32]) {
 	    *q++ = *p;		/* 930706 TBL for MVS bug */
diff --git a/WWW/Library/Implementation/HTPlain.c b/WWW/Library/Implementation/HTPlain.c
index 3e40be02..8dfa901e 100644
--- a/WWW/Library/Implementation/HTPlain.c
+++ b/WWW/Library/Implementation/HTPlain.c
@@ -1,4 +1,7 @@
-/*		Plain text object		HTWrite.c
+/*
+ * $LynxId: HTPlain.c,v 1.42 2008/09/06 14:45:09 tom Exp $
+ *
+ *		Plain text object		HTWrite.c
  *		=================
  *
  *	This version of the stream object just writes to a socket.
@@ -28,6 +31,7 @@
 #include <UCAux.h>
 
 #include <LYCharSets.h>
+#include <LYStrings.h>
 #include <LYLeaks.h>
 
 static int HTPlain_lastraw = -1;
@@ -134,7 +138,7 @@ static void HTPlain_put_character(HTStream *me, char c)
 	 * For now, don't repeat everything here that has been done below - KW
 	 */
 	HTPlain_write(me, &c, 1);
-    } else if (HTCJK != NOCJK) {
+    } else if (IS_CJK_TTY) {
 	HText_appendCharacter(me->text, c);
     } else if (TOASCII(UCH(c)) >= 127 && TOASCII(UCH(c)) < 161 &&
 	       HTPassHighCtrlRaw) {
@@ -470,7 +474,7 @@ static void HTPlain_write(HTStream *me, const char *s, int l)
 	 * display character set, and if not, the user should toggle off
 	 * raw/CJK mode to reload.  - FM
 	 */
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    HText_appendCharacter(me->text, c);
 
 #define PASSHICTRL (me->T.transp || \
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index fcc64344..0e09f761 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -1,4 +1,7 @@
-/*	WorldWideWeb - Wide Area Informaion Server Access	HTWAIS.c
+/*
+ * $LynxId: HTWAIS.c,v 1.31 2008/09/06 15:47:08 tom Exp $
+ *
+ *	WorldWideWeb - Wide Area Informaion Server Access	HTWAIS.c
  *	==================================================
  *
  *	This module allows a WWW server or client to read data from a
@@ -436,7 +439,7 @@ static void output_text_record(HTStream *target,
 		count += 4;	/* it is a paragraph marker */
 	} else if (ch == '\n' || ch == '\r') {
 	    PUTC('\n');
-	} else if (HTCJK != NOCJK || ch == '\t' || isprint(ch)) {
+	} else if (IS_CJK_TTY || ch == '\t' || isprint(ch)) {
 	    PUTC(ch);
 	}
     }
diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c
index 4c571fd7..6b3863d0 100644
--- a/WWW/Library/Implementation/SGML.c
+++ b/WWW/Library/Implementation/SGML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: SGML.c,v 1.109 2008/08/31 18:34:05 tom Exp $
+ * $LynxId: SGML.c,v 1.110 2008/09/06 14:44:04 tom Exp $
  *
  *			General SGML Parser code		SGML.c
  *			========================
@@ -395,7 +395,7 @@ static void set_chartrans_handling(HTStream *context,
      * its HTStructured object, itself, if this were needed.  - FM
      */
 #ifndef EXP_JAPANESEUTF8_SUPPORT
-    if (HTCJK != NOCJK) {
+    if (IS_CJK_TTY) {
 	context->current_tag_charset = -1;
     } else
 #endif
@@ -1829,7 +1829,7 @@ static void SGML_character(HTStream *context, char c_in)
      */
     if (TOASCII(unsign_c) < 32 &&
 	c != '\t' && c != '\n' && c != '\r' &&
-	HTCJK == NOCJK)
+	!IS_CJK_TTY)
 	goto after_switch;
 
     /*
@@ -1838,7 +1838,7 @@ static void SGML_character(HTStream *context, char c_in)
 #define PASSHICTRL (context->T.transp || \
 		    unsign_c >= LYlowest_eightbit[context->inUCLYhndl])
     if (TOASCII(c) == 127 &&	/* S/390 -- gil -- 0830 */
-	!(PASSHICTRL || HTCJK != NOCJK))
+	!(PASSHICTRL || IS_CJK_TTY))
 	goto after_switch;
 
     /*
@@ -1846,7 +1846,7 @@ static void SGML_character(HTStream *context, char c_in)
      * nor HTCJK is set.  - FM
      */
     if (TOASCII(unsign_c) > 127 && TOASCII(unsign_c) < 160 &&	/* S/390 -- gil -- 0847 */
-	!(PASSHICTRL || HTCJK != NOCJK))
+	!(PASSHICTRL || IS_CJK_TTY))
 	goto after_switch;
 
     /* Almost all CJK characters are double byte but only Japanese
@@ -1909,7 +1909,7 @@ static void SGML_character(HTStream *context, char c_in)
 	}
 	/* fall through in any case! */
     case S_text:
-	if ((HTCJK != NOCJK) && ((TOASCII(c) & 0200) != 0)
+	if (IS_CJK_TTY && ((TOASCII(c) & 0200) != 0)
 #ifdef EXP_JAPANESEUTF8_SUPPORT
 	    && !context->T.decode_utf8
 #endif
@@ -1925,7 +1925,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    context->state = S_in_kanji;
 	    context->kanji_buf = c;
 	    break;
-	} else if (HTCJK != NOCJK && TOASCII(c) == '\033') {	/* S/390 -- gil -- 0881 */
+	} else if (IS_CJK_TTY && TOASCII(c) == '\033') {	/* S/390 -- gil -- 0881 */
 	    /*
 	     * Setting up for CJK escape sequence handling (based on Takuya
 	     * ASADA's (asada@three-a.co.jp) CJK Lynx).  - FM
@@ -2023,7 +2023,7 @@ static void SGML_character(HTStream *context, char c_in)
 		PUTS(context->utf_buf);
 		context->utf_buf_p = context->utf_buf;
 		*(context->utf_buf_p) = '\0';
-	    } else if (HTCJK == NOCJK &&
+	    } else if (!IS_CJK_TTY &&
 		       (context->T.output_utf8 ||
 			context->T.trans_from_uni)) {
 		if (LYIsASCII(clong)) {
@@ -2049,7 +2049,7 @@ static void SGML_character(HTStream *context, char c_in)
 	     */
 	} else if (unsign_c == CH_NBSP &&	/* S/390 -- gil -- 0932 */
 		   !context->no_lynx_specialcodes &&
-		   !(PASS8859SPECL || HTCJK != NOCJK)) {
+		   !(PASS8859SPECL || IS_CJK_TTY)) {
 	    PUTC(HT_NON_BREAK_SPACE);
 	    /*
 	     * Convert 173 (shy) to Lynx special character if neither
@@ -2057,7 +2057,7 @@ static void SGML_character(HTStream *context, char c_in)
 	     */
 	} else if (unsign_c == CH_SHY &&	/* S/390 -- gil -- 0949 */
 		   !context->no_lynx_specialcodes &&
-		   !(PASS8859SPECL || HTCJK != NOCJK)) {
+		   !(PASS8859SPECL || IS_CJK_TTY)) {
 	    PUTC(LY_SOFT_HYPHEN);
 	    /*
 	     * Handle the case in which we think we have a character which
@@ -2121,7 +2121,7 @@ static void SGML_character(HTStream *context, char c_in)
 		    (context->T.do_8bitraw && !context->T.trans_from_uni))
 
 	} else if (unsign_c > 160 && unsign_c < 256 &&
-		   !(PASSHI8BIT || HTCJK != NOCJK) &&
+		   !(PASSHI8BIT || IS_CJK_TTY) &&
 		   !IncludesLatin1Enc) {
 #ifdef USE_PRETTYSRC
 	    int psrc_view_backup = 0;
@@ -2827,9 +2827,9 @@ static void SGML_character(HTStream *context, char c_in)
 		} else if ((code > 255) ||
 			   (code < ' ' &&	/* S/390 -- gil -- 1140 */
 			    code != '\t' && code != '\n' && code != '\r' &&
-			    HTCJK == NOCJK) ||
+			    !IS_CJK_TTY) ||
 			   (TOASCII(code) == 127 &&
-			    !(HTPassHighCtrlRaw || HTCJK != NOCJK)) ||
+			    !(HTPassHighCtrlRaw || IS_CJK_TTY)) ||
 			   (TOASCII(code) > 127 && code < 160 &&
 			    !HTPassHighCtrlNum)) {
 		    /*
@@ -3341,7 +3341,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
-	} else if (HTCJK == NOCJK &&
+	} else if (!IS_CJK_TTY &&
 		   (context->T.output_utf8 ||
 		    context->T.trans_from_uni)) {
 	    if (clong == 0xfffd && saved_char_in &&
@@ -3733,7 +3733,7 @@ static void SGML_character(HTStream *context, char c_in)
 #endif
 	    {
 #ifdef CJK_EX			/* Quick hack. - JH7AYN */
-		if (HTCJK != NOCJK) {
+		if (IS_CJK_TTY) {
 		    if (string->data[0] == '$') {
 			if (string->data[1] == 'B' || string->data[1] == '@') {
 			    char *jis_buf = 0;
@@ -3768,7 +3768,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
-	} else if (HTCJK == NOCJK &&
+	} else if (!IS_CJK_TTY &&
 		   (context->T.output_utf8 ||
 		    context->T.trans_from_uni)) {
 	    if (clong == 0xfffd && saved_char_in &&
@@ -3828,7 +3828,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
-	} else if (HTCJK == NOCJK &&
+	} else if (!IS_CJK_TTY &&
 		   (context->T.output_utf8 ||
 		    context->T.trans_from_uni)) {
 	    if (clong == 0xfffd && saved_char_in &&
@@ -3893,7 +3893,7 @@ static void SGML_character(HTStream *context, char c_in)
 	    HTChunkPuts(string, context->utf_buf);
 	    context->utf_buf_p = context->utf_buf;
 	    *(context->utf_buf_p) = '\0';
-	} else if (HTCJK == NOCJK &&
+	} else if (!IS_CJK_TTY &&
 		   (context->T.output_utf8 ||
 		    context->T.trans_from_uni)) {
 	    if (clong == 0xfffd && saved_char_in &&
diff --git a/src/AttrList.h b/src/AttrList.h
index 0bfa24a5..4ef246e1 100644
--- a/src/AttrList.h
+++ b/src/AttrList.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: AttrList.h,v 1.15 2008/09/06 15:47:47 tom Exp $
+ */
 #if !defined(__ATTRLIST_H)
 #define __ATTRLIST_H
 
diff --git a/src/GridText.c b/src/GridText.c
index 27d24e46..9d7ec48e 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.146 2008/08/31 14:58:57 tom Exp $
+ * $LynxId: GridText.c,v 1.151 2008/09/06 14:40:45 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -57,9 +57,9 @@
 #include <LYJustify.h>
 
 #ifdef CONV_JISX0201KANA_JISX0208KANA
-#define is_CJK2(b) (HTCJK != NOCJK && is8bits(UCH(b)))
+#define is_CJK2(b) (IS_CJK_TTY && is8bits(UCH(b)))
 #else
-#define is_CJK2(b) (HTCJK != NOCJK && is8bits(UCH(b)) && kanji_code != SJIS)
+#define is_CJK2(b) (IS_CJK_TTY && is8bits(UCH(b)) && kanji_code != SJIS)
 #endif
 
 #ifdef USE_CURSES_PADS
@@ -569,7 +569,7 @@ void mark_justify_start_position(void *text)
 #define REALLY_CAN_JUSTIFY(text) ( (wait_for_this_stacked_elt<0) && \
 	( text->style->alignment == HT_LEFT     || \
 	  text->style->alignment == HT_JUSTIFY) && \
-	HTCJK == NOCJK && !in_DT && \
+	!IS_CJK_TTY && !in_DT && \
 	can_justify_here && can_justify_this_line && !form_in_htext )
 
 #endif /* EXP_JUSTIFY_ELTS */
@@ -1010,7 +1010,7 @@ HText *HText_new(HTParentAnchor *anchor)
     if (HTMainText) {
 	if (HText_hasUTF8OutputSet(HTMainText) &&
 	    HTLoadedDocumentEightbit() &&
-	    LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) {
+	    IS_UTF8_TTY) {
 	    self->had_utf8 = HTMainText->has_utf8;
 	} else {
 	    self->had_utf8 = HTMainText->has_utf8;
@@ -1719,7 +1719,7 @@ static void display_title(HText *text)
      * if appropriate, preceded by the toolbar token if appropriate,
      * and truncated if necessary.  -FM & KW
      */
-    if (HTCJK != NOCJK) {
+    if (IS_CJK_TTY) {
 	if (*title &&
 	    (tmp = typecallocn(unsigned char, (strlen(title) * 2 + 256)))) {
 	    if (kanji_code == EUC) {
@@ -2202,7 +2202,7 @@ static void display_page(HText *text,
 			    tmp[1] = '\0';
 			    written += (utf_extra + 1);
 			    utf_extra = 0;
-			} else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+			} else if (IS_CJK_TTY && is8bits(tmp[0])) {
 			    /*
 			     * For CJK strings, by Masanobu Kimura.
 			     */
@@ -2389,9 +2389,8 @@ static void display_page(HText *text,
 				? checked_box
 				: unchecked_box);
 		} else if (FormInfo_ptr->type == F_PASSWORD_TYPE) {
-		    /* FIXME: use LYstrExtent, not strlen */
 		    LYSetHilite(nlinks,
-				STARS(strlen(FormInfo_ptr->value)));
+				STARS(LYstrCells(FormInfo_ptr->value)));
 		} else {	/* TEXT type */
 		    LYSetHilite(nlinks,
 				FormInfo_ptr->value);
@@ -2475,7 +2474,7 @@ static void display_page(HText *text,
 	 */
 	text->had_utf8 = text->has_utf8;
 	clearok(curscr, TRUE);
-    } else if (HTCJK != NOCJK) {
+    } else if (IS_CJK_TTY) {
 	/*
 	 * For non-multibyte curses.
 	 *
@@ -3755,7 +3754,7 @@ void HText_appendCharacter(HText *text, int ch)
     /*
      * Make sure we don't hang on escape sequences.
      */
-    if (ch == CH_ESC && HTCJK == NOCJK) {	/* decimal 27  S/390 -- gil -- 1504 */
+    if (ch == CH_ESC && !IS_CJK_TTY) {	/* decimal 27  S/390 -- gil -- 1504 */
 	return;
     }
 #ifndef USE_SLANG
@@ -3768,14 +3767,14 @@ void HText_appendCharacter(HText *text, int ch)
      * processing stage anyway.  - kw
      */
 #ifndef   EBCDIC		/* S/390 -- gil -- 1514 */
-    if (is8bits(ch) && HTCJK == NOCJK &&
+    if (is8bits(ch) && !IS_CJK_TTY &&
 	!text->T.transp && !text->T.output_utf8 &&
 	UCH(ch) < LYlowest_eightbit[current_char_set]) {
 	return;
     }
 #endif /* EBCDIC */
 #endif /* !USE_SLANG */
-    if (UCH(ch) == 155 && HTCJK == NOCJK) {	/* octal 233 */
+    if (UCH(ch) == 155 && !IS_CJK_TTY) {	/* octal 233 */
 	if (!HTPassHighCtrlRaw &&
 	    !text->T.transp && !text->T.output_utf8 &&
 	    (155 < LYlowest_eightbit[current_char_set])) {
@@ -3788,7 +3787,7 @@ void HText_appendCharacter(HText *text, int ch)
 
     indent = text->in_line_1 ? (int) style->indent1st : (int) style->leftIndent;
 
-    if (HTCJK != NOCJK) {
+    if (IS_CJK_TTY) {
 	switch (text->state) {
 	case S_text:
 	    if (ch == CH_ESC) {	/* S/390 -- gil -- 1536 */
@@ -3960,7 +3959,7 @@ void HText_appendCharacter(HText *text, int ch)
 	return;
     }
 #ifdef CJK_EX			/* MOJI-BAKE Fix! 1997/10/12 -- 10/31 (Fri) 00:22:57 - JH7AYN */
-    if (HTCJK != NOCJK &&	/* added condition - kw */
+    if (IS_CJK_TTY &&		/* added condition - kw */
 	(ch == LY_BOLD_START_CHAR || ch == LY_BOLD_END_CHAR)) {
 	text->permissible_split = (int) line->size;	/* Can split here */
 	if (HTCJK == JAPANESE)
@@ -3974,7 +3973,7 @@ void HText_appendCharacter(HText *text, int ch)
 	    return;
 	}
 #if defined(USE_COLOR_STYLE) && !defined(NO_DUMP_WITH_BACKSPACES)
-	if (with_backspaces && HTCJK == NOCJK && !text->T.output_utf8) {
+	if (with_backspaces && !IS_CJK_TTY && !text->T.output_utf8) {
 #endif
 	    if (ch == LY_UNDERLINE_START_CHAR) {
 		line->data[line->size++] = LY_UNDERLINE_START_CHAR;
@@ -4234,7 +4233,7 @@ void HText_appendCharacter(HText *text, int ch)
 	int target_cu = target + UTFXTRA_ON_THIS_LINE;
 
 	if (target >= WRAP_COLS(text) - style->rightIndent -
-	    (((HTCJK != NOCJK) && text->kanji_buf) ? 1 : 0) ||
+	    ((IS_CJK_TTY && text->kanji_buf) ? 1 : 0) ||
 	    (text->T.output_utf8 &&
 	     target_cu + UTF_XLEN(ch) >= LYcols_cu(text))) {
 	    int saved_kanji_buf;
@@ -4306,7 +4305,7 @@ void HText_appendCharacter(HText *text, int ch)
     if ((actual
 	 + (int) style->rightIndent
 	 - ctrl_chars_on_this_line
-	 + (((HTCJK != NOCJK) && text->kanji_buf) ? 1 : 0)
+	 + ((IS_CJK_TTY && text->kanji_buf) ? 1 : 0)
 	) >= WRAP_COLS(text)
 	|| (text->T.output_utf8
 	    && ((actual
@@ -4385,7 +4384,7 @@ void HText_appendCharacter(HText *text, int ch)
 
 	line = text->last_line;	/* May have changed */
 
-	if (HTCJK != NOCJK && text->kanji_buf) {
+	if (IS_CJK_TTY && text->kanji_buf) {
 	    hi = UCH(text->kanji_buf);
 	    lo = UCH(ch);
 
@@ -4478,7 +4477,7 @@ void HText_appendCharacter(HText *text, int ch)
 	    line->data[line->size++] = ch;
 	}
 #endif
-	else if (HTCJK != NOCJK) {
+	else if (IS_CJK_TTY) {
 	    line->data[line->size++] = (char) ((kanji_code != NOKANJI) ?
 					       ch :
 					       (font & HT_CAPITALS) ?
@@ -4902,7 +4901,7 @@ static void free_enclosed_stbl(HText *me)
 	STable_info *stbl;
 
 	while (NULL != (stbl = (STable_info *) HTList_nextObject(list))) {
-	    CTRACE((tfp, "endStblTABLE: finally free %p\n", me->stbl));
+	    CTRACE((tfp, "endStblTABLE: finally free %p\n", (void *) me->stbl));
 	    Stbl_free(stbl);
 	}
 	HTList_delete(me->enclosed_stbl);
@@ -4953,7 +4952,7 @@ int HText_endStblTABLE(HText *me)
 	    if (me->enclosed_stbl == NULL)
 		me->enclosed_stbl = HTList_new();
 	    HTList_addObject(me->enclosed_stbl, me->stbl);
-	    CTRACE((tfp, "endStblTABLE: postpone free %p\n", me->stbl));
+	    CTRACE((tfp, "endStblTABLE: postpone free %p\n", (void *) me->stbl));
 	}
 	me->stbl = enclosing;
     } else {
@@ -4966,7 +4965,7 @@ int HText_endStblTABLE(HText *me)
 #endif
 
     CTRACE((tfp, "endStblTABLE: have%s enclosing table (%p)\n",
-	    enclosing == 0 ? " NO" : "", enclosing));
+	    enclosing == 0 ? " NO" : "", (void *) enclosing));
 
     return enclosing != 0;
 }
@@ -6172,7 +6171,7 @@ int HTGetRelLinkNum(int num,
     int curanchor = links[cur].anchor_number;
 
     CTRACE((tfp, "HTGetRelLinkNum(%d,%d,%d) -- HTMainText=%p\n",
-	    num, rel, cur, HTMainText));
+	    num, rel, cur, (void *) HTMainText));
     CTRACE((tfp,
 	    "  scrtop=%d, curline=%d, curanchor=%d, display_lines=%d, %s\n",
 	    scrtop, curline, curanchor, display_lines,
@@ -6205,7 +6204,7 @@ int HTGetRelLinkNum(int num,
 	l = a;
 	curanchor = l->number;
     }
-    CTRACE((tfp, "  a=%p, l=%p, curanchor=%d\n", a, l, curanchor));
+    CTRACE((tfp, "  a=%p, l=%p, curanchor=%d\n", (void *) a, (void *) l, curanchor));
     if (on_screen) {		/* on screen but not a numbered link */
 	for (; a; a = a->next) {
 	    if (a->number) {
@@ -7341,7 +7340,7 @@ BOOL HText_select(HText *text)
 	if (HTMainText) {
 	    if (HText_hasUTF8OutputSet(HTMainText) &&
 		HTLoadedDocumentEightbit() &&
-		LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) {
+		IS_UTF8_TTY) {
 		text->had_utf8 = HTMainText->has_utf8;
 	    } else {
 		text->had_utf8 = NO;
@@ -7902,7 +7901,7 @@ void print_wwwfile_to_fd(FILE *fp,
     BOOL bs = (BOOL) (!is_email && !is_reply
 		      && text != 0
 		      && with_backspaces
-		      && HTCJK == NOCJK
+		      && !IS_CJK_TTY
 		      && !text->T.output_utf8);
 #endif
 
@@ -9566,7 +9565,7 @@ char *HText_setLastOptionValue(HText *text, char *value,
 	    }
 	}
 	cp[j] = '\0';
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    if (cp &&
 		(tmp = typecallocn(unsigned char, strlen(cp) * 2 + 1)) != 0) {
 		if (tmp == NULL)
@@ -9788,7 +9787,7 @@ int HText_beginInput(HText *text, BOOL underline,
     if (I->value)
 	StrAllocCopy(IValue, I->value);
     if (IValue &&
-	HTCJK != NOCJK &&
+	IS_CJK_TTY &&
 	((I->type == NULL) || strcasecomp(I->type, "hidden"))) {
 	if ((tmp = typecallocn(unsigned char, strlen(IValue) * 2 + 1)) != 0) {
 	    if (kanji_code == EUC) {
@@ -11224,7 +11223,7 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc, char *link_name,
 			NonNull(my_data[anchor_count].name),
 			my_data[anchor_count].first,
 			NonNull(my_data[anchor_count].value),
-			my_data[anchor_count].data));
+			(void *) my_data[anchor_count].data));
 
 		if (my_data[anchor_count].first) {
 		    if (first_one) {
@@ -11841,7 +11840,7 @@ void HText_setKcode(HText *text, const char *charset,
 	 * it is enabled.  But only if we are quite sure.  -FM & kw
 	 */
 	text->kcode = NOKANJI;
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    if (!p_in || ((p_in->enc != UCT_ENC_CJK)
 #ifdef EXP_JAPANESEUTF8_SUPPORT
 			  && (p_in->enc != UCT_ENC_UTF8)
@@ -13956,7 +13955,7 @@ static void move_to_glyph(int YP,
 	    if (incurlink && intarget && flag && i_after_tgt > i) {
 		if (i == last_i - 1) {
 		    i_after_tgt = i;
-		} else if (i == last_i - 2 && HTCJK != NOCJK &&
+		} else if (i == last_i - 2 && IS_CJK_TTY &&
 			   is8bits(buffer[0])) {
 		    i_after_tgt = i;
 		    cp_tgt = NULL;
@@ -14049,7 +14048,7 @@ static void move_to_glyph(int YP,
 		sdata += utf_extra;
 		data += utf_extra;
 		utf_extra = 0;
-	    } else if (HTCJK != NOCJK && is8bits(buffer[0])) {
+	    } else if (IS_CJK_TTY && is8bits(buffer[0])) {
 		/*
 		 * For CJK strings, by Masanobu Kimura.
 		 */
diff --git a/src/HTAlert.c b/src/HTAlert.c
index 5c4a276c..a5fbf13e 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAlert.c,v 1.81 2008/07/06 12:55:40 tom Exp $
+ * $LynxId: HTAlert.c,v 1.82 2008/09/06 14:35:56 tom Exp $
  *
  *	Displaying messages and getting input for Lynx Browser
  *	==========================================================
@@ -123,7 +123,7 @@ void HTUserMsg(const char *Msg)
 	CTRACE((tfp, "User message: %s\n", Msg));
 	LYstore_message(Msg);
 #if !(defined(USE_SLANG) || defined(WIDEC_CURSES))
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    clearok(curscr, TRUE);
 	    LYrefresh();
 	}
diff --git a/src/HTForms.h b/src/HTForms.h
index 8cf01eaa..4cca9484 100644
--- a/src/HTForms.h
+++ b/src/HTForms.h
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: HTForms.h,v 1.25 2008/09/06 15:46:41 tom Exp $
+ */
 #ifndef HTFORMS_H
 #define HTFORMS_H
 
@@ -115,20 +118,23 @@ extern "C" {
 #define INPUT_ANCHOR     2	/* forms mode input fields */
 #define INTERNAL_LINK_ANCHOR 5	/* 1+4, can be used as bitflag... - kw */
 
-#define F_TEXT_TYPE	   1
-#define F_PASSWORD_TYPE    2
-#define F_CHECKBOX_TYPE    3
-#define F_RADIO_TYPE	   4
-#define F_SUBMIT_TYPE	   5
-#define F_RESET_TYPE	   6
-#define F_OPTION_LIST_TYPE 7
-#define F_HIDDEN_TYPE      8
-#define F_TEXTAREA_TYPE    9
-#define F_RANGE_TYPE      10
-#define F_FILE_TYPE       11
-#define F_TEXT_SUBMIT_TYPE 12
-#define F_IMAGE_SUBMIT_TYPE 13
-#define F_KEYGEN_TYPE     14
+    typedef enum {
+	F_UNKNOWN = 0,
+	F_TEXT_TYPE,
+	F_PASSWORD_TYPE,
+	F_CHECKBOX_TYPE,
+	F_RADIO_TYPE,
+	F_SUBMIT_TYPE,
+	F_RESET_TYPE,
+	F_OPTION_LIST_TYPE,
+	F_HIDDEN_TYPE,
+	F_TEXTAREA_TYPE,
+	F_RANGE_TYPE,
+	F_FILE_TYPE,
+	F_TEXT_SUBMIT_TYPE,
+	F_IMAGE_SUBMIT_TYPE,
+	F_KEYGEN_TYPE
+    } FieldTypes;
 
 #define F_TEXTLIKE(type) ((type)==F_TEXT_TYPE ||\
 			  (type)==F_TEXT_SUBMIT_TYPE ||\
diff --git a/src/HTML.c b/src/HTML.c
index 3a9b1d50..a66ba5b4 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTML.c,v 1.113 2007/07/02 23:43:40 tom Exp $
+ * $LynxId: HTML.c,v 1.114 2008/09/06 14:33:02 tom Exp $
  *
  *		Structured stream to Rich hypertext converter
  *		============================================
@@ -7886,7 +7886,7 @@ static void CacheThru_do_free(HTStream *me)
     } else if (me->status != HT_OK) {
 	if (me->chunk) {
 	    CTRACE((tfp, "SourceCacheWriter: memory chunk %p had errors.\n",
-		    me->chunk));
+		    (void *) me->chunk));
 	    HTChunkFree(me->chunk);
 	    me->chunk = me->last_chunk = NULL;
 	}
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index 935763dc..db56146a 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: LYCharSets.c,v 1.58 2008/09/06 15:45:56 tom Exp $
+ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <HTMLDTD.h>
@@ -456,10 +459,10 @@ void HTMLSetCharacterHandling(int i)
 	/* for any CJK: */
 	if (!LYUseDefaultRawMode)
 	    HTCJK = NOCJK;
-	LYRawMode = (BOOL) ((HTCJK != NOCJK) ? TRUE : FALSE);
+	LYRawMode = (BOOL) (IS_CJK_TTY ? TRUE : FALSE);
 	HTPassEightBitRaw = FALSE;
 	HTPassEightBitNum = FALSE;
-	HTPassHighCtrlRaw = (BOOL) ((HTCJK != NOCJK) ? TRUE : FALSE);
+	HTPassHighCtrlRaw = (BOOL) (IS_CJK_TTY ? TRUE : FALSE);
 	HTPassHighCtrlNum = FALSE;
     }
 
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index f268c301..d4b5917a 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYCharUtils.c,v 1.90 2008/08/31 17:00:05 tom Exp $
+ * $LynxId: LYCharUtils.c,v 1.92 2008/09/06 14:40:45 tom Exp $
  *
  *  Functions associated with LYCharSets.c and the Lynx version of HTML.c - FM
  *  ==========================================================================
@@ -118,7 +118,7 @@ void LYEntify(char **str,
 	outofmem(__FILE__, "LYEntify");
     for (p = *str; *p; p++) {
 #ifdef CJK_EX
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    switch (state) {
 	    case S_text:
 		if (*p == '\033') {
@@ -1144,7 +1144,7 @@ char **LYUCFullyTranslateString(char **str,
      * iso-8859-1 (and we are not called to back-translate), or if we are in
      * CJK mode.
      */
-    if ((HTCJK != NOCJK)
+    if (IS_CJK_TTY
 #ifdef EXP_JAPANESEUTF8_SUPPORT
 	&& (strcmp(LYCharSet_UC[cs_from].MIMEname, "utf-8") != 0)
 	&& (strcmp(LYCharSet_UC[cs_to].MIMEname, "utf-8") != 0)
@@ -1251,7 +1251,7 @@ char **LYUCFullyTranslateString(char **str,
 	    }
 #endif
 	    if (*p == '\033') {
-		if ((HTCJK != NOCJK && !hidden) || stype != st_HTML) {
+		if ((IS_CJK_TTY && !hidden) || stype != st_HTML) {
 		    state = S_esc;
 		    if (stype == st_URL) {
 			REPLACE_STRING("%1B");
@@ -1332,7 +1332,7 @@ char **LYUCFullyTranslateString(char **str,
 
 	case S_nonascii_text:
 	    if (*p == '\033') {
-		if ((HTCJK != NOCJK && !hidden) || stype != st_HTML) {
+		if ((IS_CJK_TTY && !hidden) || stype != st_HTML) {
 		    state = S_esc;
 		    if (stype == st_URL) {
 			REPLACE_STRING("%1B");
@@ -1678,9 +1678,9 @@ char **LYUCFullyTranslateString(char **str,
 	     */
 	    if ((code < 32 &&
 		 code != 9 && code != 10 && code != 13 &&
-		 HTCJK == NOCJK) ||
+		 !IS_CJK_TTY) ||
 		(code == 127 &&
-		 !(HTPassHighCtrlRaw || HTCJK != NOCJK)) ||
+		 !(HTPassHighCtrlRaw || IS_CJK_TTY)) ||
 		(code > 127 && code < 160 &&
 		 !HTPassHighCtrlNum)) {
 		state = S_recover;
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 2a05ee2b..a9dacd31 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYCookie.c,v 1.91 2008/07/06 17:42:46 tom Exp $
+ * $LynxId: LYCookie.c,v 1.92 2008/09/06 14:27:22 tom Exp $
  *
  *			       Lynx Cookie Support		   LYCookie.c
  *			       ===================
@@ -145,7 +145,7 @@ static cookie *newCookie(void)
 
     if (p == NULL)
 	outofmem(__FILE__, "newCookie");
-    HTSprintf0(&(p->lynxID), "%p", p);
+    HTSprintf0(&(p->lynxID), "%p", (void *) p);
     p->port = 80;
     return p;
 }
@@ -680,7 +680,7 @@ static char *scan_cookie_sublist(char *hostname,
 	if ((co) &&		/* speed-up host_matches() and limit trace output */
 	    (LYstrstr(hostname, co->domain) != NULL)) {
 	    CTrace((tfp, "Checking cookie %p %s=%s\n",
-		    hl,
+		    (void *) hl,
 		    (co->name ? co->name : "(no name)"),
 		    (co->value ? co->value : "(no value)")));
 	    CTrace((tfp, "\t%s %s %d %s %s %d%s\n",
diff --git a/src/LYForms.c b/src/LYForms.c
index ef832d9c..30db75fb 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYForms.c,v 1.76 2008/09/05 00:28:05 tom Exp $ */
+/* $LynxId: LYForms.c,v 1.79 2008/09/06 14:40:45 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <HTTP.h>
@@ -204,9 +204,9 @@ int change_form_link_ex(int cur,
     case F_TEXTAREA_TYPE:
     case F_PASSWORD_TYPE:
 	c = form_getstr(cur, use_last_tfpos, redraw_only);
-	LYSetHilite(cur, (form->type == F_PASSWORD_TYPE)
-		    ? STARS(LYstrCells(form->value))
-		    : form->value);
+	LYSetHilite(cur, ((form->type == F_PASSWORD_TYPE)
+			  ? STARS(LYstrCells(form->value))
+			  : form->value));
 	break;
 
     case F_RESET_TYPE:
@@ -655,7 +655,7 @@ static int form_getstr(int cur,
 #endif
 #ifndef WIN_EX
 	if (action == LYE_AIX &&
-	    (HTCJK == NOCJK && LYlowest_eightbit[current_char_set] > 0x97))
+	    (!IS_CJK_TTY && LYlowest_eightbit[current_char_set] > 0x97))
 	    break;
 #endif
 	if (action == LYE_TAB) {
@@ -769,7 +769,7 @@ static int form_getstr(int cur,
 		}
 #ifdef SUPPORT_MULTIBYTE_EDIT
 		if (rc == 0) {
-		    if (HTCJK != NOCJK && (0x80 <= ch)
+		    if (IS_CJK_TTY && (0x80 <= ch)
 			&& (ch <= 0xfe) && refresh_mb)
 			refresh_mb = FALSE;
 		    else
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 41083eed..1eb5c2d9 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.147 2008/09/05 00:17:48 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.155 2008/09/06 15:01:28 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <UCAux.h>
@@ -629,7 +629,7 @@ char *LYmbcsstrncpy(char *dst,
 }
 
 /*
- * LYmbcs_skip_glyphs() skips a given number of display positions in a string
+ * LYmbcs_skip_glyphs() skips a given number of character positions in a string
  * and returns the resulting pointer.  It takes account of UTF-8 encoded
  * characters.  - KW
  */
@@ -662,6 +662,11 @@ const char *LYmbcs_skip_glyphs(const char *data,
     return data;
 }
 
+/*
+ * LYmbcs_skip_cells() skips a given number of display positions in a string
+ * and returns the resulting pointer.  It takes account of UTF-8 encoded
+ * characters.  - TD
+ */
 const char *LYmbcs_skip_cells(const char *data,
 			      int n_cells,
 			      BOOL utf_flag)
@@ -709,7 +714,7 @@ int LYmbcsstrlen(const char *str,
 			    i++;
 			    j++;
 			}
-		    } else if (!utf_flag && HTCJK != NOCJK && !count_gcells &&
+		    } else if (!utf_flag && IS_CJK_TTY && !count_gcells &&
 			       is8bits(str[i]) &&
 			       IsNormalChar(str[(i + 1)])) {
 			i++;
@@ -1757,7 +1762,7 @@ static int LYgetch_for(int code)
 
 	CTRACE((tfp,
 		"nozap: Got EOF, curses %s, stdin is %p, LYNoZapKey reduced from %d to 0.\n",
-		LYCursesON ? "on" : "off", stdin, LYNoZapKey));
+		LYCursesON ? "on" : "off", (void *) stdin, LYNoZapKey));
 	LYNoZapKey = 0;		/* 2 -> 0 */
 	if (LYReopenInput() > 0) {
 	    if (LYCursesON) {
@@ -2901,15 +2906,12 @@ void LYSetupEdit(EDREC * edit, char *old,
  *
  * LYmbcs* functions don't look very convenient to use here...
  * Do we really need utf_flag as an argument?
- * It is set LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8 for every
- * invocation out there, and they use HTCJK flag internally anyway.
- * Something like LYmbcsstrnlen == mbcs_glyphs would be useful to work
- * with string slices.
+ *
+ * It is set (see IS_UTF8_TTY) for every invocation out there, and they use
+ * HTCJK flag internally anyway.  Something like LYmbcsstrnlen == mbcs_glyphs
+ * would be useful to work with string slices -Sergej Kvachonok 
  */
 
-#define IS_UTF8_TTY (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8)
-#define IS_CJK_TTY (HTCJK != NOCJK)
-
 #define IS_UTF8_EXTRA(x) (((unsigned char)(x) & 0300) == 0200)
 
 /*
@@ -3021,7 +3023,7 @@ int LYEditInsert(EDREC * edit, unsigned const char *s,
 #ifdef EXP_KEYBOARD_LAYOUT
     if (map < 0)
 	map = map_active;
-    if (map && LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) {
+    if (map && IS_UTF8_TTY) {
 	int off = Pos;
 	unsigned const char *e = s + len;
 	char *tail = 0;
@@ -3141,7 +3143,7 @@ int LYEdit1(EDREC * edit, int ch,
 	 * in the current display character set.  Otherwise, we treat this as
 	 * LYE_ENTER.
 	 */
-	if (HTCJK == NOCJK && LYlowest_eightbit[current_char_set] > 0x97)
+	if (!IS_CJK_TTY && LYlowest_eightbit[current_char_set] > 0x97)
 	    return (ch);
 	/* FALLTHRU */
 #endif
@@ -3578,14 +3580,6 @@ int get_popup_number(const char *msg,
 #  define TmpStyleOff(s)
 #endif /* defined USE_COLOR_STYLE */
 
-static void fill_edited_line(int prompting GCC_UNUSED, int length, int ch)
-{
-    TmpStyleOn(prompting ? s_prompt_edit_pad : s_aedit_pad);
-    while (length-- > 0)
-	LYaddch(UCH(ch));
-    TmpStyleOff(prompting ? s_prompt_edit_pad : s_aedit_pad);
-}
-
 static void remember_column(EDREC * edit, int offset)
 {
     int y0, x0;
@@ -3601,6 +3595,19 @@ static void remember_column(EDREC * edit, int offset)
     edit->offset2col[offset] = x0;
 }
 
+static void fill_edited_line(int prompting GCC_UNUSED, int length, int ch)
+{
+    int i;
+
+    TmpStyleOn(prompting ? s_prompt_edit_pad : s_aedit_pad);
+
+    for (i = 0; i < length; i++) {
+	LYaddch(UCH(ch));
+    }
+
+    TmpStyleOff(prompting ? s_prompt_edit_pad : s_aedit_pad);
+}
+
 /*
  * Multibyte string display subroutine.
  * EDREC fields retain their values as byte offsets.
@@ -3788,7 +3795,23 @@ void LYRefreshEdit(EDREC * edit)
     }
 #endif
     if (IsHidden) {
+	BOOL utf_flag = IS_UTF8_TTY;
+	int cell = 0;
+
 	fill_edited_line(0, dpy_cells, '*');
+
+	i = 0;
+	do {
+	    const char *last = str + i;
+	    const char *next = LYmbcs_skip_glyphs(last, 1, utf_flag);
+	    int j = (next - str);
+
+	    while (i < j) {
+		edit->offset2col[i++] = cell + StartX;
+	    }
+	    cell += LYstrExtent2(last, (next - last));
+	} while (i < dpy_bytes);
+	edit->offset2col[i] = cell + StartX;
     } else {
 #if defined(ENHANCED_LINEEDIT) && defined(USE_COLOR_STYLE)
 	if (Mark >= 0 && DspStart > Mark)
@@ -3797,7 +3820,6 @@ void LYRefreshEdit(EDREC * edit)
 	remember_column(edit, 0);
 	for (i = 0; i < dpy_bytes; i++) {
 #if defined(ENHANCED_LINEEDIT) && defined(USE_COLOR_STYLE)
-	    /* FIXME - make this work with multibyte-chars */
 	    if (Mark >= 0 && ((DspStart + i == Mark && Pos > Mark)
 			      || (DspStart + i == Pos && Pos < Mark)))
 		TmpStyleOn(prompting ? s_prompt_sel : s_aedit_sel);
@@ -3807,7 +3829,7 @@ void LYRefreshEdit(EDREC * edit)
 #endif
 	    if (str[i] == 1 || str[i] == 2 ||
 		(UCH(str[i]) == 160 &&
-		 !(HTPassHighCtrlRaw || HTCJK != NOCJK ||
+		 !(HTPassHighCtrlRaw || IS_CJK_TTY ||
 		   (LYCharSet_UC[current_char_set].enc != UCT_ENC_8859 &&
 		    !(LYCharSet_UC[current_char_set].like8859
 		      & UCT_R_8859SPECL))))) {
@@ -3818,7 +3840,6 @@ void LYRefreshEdit(EDREC * edit)
 	    remember_column(edit, i + 1);
 	}
 #if defined(ENHANCED_LINEEDIT) && defined(USE_COLOR_STYLE)
-	/* FIXME - make this work with multibyte-chars */
 	if (Mark >= 0 &&
 	    ((DspStart + dpy_bytes <= Mark && DspStart + dpy_bytes > Pos)
 	     || (DspStart + dpy_bytes > Mark
@@ -5098,7 +5119,7 @@ int LYgetstr(char *inputline,
 	     * LYE_ENTER.
 	     */
 	    if (ch != '\t' &&
-		(HTCJK != NOCJK ||
+		(IS_CJK_TTY ||
 		 LYlowest_eightbit[current_char_set] <= 0x97)) {
 		LYLineEdit(&MyEdit, ch, FALSE);
 		break;
@@ -5207,7 +5228,7 @@ int LYgetstr(char *inputline,
 	    LYLineEdit(&MyEdit, ch, FALSE);
 #else /* SUPPORT_MULTIBYTE_EDIT */
 	    if (LYLineEdit(&MyEdit, ch, FALSE) == 0) {
-		if (refresh_mb && HTCJK != NOCJK && (0x81 <= ch) && (ch <= 0xfe))
+		if (refresh_mb && IS_CJK_TTY && (0x81 <= ch) && (ch <= 0xfe))
 		    refresh_mb = FALSE;
 		else
 		    refresh_mb = TRUE;
@@ -5439,7 +5460,7 @@ const char *LYno_attr_mbcs_case_strstr(const char *chptr,
      * Seek a first target match.  - FM
      */
     for (; *chptr != '\0'; chptr++) {
-	if ((!utf_flag && HTCJK != NOCJK && is8bits(*chptr) &&
+	if ((!utf_flag && IS_CJK_TTY && is8bits(*chptr) &&
 	     *chptr == *tarptr &&
 	     IsNormalChar(*(chptr + 1))) ||
 	    (0 == UPPER8(*chptr, *tarptr))) {
@@ -5464,7 +5485,7 @@ const char *LYno_attr_mbcs_case_strstr(const char *chptr,
 		    *nendp = len;
 		return (chptr);
 	    }
-	    if (!utf_flag && HTCJK != NOCJK && is8bits(*chptr) &&
+	    if (!utf_flag && IS_CJK_TTY && is8bits(*chptr) &&
 		*chptr == *tarptr &&
 		IsNormalChar(*tmpchptr)) {
 		/*
@@ -5504,7 +5525,7 @@ const char *LYno_attr_mbcs_case_strstr(const char *chptr,
 	     */
 	    while (1) {
 		if (!IsSpecialAttrChar(*tmpchptr)) {
-		    if (!utf_flag && HTCJK != NOCJK && is8bits(*tmpchptr)) {
+		    if (!utf_flag && IS_CJK_TTY && is8bits(*tmpchptr)) {
 			if (*tmpchptr == *tmptarptr &&
 			    *(tmpchptr + 1) == *(tmptarptr + 1) &&
 			    !IsSpecialAttrChar(*(tmpchptr + 1))) {
@@ -5541,7 +5562,7 @@ const char *LYno_attr_mbcs_case_strstr(const char *chptr,
 	    }
 	} else if (!(IS_UTF_EXTRA(*chptr) ||
 		     IsSpecialAttrChar(*chptr))) {
-	    if (!utf_flag && HTCJK != NOCJK && is8bits(*chptr) &&
+	    if (!utf_flag && IS_CJK_TTY && is8bits(*chptr) &&
 		IsNormalChar(*(chptr + 1))) {
 		chptr++;
 		if (count_gcells)
@@ -5624,7 +5645,7 @@ const char *LYno_attr_mbcs_strstr(const char *chptr,
 		    *nendp = len;
 		return (chptr);
 	    }
-	    if (!utf_flag && HTCJK != NOCJK && is8bits(*chptr) &&
+	    if (!utf_flag && IS_CJK_TTY && is8bits(*chptr) &&
 		IsNormalChar(*tmpchptr)) {
 		/*
 		 * Check the CJK multibyte.  - FM
@@ -5663,7 +5684,7 @@ const char *LYno_attr_mbcs_strstr(const char *chptr,
 	     */
 	    while (1) {
 		if (!IsSpecialAttrChar(*tmpchptr)) {
-		    if (!utf_flag && HTCJK != NOCJK && is8bits(*tmpchptr)) {
+		    if (!utf_flag && IS_CJK_TTY && is8bits(*tmpchptr)) {
 			if (*tmpchptr == *tmptarptr &&
 			    *(tmpchptr + 1) == *(tmptarptr + 1) &&
 			    !IsSpecialAttrChar(*(tmpchptr + 1))) {
@@ -5699,7 +5720,7 @@ const char *LYno_attr_mbcs_strstr(const char *chptr,
 	    }
 	} else if (!(IS_UTF_EXTRA(*chptr) ||
 		     IsSpecialAttrChar(*chptr))) {
-	    if (!utf_flag && HTCJK != NOCJK && is8bits(*chptr) &&
+	    if (!utf_flag && IS_CJK_TTY && is8bits(*chptr) &&
 		IsNormalChar(*(chptr + 1))) {
 		chptr++;
 		if (count_gcells)
diff --git a/src/LYStrings.h b/src/LYStrings.h
index 85d0958c..a42ec557 100644
--- a/src/LYStrings.h
+++ b/src/LYStrings.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStrings.h,v 1.67 2008/09/05 00:18:18 tom Exp $
+ * $LynxId: LYStrings.h,v 1.68 2008/09/06 14:07:46 tom Exp $
  */
 #ifndef LYSTRINGS_H
 #define LYSTRINGS_H
@@ -16,6 +16,9 @@ extern "C" {
 	,RECALL_MAIL
     } RecallType;
 
+#define IS_UTF8_TTY (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8)
+#define IS_CJK_TTY  (HTCJK != NOCJK)
+
 #define is8bits(ch) (UCH(ch) >= 128)	/* isascii(ch) is not POSIX */
 
 /*  UPPER8(ch1,ch2) is an extension of (TOUPPER(ch1) - TOUPPER(ch2))  */
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 7b1cb164..6bdf302b 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYUtils.c,v 1.170 2008/09/05 00:19:21 tom Exp $ */
+/* $LynxId: LYUtils.c,v 1.173 2008/09/06 14:35:56 tom Exp $ */
 #include <HTUtils.h>
 #include <HTTCP.h>
 #include <HTParse.h>
@@ -428,7 +428,7 @@ static BOOL show_whereis_targets(int flag,
 		      (LYcolLimit - LYGetHilitePos(cur, count)),
 		      utf_flag);
 	hlen = strlen(buffer);
-	hLen = ((HTCJK != NOCJK || utf_flag) ?
+	hLen = ((IS_CJK_TTY || utf_flag) ?
 		LYmbcsstrlen(buffer, utf_flag, YES) : hlen);
 
 	/*
@@ -495,7 +495,7 @@ static BOOL show_whereis_targets(int flag,
 		    tmp[1] = '\0';
 		    written += (utf_extra + 1);
 		    utf_extra = 0;
-		} else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+		} else if (IS_CJK_TTY && is8bits(tmp[0])) {
 		    /*
 		     * For CJK strings, by Masanobu Kimura.
 		     */
@@ -569,7 +569,7 @@ static BOOL show_whereis_targets(int flag,
 			tmp[1] = '\0';
 			written += (utf_extra + 1);
 			utf_extra = 0;
-		    } else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+		    } else if (IS_CJK_TTY && is8bits(tmp[0])) {
 			/*
 			 * For CJK strings, by Masanobu Kimura.
 			 */
@@ -696,7 +696,7 @@ static BOOL show_whereis_targets(int flag,
 		    tmp[1] = '\0';
 		    written += (utf_extra + 1);
 		    utf_extra = 0;
-		} else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+		} else if (IS_CJK_TTY && is8bits(tmp[0])) {
 		    /*
 		     * For CJK strings, by Masanobu Kimura.
 		     */
@@ -771,7 +771,7 @@ static BOOL show_whereis_targets(int flag,
 			tmp[1] = '\0';
 			written += (utf_extra + 1);
 			utf_extra = 0;
-		    } else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+		    } else if (IS_CJK_TTY && is8bits(tmp[0])) {
 			/*
 			 * For CJK strings, by Masanobu Kimura.
 			 */
@@ -892,7 +892,7 @@ static BOOL show_whereis_targets(int flag,
 				tmp[1] = '\0';
 				written += (utf_extra + 1);
 				utf_extra = 0;
-			    } else if (HTCJK != NOCJK && is8bits(tmp[0])) {
+			    } else if (IS_CJK_TTY && is8bits(tmp[0])) {
 				/*
 				 * For CJK strings, by Masanobu Kimura.
 				 */
@@ -1024,7 +1024,7 @@ void LYhighlight(int flag,
     BOOL TargetEmphasisON = FALSE;
     BOOL target1_drawn = NO;
 #endif
-    BOOL utf_flag = (BOOL) (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8);
+    BOOL utf_flag = (BOOL) IS_UTF8_TTY;
     BOOL hl1_drawn = NO;
 
 #ifdef USE_COLOR_STYLE
@@ -1151,7 +1151,7 @@ void LYhighlight(int flag,
 			/*
 			 * For CJK strings, by Masanobu Kimura.
 			 */
-			if (HTCJK != NOCJK && is8bits(tmp[0])) {
+			if (IS_CJK_TTY && is8bits(tmp[0])) {
 			    tmp[1] = hi_string[++i];
 			    LYaddstr(tmp);
 			    tmp[1] = '\0';
@@ -1433,7 +1433,7 @@ void statusline(const char *text)
     if (buffer[0] != '\0') {
 	BOOLEAN has_CJK = FALSE;
 
-	if (HTCJK != NOCJK) {
+	if (IS_CJK_TTY) {
 	    for (i = 0; buffer[i] != '\0'; i++) {
 		if (buffer[i] & 0x80) {
 		    has_CJK = TRUE;
@@ -1444,7 +1444,7 @@ void statusline(const char *text)
 
 	if (has_CJK
 #ifdef HAVE_UTF8_STATUSLINES
-	    || (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8)
+	    || IS_UTF8_TTY
 #endif
 	    ) {
 	    LYrefresh();
@@ -1590,7 +1590,7 @@ int LYReopenInput(void)
 	    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)));
+		    term_name, (void *) frp, (void *) stdin, fileno(stdin)));
 	    result = 1;
 	} else {
 	    result = -1;
diff --git a/src/UCAux.c b/src/UCAux.c
index d041ee8e..1db897bd 100644
--- a/src/UCAux.c
+++ b/src/UCAux.c
@@ -1,3 +1,6 @@
+/*
+ * $LynxId: UCAux.c,v 1.37 2008/09/06 15:46:17 tom Exp $
+ */
 #include <HTUtils.h>
 
 #include <HTCJK.h>
@@ -7,6 +10,7 @@
 #include <UCAux.h>
 #include <LYCharSets.h>
 #include <LYCurses.h>
+#include <LYStrings.h>
 
 BOOL UCCanUniTranslateFrom(int from)
 {
@@ -58,7 +62,7 @@ BOOL UCCanTranslateFromTo(int from,
 	}
 	if (LYCharSet_UC[from].enc == UCT_ENC_CJK) {
 	    /*
-	     * CJK mode may be off (i.e., HTCJK == NOCJK) because the current
+	     * CJK mode may be off (i.e., !IS_CJK_TTY) because the current
 	     * document is not CJK, but the check may be for capability in
 	     * relation to another document, for which CJK mode might be turned
 	     * on when retrieved.  Thus, when the from charset is CJK, check if
@@ -122,7 +126,7 @@ BOOL UCNeedNotTranslate(int from,
 	    return YES;
     }
     if (LYCharSet_UC[from].enc == UCT_ENC_CJK) {
-	if (HTCJK == NOCJK)	/* Use that global flag, for now. */
+	if (!IS_CJK_TTY)	/* Use that global flag, for now. */
 	    return NO;
 	if (HTCJK == JAPANESE &&
 	    (!strcmp(fromname, "euc-jp") ||
@@ -192,7 +196,7 @@ void UCSetTransParams(UCTransParams * pT, int cs_in,
 	/*
 	 * Set this element if we want to treat the input as CJK.  - FM
 	 */
-	pT->do_cjk = (BOOL) ((p_in->enc == UCT_ENC_CJK) && (HTCJK != NOCJK));
+	pT->do_cjk = (BOOL) ((p_in->enc == UCT_ENC_CJK) && IS_CJK_TTY);
 	/*
 	 * Set these elements based on whether we are dealing with UTF-8.  - FM
 	 */
@@ -201,7 +205,7 @@ void UCSetTransParams(UCTransParams * pT, int cs_in,
 	if (pT->do_cjk) {
 	    /*
 	     * Set up the structure for a CJK input with
-	     * a CJK output (HTCJK != NOCJK).  - FM
+	     * a CJK output (IS_CJK_TTY).  - FM
 	     */
 	    intm_ucs = FALSE;
 	    pT->trans_to_uni = FALSE;