else {
check_WrapSource: if ( (text->source || dont_wrap_pre) && text == HTMainText) {
PUBLIC void HText_appendCharacter ARGS2(	HText *,	text,	char,		ch){    HTLine * line;    HTStyle * style;    int indent;#ifdef DEBUG_APPCH    if (TRACE) {	char * special = NULL;  /* make trace a little more readable */	switch(ch) {	case HT_NON_BREAK_SPACE:		special = "HT_NON_BREAK_SPACE";		break;	case HT_EN_SPACE:		special = "HT_EN_SPACE";		break;	case LY_UNDERLINE_START_CHAR:		special = "LY_UNDERLINE_START_CHAR";		break;	case LY_UNDERLINE_END_CHAR:		special = "LY_UNDERLINE_END_CHAR";		break;	case LY_BOLD_START_CHAR:		special = "LY_BOLD_START_CHAR";		break;	case LY_BOLD_END_CHAR:		special = "LY_BOLD_END_CHAR";		break;	case LY_SOFT_HYPHEN:		special = "LY_SOFT_HYPHEN";		break;	case LY_SOFT_NEWLINE:		special = "LY_SOFT_NEWLINE";		break;	default:		special = NULL;		break;	}	if (special != NULL) {	    CTRACE(tfp, "add(%s %d special char) %d/%d\n", special, ch,		   HTisDocumentSource(), HTOutputFormat != WWW_SOURCE);	} else {	    CTRACE(tfp, "add(%c) %d/%d\n", ch,		   HTisDocumentSource(), HTOutputFormat != WWW_SOURCE);	}    } /* trace only */#endif /* DEBUG_APPCH */    /*     *  Make sure we don't crash on NULLs.     */    if (!text)	return;    if (text->halted > 1) {	/*	 *  We should stop outputting more text, because low memory was	 *  detected.  - kw	 */	if (text->halted == 2) {	    /*	     *  But if we haven't done so yet, first append a warning.	     *  We should still have a few bytes left for that :).	     *  We temporarily reset test->halted to 0 for this, since	     *  this function will get called recursively. - kw	     */	    text->halted = 0;	    text->kanji_buf = '\0';	    HText_appendText(text, gettext(" *** MEMORY EXHAUSTED ***"));	}	text->halted = 3;	return;    }    /*     *  Make sure we don't hang on escape sequences.     */    if (ch == CH_ESC && HTCJK == NOCJK)			/* decimal 27  S/390 -- gil -- 1504 */	return;#ifndef USE_SLANG    /*     *  Block 8-bit chars not allowed by the current display character     *  set if they are below what LYlowest_eightbit indicates.     *  Slang used its own replacements, so for USE_SLANG blocking here     *  is not necessary to protect terminals from those characters.     *  They should have been filtered out or translated by an earlier     *  processing stage anyway. - kw     */#ifndef   EBCDIC  /* S/390 -- gil -- 1514 */    if ((unsigned char)ch >= 128 && HTCJK == NOCJK &&	!text->T.transp && !text->T.output_utf8 &&	(unsigned char)ch < LYlowest_eightbit[current_char_set])	return;#endif /* EBCDIC */#endif /* !USE_SLANG */    if ((unsigned char)ch == 155 && HTCJK == NOCJK) {	/* octal 233 */	if (!HTPassHighCtrlRaw &&	    !text->T.transp && !text->T.output_utf8 &&	    (155 < LYlowest_eightbit[current_char_set])) {	    return;	}    }    line = text->last_line;    style = text->style;    indent = text->in_line_1 ? (int)style->indent1st : (int)style->leftIndent;    if (HTCJK != NOCJK) {	switch(text->state) {	    case S_text:		if (ch == CH_ESC) {  /* S/390 -- gil -- 1536 */		    /*		    **  Setting up for CJK escape sequence handling (based on		    **  Takuya ASADA's (asada@three-a.co.jp) CJK Lynx). - FM		    */		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		}		break;		case S_esc:		/*		 *  Expecting '$'or '(' following CJK ESC.		 */		if (ch == '$') {		    text->state = S_dollar;		    return;		} else if (ch == '(') {		    text->state = S_paren;		    return;		} else {		    text->state = S_text;		}		case S_dollar:		/*		 *  Expecting '@', 'B', 'A' or '(' after CJK "ESC$".		 */		if (ch == '@' || ch == 'B' || ch=='A') {		    text->state = S_nonascii_text;		    return;		} else if (ch == '(') {		    text->state = S_dollar_paren;		    return;		} else {		    text->state = S_text;		}		break;		case S_dollar_paren:		/*		 * Expecting 'C' after CJK "ESC$(".		 */		if (ch == 'C') {		    text->state = S_nonascii_text;		    return;		} else {		    text->state = S_text;		}		break;		case S_paren:		/*		 *  Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(".		 */		if (ch == 'B' || ch == 'J' || ch == 'T')  {		    /*		     *  Can split here. - FM		     */		    text->permissible_split = text->last_line->size;		    text->state = S_text;		    return;		} else if (ch == 'I')  {		    text->state = S_jisx0201_text;		    /*		     *  Can split here. - FM		     */		    text->permissible_split = text->last_line->size;		    return;		} else {		    text->state = S_text;		}		break;		case S_nonascii_text:		/*		 *  Expecting CJK ESC after non-ASCII text.		 */		if (ch == CH_ESC) {  /* S/390 -- gil -- 1553 */		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		} else {		    ch |= 0200;		}		break;		/*		 *  JIS X0201 Kana in JIS support. - by ASATAKU		 */		case S_jisx0201_text:		if (ch == CH_ESC) {  /* S/390 -- gil -- 1570 */		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		} else {		    text->kanji_buf = '\216';		    ch |= 0200;		}		break;	}	if (!text->kanji_buf) {	    if ((ch & 0200) != 0) {		/*		 *  JIS X0201 Kana in SJIS support. - by ASATAKU		 */		if ((text->kcode == SJIS) &&		    ((unsigned char)ch >= 0xA1) &&		    ((unsigned char)ch <= 0xDF)) {		    unsigned char c = (unsigned char)ch;		    unsigned char kb = (unsigned char)text->kanji_buf;		    JISx0201TO0208_SJIS(c,					(unsigned char *)&kb,					(unsigned char *)&c);		    ch = (char)c;		    text->kanji_buf = kb;		} else {		    text->kanji_buf = ch;		    /*		     *  Can split here. - FM		     */		    text->permissible_split = text->last_line->size;		    return;		}	    }	} else {	    goto check_IgnoreExcess;	}    } else if (ch == CH_ESC) {  /* S/390 -- gil -- 1587 */	return;    }    if (IsSpecialAttrChar(ch) && ch != LY_SOFT_NEWLINE) {#ifndef USE_COLOR_STYLE	if (line->size >= (MAX_LINE-1)) return;	if (ch == LY_UNDERLINE_START_CHAR) {	    line->data[line->size++] = LY_UNDERLINE_START_CHAR;	    line->data[line->size] = '\0';	    underline_on = ON;	    if (!(dump_output_immediately && use_underscore))		ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_UNDERLINE_END_CHAR) {	    line->data[line->size++] = LY_UNDERLINE_END_CHAR;	    line->data[line->size] = '\0';	    underline_on = OFF;	    if (!(dump_output_immediately && use_underscore))		ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_BOLD_START_CHAR) {	    line->data[line->size++] = LY_BOLD_START_CHAR;	    line->data[line->size] = '\0';	    bold_on = ON;	    ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_BOLD_END_CHAR) {	    line->data[line->size++] = LY_BOLD_END_CHAR;	    line->data[line->size] = '\0';	    bold_on = OFF;	    ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_SOFT_HYPHEN) {	    int i;	    /*	     *  Ignore the soft hyphen if it is the first character	     *  on the line, or if it is preceded by a space or	     *  hyphen. - FM	     */	    if (line->size < 1 || text->permissible_split >= line->size)		return;	    for (i = (text->permissible_split + 1); line->data[i]; i++) {		if (!IsSpecialAttrChar((unsigned char)line->data[i]) &&		    !isspace((unsigned char)line->data[i]) &&		    (unsigned char)line->data[i] != '-' &&		    (unsigned char)line->data[i] != HT_NON_BREAK_SPACE &&		    (unsigned char)line->data[i] != HT_EN_SPACE) {		    break;		}	    }	    if (line->data[i] == '\0') {		return;	    }	}#else	return;#endif    } else if (ch == LY_SOFT_NEWLINE) {	line->data[line->size++] = LY_SOFT_NEWLINE;	line->data[line->size] = '\0';	return;    }    if (IS_UTF_EXTRA(ch)) {	line->data[line->size++] = ch;	line->data[line->size] = '\0';	ctrl_chars_on_this_line++;	return;    }    /*     *  New Line.     */    if (ch == '\n') {	    new_line(text);	    text->in_line_1 = YES;	/* First line of new paragraph */	    /*	     *  There are some pages written in	     *  different kanji codes. - TA & kw	     */	    if (HTCJK == JAPANESE)		text->kcode = NOKANJI;	    return;    }    /*     *  Convert EN_SPACE to a space here so that it doesn't get collapsed.     */    if (ch == HT_EN_SPACE)	ch = ' ';    /*     *  I'm going to cheat here in a BIG way.  Since I know that all     *  \r's will be trapped by HTML_put_character I'm going to use     *  \r to mean go down a line but don't start a new paragraph.     *  i.e., use the second line indenting.     */    if (ch == '\r') {	new_line(text);	text->in_line_1 = NO;	/*	 *  There are some pages written in	 *  different kanji codes. - TA & kw	 */	if (HTCJK == JAPANESE)	    text->kcode = NOKANJI;	return;    }    /*     *  Tabs.     */    if (ch == '\t') {	CONST HTTabStop * Tab;	int target;	/* Where to tab to */	int here;	if (line->size > 0 && line->data[line->size-1] == LY_SOFT_HYPHEN) {	    /*	     *  A tab shouldn't follow a soft hyphen, so	     *  if one does, we'll dump the soft hyphen. - FM	     */	    line->data[--line->size] = '\0';	    ctrl_chars_on_this_line--;	}	here = ((int)(line->size + line->offset) + indent)		- ctrl_chars_on_this_line; /* Consider special chars GAB */	if (style->tabs) {	/* Use tab table */	    for (Tab = style->tabs;		Tab->position <= here;		Tab++) {		if (!Tab->position) {		    new_line(text);		    return;		}	    }	    target = Tab->position;	} else if (text->in_line_1) {	/* Use 2nd indent */	    if (here >= (int)style->leftIndent) {		new_line(text); /* wrap */		return;	    } else {		target = (int)style->leftIndent;	    }	} else {		/* Default tabs align with left indent mod 8 */#ifdef DEFAULT_TABS_8	    target = (((int)line->offset + (int)line->size + 8) & (-8))			+ (int)style->leftIndent;#else	    new_line(text);	    return;#endif	}	if (target > (LYcols-1) - (int)style->rightIndent &&	    HTOutputFormat != WWW_SOURCE) {	    new_line(text);	} else {	    /*	     *  Can split here. - FM	     */	    text->permissible_split = line->size;	    if (line->size == 0) {		line->offset = line->offset + target - here;	    } else {		for (; here<target; here++) {		    /* Put character into line */		    line->data[line->size++] = ' ';		    line->data[line->size] = '\0';		}	    }	}	return;    } /* if tab */    else {	/*	 * If we're displaying document source, wrap long lines to keep all of	 * the source visible.	 */	int target = (int)(line->offset + line->size);	if ((target >= (LYcols-1) - style->rightIndent) &&		HTisDocumentSource()) {	    new_line(text);	    line = text->last_line;	    HText_appendCharacter (text, LY_SOFT_NEWLINE);	}    }    if (ch == ' ') {	/*	 *  Can split here. - FM	 */	text->permissible_split = text->last_line->size;	/*	 *  There are some pages written in	 *  different kanji codes. - TA	 */	if (HTCJK == JAPANESE)	    text->kcode = NOKANJI;    }    /*     *  Check if we should ignore characters at the wrap point.     */check_IgnoreExcess:    if (text->IgnoreExcess &&	((indent + (int)line->offset + (int)line->size) +	(int)style->rightIndent - ctrl_chars_on_this_line) >= (LYcols-1))	return;    /*     *  Check for end of line.     */    if (((indent + (int)line->offset + (int)line->size) +	 (int)style->rightIndent - ctrl_chars_on_this_line +	 ((line->size > 0) &&	  (int)(line->data[line->size-1] ==				LY_SOFT_HYPHEN ?					     1 : 0))) >= (LYcols - 1)) {	if (style->wordWrap && HTOutputFormat != WWW_SOURCE) {	    split_line(text, text->permissible_split);	    if (ch == ' ') return;	/* Ignore space causing split */	}  else if (HTOutputFormat == WWW_SOURCE) {		 /*		  *  For source output we don't want to wrap this stuff		  *  unless absolutely necessary. - LJM		  *  !		  *  If we don't wrap here we might get a segmentation fault.		  *  but let's see what happens		  */		if ((int)line->size >= (int)(MAX_LINE-1))		   new_line(text);  /* try not to linewrap */	} else {		/*		 *  For normal stuff like pre let's go ahead and		 *  wrap so the user can see all of the text.		 */		new_line(text);	}    } else if ((int)line->size >= (int)(MAX_LINE-1)) {	/*	 *  Never overrun memory if LYcols is set to a large value - KW	 */	new_line(text);    }    /*     *  Insert normal characters.     */    if (ch == HT_NON_BREAK_SPACE) {	ch = ' ';    }    if (ch & 0x80)	text->have_8bit_chars = YES;    {	HTFont font = style->font;	unsigned char hi, lo, tmp[2];	line = text->last_line; /* May have changed */	if (HTCJK != NOCJK && text->kanji_buf) {	    hi = (unsigned char)text->kanji_buf, lo = (unsigned char)ch;	    if (HTCJK == JAPANESE && text->kcode == NOKANJI) {		if (IS_SJIS(hi, lo, text->in_sjis) && IS_EUC(hi, lo)) {		    text->kcode = NOKANJI;		} else if (IS_SJIS(hi, lo, text->in_sjis)) {		    text->kcode = SJIS;		} else if (IS_EUC(hi, lo)) {		    text->kcode = EUC;		}	    }	    if (HTCJK == JAPANESE &&		(kanji_code == EUC) && (text->kcode == SJIS)) {		SJIS_TO_EUC1(hi, lo, tmp);		line->data[line->size++] = tmp[0];		line->data[line->size++] = tmp[1];	    } else if (HTCJK == JAPANESE &&		       (kanji_code == EUC) && (text->kcode == EUC)) {		JISx0201TO0208_EUC(hi, lo, &hi, &lo);		line->data[line->size++] = hi;		line->data[line->size++] = lo;	    } else if (HTCJK == JAPANESE &&		       (kanji_code == SJIS) && (text->kcode == EUC)) {		EUC_TO_SJIS1(hi, lo, tmp);		line->data[line->size++] = tmp[0];		line->data[line->size++] = tmp[1];	    } else {		line->data[line->size++] = hi;		line->data[line->size++] = lo;	    }	    text->kanji_buf = 0;	} else if (HTCJK != NOCJK) {	    line->data[line->size++] = (kanji_code != NOKANJI) ?							    ch :					  (font & HT_CAPITALS) ?						   TOUPPER(ch) : ch;	} else {	    line->data[line->size++] =	/* Put character into line */		font & HT_CAPITALS ? TOUPPER(ch) : ch;	}	line->data[line->size] = '\0';	if (font & HT_DOUBLE)		/* Do again if doubled */	    HText_appendCharacter(text, HT_NON_BREAK_SPACE);	    /* NOT a permissible split */	if (ch == LY_SOFT_HYPHEN) {	    ctrl_chars_on_this_line++;	    /*	     *  Can split here. - FM	     */	    text->permissible_split = text->last_line->size;	}	if (ch == LY_SOFT_NEWLINE) {	    ctrl_chars_on_this_line++;	}    }}