diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1997-10-27 19:05:04 -0500 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1997-10-27 19:05:04 -0500 |
commit | 8f8c57cc7c0e876cd291e2b4de23a52e060b30ba (patch) | |
tree | b813d59380c9db4f7b59bf8a5a965aa606627183 /src | |
parent | cbcc3a1e1a82b01eea370bf7841e6b5f4d1e46c1 (diff) | |
download | lynx-snapshots-8f8c57cc7c0e876cd291e2b4de23a52e060b30ba.tar.gz |
snapshot of project "lynx", label v2-7-1ac_0-89
Diffstat (limited to 'src')
43 files changed, 1823 insertions, 1387 deletions
diff --git a/src/GridText.c b/src/GridText.c index f7dfd402..3eb1cf0a 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -33,14 +33,12 @@ #include "LYList.h" #include "LYCharSets.h" #include "LYCharUtils.h" /* LYUCTranslateBack... */ -#ifdef EXP_CHARTRANS #include "UCDefs.h" #include "UCAux.h" #include "UCMap.h" #ifdef EXP_CHARTRANS_AUTOSWITCH #include "UCAuto.h" #endif /* EXP_CHARTRANS_AUTOSWITCH */ -#endif /* EXP_CHARTRANS */ #include "LYexit.h" #include "LYLeaks.h" @@ -172,6 +170,7 @@ struct _HText { int chars; /* Number of them */ TextAnchor * first_anchor; /* Singly linked list */ TextAnchor * last_anchor; + HTList * forms; /* also linked internally */ int last_anchor_number; /* user number */ BOOL source; /* Is the text source? */ BOOL toolbar; /* Toolbar set? */ @@ -202,11 +201,9 @@ struct _HText { int halted; /* emergency halt */ BOOL have_8bit_chars; /* Any non-ASCII chars? */ -#ifdef EXP_CHARTRANS LYUCcharset * UCI; /* node_anchor UCInfo */ int UCLYhndl; /* charset we are fed */ UCTransParams T; -#endif HTStream * target; /* Output stream */ HTStreamClass targetClass; /* Output routines */ @@ -358,13 +355,13 @@ PRIVATE void * LY_check_calloc ARGS2( #define LY_CALLOC LY_check_calloc -#else +#else /* CHECK_FREE_MEM */ + /* using the regular calloc */ #define LY_CALLOC calloc #endif /* CHECK_FREE_MEM */ -#ifdef EXP_CHARTRANS PRIVATE void HText_getChartransInfo ARGS1( HText *, me) { @@ -378,7 +375,26 @@ PRIVATE void HText_getChartransInfo ARGS1( } me->UCI = HTAnchor_getUCInfoStage(me->node_anchor, UCT_STAGE_HTEXT); } -#endif /* EXP_CHARTRANS */ + +PRIVATE void PerFormInfo_free ARGS1( + PerFormInfo *, form) +{ + if (form) { + FREE(form->accept_cs); + FREE(form->thisacceptcs); + FREE(form); + } +} + +PRIVATE void FormList_delete ARGS1( + HTList *, forms) +{ + HTList *cur = forms; + PerFormInfo *form; + while ((form = (PerFormInfo *)HTList_nextObject(cur)) != NULL) + PerFormInfo_free(form); + HTList_delete(forms); +} /* Creation Method ** --------------- @@ -475,14 +491,12 @@ PUBLIC HText * HText_new ARGS1( self->state = S_text; self->kanji_buf = '\0'; self->in_sjis = 0; -#ifdef EXP_CHARTRANS self->have_8bit_chars = NO; HText_getChartransInfo(self); UCSetTransParams(&self->T, self->UCLYhndl, self->UCI, current_char_set, &LYCharSet_UC[current_char_set]); -#endif /* EXP_CHARTRANS */ /* * Check the kcode setting if the anchor has a charset element. - FM @@ -499,13 +513,13 @@ PUBLIC HText * HText_new ARGS1( */ if (underscore_string[0] != '.') { /* - * Create and array of dots for the UNDERSCORES macro. - FM + * Create an array of dots for the UNDERSCORES macro. - FM */ memset(underscore_string, '.', (MAX_LINE-1)); underscore_string[(MAX_LINE-1)] = '\0'; underscore_string[MAX_LINE] = '\0'; /* - * Create and array of underscores for the STARS macro. - FM + * Create an array of underscores for the STARS macro. - FM */ memset(star_string, '_', (MAX_LINE-1)); star_string[(MAX_LINE-1)] = '\0'; @@ -618,6 +632,7 @@ PUBLIC void HText_free ARGS1( FREE(l); } + FormList_delete(self->forms); /* * Free the tabs list. - FM @@ -652,12 +667,10 @@ PUBLIC void HText_free ARGS1( * if it is not a destination of other links. - FM */ if (self->node_anchor) { -#ifdef EXP_CHARTRANS HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_STRUCTURED, UCT_SETBY_NONE); HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_HTEXT, UCT_SETBY_NONE); -#endif /* EXP_CHARTRANS */ if (HTAnchor_delete(self->node_anchor)) /* * Make sure HTMainAnchor won't point @@ -684,9 +697,7 @@ PRIVATE int display_line ARGS2( register int i, j; char buffer[7]; char *data; -#ifdef EXP_CHARTRANS size_t utf_extra = 0; -#endif #ifdef USE_COLOR_STYLE int current_style = 0; #endif @@ -793,8 +804,7 @@ PRIVATE int display_line ARGS2( } default: - i++; -#ifdef EXP_CHARTRANS + i++; if (text->T.output_utf8 && !isascii(buffer[0])) { if ((*buffer & 0xe0) == 0xc0) { utf_extra = 1; @@ -827,9 +837,7 @@ PRIVATE int display_line ARGS2( buffer[1] = '\0'; data += utf_extra; utf_extra = 0; - } else -#endif /* EXP_CHARTRANS */ - if (HTCJK != NOCJK && !isascii(buffer[0])) { + } else if (HTCJK != NOCJK && !isascii(buffer[0])) { /* * For CJK strings, by Masanobu Kimura. */ @@ -1016,9 +1024,7 @@ PRIVATE void display_page ARGS3( BOOL display_flag = FALSE; HTAnchor *link_dest, *link_dest_intl = NULL; static int last_nlinks = 0; -#ifdef EXP_CHARTRANS static int charset_last_displayed = -1; -#endif /* EXP_CHARTRANS */ lynx_mode = NORMAL_LYNX_MODE; @@ -1033,7 +1039,7 @@ PRIVATE void display_page ARGS3( refresh(); clear(); } - addstr("\n\nError accessing document\nNo data available\n"); + addstr("\n\nError accessing document.\nNo data available.\n"); refresh(); nlinks = 0; /* set number of links to 0 */ return; @@ -1076,7 +1082,6 @@ PRIVATE void display_page ARGS3( #endif /* !VMS */ } -#ifdef EXP_CHARTRANS if (LYlowest_eightbit[current_char_set] <= 255 && (current_char_set != charset_last_displayed) && /* @@ -1111,8 +1116,6 @@ PRIVATE void display_page ARGS3( #endif /* EXP_CHARTRANS_AUTOSWITCH */ } -#endif /* EXP_CHARTRANS */ - /* * Check whether to force a screen clear to enable scrollback, * or as a hack to fix a reverse clear screen problem for some @@ -1189,9 +1192,7 @@ PRIVATE void display_page ARGS3( int written = 0; int x_pos = offset + (int)(cp - data); int len = strlen(target); -#ifdef EXP_CHARTRANS size_t utf_extra = 0; -#endif /* EXP_CHARTRANS */ int y; text->page_has_target = YES; @@ -1218,7 +1219,6 @@ PRIVATE void display_page ARGS3( * First printable character of target. */ move((i + 1), x_pos); -#ifdef EXP_CHARTRANS if (text->T.output_utf8 && !isascii(tmp[0])) { if ((*tmp & 0xe0) == 0xc0) { utf_extra = 1; @@ -1251,9 +1251,7 @@ PRIVATE void display_page ARGS3( tmp[1] = '\0'; written += (utf_extra + 1); utf_extra = 0; - } else -#endif /* EXP_CHARTRANS */ - if (HTCJK != NOCJK && !isascii(tmp[0])) { + } else if (HTCJK != NOCJK && !isascii(tmp[0])) { /* * For CJK strings, by Masanobu Kimura. */ @@ -1270,7 +1268,6 @@ PRIVATE void display_page ARGS3( /* * Output all the other printable target chars. */ -#ifdef EXP_CHARTRANS if (text->T.output_utf8 && !isascii(tmp[0])) { if ((*tmp & 0xe0) == 0xc0) { utf_extra = 1; @@ -1303,9 +1300,7 @@ PRIVATE void display_page ARGS3( tmp[1] = '\0'; written += (utf_extra + 1); utf_extra = 0; - } else -#endif /* EXP_CHARTRANS */ - if (HTCJK != NOCJK && !isascii(tmp[0])) { + } else if (HTCJK != NOCJK && !isascii(tmp[0])) { /* * For CJK strings, by Masanobu Kimura. */ @@ -1396,6 +1391,7 @@ PRIVATE void display_page ARGS3( if (traversal) cp_AnchorAddress = stub_HTAnchor_address(link_dest); else { +#ifndef DONT_TRACK_INTERNAL_LINKS if (Anchor_ptr->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink( (HTAnchor *)Anchor_ptr->anchor, LINK_INTERNAL); @@ -1410,14 +1406,17 @@ PRIVATE void display_page ARGS3( link_dest_intl = NULL; if (link_dest_intl) { char *cp2 = HTAnchor_address(link_dest_intl); +#if 0 cp = strchr(cp2, '#'); if (cp && cp != cp2 && 0!=strncmp(cp2, "LYNXIMGMAP:", 11)) { StrAllocCopy(cp_AnchorAddress, cp); FREE(cp2); } else +#endif cp_AnchorAddress = cp2; } else +#endif cp_AnchorAddress = HTAnchor_address(link_dest); } FREE(links[nlinks].lname); @@ -1552,13 +1551,8 @@ PRIVATE void display_page ARGS3( addstr("\n Document is empty"); } - - if (HTCJK != NOCJK || -#ifdef EXP_CHARTRANS - text->T.output_utf8 || -#endif /* EXP_CHARTRANS */ - TRACE) { - /* + if (HTCJK != NOCJK || text->T.output_utf8 || TRACE) { + /* * For non-multibyte curses. */ lynx_force_repaint(); @@ -1607,7 +1601,10 @@ PRIVATE void split_line ARGS2( { HTStyle * style = text->style; HTLine * temp; - int spare, inew; + int spare; +#if defined(USE_COLOR_STYLE) + int inew; +#endif int indent = text->in_line_1 ? text->style->indent1st : text->style->leftIndent; TextAnchor * a; @@ -1867,9 +1864,7 @@ PRIVATE void split_line ARGS2( for (i = (plen - 1); i >= 0; i--) { if (p[i] == LY_BOLD_START_CHAR || p[i] == LY_BOLD_END_CHAR || -#ifdef EXP_CHARTRANS IS_UTF_EXTRA(p[i]) || -#endif /* EXP_CHARTRANS */ p[i] == LY_SOFT_HYPHEN) { ctrl_chars_on_this_line++; } @@ -1920,9 +1915,7 @@ PRIVATE void split_line ARGS2( *cp == LY_UNDERLINE_END_CHAR || *cp == LY_BOLD_START_CHAR || *cp == LY_BOLD_END_CHAR || -#ifdef EXP_CHARTRANS IS_UTF_EXTRA(*cp) || -#endif /* EXP_CHARTRANS */ *cp == LY_SOFT_HYPHEN) ctrl_chars_on_previous_line++; } @@ -2059,7 +2052,17 @@ PUBLIC void HText_appendCharacter ARGS2( 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, " *** MEMORY EXHAUSTED ***"); @@ -2072,12 +2075,20 @@ PUBLIC void HText_appendCharacter ARGS2( */ if (ch == '\033' && HTCJK == NOCJK) /* decimal 27 */ return; -#ifdef EXP_CHARTRANS +#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 her + * is not necessary to protect terminas from those characters. + * They should have been filtered out or translated by an earlier + * processing stage anyway. - kw + */ if ((unsigned char)ch >= 128 && HTCJK == NOCJK && !text->T.transp && !text->T.output_utf8 && (unsigned char)ch < LYlowest_eightbit[current_char_set]) return; -#endif /* EXP_CHARTRANS */ +#endif /* USE_SLANG */ if ((unsigned char)ch == 155 && HTCJK == NOCJK) { /* octal 233 */ if (!HTPassHighCtrlRaw && #ifdef EXP_CHARTRANS @@ -2105,6 +2116,10 @@ PUBLIC void HText_appendCharacter ARGS2( switch(text->state) { case S_text: if (ch == '\033') { + /* + ** 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; @@ -2112,6 +2127,9 @@ PUBLIC void HText_appendCharacter ARGS2( break; case S_esc: + /* + * Expecting '$'or '(' following CJK ESC. + */ if (ch == '$') { text->state = S_dollar; return; @@ -2123,6 +2141,9 @@ PUBLIC void HText_appendCharacter ARGS2( } case S_dollar: + /* + * Expecting '@', 'B', 'A' or '(' after CJK "ESC$". + */ if (ch == '@' || ch == 'B' || ch=='A') { text->state = S_nonascii_text; return; @@ -2135,6 +2156,9 @@ PUBLIC void HText_appendCharacter ARGS2( break; case S_dollar_paren: + /* + * Expecting 'C' after CJK "ESC$(". + */ if (ch == 'C') { text->state = S_nonascii_text; return; @@ -2144,11 +2168,22 @@ PUBLIC void HText_appendCharacter ARGS2( 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 = (int)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 = (int)text->last_line->size; return; } else { text->state = S_text; @@ -2197,7 +2232,10 @@ PUBLIC void HText_appendCharacter ARGS2( text->kanji_buf = (char)kb; } else { text->kanji_buf = ch; - text->permissible_split = line->size; /* Can split here */ + /* + * Can split here. - FM + */ + text->permissible_split = (int)text->last_line->size; return; } } @@ -2265,14 +2303,12 @@ PUBLIC void HText_appendCharacter ARGS2( #endif } -#ifdef EXP_CHARTRANS if (IS_UTF_EXTRA(ch)) { line->data[line->size++] = ch; line->data[line->size] = '\0'; ctrl_chars_on_this_line++; return; } -#endif /* EXP_CHARTRANS */ /* * New Line. @@ -2431,12 +2467,11 @@ check_IgnoreExcess: } } else if ((int)line->size >= (int)(MAX_LINE-1)) { /* - * Never overrun memory if LYcols is set to a large value - kw + * Never overrun memory if LYcols is set to a large value - KW */ new_line(text); } - /* * Insert normal characters. */ @@ -2444,16 +2479,14 @@ check_IgnoreExcess: ch = ' '; } -#ifdef EXP_CHARTRANS if (ch & 0x80) text->have_8bit_chars = YES; -#endif { - HTLine * line = text->last_line; /* May have changed */ 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) { @@ -2606,11 +2639,14 @@ PUBLIC int HText_beginAnchor ARGS3( a->anchor = anc; a->extent = 0; text->last_anchor = a; - + +#ifndef DONT_TRACK_INTERNAL_LINKS if (HTAnchor_followTypedLink((HTAnchor*)anc, LINK_INTERNAL)) { a->number = ++(text->last_anchor_number); a->link_type = INTERNAL_LINK_ANCHOR; - } else if (HTAnchor_followMainLink((HTAnchor*)anc)) { + } else +#endif + if (HTAnchor_followMainLink((HTAnchor*)anc)) { a->number = ++(text->last_anchor_number); a->link_type = HYPERTEXT_ANCHOR; } else { @@ -3124,6 +3160,11 @@ PUBLIC void HText_endAppend ARGS1( new_line(text); if (text->halted) { + /* + * If output was stopped becasue memory was low, and we made + * it to the end of the document, reset those flags and hope + * things are better now. - kw + */ LYFakeZap(NO); text->halted = 0; } @@ -3575,6 +3616,7 @@ PUBLIC int HTGetLinkInfo ARGS6( if (traversal) { cp_freeme = stub_HTAnchor_address(link_dest); } else { +#ifndef DONT_TRACK_INTERNAL_LINKS if (a->link_type == INTERNAL_LINK_ANCHOR) { link_dest_intl = HTAnchor_followTypedLink( (HTAnchor *)a->anchor, LINK_INTERNAL); @@ -3588,6 +3630,7 @@ PUBLIC int HTGetLinkInfo ARGS6( } if (link_dest_intl) { char *cp2 = HTAnchor_address(link_dest_intl); +#if 0 char *cp = strchr(cp2, '#'); if (cp && cp != cp2 && 0!=strncmp(cp2, "LYNXIMGMAP:", 11)) { @@ -3595,11 +3638,15 @@ PUBLIC int HTGetLinkInfo ARGS6( FREE(cp2); return(WWW_INTERN_LINK_TYPE); } else { +#endif FREE(*lname); *lname = cp2; return(WWW_INTERN_LINK_TYPE); +#if 0 } +#endif } else +#endif cp_freeme = HTAnchor_address(link_dest); } StrAllocCopy(*lname, cp_freeme); @@ -3716,7 +3763,7 @@ PUBLIC char * HText_getTitle NOARGS (char *) HTAnchor_title(HTMainText->node_anchor) : NULL); } -#ifdef USEHASH +#ifdef USE_HASH PUBLIC char *HText_getStyle NOARGS { return(HTMainText ? @@ -4708,9 +4755,11 @@ PUBLIC void print_crawl_to_fd ARGS3( return; line = HTMainText->last_line->next; - fprintf(fp,"THE_URL:%s\n",thelink); - if (thetitle != NULL)fprintf(fp,"THE_TITLE:%s\n",thetitle);; - + fprintf(fp, "THE_URL:%s\n", thelink); + if (thetitle != NULL) { + fprintf(fp, "THE_TITLE:%s\n", thetitle); + } + for (;; line = line->next) { /* * Add offset. @@ -5364,7 +5413,6 @@ PUBLIC char * HTLoadedDocumentCharset NOARGS return (NULL); } -#ifdef EXP_CHARTRANS PUBLIC BOOL HTLoadedDocumentEightbit NOARGS { if (!HTMainText) @@ -5372,7 +5420,6 @@ PUBLIC BOOL HTLoadedDocumentEightbit NOARGS else return (HTMainText->have_8bit_chars); } -#endif PUBLIC void HText_setNodeAnchorBookmark ARGS1( CONST char *, bookmark) @@ -5431,28 +5478,21 @@ PRIVATE int HText_TrueLineSize ARGS3( if (IgnoreSpaces) { for (i = 0; i < line->size; i++) { if (!IsSpecialAttrChar((unsigned char)line->data[i]) && -#ifdef EXP_CHARTRANS (!(text && text->T.output_utf8) || (unsigned char)line->data[i] < 128 || ((unsigned char)(line->data[i] & 0xc0) == 0xc0)) && -#endif !isspace((unsigned char)line->data[i]) && (unsigned char)line->data[i] != HT_NON_BREAK_SPACE && (unsigned char)line->data[i] != HT_EM_SPACE) { -#ifdef EXP_CHARTRANS - if (!text->T.output_utf8 || (unsigned char)line->data[i] < 128 || - ((unsigned char)(line->data[i] & 0xc0) == 0xc0)) -#endif /* EXP_CHARTRANS */ true_size++; } } } else { for (i = 0; i < line->size; i++) { - if (!IsSpecialAttrChar(line->data[i])) { -#ifdef EXP_CHARTRANS - if (!text->T.output_utf8 || (unsigned char)line->data[i] < 128 || - ((unsigned char)(line->data[i] & 0xc0) == 0xc0)) -#endif /* EXP_CHARTRANS */ + if (!IsSpecialAttrChar(line->data[i]) && + (!(text && text->T.output_utf8) || + (unsigned char)line->data[i] < 128 || + ((unsigned char)(line->data[i] & 0xc0) == 0xc0))) { true_size++; } } @@ -5674,8 +5714,9 @@ PRIVATE int HTFormMethod; PRIVATE char * HTFormAction = NULL; PRIVATE char * HTFormEnctype = NULL; PRIVATE char * HTFormTitle = NULL; -PRIVATE char * HTFormAcceptCharset = NULL; /* !!! NEED TO DO SOMETHING WITH IT */ +PRIVATE char * HTFormAcceptCharset = NULL; PRIVATE BOOLEAN HTFormDisabled = FALSE; +PRIVATE PerFormInfo * HTCurrentForm; PUBLIC void HText_beginForm ARGS5( char *, action, @@ -5684,6 +5725,7 @@ PUBLIC void HText_beginForm ARGS5( char *, title, CONST char *, accept_cs) { + PerFormInfo * newform; HTFormMethod = URL_GET_METHOD; HTFormNumber++; HTFormFields = 0; @@ -5709,12 +5751,6 @@ PUBLIC void HText_beginForm ARGS5( HTFormMethod = URL_POST_METHOD; /* - * Check the ACCEPT_CHARSET. - kw - */ - if (accept_cs != NULL) - StrAllocCopy(HTFormAcceptCharset, accept_cs); - - /* * Check the ENCTYPE. - FM */ if ((enctype != NULL) && *enctype) { @@ -5734,6 +5770,35 @@ PUBLIC void HText_beginForm ARGS5( else FREE(HTFormTitle); + /* + * Check for an ACCEPT_CHARSET. If present, store it and + * convert to lowercase and collapse spaces. - kw + */ + if (accept_cs != NULL) { + int i; + StrAllocCopy(HTFormAcceptCharset, accept_cs); + collapse_spaces(HTFormAcceptCharset); + for (i = 0; HTFormAcceptCharset[i]; i++) + HTFormAcceptCharset[i] = TOLOWER(HTFormAcceptCharset[i]); + } + + /* + * Create a new "PerFormInfo" structure to hold info on the current + * form. The HTForm* variables could all migrate there, currently + * this isn't done (yet?) but it might be less confusing. + * Currently the only data saved in this structure that will actually + * be used is the accept_cs string. + * This will be appended to the forms list kept by the HText object + * if and when we reach a HText_endForm. - kw + */ + newform = (PerFormInfo *)calloc(1, sizeof(PerFormInfo)); + if (newform == NULL) + outofmem(__FILE__,"HText_beginForm"); + newform->number = HTFormNumber; + + PerFormInfo_free(HTCurrentForm); /* shouldn't happen here - kw */ + HTCurrentForm = newform; + if (TRACE) fprintf(stderr, "BeginForm: action:%s Method:%d%s%s%s%s%s%s\n", @@ -5783,6 +5848,28 @@ PUBLIC void HText_endForm ARGS1( a = a->next; } } + /* + * Append info on the current form to the HText object's list of + * forms. + * HText_beginInput call will have set some of the data in the + * PerFormInfo structure (if there were any form fields at all), + * we also fill in the ACCEPT-CHARSET data now (this could have + * been done earlier). - kw + */ + if (HTCurrentForm) { + if (HTFormDisabled) + HTCurrentForm->disabled = TRUE; + HTCurrentForm->accept_cs = HTFormAcceptCharset; + HTFormAcceptCharset = NULL; + if (!text->forms) + text->forms = HTList_new(); + HTList_appendObject(text->forms, HTCurrentForm); + HTCurrentForm = NULL; + } else { + if (TRACE) + fprintf(stderr, "endForm: HTCurrentForm is missing!\n"); + } + FREE(HTCurSelectGroup); FREE(HTCurSelectGroupSize); FREE(HTCurSelectedOptionValue); @@ -6239,11 +6326,6 @@ PUBLIC int HText_beginInput ARGS3( } } - if (text->last_anchor) { - text->last_anchor->next = a; - } else { - text->first_anchor = a; - } a->next = 0; a->anchor = NULL; a->link_type = INPUT_ANCHOR; @@ -6420,6 +6502,15 @@ PUBLIC int HText_beginInput ARGS3( } } + /* + * Add this anchor to the anchor list + */ + if (text->last_anchor) { + text->last_anchor->next = a; + } else { + text->first_anchor = a; + } + /* * Set VALUE, if it exists. Otherwise, if it's not * an option list make it a zero-length string. - FM @@ -6502,7 +6593,8 @@ PUBLIC int HText_beginInput ARGS3( } /* - * Store accept-charset if present. - kw + * Store accept-charset if present, converting to lowercase + * and collapsing spaces. - kw */ if (I->accept_cs) { StrAllocCopy(f->accept_cs, I->accept_cs); @@ -6607,10 +6699,31 @@ PUBLIC int HText_beginInput ARGS3( } /* - * Add this anchor to the anchor list + * Finalise adding this anchor to the anchor list */ text->last_anchor = a; + if (HTCurrentForm) { /* should always apply! - kw */ + if (!HTCurrentForm->first_field) { + HTCurrentForm->first_field = f; + } + HTCurrentForm->last_field = f; + HTCurrentForm->nfields++; /* will count hidden fields - kw */ + /* + * Propagate form field's accept-charset attribute to enclosing + * form if the form itself didn't have an accept-charset - kw + */ + if (f->accept_cs && !HTFormAcceptCharset) { + StrAllocCopy(HTFormAcceptCharset, f->accept_cs); + } + if (!text->forms) { + text->forms = HTList_new(); + } + } else { + if (TRACE) + fprintf(stderr, "beginInput: HTCurrentForm is missing!\n"); + } + if (TRACE) { fprintf(stderr,"Input link: name=%s\nvalue=%s\nsize=%d\n", f->name, @@ -6640,6 +6753,102 @@ PUBLIC int HText_beginInput ARGS3( return(f->size); } +/* + * Get a translation (properly: transcoding) quality, factoring in + * our ability to translate (an UCTQ_t) and a possible q parameter + * on the given charset string, for cs_from -> givenmime. + * The parsed input string will be mutilated on exit(!). + * Note that results are not normalised to 1.0, but results from + * different calls of this function can be compared. - kw + */ +PRIVATE double get_trans_q ARGS2( + int, cs_from, + char *, givenmime) +{ + double dq = 0.0, df = 1.0; + UCTQ_t tq; + char *p; + if (!givenmime || !(*givenmime)) + return dq; + if ((p = strchr(givenmime,';')) != NULL) { + *p++ = '\0'; + } + if (!strcmp(givenmime, "*")) + tq = UCCanTranslateFromTo(cs_from, + UCGetLYhndl_byMIME("utf-8")); + else + tq = UCCanTranslateFromTo(cs_from, + UCGetLYhndl_byMIME(givenmime)); + if (tq <= TQ_NO) + return dq; + dq = 1.0; + if (p && *p) { + char *pair, *field = p, *pval, *ptok; + /* Get all the parameters to the Charset */ + while ((pair = HTNextTok(&field, ";", "\"", NULL)) != NULL) { + if ((ptok = HTNextTok(&pair, "= ", NULL, NULL)) != NULL && + (pval = HTNextField(&pair)) != NULL) { + if (0==strcasecomp(ptok,"q")) { + df = strtod(pval, NULL); + break; + } + } + } + return (df * tq); + } else { + return tq; + } +} + +/* + * Find the best charset for submission, if we have an ACCEPT_CHARSET + * list. It factors in how well we can translate (just as guess, and + * not a very good one..) and possible ";q=" factors. Yes this is + * more general than it needs to be here. + * + * Input is cs_in and acceptstring. + * + * Will return charset handle as int. + * best_csname will point to a newly allocated MIME string for the + * charset corresponding to the return value if return value >= 0. + * - kw + */ +PRIVATE int find_best_target_cs ARGS3( + char **, best_csname, + int, cs_from, + CONST char *, acceptstring) +{ + char *paccept = NULL; + double bestq = -1.0; + char *bestmime = NULL; + char *field, *nextfield; + StrAllocCopy(paccept, acceptstring); + nextfield = paccept; + while ((field = HTNextTok(&nextfield, ",", "\"", NULL)) != NULL) { + double q; + if (*field != '\0') { + /* Get the Charset*/ + q = get_trans_q(cs_from, field); + if (q > bestq) { + bestq = q; + bestmime = field; + } + } + } + if (bestmime) { + if (!strcmp(bestmime, "*")) /* non-standard for HTML attribute.. */ + StrAllocCopy(*best_csname, "utf-8"); + else + StrAllocCopy(*best_csname, bestmime); + FREE(paccept); + if (bestq > 0) + return (UCGetLYhndl_byMIME(*best_csname)); + else + return (-1); + } + FREE(paccept); + return (-1); +} PUBLIC void HText_SubmitForm ARGS4( FormInfo *, submit_item, @@ -6650,6 +6859,7 @@ PUBLIC void HText_SubmitForm ARGS4( TextAnchor *anchor_ptr; int form_number = submit_item->number; FormInfo *form_ptr; + PerFormInfo *thisform; int len; char *query = NULL; char *escaped1 = NULL, *escaped2 = NULL; @@ -6664,7 +6874,7 @@ PUBLIC void HText_SubmitForm ARGS4( int target_cs = -1; CONST char *out_csname; CONST char *target_csname = NULL; - char *name_used; + char *name_used = ""; #ifdef EXP_CHARTRANS BOOL form_has_8bit = NO, form_has_special = NO; BOOL field_has_8bit = NO, field_has_special = NO; @@ -6672,7 +6882,7 @@ PUBLIC void HText_SubmitForm ARGS4( BOOL have_accept_cs = NO; BOOL success; BOOL had_chartrans_warning = NO; - char *val_used; + char *val_used = ""; char *copied_val_used = NULL; char *copied_name_used = NULL; #endif @@ -6680,6 +6890,21 @@ PUBLIC void HText_SubmitForm ARGS4( if (!HTMainText) return; + thisform = HTList_objectAt(HTMainText->forms, form_number - 1); + /* Sanity check */ + if (!thisform) { + if (TRACE) + fprintf(stderr, + "SubmitForm: form %d not in HTMainText's list!\n", + form_number); + } else if (thisform->number != form_number) { + if (TRACE) + fprintf(stderr, + "SubmitForm: failed sanity check, %d!=%d !\n", + thisform->number, form_number); + thisform = NULL; + } + if (submit_item->submit_action) { /* * If we're mailing, make sure it's a mailto ACTION. - FM @@ -6737,17 +6962,26 @@ PUBLIC void HText_SubmitForm ARGS4( * charset to submit */ #ifdef EXP_CHARTRANS - - if (submit_item->accept_cs && - strcasecomp(submit_item->accept_cs, "UNKNOWN")) - have_accept_cs = YES; - if (submit_item->accept_cs && *submit_item->accept_cs && - strcmp(submit_item->accept_cs, "*") && + + /* Look at ACCEPT-CHARSET on the submitting field if we have one. */ + if (thisform && submit_item->accept_cs && strcasecomp(submit_item->accept_cs, "UNKNOWN")) { - target_cs = UCGetLYhndl_byMIME(submit_item->accept_cs); - if (target_cs >= 0) { - target_csname = submit_item->accept_cs; - } + have_accept_cs = YES; + target_cs = find_best_target_cs(&thisform->thisacceptcs, + current_char_set, + submit_item->accept_cs); + } + /* Look at ACCEPT-CHARSET on form as a whole if submitting field + * didn't have one. */ + if (thisform && !have_accept_cs && thisform->accept_cs && + strcasecomp(thisform->accept_cs, "UNKNOWN")) { + have_accept_cs = YES; + target_cs = find_best_target_cs(&thisform->thisacceptcs, + current_char_set, + thisform->accept_cs); + } + if (have_accept_cs && (target_cs >= 0) && thisform->thisacceptcs) { + target_csname = thisform->thisacceptcs; } if (target_cs < 0 && @@ -7798,6 +8032,7 @@ PRIVATE void free_all_texts NOARGS FREE(HTFormEnctype); FREE(HTFormTitle); FREE(HTFormAcceptCharset); + PerFormInfo_free(HTCurrentForm); return; } @@ -7846,13 +8081,11 @@ PUBLIC BOOL HText_hasNoCacheSet ARGS1( return ((text && text->no_cache) ? TRUE : FALSE); } -#ifdef EXP_CHARTRANS PUBLIC BOOL HText_hasUTF8OutputSet ARGS1( HText *, text) { return ((text && text->T.output_utf8) ? TRUE : FALSE); } -#endif /* ** Check charset and set the kcode element. - FM @@ -7873,7 +8106,7 @@ PUBLIC void HText_setKcode ARGS3( return; /* - ** Check whether we have some king of info. - kw + ** Check whether we have some kind of info. - kw */ if (!charset && !p_in) { return; @@ -7897,7 +8130,8 @@ PUBLIC void HText_setKcode ARGS3( ** so check the charset value and set the text->kcode element ** appropriately. - FM */ - if (!strcmp(charset, "shift_jis")) { + if (!strcmp(charset, "shift_jis") || + !strcmp(charset, "x-shift-jis")) { text->kcode = SJIS; } else if ((p_in && (p_in->enc == UCT_ENC_CJK)) || !strcmp(charset, "euc-jp") || @@ -7935,7 +8169,10 @@ PUBLIC void HText_setBreakPoint ARGS1( if (!text) return; - text->permissible_split = (int)text->last_line->size; /* Can split here */ + /* + * Can split here. - FM + */ + text->permissible_split = (int)text->last_line->size; return; } diff --git a/src/GridText.h b/src/GridText.h index 9247e14d..42a50c0c 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -83,7 +83,7 @@ extern char * HText_getServer NOPARAMS; extern char * HText_getOwner NOPARAMS; extern char * HText_getContentBase NOPARAMS; extern char * HText_getContentLocation NOPARAMS; -#ifdef USEHASH +#ifdef USE_HASH extern char * HText_getStyle NOPARAMS; #endif extern void HText_setMainTextOwner PARAMS((CONST char * owner)); diff --git a/src/HTForms.h b/src/HTForms.h index b140f4d7..3d6f608d 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -81,6 +81,27 @@ typedef struct _FormInfo { char * accept_cs; } FormInfo; +/* + * As structure for info associated with a form. + * There is some redundancy here, this shouldn't waste too much memory + * since the total number of forms (as opposed to form fields) per doc + * is expected to be rather small. + * More things which are per form rather than per field could be moved + * here. - kw + */ +typedef struct _PerFormInfo +{ + int number; /* form number, see GridText.c */ + /* except for the last two, the followign fields aren't actually used.. */ + int disabled; /* If YES, can't change values */ + struct _PerFormInfo * next; /* pointer to next form in doc */ + int nfields; /* number of fields */ + FormInfo * first_field; + FormInfo * last_field; /* pointer to last field in form */ + char * accept_cs; + char * thisacceptcs; /* used during submit */ +} PerFormInfo; + #define HYPERTEXT_ANCHOR 1 #define INPUT_ANCHOR 2 /* forms mode input fields */ #define INTERNAL_LINK_ANCHOR 5 /* 1+4, can be used as bitflag... - kw */ diff --git a/src/HTInit.c b/src/HTInit.c index 540c1c67..38856772 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -46,7 +46,6 @@ PUBLIC void HTFormatInit NOARGS { FILE *fp = NULL; char *cp = NULL; - extern char * personal_type_map, * global_type_map; #ifdef NeXT HTSetPresentation("application/postscript", "open %s", 1.0, 2.0, 0.0, 0); @@ -679,8 +678,6 @@ PRIVATE int HTLoadTypesConfigFile ARGS1(char *,fn) PUBLIC void HTFileInit NOARGS { FILE *fp; - extern char *global_extension_map; - extern char *personal_extension_map; if (TRACE) fprintf (stderr, "@@@ Using default extension map\n"); diff --git a/src/HTML.c b/src/HTML.c index 5da10c39..15ed71c6 100644 --- a/src/HTML.c +++ b/src/HTML.c @@ -26,15 +26,13 @@ #include "HTMLGen.h" #include "HTParse.h" #include "HTList.h" +#include "UCMap.h" +#include "UCDefs.h" +#include "UCAux.h" #include "LYGlobalDefs.h" #include "LYCharUtils.h" #include "LYCharSets.h" -#ifdef EXP_CHARTRANS -#include "UCMap.h" -#include "UCDefs.h" -#include "UCAux.h" -#endif #include "HTAlert.h" #include "HTFont.h" @@ -500,16 +498,26 @@ PUBLIC void HTML_write ARGS3(HTStructured *, me, CONST char*, s, int, l) HTML_put_character(me, *p); } +#ifndef DONT_TRACK_INTERNAL_LINKS + /* A flag is used to keep track of whether an "URL reference" encountered had a real "URL" or not. (This is the terminology of the Fielding Internet Draft.) In the latter case, it will be marked as an "internal" - link. The flag is set before we stard messing around with the string + link. The flag is set before we start messing around with the string (resolution of relative URLs etc.). - kw */ #define CHECK_FOR_INTERN(s) intern_flag = (s && (*s=='#' || *s=='\0')) ? TRUE : FALSE; + /* Last argument to pass to HTAnchor_findChildAndLink() calls, just an abbreviation. - kw */ #define INTERN_LT (HTLinkType *)(intern_flag ? LINK_INTERNAL : NULL) +#else /* TRACK_INTERNAL_LINKS */ + +#define CHECK_FOR_INTERN(s) /* do nothing */ ; +#define INTERN_LT (HTLinkType *)NULL + +#endif /* TRACK_INTERNAL_LINKS */ + #ifdef USE_COLOR_STYLE char class_string[TEMPSTRINGSIZE]; char prevailing_class[TEMPSTRINGSIZE]; @@ -615,9 +623,7 @@ PRIVATE void HTML_start_element ARGS6( char *title = NULL; char *I_value = NULL, *I_name = NULL; char *temp = NULL; -#ifdef EXP_CHARTRANS int dest_char_set = -1; -#endif HTParentAnchor *dest = NULL; /* An anchor's destination */ BOOL dest_ismap = FALSE; /* Is dest an image map script? */ BOOL UseBASE = TRUE; /* Resoved vs. BASE if present? */ @@ -801,7 +807,7 @@ PRIVATE void HTML_start_element ARGS6( if (!me->text) UPDATE_STYLE; if (present) - LYHandleMETA(me, present, (CONST char **)value, (char **)&include); + LYHandleMETA(me, present, value, (char **)&include); break; case HTML_TITLE: @@ -1091,14 +1097,14 @@ PRIVATE void HTML_start_element ARGS6( INTERN_LT); /* Type */ if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) - )) != 0) { + )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); dest = NULL; #ifdef EXP_CHARTRANS - if (present[HTML_A_CHARSET] && - value[HTML_A_CHARSET] && *value[HTML_A_CHARSET] != '\0') { - dest_char_set = UCGetLYhndl_byMIME(value[HTML_A_CHARSET]); + if (present[HTML_LINK_CHARSET] && + value[HTML_LINK_CHARSET] && *value[HTML_LINK_CHARSET] != '\0') { + dest_char_set = UCGetLYhndl_byMIME(value[HTML_LINK_CHARSET]); if (dest_char_set < 0) dest_char_set = UCLYhndl_for_unrec; } @@ -1861,7 +1867,8 @@ PRIVATE void HTML_start_element ARGS6( * The INDENT value is in "en" (enval per column) units. * Divide it by enval, rounding odd values up. - FM */ - target = ((1.0 * atoi(value[HTML_TAB_INDENT])) / enval) + 0.5; + target = + (int)(((1.0 * atoi(value[HTML_TAB_INDENT])) / enval)+(0.5)); } FREE(temp); /* @@ -2156,8 +2163,9 @@ PRIVATE void HTML_start_element ARGS6( CHECK_ID(HTML_GEN_ID); HText_setLastChar(me->text, ' '); /* absorb white space */ if (!me->style_change) { - if (HText_LastLineSize(me->text, FALSE)) + if (HText_LastLineSize(me->text, FALSE)) { HText_appendCharacter(me->text, '\r'); + } } else { UPDATE_STYLE; HText_appendCharacter(me->text, '\t'); @@ -2549,6 +2557,8 @@ PRIVATE void HTML_start_element ARGS6( * Set to know we are in an anchor. */ me->inA = TRUE; + if (!me->text) + UPDATE_STYLE; /* * Load id_string if we have an ID or NAME. - FM @@ -2571,11 +2581,12 @@ PRIVATE void HTML_start_element ARGS6( * Handle the reference. - FM */ if (present && present[HTML_A_HREF]) { - +#ifndef DONT_TRACK_INTERNAL_LINKS if (present[HTML_A_ISMAP]) intern_flag = FALSE; else CHECK_FOR_INTERN(value[HTML_A_HREF]); +#endif /* * Prepare to do housekeeping on the reference. - FM */ @@ -2679,37 +2690,38 @@ PRIVATE void HTML_start_element ARGS6( } if (present[HTML_A_ISMAP]) dest_ismap = TRUE; -#ifdef EXP_CHARTRANS - if (present[HTML_A_CHARSET] && - value[HTML_A_CHARSET] && *value[HTML_A_CHARSET] != '\0') { - dest_char_set = UCGetLYhndl_byMIME(value[HTML_A_CHARSET]); + if (present[HTML_A_CHARSET] && + value[HTML_A_CHARSET] && *value[HTML_A_CHARSET] != '\0') { + /* + ** Set up to load the anchor's chartrans structures. + */ + StrAllocCopy(temp, value[HTML_A_CHARSET]); + TRANSLATE_AND_UNESCAPE_TO_STD(&temp); + dest_char_set = UCGetLYhndl_byMIME(temp); if (dest_char_set < 0) { dest_char_set = UCLYhndl_for_unrec; } - } - if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) -#else - if (title != NULL || dest_ismap == TRUE) -#endif /* EXP_CHARTRANS */ + } + if (title != NULL || dest_ismap == TRUE || dest_char_set >= 0) { dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) ); + } if (dest && title != NULL && HTAnchor_title(dest) == NULL) HTAnchor_setTitle(dest, title); if (dest && dest_ismap) dest->isISMAPScript = TRUE; -#ifdef EXP_CHARTRANS - if (dest && dest_char_set >= 0) - HTAnchor_setUCInfoStage(dest, dest_char_set, - UCT_STAGE_PARSER, - UCT_SETBY_LINK); - dest_char_set = -1; -#endif /* EXP_CHARTRANS */ + if (dest && dest_char_set >= 0) { + HTAnchor_setUCInfoStage(dest, dest_char_set, + UCT_STAGE_PARSER, + UCT_SETBY_LINK); + } + FREE(temp); dest = NULL; dest_ismap = FALSE; + dest_char_set = -1; FREE(title); } - UPDATE_STYLE; me->CurrentANum = HText_beginAnchor(me->text, me->inUnderline, me->CurrentA); if (me->inBoldA == TRUE && me->inBoldH == FALSE) @@ -2740,7 +2752,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->inA && me->CurrentA) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) - )) != 0) { + )) != NULL) { if (dest->isISMAPScript == TRUE) { dest_ismap = TRUE; if (TRACE) @@ -2768,17 +2780,19 @@ PRIVATE void HTML_start_element ARGS6( CHECK_FOR_INTERN(map_href); url_type = LYLegitimizeHREF(me, (char**)&map_href, TRUE, TRUE); /* - * If map_href ended up zero-length or otherwise doesn't - * have a hash, it can't be valid, so ignore it. - FM + * If map_href ended up zero-length or otherwise doesn't + * have a hash, it can't be valid, so ignore it. - FM */ if (strchr(map_href, '#') == NULL) { FREE(map_href); } } - if (map_href) { + + if (map_href) { /* - * Check whether a base tag is in effect. - FM + * If the MAP reference doesn't yet begin with a scheme, + * check whether a base tag is in effect. - FM */ if (!url_type && me->inBASE) { /* @@ -3032,7 +3046,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) - )) != 0) { + )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); } @@ -3089,7 +3103,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) - )) != 0) { + )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); } @@ -3183,7 +3197,7 @@ PRIVATE void HTML_start_element ARGS6( if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) - )) != 0) { + )) != NULL) { if (!HTAnchor_title(dest)) HTAnchor_setTitle(dest, title); } @@ -4160,9 +4174,11 @@ PRIVATE void HTML_start_element ARGS6( url_type = LYLegitimizeHREF(me, (char**)&action, TRUE, TRUE); /* - * Check whether a base tag is in effect. + * Check whether a base tag is in effect. Note that + * actions always are resolved w.r.t. to the base, + * even if the action is empty. - FM */ - if ((me->inBASE && *action != '\0' && *action != '#') && + if ((me->inBASE && me->base_href && *me->base_href) && (temp = HTParse(action, me->base_href, PARSE_ALL)) && *temp != '\0') { /* @@ -4262,7 +4278,6 @@ PRIVATE void HTML_start_element ARGS6( FREE(method); FREE(enctype); FREE(title); - FREE(title); } CHECK_ID(HTML_FORM_ID); break; @@ -5254,10 +5269,12 @@ PRIVATE void HTML_start_element ARGS6( /* * Convert any HTML entities or decimal escaping. - FM */ +#ifndef EXP_CHARTRANS int CurrentCharSet = current_char_set; BOOL CurrentEightBitRaw = HTPassEightBitRaw; BOOLEAN CurrentUseDefaultRawMode = LYUseDefaultRawMode; HTCJKlang CurrentHTCJK = HTCJK; +#endif StrAllocCopy(I_value, value[HTML_OPTION_VALUE]); me->HiddenValue = TRUE; @@ -5354,10 +5371,12 @@ PRIVATE void HTML_start_element ARGS6( /* * Convert any HTML entities or decimal escaping. - FM */ +#ifndef EXP_CHARTRANS int CurrentCharSet = current_char_set; BOOL CurrentEightBitRaw = HTPassEightBitRaw; BOOLEAN CurrentUseDefaultRawMode = LYUseDefaultRawMode; HTCJKlang CurrentHTCJK = HTCJK; +#endif StrAllocCopy(I_value, value[HTML_OPTION_VALUE]); me->HiddenValue = TRUE; @@ -5585,11 +5604,11 @@ PRIVATE void HTML_start_element ARGS6( { if (TRACE) fprintf(stderr, "STYLE:begin_element:ending EMPTY element style\n"); -#if !defined(USEHASH) +#if !defined(USE_HASH) HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); #else HText_characterStyle(me->text, hcode, STACK_OFF); -#endif /* USEHASH */ +#endif /* USE_HASH */ { char *end, *start=NULL, *lookfrom; char tmp[64]; @@ -6755,6 +6774,14 @@ End_Object: I.disabled = me->textarea_disabled; I.id = me->textarea_id; + /* + * SGML unescape any character references in TEXTAREA + * content, then parse it into individual lines + * to be handled as a series of INPUT fields (ugh!). + * Any raw 8-bit or multibye characters already have been + * handled in relation to the display character set + * in SGML_character(). + */ me->UsePlainSpace = TRUE; #ifndef EXP_CHARTRANS @@ -6828,7 +6855,6 @@ End_Object: } } FREE(temp); - me->UsePlainSpace = FALSE; HTChunkClear(&me->textarea); @@ -7065,11 +7091,11 @@ End_Object: { if (TRACE) fprintf(stderr, "STYLE:end_element: ending non-EMPTY style\n"); -#if !defined(USEHASH) +#if !defined(USE_HASH) HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); #else HText_characterStyle(me->text, hcode, STACK_OFF); -#endif /* USEHASH */ +#endif /* USE_HASH */ #if defined(PREVAIL) /* reset the prevailing class to the previous one */ { diff --git a/src/LYCgi.c b/src/LYCgi.c index 86d2db58..4f6d0171 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -301,7 +301,7 @@ PRIVATE int LYLoadCGI ARGS4( int fd1[2], fd2[2]; char buf[1024]; pid_t pid; -#if HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID +#if HAVE_TYPE_UNIONWAIT union wait wstatus; #else int wstatus; @@ -388,7 +388,7 @@ PRIVATE int LYLoadCGI ARGS4( (*target->isa->put_block)(target, buf, chars); } -#if HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID +#if !HAVE_WAITPID while (wait(&wstatus) != pid) ; /* do nothing */ #else @@ -403,7 +403,7 @@ PRIVATE int LYLoadCGI ARGS4( #endif /* ERESTARTSYS */ break; } -#endif /* HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID */ +#endif /* !HAVE_WAITPID */ if (anAnchor->post_data) { close(fd1[1]); } diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 25ca634d..e41a9047 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -825,15 +825,18 @@ PUBLIC void LYGetChartransInfo ARGS1( if (chndl < 0) { chndl = current_char_set; - HTAnchor_setUCInfoStage(me->node_anchor, chndl, UCT_STAGE_HTEXT, + HTAnchor_setUCInfoStage(me->node_anchor, chndl, + UCT_STAGE_HTEXT, UCT_SETBY_STRUCTURED); } HTAnchor_setUCInfoStage(me->node_anchor, chndl, - UCT_STAGE_STRUCTURED, UCT_SETBY_STRUCTURED); + UCT_STAGE_STRUCTURED, + UCT_SETBY_STRUCTURED); me->UCLYhndl = HTAnchor_getUCLYhndl(me->node_anchor, UCT_STAGE_STRUCTURED); } - me->UCI = HTAnchor_getUCInfoStage(me->node_anchor, UCT_STAGE_STRUCTURED); + me->UCI = HTAnchor_getUCInfoStage(me->node_anchor, + UCT_STAGE_STRUCTURED); } #endif /* EXP_CHARTRANS */ @@ -1026,23 +1029,23 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( char * p; char *q, *qs; HTChunk *chunk = NULL; - char * cp; - char cpe; + char * cp = 0; + char cpe = 0; char *esc = NULL; char replace_buf[64]; int uck; int lowest_8; - UCode_t code; + UCode_t code = 0; long int lcode; - BOOL output_utf8, repl_translated_C0; + BOOL output_utf8 = 0, repl_translated_C0 = 0; size_t len; int high, low, diff = 0, i; CONST char ** entities = HTML_dtd.entity_names; CONST UC_entity_info * extra_entities = HTML_dtd.extra_entity_info; - CONST char * name; + CONST char * name = 0; BOOLEAN no_bytetrans; UCTransParams T; - BOOL from_is_utf8; + BOOL from_is_utf8 = FALSE; char * puni; enum _state { S_text, S_esc, S_dollar, S_paren, S_nonascii_text, S_dollar_paren, @@ -1480,17 +1483,23 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( ** the Lynx special character. - FM */ if (code == 173) { - if (hidden) { - ; - } else if (plain_space) { + if (plain_space) { replace_buf[0] = '\0'; state = S_got_outstring; break; + } else if (Back && + !(LYCharSet_UC[cs_to].enc == UCT_ENC_8859 || + (LYCharSet_UC[cs_to].like8859 & + UCT_R_8859SPECL))) { + ; /* nothing, may be translated later */ + } else if (hidden || Back) { + state = S_got_outchar; + break; } else { code = LY_SOFT_HYPHEN; + state = S_got_outchar; + break; } - state = S_got_outchar; - break; } /* ** Seek a translation from the chartrans tables. @@ -1538,7 +1547,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( */ (uck = UCTransUniCharStr(replace_buf, 60, code, - current_char_set, + cs_to, 0) >= 0)) { state = S_got_outstring; break; @@ -1606,7 +1615,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( } else if (code < 161 || (code < 256 && (HTPassEightBitNum || - !strncmp(LYchar_set_names[current_char_set], + !strncmp(LYchar_set_names[cs_to], "ISO Latin 1", 11)))) { /* ** No conversion needed. @@ -2122,10 +2131,10 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( ** Seek a translation from the chartrans tables. */ if ((uck = UCTransUniChar(code, - current_char_set)) >= 32 && + cs_to)) >= 32 && uck < 256 && (uck < 127 || uck >= lowest_8)) { - if (uck == 160 && current_char_set == 0) { + if (uck == 160 && cs_to == 0) { /* ** Would only happen if some other unicode ** is mapped to Latin-1 160. @@ -2142,7 +2151,7 @@ PRIVATE char ** LYUCFullyTranslateString_1 ARGS9( *p = cpe; } continue; - } else if (uck == 173 && current_char_set == 0) { + } else if (uck == 173 && cs_to == 0) { /* ** Would only happen if some other unicode ** is mapped to Latin-1 173. @@ -3343,7 +3352,6 @@ PUBLIC void LYHandleMETA ARGS4( cp1 += 7; while (*cp1 == ' ' || *cp1 == '=' || *cp1 == '"') cp1++; -#ifdef EXP_CHARTRANS StrAllocCopy(cp3, cp1); /* copy to mutilate more */ for (cp4 = cp3; (*cp4 != '\0' && *cp4 != '"' && *cp4 != ';' && *cp4 != ':' && @@ -3381,7 +3389,6 @@ PUBLIC void LYHandleMETA ARGS4( UCT_SETBY_STRUCTURED); } } - FREE(cp3); if (chartrans_ok) { LYUCcharset * p_out = HTAnchor_setUCInfoStage(me->node_anchor, @@ -3410,22 +3417,44 @@ PUBLIC void LYHandleMETA ARGS4( HTAnchor_setUCInfoStage(me->node_anchor, HTAnchor_getUCLYhndl(me->node_anchor, UCT_STAGE_PARSER), - UCT_STAGE_HTEXT, - UCT_SETBY_DEFAULT); + UCT_STAGE_HTEXT, + UCT_SETBY_DEFAULT); } - if ((p_in->enc != UCT_ENC_CJK) && - (p_in->codepoints & UCT_CP_SUBSETOF_LAT1)) { + if (p_in->enc != UCT_ENC_CJK) { HTCJK = NOCJK; - } else if (chndl == current_char_set) { - HTPassEightBitRaw = TRUE; + if (!(p_in->codepoints & + UCT_CP_SUBSETOF_LAT1) && + chndl == current_char_set) { + HTPassEightBitRaw = TRUE; + } + } else if (p_out->enc == UCT_ENC_CJK) { + if (LYRawMode) { + if ((!strcmp(p_in->MIMEname, "euc-jp") || + !strcmp(p_in->MIMEname, "shift_jis")) && + (!strcmp(p_out->MIMEname, "euc-jp") || + !strcmp(p_out->MIMEname, "shift_jis"))) { + HTCJK = JAPANESE; + } else if (!strcmp(p_in->MIMEname, "euc-cn") && + !strcmp(p_out->MIMEname, "euc-cn")) { + HTCJK = CHINESE; + } else if (!strcmp(p_in->MIMEname, "big-5") && + !strcmp(p_out->MIMEname, "big-5")) { + HTCJK = TAIPEI; + } else if (!strcmp(p_in->MIMEname, "euc-kr") && + !strcmp(p_out->MIMEname, "euc-kr")) { + HTCJK = KOREAN; + } else { + HTCJK = NOCJK; + } + } else { + HTCJK = NOCJK; + } } LYGetChartransInfo(me); /* * Fall through to old behavior. */ - } else -#endif /* EXP_CHARTRANS */ - if (!strncmp(cp1, "us-ascii", 8) || + } else if (!strncmp(cp1, "us-ascii", 8) || !strncmp(cp1, "iso-8859-1", 10)) { StrAllocCopy(me->node_anchor->charset, "iso-8859-1"); HTCJK = NOCJK; @@ -3436,14 +3465,18 @@ PUBLIC void LYHandleMETA ARGS4( StrAllocCopy(me->node_anchor->charset, "iso-8859-2"); HTPassEightBitRaw = TRUE; - } else if (!strncmp(cp1, "iso-8859-", 9) && + } else if (!strncmp(cp4, "iso-8859-", 9) && !strncmp(LYchar_set_names[current_char_set], "Other ISO Latin", 15)) { /* * Hope it's a match, for now. - FM */ - StrAllocCopy(me->node_anchor->charset, "iso-8859- "); - me->node_anchor->charset[9] = cp1[9]; + cp1 = &cp4[10]; + while (*cp1 && + isdigit((unsigned char)(*cp1))) + cp1++; + *cp1 = '\0'; + StrAllocCopy(me->node_anchor->charset, cp4); HTPassEightBitRaw = TRUE; HTAlert(me->node_anchor->charset); @@ -3489,10 +3522,11 @@ PUBLIC void LYHandleMETA ARGS4( } else if (!strncmp(cp1, "iso-2022-cn", 11) && HTCJK == CHINESE) { StrAllocCopy(me->node_anchor->charset, "iso-2022-cn"); } + FREE(cp3); if (TRACE && me->node_anchor->charset) { fprintf(stderr, - "HTML: New charset: %s\n", + "LYHandleMETA: New charset: %s\n", me->node_anchor->charset); } } @@ -3894,7 +3928,7 @@ PUBLIC void LYHandleSELECT ARGS5( */ if (TRACE) fprintf(stderr, - "HTML: Ignoring SIZE=\"%s\" for SELECT.\n", + "LYHandleSELECT: Ignoring SIZE=\"%s\" for SELECT.\n", (char *)value[HTML_SELECT_SIZE]); #endif /* NOTDEFINED */ } @@ -4419,66 +4453,35 @@ PUBLIC void LYResetParagraphAlignment ARGS1( } /* -** This is an example interface for accessing elements of the HTML -** parser's HTStructured object by the SGML parser. The SGML parser -** knows the HTML parsers's HTStructured objects as context->target -** elements, and, homologously, uses them as an argument in calls to -** HTML_start_element() and HTML_end_element(), but should not -** manipulate the context->target's elements, itself, because those -** are defined in the Lynx_HTML_Handler section of HTML.h, to which -** SGML.c is blind. This *example* function check's whether the -** node_anchor element of an HTML parser HTStructured object has +** This example function checks whether the given anchor has ** an address with a file scheme, and if so, loads it into the ** the SGML parser's context->url element, which was passed as ** the second argument. The handle_comment() calling function in ** SGML.c then calls LYDoCSI() in LYUtils.c to insert HTML markup ** into the corresponding stream, homologously to an SSI by an ** HTTP server. - FM -** Since SGML.c is blind to the HTML parsers's HTStructured object -** details it may be calling this function inappropriately when -** its context->target isn't actually the HTStructured object -** implemented in HTML.c but one in HTMLDTD.c. Therefore this -** function checks for the expected HTStructuredClass's signature -** in me->isa->name before doing anything else which requires -** access to the expected HTStructured object's data fields, and -** returns a failure indication if it finds that it has been called -** inappropriately. - kw -** Functions such as this also could -** be used to set the values of elements (existing ones, or any -** new ones needed for future development) in the HTML parser's -** HTStructured objects, so that they will be accessible to all -** Lynx_HTML_Handler utility functions, thus avoiding the need -** to increase the number of arguments in the calls to those -** functions, and keeping them object-specific via their 'me' -** arguments. - FM -** But to generalize the SGML.c -> HTStructured calling mechanism -** so that it can deal with more than one implementation of what -** SGML.c sees as context->target, new functions will either have -** to check whether they are called for the expected kind of target -** object (such as here), or they have to come in several object- -** specific versions to work across all possible target object classes; -** in the latter case they should become new member functions of the -** Structured Object definition in SGML.h. - kw +** +** For functions similar to this but which depend on details of +** the HTML handler's internal data, the calling interface should +** be changed, and functions in SGML.c would have to make sure not +** to call such functions inappropriately (e.g. calling a function +** specific to the Lynx_HTML_Handler when SGML.c output goes to +** some other HTStructured object like in HTMLGen.c), or the new +** functions could be added to the SGML.h interface. */ PUBLIC BOOLEAN LYCheckForCSI ARGS2( - HTStructured *, me, + HTParentAnchor *, anchor, char **, url) { - if (!me) + if (!(anchor && anchor->address)) return FALSE; - if (!me->isa || strcmp(me->isa->name, "Lynx_HTML_Handler")) - return FALSE; - - if (!(me->node_anchor && me->node_anchor->address)) - return FALSE; - - if (strncasecomp(me->node_anchor->address, "file:", 5)) + if (strncasecomp(anchor->address, "file:", 5)) return FALSE; - if (!LYisLocalHost(me->node_anchor->address)) + if (!LYisLocalHost(anchor->address)) return FALSE; - - StrAllocCopy(*url, me->node_anchor->address); + + StrAllocCopy(*url, anchor->address); return TRUE; } diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index f276ad0a..c1c58f40 100644 --- a/src/LYCharUtils.h +++ b/src/LYCharUtils.h @@ -109,7 +109,7 @@ extern void LYEnsureSingleSpace PARAMS(( extern void LYResetParagraphAlignment PARAMS(( HTStructured * me)); extern BOOLEAN LYCheckForCSI PARAMS(( - HTStructured * me, + HTParentAnchor * anchor, char ** url)); #endif /* Lynx_HTML_Handler */ diff --git a/src/LYCurses.c b/src/LYCurses.c index d134f4b9..35bfc6eb 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -667,7 +667,7 @@ PUBLIC void start_curses NOARGS if (first_time) { /* - * If we're not VMS then only do initsrc() one time, + * If we're not VMS then only do initscr() one time, * and one time only! */ if (initscr() == NULL) { /* start curses */ @@ -684,6 +684,9 @@ PUBLIC void start_curses NOARGS #endif /* SIGTSTP */ exit (-1); } +#if defined(SIGWINCH) && defined(NCURSES_VERSION) + size_change(0); +#endif /* SIGWINCH */ /* * This is a workaround for a bug in SVr4 curses, observed on Solaris diff --git a/src/LYForms.c b/src/LYForms.c index 26f54f74..12e6f032 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -6,6 +6,7 @@ #include "LYCurses.h" #include "GridText.h" #include "LYCharSets.h" +#include "UCAux.h" #include "LYUtils.h" #include "LYStructs.h" /* includes HTForms.h */ #include "LYStrings.h" @@ -468,7 +469,7 @@ breakfor: * truthfully) the user confirms by changing the field that * the character encoding is right. - kw */ - if (*p) + if (form->value && *form->value) form->value_cs = current_char_set; } return(ch); @@ -747,13 +748,17 @@ redraw: #ifdef VMS VMSbox(form_window, (bottom - top), (width + 4)); #else + { + int boxvert, boxhori; + UCSetBoxChars(current_char_set, &boxvert, &boxhori, BOXVERT, BOXHORI); #ifdef CSS - wcurses_css(form_window, "frame", ABS_ON); - box(form_window, BOXVERT, BOXHORI); - wcurses_css(form_window, "frame", ABS_OFF); + wcurses_css(form_window, "frame", ABS_ON); + box(form_window, boxvert, boxhori); + wcurses_css(form_window, "frame", ABS_OFF); #else - box(form_window, BOXVERT, BOXHORI); + box(form_window, boxvert, boxhori); #endif + } #endif /* VMS */ wrefresh(form_window); #endif /* USE_SLANG */ diff --git a/src/LYGetFile.c b/src/LYGetFile.c index e8787cfd..08551035 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -197,8 +197,6 @@ Try_Redirected_URL: url_type == LYNXCOOKIE_URL_TYPE || 0==strncasecomp(WWWDoc.address, helpfilepath, strlen(helpfilepath)) || - 0==strncasecomp(WWWDoc.address, aboutfilepath, - strlen(aboutfilepath)) || (lynxlistfile != NULL && 0==strncasecomp(WWWDoc.address, lynxlistfile, strlen(lynxlistfile))) || @@ -242,8 +240,6 @@ Try_Redirected_URL: *WWWDoc.bookmark != '\0') || 0==strncasecomp(WWWDoc.address, helpfilepath, strlen(helpfilepath)) || - 0==strncasecomp(WWWDoc.address, aboutfilepath, - strlen(aboutfilepath)) || (lynxlistfile != NULL && 0==strncasecomp(WWWDoc.address, lynxlistfile, strlen(lynxlistfile))) || @@ -352,9 +348,11 @@ Try_Redirected_URL: WWWDoc.bookmark = doc->bookmark; WWWDoc.isHEAD = doc->isHEAD; WWWDoc.safe = doc->safe; +#ifndef DONT_TRACK_INTERNAL_LINKS if (doc->internal_link && !reloading) { LYoverride_no_cache = TRUE; } +#endif if (!HTLoadAbsolute(&WWWDoc)) { HTMLSetCharacterHandling(current_char_set); diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index fad330cc..bff8c881 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -132,7 +132,6 @@ extern char *LynxHome; extern char *startfile; extern char *helpfile; extern char *helpfilepath; -extern char *aboutfilepath; extern char *lynxjumpfile; extern char *lynxlistfile; extern char *lynxlinksfile; diff --git a/src/LYHistory.c b/src/LYHistory.c index aa473d5e..1a3a3990 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -377,7 +377,7 @@ PUBLIC void LYpop_num ARGS2( int, number, document *, doc) { - if (number >= 0 && nhist >= number) { + if (number >= 0 && nhist > number) { doc->link = history[number].link; doc->line = history[number].page; StrAllocCopy(doc->title, history[number].title); @@ -499,12 +499,18 @@ PUBLIC BOOLEAN historytarget ARGS1( return(FALSE); LYpop_num(number, newdoc); - if (newdoc->internal_link && - history[number].intern_seq_start == history[nhist-1].intern_seq_start + if (((newdoc->internal_link && + history[number].intern_seq_start == history[nhist-1].intern_seq_start) || + (number < nhist-1 && + history[nhist-1].internal_link && + number == history[nhist-1].intern_seq_start)) && !(LYforce_no_cache == TRUE && LYoverride_no_cache == FALSE)) { +#ifndef DONT_TRACK_INTERNAL_LINKS LYforce_no_cache = FALSE; LYoverride_no_cache = TRUE; + newdoc->internal_link = TRUE; treat_as_intern = TRUE; +#endif } else { newdoc->internal_link = FALSE; } @@ -592,9 +598,7 @@ PUBLIC int LYShowVisitedLinks ARGS1( LYforce_no_cache = TRUE; /* force this file to be new */ fprintf(fp0, "<head>\n"); -#ifdef EXP_CHARTRANS LYAddMETAcharsetToFD(fp0, -1); -#endif fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", VISITED_LINKS_TITLE); fprintf(fp0, "<h1>You have reached the Visited Links Page</h1>\n"); diff --git a/src/LYJump.c b/src/LYJump.c index 739c1e2f..89ba0728 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -494,5 +494,5 @@ PRIVATE unsigned LYRead_Jumpfile ARGS1(struct JumpTable *,jtp) PRIVATE int LYCompare ARGS2 (CONST void *, e1, CONST void *, e2) { - return strcasecomp(((JumpDatum *)e1)->key, ((JumpDatum *)e2)->key); + return strcasecomp(((CONST JumpDatum *)e1)->key, ((CONST JumpDatum *)e2)->key); } diff --git a/src/LYList.c b/src/LYList.c index c9a4faa7..804da051 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -96,9 +96,7 @@ PUBLIC int showlist ARGS2( fprintf(fp0, "<head>\n"); -#ifdef EXP_CHARTRANS LYAddMETAcharsetToFD(fp0, -1); -#endif fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", LIST_PAGE_TITLE); fprintf(fp0, "<h1>You have reached the List Page</h1>\n"); @@ -117,7 +115,7 @@ PUBLIC int showlist ARGS2( } for (cnt = 1; cnt <= refs; cnt++) { HTChildAnchor *child = HText_childNumber(cnt); - HTAnchor *dest_intl; + HTAnchor *dest_intl = NULL; HTAnchor *dest; HTParentAnchor *parent; char *address; @@ -139,8 +137,10 @@ PUBLIC int showlist ARGS2( } continue; } +#ifndef DONT_TRACK_INTERNAL_LINKS dest_intl = HTAnchor_followTypedLink((HTAnchor *)child, LINK_INTERNAL); +#endif dest = dest_intl ? dest_intl : HTAnchor_followMainLink((HTAnchor *)child); parent = HTAnchor_parent(dest); @@ -151,11 +151,12 @@ PUBLIC int showlist ARGS2( LYEntify(&Address, TRUE); if (title && *title) { StrAllocCopy(Title, title); - if (*Title) - LYEntify(&Title, TRUE); - else + LYEntify(&Title, TRUE); + if (*Title) { + cp = strchr(Address, '#'); + } else { FREE(Title); - cp = strchr(Address, '#'); + } } fprintf(fp0, "<li><a href=\"%s\"%s>%s%s%s%s%s</a>\n", Address, diff --git a/src/LYLocal.c b/src/LYLocal.c index 83ae0edb..ba553a68 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -53,10 +53,27 @@ #endif /*_WINDOWS */ #endif /* VMS */ +#ifndef WEXITSTATUS +# if HAVE_TYPE_UNIONWAIT +# define WEXITSTATUS(status) (status.w_retcode) +# else +# define WEXITSTATUS(status) (((status) & 0xff00) >> 8) +# endif +#endif + +#ifndef WTERMSIG +# if HAVE_TYPE_UNIONWAIT +# define WTERMSIG(status) (status.w_termsig) +# else +# define WTERMSIG(status) ((status) & 0x7f) +# endif +#endif + #include "LYLeaks.h" #define FREE(x) if (x) {free(x); x = NULL;} + PUBLIC int LYExecv PARAMS(( char * path, char ** argv, @@ -2204,7 +2221,7 @@ PUBLIC int LYExecv ARGS3( int rc; char tmpbuf[512]; pid_t pid; -#if HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID +#if HAVE_TYPE_UNIONWAIT union wait wstatus; #else int wstatus; @@ -2223,7 +2240,7 @@ PUBLIC int LYExecv ARGS3( execv(path, argv); exit(-1); /* execv failed, give wait() something to look at */ default: /* parent */ -#if HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID +#if !HAVE_WAITPID while (wait(&wstatus) != pid) ; /* do nothing */ #else @@ -2238,7 +2255,7 @@ PUBLIC int LYExecv ARGS3( #endif /* ERESTARTSYS */ break; } -#endif /* HAVE_TYPE_UNIONWAIT && !HAVE_WAITPID */ +#endif /* !HAVE_WAITPID */ if (WEXITSTATUS(wstatus) != 0 || WTERMSIG(wstatus) > 0) { /* error return */ sprintf(tmpbuf, "Probable failure to %s due to system error!", diff --git a/src/LYMain.c b/src/LYMain.c index bcb69040..b5749c9e 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -263,7 +263,6 @@ PUBLIC char *LynxHome = NULL; /* the default Home HREF. */ PUBLIC char *startfile = NULL; /* the first file */ PUBLIC char *helpfile = NULL; /* the main help file */ PUBLIC char *helpfilepath = NULL; /* the path to the help file set */ -PUBLIC char *aboutfilepath = NULL; /* the path to the about lynx file */ PUBLIC char *lynxjumpfile = NULL; /* the current jump file URL */ PUBLIC char *lynxlistfile = NULL; /* the current list file URL */ PUBLIC char *lynxlinksfile = NULL; /* the current visited links file URL */ @@ -390,7 +389,7 @@ PUBLIC BOOLEAN LYNoCore = NO_FORCED_CORE_DUMP; PRIVATE void FatalProblem PARAMS((int sig)); #endif /* !VMS */ -#if defined(USEHASH) +#if defined(USE_HASH) char *lynx_lss_file=NULL; #endif @@ -455,7 +454,6 @@ PRIVATE void free_lynx_globals NOARGS FREE(lynx_save_space); FREE(homepage); FREE(helpfilepath); - FREE(aboutfilepath); FREE(bookmark_page); FREE(BookmarkPage); for (i = 0; i <= MBM_V_MAXFILES; i++) { @@ -474,9 +472,12 @@ PRIVATE void free_lynx_globals NOARGS FREE(URLDomainSuffixes); FREE(XLoadImageCommand); FREE(LYTraceLogPath); -#if defined(USEHASH) +#if defined(USE_HASH) FREE(lynx_lss_file); #endif + FREE(UCAssume_MIMEcharset); + FREE(UCAssume_unrecMIMEcharset); + FREE(UCAssume_localMIMEcharset); for (i = 0; i < nlinks; i++) { FREE(links[i].lname); } @@ -657,6 +658,9 @@ PUBLIC int main ARGS2( StrAllocCat(lynx_version_putenv_command, LYNX_VERSION); putenv(lynx_version_putenv_command); #endif /* VMS */ + if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL) + StrAllocCopy(lynx_temp_space, cp); + else #ifdef DOSPATH if ((cp = getenv("TEMP")) != NULL) StrAllocCopy(lynx_temp_space, cp); @@ -664,9 +668,6 @@ PUBLIC int main ARGS2( StrAllocCopy(lynx_temp_space, cp); else #endif - if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL) - StrAllocCopy(lynx_temp_space, cp); - else StrAllocCopy(lynx_temp_space, TEMP_SPACE); if ((cp = strchr(lynx_temp_space, '~'))) { *(cp++) = '\0'; @@ -719,12 +720,17 @@ PUBLIC int main ARGS2( StrAllocCat(lynx_temp_space, ":"); } #else - { - if (((len = strlen(lynx_temp_space)) > 1) && - lynx_temp_space[len-1] != '/') { - StrAllocCat(lynx_temp_space, "/"); - } +#ifndef __DJGPP__ + if (((len = strlen(lynx_temp_space)) > 1) && + lynx_temp_space[len-1] != '/') { + StrAllocCat(lynx_temp_space, "/"); + } +#else + if (((len = strlen(lynx_temp_space)) > 1) && + lynx_temp_space[len-1] != '\\') { + StrAllocCat(lynx_temp_space, "\\"); } +#endif /* __DJGPP__ */ #endif /* VMS */ #ifdef VMS StrAllocCopy(mail_adrs, MAIL_ADRS); @@ -800,7 +806,7 @@ PUBLIC int main ARGS2( i++; } -#if defined(USEHASH) +#if defined(USE_HASH) } else if (strncmp(argv[i], "-lss", 4) == 0) { if ((cp=strchr(argv[i],'=')) != NULL) StrAllocCopy(lynx_lss_file, cp+1); @@ -878,7 +884,7 @@ PUBLIC int main ARGS2( if (*cp) StrAllocCopy(lynx_cfg_file, cp); } - #if defined(USEHASH) +#if defined(USE_HASH) } else if (strncmp(buf, "-lss", 4) == 0) { if ((cp = strchr(buf,'=')) != NULL) { StrAllocCopy(lynx_lss_file, cp+1); @@ -1143,7 +1149,7 @@ PUBLIC int main ARGS2( } #endif /* EXP_CHARTRANS */ -#if defined(USEHASH) +#if defined(USE_HASH) /* * If no alternate lynx-style file was specified on * the command line, see if it's in the environment. @@ -1623,11 +1629,10 @@ PUBLIC int main ARGS2( StrAllocCopy(helpfilepath, helpfile); if ((cp=strrchr(helpfilepath, '/')) != NULL) *cp = '\0'; - StrAllocCopy(aboutfilepath, helpfilepath); - if ((cp=strrchr(aboutfilepath, '/')) != NULL) { - *cp = '\0'; - StrAllocCat(aboutfilepath, "/about_lynx/"); - } + /* + * Remove code to merge the historical about_lynx + * directory into lynx_help. - HN + */ StrAllocCat(helpfilepath, "/"); @@ -2181,7 +2186,7 @@ PRIVATE void parse_arg ARGS3( local_exec_on_local_files = TRUE; #endif /* EXEC_LINKS || EXEC_SCRIPTS */ -#if defined(USEHASH) +#if defined(USE_HASH) } else if (strncmp(argv[0], "-lss", 4) == 0) { /* * Already read the alternate lynx-style file @@ -2714,7 +2719,7 @@ Output_Help_List: printf(" MAPs are present\n"); printf(" -link=NUMBER starting count for lnk#.dat files produced by -crawl\n"); printf(" -localhost disable URLs that point to remote hosts\n"); -#if defined(USEHASH) +#if defined(USE_HASH) printf(" -lss=FILENAME specifies a lynx.css file other than the default\n"); #endif printf(" -mime_header include mime headers and force source dump\n"); diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index f541e0ba..12e43f5b 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -102,7 +102,7 @@ PRIVATE void free_mainloop_variables NOARGS FREE(curdoc.post_data); FREE(curdoc.post_content_type); FREE(curdoc.bookmark); -#ifdef USEHASH +#ifdef USE_HASH FREE(curdoc.style); FREE(newdoc.style); #endif @@ -199,7 +199,7 @@ int mainloop NOARGS curdoc.post_data = NULL; curdoc.post_content_type = NULL; curdoc.bookmark = NULL; -#ifdef USEHASH +#ifdef USE_HASH curdoc.style = NULL; newdoc.style = NULL; #endif @@ -288,7 +288,7 @@ initialize: display_lines = LYlines-2; while (TRUE) { -#ifdef USEHASH +#ifdef USE_HASH if (curdoc.style != NULL) force_load = TRUE; #endif /* @@ -333,6 +333,19 @@ try_again: */ LYpop(&newdoc); popped_doc = TRUE; + + +#ifndef DONT_TRACK_INTERNAL_LINKS +#define NONINTERNAL_OR_DIFFERENT(c,n) TRUE +#define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) (!curdoc.internal_link || \ + are_phys_different(p,n)) +#else /* TRACK_INTERNAL_LINKS */ +#define NONINTERNAL_OR_DIFFERENT(c,n) are_different(c,n) +#define NONINTERNAL_OR_PHYS_DIFFERENT(p,n) are_different(p,n) +#endif /* TRACK_INTERNAL_LINKS */ + + +#ifndef DONT_TRACK_INTERNAL_LINKS /* ** If curdoc had been reached via an internal ** (fragment) link from what we now have just @@ -344,9 +357,12 @@ try_again: LYoverride_no_cache = TRUE; LYforce_no_cache = FALSE; try_internal = TRUE; - } else if ((newdoc.bookmark != NULL) || + } else +#endif /* TRACK_INTERNAL_LINKS */ + if ((newdoc.bookmark != NULL) || (newdoc.post_data != NULL && !newdoc.safe && - LYresubmit_posts)) { + LYresubmit_posts && + NONINTERNAL_OR_DIFFERENT(&curdoc, &newdoc))) { LYoverride_no_cache = FALSE; } else { LYoverride_no_cache = TRUE; @@ -357,9 +373,19 @@ try_again: /* * Make SURE this is an appropriate request. - FM */ - if (newdoc.address && - !strncmp(newdoc.address, "http", 4)) - newdoc.isHEAD = TRUE; + if (newdoc.address) { + if (!strncmp(newdoc.address, "http", 4)) { + newdoc.isHEAD = TRUE; + } else if (!strncmp(newdoc.address, "LYNXIMGMAP:", 11)) { + if (!strncmp(newdoc.address + 11, "http", 4)) { + StrAllocCopy(temp, newdoc.address + 11); + FREE(newdoc.address); + newdoc.address = temp; + newdoc.isHEAD = TRUE; + temp = NULL; + } + } + } try_internal = FALSE; HEAD_request = FALSE; } @@ -419,6 +445,7 @@ try_again: LYPermitURL = TRUE; } +#ifndef DONT_TRACK_INTERNAL_LINKS if (try_internal) { if (newdoc.address && 0==strncmp(newdoc.address, "LYNXIMGMAP:", 11)) { @@ -465,6 +492,9 @@ try_again: } getresult = getfile(&newdoc); } +#else /* TRACK_INTERNAL_LINKS */ + getresult = getfile(&newdoc); +#endif /* TRACK_INTERNAL_LINKS */ switch(getresult) { @@ -766,7 +796,7 @@ try_again: (BookmarkPage + 2))); StrAllocCopy(newdoc.title, BOOKMARK_TITLE); StrAllocCopy(newdoc.bookmark, BookmarkPage); -#ifdef USEHASH +#ifdef USE_HASH if (curdoc.style) StrAllocCopy(newdoc.style, curdoc.style); #endif @@ -865,7 +895,7 @@ try_again: StrAllocCopy(curdoc.post_data, newdoc.post_data); StrAllocCopy(curdoc.post_content_type, newdoc.post_content_type); StrAllocCopy(curdoc.bookmark, newdoc.bookmark); -#ifdef USEHASH +#ifdef USE_HASH StrAllocCopy(curdoc.style, HText_getStyle()); if (curdoc.style != NULL) style_readFromFile (curdoc.style); @@ -925,7 +955,7 @@ try_again: } /* - * If the resent_sizechange variable is set to TRUE + * If the recent_sizechange variable is set to TRUE * then the window size changed recently. */ if (recent_sizechange) { @@ -983,7 +1013,7 @@ try_again: /* * We forced HTML for a local startfile which * is not a bookmark file and has a path of at - * least two letters. It it doesn't have a + * least two letters. If it doesn't have a * suffix mapped to text/html, we'll set the * entire path (including the lead slash) as a * "suffix" mapped to text/html to ensure it is @@ -1277,19 +1307,26 @@ try_again: } else if (user_mode == ADVANCED_MODE && nlinks > 0) { /* - * Show the URL. + * Show the URL or, for some internal links, the fragment */ + cp = NULL; + if (links[curdoc.link].type == WWW_INTERN_LINK_TYPE && + strncmp(links[curdoc.link].lname, "LYNXIMGMAP:", 11)) { + cp = strchr(links[curdoc.link].lname, '#'); + } + if (!cp) + cp = links[curdoc.link].lname; if (more) if (is_www_index) _user_message("-more- -index- %s", - links[curdoc.link].lname); + cp); else - _user_message("-more- %s",links[curdoc.link].lname); + _user_message("-more- %s",cp); else if (is_www_index) - _user_message("-index- %s",links[curdoc.link].lname); + _user_message("-index- %s",cp); else - statusline(links[curdoc.link].lname); + statusline(cp); } else if (is_www_index && more) { char buf[128]; @@ -1910,7 +1947,7 @@ new_cmd: /* else New_DTD = YES; HTSwitchDTD(New_DTD); - _statusline(New_DTD ? USING_DTD_0 : USING_DTD_1); + _statusline(New_DTD ? USING_DTD_1 : USING_DTD_0); sleep(MessageSecs); break; @@ -2379,11 +2416,9 @@ new_cmd: /* } if (((HText *)HTAnchor_document(tmpanchor) == NULL || (LYresubmit_posts && - !(curdoc.internal_link && - !are_phys_different((document *)&history[(nhist - 1)], - &curdoc)) - ) - ) && + NONINTERNAL_OR_PHYS_DIFFERENT( + (document *)&history[(nhist - 1)], + &curdoc))) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { if (nhist == 1) { _statusline(CANCELLED); @@ -2671,6 +2706,7 @@ new_cmd: /* */ StrAllocCopy(newdoc.address, links[curdoc.link].lname); StrAllocCopy(newdoc.title, links[curdoc.link].hightext); +#ifndef DONT_TRACK_INTERNAL_LINKS /* * Might be an internal link anchor in the same doc. * If so, take the try_internal shortcut if we didn't @@ -2678,19 +2714,22 @@ new_cmd: /* */ newdoc.internal_link = (links[curdoc.link].type == WWW_INTERN_LINK_TYPE); - if (newdoc.internal_link && cmd != LYK_NOCACHE) { + if (newdoc.internal_link) { if (0==strcmp(curdoc.address, LYlist_temp_url()) && 0==strcmp((curdoc.title ? curdoc.title : ""), LIST_PAGE_TITLE)) { FREE(curdoc.address); - } else + } else if (cmd != LYK_NOCACHE) { try_internal = TRUE; + } LYoverride_no_cache = TRUE; /* ??? */ /* We still set force_load so that history pushing ** etc. will be done. - kw */ force_load = TRUE; break; + } else { } +#endif /* TRACK_INTERNAL_LINKS */ /* * Might be an anchor in the same doc from a POST * form. If so, dont't free the content. -- FM @@ -3100,13 +3139,13 @@ check_goto_URL: newdoc.safe = FALSE; newdoc.internal_link = FALSE; force_load = TRUE; - LYUserSpecifiedURL = TRUE; #ifdef DIRED_SUPPORT if (lynx_edit_mode) HTuncache_current_document(); #endif /* DIRED_SUPPORT */ - HTAddGotoURL(newdoc.address); } + LYUserSpecifiedURL = TRUE; + HTAddGotoURL(newdoc.address); } break; @@ -4703,7 +4742,9 @@ check_add_bookmark_to_self: _statusline(HEAD_D_L_OR_CANCEL); c = LYgetch(); if (TOUPPER(c) == 'D') { - if (strncmp(curdoc.address, "http", 4)) { + char *scheme = strncmp(curdoc.address, "LYNXIMGMAP:", 11) ? + curdoc.address : curdoc.address + 11; + if (strncmp(scheme, "http", 4)) { _statusline(DOC_NOT_HTTP_URL); sleep(MessageSecs); } else { @@ -4733,6 +4774,8 @@ check_add_bookmark_to_self: } else if (TOUPPER(c) == 'L') { if (links[curdoc.link].type != WWW_FORM_LINK_TYPE && strncmp(links[curdoc.link].lname, "http", 4) && + strncmp(links[curdoc.link].lname, + "LYNXIMGMAP:http", 15) && (links[curdoc.link].type != WWW_INTERN_LINK_TYPE || !curdoc.address || strncmp(curdoc.address, "http", 4))) { @@ -4794,12 +4837,14 @@ check_add_bookmark_to_self: c = 'D'; } if (TOUPPER(c) == 'D') { + char *scheme = strncmp(curdoc.address, "LYNXIMGMAP:", 11) ? + curdoc.address : curdoc.address + 11; /* * The user didn't cancel, so check if * a HEAD request is appropriate for the * current document. - FM */ - if (strncmp(curdoc.address, "http", 4)) { + if (strncmp(scheme, "http", 4)) { _statusline(DOC_NOT_HTTP_URL); sleep(MessageSecs); } else { diff --git a/src/LYOptions.c b/src/LYOptions.c index cbc4912b..61f9e187 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -12,6 +12,7 @@ #include "LYCharSets.h" #include "LYCharUtils.h" #include "UCMap.h" +#include "UCAux.h" #include "LYKeymap.h" #include "LYrcFile.h" #include "HTAlert.h" @@ -2321,7 +2322,11 @@ redraw: #ifdef VMS VMSbox(form_window, (bottom - top), (Lnum + width + 4)); #else - box(form_window, BOXVERT, BOXHORI); + { + int boxvert, boxhori; + UCSetBoxChars(current_char_set, &boxvert, &boxhori, BOXVERT, BOXHORI); + box(form_window, boxvert, boxhori); + } #endif /* VMS */ wrefresh(form_window); #endif /* USE_SLANG */ diff --git a/src/LYStrings.c b/src/LYStrings.c index 6d9a68c7..f11b2e7f 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -842,7 +842,7 @@ PUBLIC int LYEdit1 ARGS4( /* * Delete current character. */ - if (length == 0) + if (length == 0 || Pos == length) break; for (i = Pos; i < length; i++) Buf[i] = Buf[i+1]; diff --git a/src/LYStructs.h b/src/LYStructs.h index fc438376..128d7426 100644 --- a/src/LYStructs.h +++ b/src/LYStructs.h @@ -39,7 +39,7 @@ typedef struct _document { int line; BOOL internal_link; /* whether doc was reached via an internal (fragment) link. - kw */ -#ifdef USEHASH +#ifdef USE_HASH char * style; #endif } document; diff --git a/src/LYStyle.c b/src/LYStyle.c index 3f529264..160eff5f 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,6 +1,6 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * @Id: LYStyle.c 1.7 Wed, 17 Sep 1997 17:34:13 -0600 dickey @ + * @Id: LYStyle.c 1.13 Wed, 22 Oct 1997 08:29:34 -0600 dickey @ */ #include "HTUtils.h" #include "HTML.h" @@ -247,7 +247,7 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); */ else { -#if !defined(USEHASH) +#if !defined(USE_HASH) int i; for (i=0; i<HTML_ELEMENTS; i++) { diff --git a/src/LYUtils.c b/src/LYUtils.c index 117d44b3..a39042f3 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -2966,13 +2966,27 @@ PUBLIC void change_sug_filename ARGS1( */ HTUnEscape(fname); - /*** rename any temporary files ***/ - temp = (char *)calloc(1, (strlen(lynx_temp_space) + 60)); - if (*lynx_temp_space == '/') - sprintf(temp, "file://localhost%sL%d", lynx_temp_space, (int)getpid()); - else - sprintf(temp, "file://localhost/%sL%d", lynx_temp_space, (int)getpid()); - len = strlen(temp); + /*** rename any temporary files ***/ + temp = (char *)calloc(1, (strlen(lynx_temp_space) + 60)); +#ifdef FNAMES_8_3 +#ifdef DOSPATH + cp = HTDOS_wwwName(lynx_temp_space); +#else + cp = lynx_temp_space; +#endif + if (*cp == '/') { + sprintf(temp, "file://localhost%s%d", cp, (int)getpid()); + } else { + sprintf(temp, "file://localhost/%s%d", cp, (int)getpid()); + } +#else /* FNAMES_8_3 */ + if (*lynx_temp_space == '/') { + sprintf(temp, "file://localhost%sL%d", lynx_temp_space, (int)getpid()); + } else { + sprintf(temp, "file://localhost/%sL%d", lynx_temp_space, (int)getpid()); + } +#endif /* FNAMES_8_3 */ + len = strlen(temp); if (!strncmp(fname, temp, len)) { cp = strrchr(fname, '.'); if (strlen(cp) > (len - 4)) @@ -3223,21 +3237,36 @@ PUBLIC void tempname ARGS2( { static int counter = 0; FILE *fp = NULL; +#ifdef FNAMES_8_3 + int LYMaxTempCount = 1000; /* Arbitrary limit. Make it configurable? */ +#else int LYMaxTempCount = 10000; /* Arbitrary limit. Make it configurable? */ +#endif /* FNAMES_8_3 */ if (action == REMOVE_FILES) { /* * Remove all temporary files with .txt or .html suffixes. - FM */ for (; counter > 0; counter--) { +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u.txt", + lynx_temp_space, (int)getpid(), counter-1); + remove(namebuffer); + sprintf(namebuffer, + "%s%d%u%s", + lynx_temp_space, (int)getpid(), counter-1, HTML_SUFFIX); + remove(namebuffer); +#else sprintf(namebuffer, - "%sL%d%uTMP.txt", + "%sL%d-%uTMP.txt", lynx_temp_space, (int)getpid(), counter-1); remove(namebuffer); sprintf(namebuffer, - "%sL%d%uTMP%s", + "%sL%d-%uTMP%s", lynx_temp_space, (int)getpid(), counter-1, HTML_SUFFIX); remove(namebuffer); +#endif /* FNAMES_8_3 */ } } else { /* @@ -3257,9 +3286,15 @@ PUBLIC void tempname ARGS2( * should be done consistently by always using HTML_SUFFIX * where filenames are generated for new local files. - kw */ +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u.txt", + lynx_temp_space, (int)getpid(), counter); +#else sprintf(namebuffer, - "%sL%d%uTMP.txt", + "%sL%d-%uTMP.txt", lynx_temp_space, (int)getpid(), counter); +#endif /* FNAMES_8_3 */ if ((fp = fopen(namebuffer, "r")) != NULL) { fclose(fp); if (TRACE) @@ -3269,9 +3304,15 @@ PUBLIC void tempname ARGS2( counter++; continue; } +#ifdef FNAMES_8_3 sprintf(namebuffer, - "%sL%d%uTMP.bin", + "%s%d%u.bin", lynx_temp_space, (int)getpid(), counter); +#else + sprintf(namebuffer, + "%sL%d-%uTMP.bin", + lynx_temp_space, (int)getpid(), counter); +#endif /* FNAMES_8_3 */ if ((fp = fopen(namebuffer, "r")) != NULL) { fclose(fp); if (TRACE) @@ -3281,9 +3322,15 @@ PUBLIC void tempname ARGS2( counter++; continue; } +#ifdef FNAMES_8_3 + sprintf(namebuffer, + "%s%d%u%s", + lynx_temp_space, (int)getpid(), counter++, HTML_SUFFIX); +#else sprintf(namebuffer, - "%sL%d%uTMP%s", + "%sL%d-%uTMP%s", lynx_temp_space, (int)getpid(), counter++, HTML_SUFFIX); +#endif /* FNAMES_8_3 */ if ((fp = fopen(namebuffer, "r")) != NULL) { fclose(fp); if (TRACE) diff --git a/src/Makefile b/src/Makefile.old index 3b325018..3b325018 100644 --- a/src/Makefile +++ b/src/Makefile.old diff --git a/src/UCAux.c b/src/UCAux.c index d63e04e0..f03bbfa9 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -55,6 +55,8 @@ PUBLIC UCTQ_t UCCanTranslateFromTo ARGS2( if (!strcmp(fromname, "x-transparent") || !strcmp(toname, "x-transparent")) { return TQ_GOOD; + } else if (!strcmp(fromname, "us-ascii")) { + return TQ_GOOD; } if (LYCharSet_UC[from].enc == UCT_ENC_CJK) { if (HTCJK == NOCJK) /* use that global flag, for now */ @@ -232,7 +234,29 @@ PUBLIC void UCTransParams_clear ARGS1( pT->repl_translated_C0 = FALSE; pT->trans_from_uni = FALSE; } - +/* + * If terminal is in UTF-8 mode, it probably cannot understand + * box drawing chars as (n)curses handles them. (This may also + * be true for other display character sets, but isn't currently + * checked.) In that case set the chars for hori and vert drawing + * chars to displayable ASCII chars if '0' was requested. They'll + * stay as they are otherwise. - kw + */ +PUBLIC void UCSetBoxChars ARGS5( + int, cset, + int *, pvert_out, + int *, phori_out, + int, vert_in, + int, hori_in) +{ + if (cset >= -1 && LYCharSet_UC[cset].enc == UCT_ENC_UTF8) { + *pvert_out = (vert_in ? vert_in : '|'); + *phori_out = (hori_in ? hori_in : '-'); + } else { + *pvert_out = vert_in; + *phori_out = hori_in; + } +} /* * Given an output target HTStream* (can also be a HTStructured* via * typecast), the target stream's put_character method, and a unicode diff --git a/src/UCdomap.c b/src/UCdomap.c index 61bdfd70..344f3057 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -4,7 +4,7 @@ * * Derived from code in the Linux kernel console driver. * The GNU Public Licence therefore applies, see - * the file COPYING in the about_lynx directory + * the file COPYING in the top-level directory * which should come with every Lynx distribution. * * [ original comment: - KW ] @@ -282,12 +282,16 @@ PRIVATE void UC_con_set_trans PARAMS(( int update_flag)); PRIVATE int con_insert_unipair PARAMS(( u16 unicode, - u16 fontpos)); + u16 fontpos, + int fordefault)); PRIVATE int con_insert_unipair_str PARAMS(( u16 unicode, - char * replace_str)); -PRIVATE void con_clear_unimap NOPARAMS; -PRIVATE void con_clear_unimap_str NOPARAMS; + char * replace_str, + int fordefault)); +PRIVATE void con_clear_unimap PARAMS(( + int fordefault)); +PRIVATE void con_clear_unimap_str PARAMS(( + int fordefault)); #ifdef NOTDEFINED PRIVATE int con_set_unimap PARAMS(( u16 ct, @@ -299,7 +303,8 @@ PRIVATE int UC_con_set_unimap PARAMS(( int update_flag)); PRIVATE int UC_con_set_unimap_str PARAMS(( u16 ct, - struct unipair_str * list)); + struct unipair_str * list, + int fordefault)); #ifdef NOTDEFINED PRIVATE int con_get_unimap PARAMS(( u16 ct, @@ -307,11 +312,13 @@ PRIVATE int con_get_unimap PARAMS(( struct unipair * list)); #endif /* NOTDEFINED */ PRIVATE int conv_uni_to_pc PARAMS(( - long ucs)); + long ucs, + int usedefault)); PRIVATE int conv_uni_to_str PARAMS(( char* outbuf, int buflen, - long ucs)); + long ucs, + int usedefault)); PRIVATE void UCconsole_map_init NOPARAMS; PRIVATE int UC_MapGN PARAMS(( int UChndl, @@ -330,6 +337,7 @@ PRIVATE int UC_Register_with_LYCharSets PARAMS(( int lowest_eightbit)); PRIVATE void UCcleanup_mem NOPARAMS; +PRIVATE int default_UChndl = -1; PRIVATE void set_inverse_transl ARGS1( int, i) @@ -350,7 +358,7 @@ PRIVATE void set_inverse_transl ARGS1( q[j] = 0; for (j=0; j<E_TABSZ; j++) { - glyph = conv_uni_to_pc(p[j]); + glyph = conv_uni_to_pc(p[j], 0); if (glyph >= 0 && glyph < MAX_GLYPH && q[glyph] < 32) { /* prefer '-' above SHY etc. */ q[glyph] = j; @@ -480,13 +488,13 @@ PRIVATE void UC_con_set_trans ARGS3( u16 *ptrans; if (!UC_valid_UC_charset(UC_charset_in_hndl)) { - if (TRACE) - fprintf(stderr,"UC_con_set_trans: Invalid charset handle %i.\n", - UC_charset_in_hndl); - return; + if (TRACE) + fprintf(stderr,"UC_con_set_trans: Invalid charset handle %i.\n", + UC_charset_in_hndl); + return; } - ptrans = translations[Gn]; - p = UCInfo[UC_charset_in_hndl].unitable; + ptrans = translations[Gn]; + p = UCInfo[UC_charset_in_hndl].unitable; #if(0) if (p == UC_current_unitable) { /* test whether pointers are equal */ return; /* nothing to be done */ @@ -497,18 +505,18 @@ PRIVATE void UC_con_set_trans ARGS3( con_clear_unimap(); #endif for (i = 0; i < 256; i++) { - if ((j = UCInfo[UC_charset_in_hndl].unicount[i])) { - ptrans[i] = *p; + if ((j = UCInfo[UC_charset_in_hndl].unicount[i])) { + ptrans[i] = *p; for (; j; j--) { - p++; - } + p++; + } } else { - ptrans[i] = 0xfffd; - } + ptrans[i] = 0xfffd; + } } if (update_flag) { - set_inverse_transl(Gn); /* Update inverse translation for this one */ -} + set_inverse_transl(Gn); /* Update inverse translation for this one */ + } } /* @@ -521,8 +529,8 @@ PRIVATE void UC_con_set_trans ARGS3( * this 3-level paged table scheme to be comparable to a hash table. */ -int hashtable_contents_valid = 0; /* Use ASCII-only mode for bootup*/ -int hashtable_str_contents_valid = 0; +PRIVATE int unitable_contents_valid = 0; /* Use ASCII-only mode for bootup*/ +PRIVATE int unitable_str_contents_valid = 0; static u16 **uni_pagedir[32] = { @@ -542,16 +550,50 @@ static char* **uni_pagedir_str[32] = PRIVATE u16 * UC_current_unitable = NULL; PRIVATE struct unimapdesc_str *UC_current_unitable_str = NULL; -PRIVATE int con_insert_unipair ARGS2( +/* + * Keep a second set of structures for the translation designated + * as "default" - kw + */ +PRIVATE int unidefault_contents_valid = 0; /* Use ASCII-only mode for bootup*/ +PRIVATE int unidefault_str_contents_valid = 0; + +static u16 **unidefault_pagedir[32] = +{ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; +static char* **unidefault_pagedir_str[32] = +{ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; + +PRIVATE u16 * UC_default_unitable = NULL; +PRIVATE struct unimapdesc_str *UC_default_unitable_str = NULL; + +PRIVATE int con_insert_unipair ARGS3( u16, unicode, - u16, fontpos) + u16, fontpos, + int, fordefault) { int i, n; u16 **p1, *p2; - if ( !(p1 = uni_pagedir[n = unicode >> 11]) ) + if(fordefault) + p1 = unidefault_pagedir[n = unicode >> 11]; + else + p1 = uni_pagedir[n = unicode >> 11]; + if (!p1) { - p1 = uni_pagedir[n] = (u16* *) malloc(32*sizeof(u16 *)); + p1 = (u16* *) malloc(32*sizeof(u16 *)); + if (fordefault) + unidefault_pagedir[n] = p1; + else + uni_pagedir[n] = p1; if ( !p1 ) return -ENOMEM; @@ -574,16 +616,25 @@ PRIVATE int con_insert_unipair ARGS2( return 0; } -PRIVATE int con_insert_unipair_str ARGS2( +PRIVATE int con_insert_unipair_str ARGS3( u16, unicode, - char *, replace_str) + char *, replace_str, + int, fordefault) { int i, n; char ***p1, **p2; - if ( !(p1 = uni_pagedir_str[n = unicode >> 11]) ) + if(fordefault) + p1 = unidefault_pagedir_str[n = unicode >> 11]; + else + p1 = uni_pagedir_str[n = unicode >> 11]; + if (!p1) { - p1 = uni_pagedir_str[n] = (char** *) malloc(32*sizeof(char **)); + p1 = (char** *) malloc(32*sizeof(char **)); + if (fordefault) + unidefault_pagedir_str[n] = p1; + else + uni_pagedir_str[n] = p1; if ( !p1 ) return -ENOMEM; @@ -608,11 +659,24 @@ PRIVATE int con_insert_unipair_str ARGS2( /* ui arg was a leftover, deleted -kw */ PRIVATE void -con_clear_unimap NOARGS +con_clear_unimap ARGS1(int, fordefault) { int i, j; u16 **p1; - + + if (fordefault) { + for (i = 0; i < 32; i++) { + if ((p1 = unidefault_pagedir[i]) != NULL) { + for (j = 0; j < 32; j++) { + FREE(p1[j]); + } + FREE(p1); + } + unidefault_pagedir[i] = NULL; + } + + unidefault_contents_valid = 1; + } else { for (i = 0; i < 32; i++) { if ((p1 = uni_pagedir[i]) != NULL) { for (j = 0; j < 32; j++) { @@ -623,15 +687,29 @@ con_clear_unimap NOARGS uni_pagedir[i] = NULL; } - hashtable_contents_valid = 1; + unitable_contents_valid = 1; + } } PRIVATE void -con_clear_unimap_str NOARGS +con_clear_unimap_str ARGS1(int, fordefault) { int i, j; char ***p1; - + + if (fordefault) { + for (i = 0; i < 32; i++) { + if ((p1 = unidefault_pagedir_str[i]) != NULL) { + for (j = 0; j < 32; j++) { + FREE(p1[j]); + } + FREE(p1); + } + unidefault_pagedir_str[i] = NULL; + } + + unidefault_str_contents_valid = 1; /* ??? probably no use... */ + } else { for (i = 0; i < 32; i++) { if ((p1 = uni_pagedir_str[i]) != NULL) { for (j = 0; j < 32; j++) { @@ -642,7 +720,8 @@ con_clear_unimap_str NOARGS uni_pagedir_str[i] = NULL; } - hashtable_str_contents_valid = 1; /* ??? probably no use... */ + unitable_str_contents_valid = 1; /* ??? probably no use... */ + } } #ifdef NOTDEFINED @@ -679,17 +758,23 @@ con_set_default_unimap NOARGS /* The default font is always 256 characters */ - con_clear_unimap(); + con_clear_unimap(1); p = dfont_unitable; for ( i = 0 ; i < 256 ; i++ ) for ( j = dfont_unicount[i] ; j ; j-- ) - con_insert_unipair(*(p++), i); + con_insert_unipair(*(p++), i, 1); +#if 0 for ( i = 0 ; i <= 3 ; i++ ) set_inverse_transl(i); /* Update all inverse translations */ +#endif + + UC_default_unitable = dfont_unitable; - UC_current_unitable = dfont_unitable; + con_clear_unimap_str(1); + UC_con_set_unimap_str(dfont_replacedesc.entry_ct, repl_map, 1); + UC_default_unitable_str = &dfont_replacedesc; } PUBLIC int UCNumCharsets = 0; @@ -721,11 +806,11 @@ PRIVATE int UC_con_set_unimap ARGS2( /* The font is always 256 characters - so far. */ - con_clear_unimap(); + con_clear_unimap(0); for (i = 0; i < 256; i++) { for (j = UCInfo[UC_charset_out_hndl].unicount[i]; j; j--) { - con_insert_unipair(*(p++), i); + con_insert_unipair(*(p++), i, 0); } } @@ -735,15 +820,18 @@ PRIVATE int UC_con_set_unimap ARGS2( return 0; } -PRIVATE int -UC_con_set_unimap_str ARGS2(u16, ct, struct unipair_str *, list) +PRIVATE int UC_con_set_unimap_str ARGS3( + u16, ct, + struct unipair_str *, list, + int, fordefault) { int err = 0, err1; while( ct-- ) { if ( (err1 = con_insert_unipair_str(list->unicode, - list->replace_str)) != 0 ) + list->replace_str, + fordefault)) != 0 ) err = err1; list++; } @@ -752,7 +840,10 @@ UC_con_set_unimap_str ARGS2(u16, ct, struct unipair_str *, list) * No inverse translations for replacement strings! */ if (!err) { - hashtable_str_contents_valid = 1; + if (fordefault) + unidefault_str_contents_valid = 1; + else + unitable_str_contents_valid = 1; } return err; @@ -788,8 +879,9 @@ con_get_unimap ARGS3(u16, ct, u16 *, uct, struct unipair *, list) } #endif -PRIVATE int conv_uni_to_pc ARGS1( - long, ucs) +PRIVATE int conv_uni_to_pc ARGS2( + long, ucs, + int, usedefault) { int h; u16 **p1, *p2; @@ -809,10 +901,17 @@ PRIVATE int conv_uni_to_pc ARGS1( else if ( (ucs & ~UNI_DIRECT_MASK) == UNI_DIRECT_BASE ) return ucs & UNI_DIRECT_MASK; - if (!hashtable_contents_valid) - return -3; - - if ( (p1 = uni_pagedir[ucs >> 11]) && + if (usedefault) { + if (!unidefault_contents_valid) + return -3; + p1 = unidefault_pagedir[ucs >> 11]; + } else { + if (!unitable_contents_valid) + return -3; + p1 = uni_pagedir[ucs >> 11]; + } + + if (p1 && (p2 = p1[(ucs >> 6) & 0x1f]) && (h = p2[ucs & 0x3f]) < MAX_GLYPH ) return h; @@ -823,10 +922,11 @@ PRIVATE int conv_uni_to_pc ARGS1( /* * Note: contents of outbuf is not changes for negative return value! */ -PRIVATE int conv_uni_to_str ARGS3( +PRIVATE int conv_uni_to_str ARGS4( char*, outbuf, int, buflen, - long, ucs) + long, ucs, + int, usedefault) { char *h; char ***p1, **p2; @@ -849,10 +949,18 @@ PRIVATE int conv_uni_to_str ARGS3( else if ( (ucs & ~UNI_DIRECT_MASK) == UNI_DIRECT_BASE ) return ucs & UNI_DIRECT_MASK; #endif - if (!hashtable_str_contents_valid) - return -3; - - if ( (p1 = uni_pagedir_str[ucs >> 11]) && + + if (usedefault) { + if (!unidefault_str_contents_valid) + return -3; + p1 = unidefault_pagedir_str[ucs >> 11]; + } else { + if (!unitable_str_contents_valid) + return -3; + p1 = uni_pagedir_str[ucs >> 11]; + } + + if (p1 && (p2 = p1[(ucs >> 6) & 0x1f]) && (h = p2[ucs & 0x3f]) ) { strncpy (outbuf,h,(size_t) (buflen-1)); @@ -875,8 +983,8 @@ PUBLIC int UCInitialized = 0; PRIVATE void UCconsole_map_init NOARGS { - con_set_default_unimap(); - UCInitialized = 1; + con_set_default_unimap(); + UCInitialized = 1; } /* @@ -891,24 +999,44 @@ PUBLIC int UCTransUniChar ARGS2( long, unicode, int, charset_out) { - int rc; - int UChndl_out; - u16 * ut; + int rc; + int UChndl_out; + int isdefault, trydefault; + u16 * ut; - if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) - return -12; + if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if ((UChndl_out = default_UChndl) < 0) + return -12; + isdefault = 1; + } else { + isdefault = UCInfo[UChndl_out].replacedesc.isdefault; + trydefault = UCInfo[UChndl_out].replacedesc.trydefault; + } - ut = UCInfo[UChndl_out].unitable; - if (ut != UC_current_unitable) { - rc = UC_con_set_unimap(UChndl_out, 1); - if (rc < 0) { - return rc; - } + if (!isdefault) { + ut = UCInfo[UChndl_out].unitable; + if (ut != UC_current_unitable) { + rc = UC_con_set_unimap(UChndl_out, 1); + if (rc < 0) { + return rc; + } + } + rc = conv_uni_to_pc(unicode, 0); + if (rc >= 0) + return rc; + } + if (isdefault || trydefault) { + rc = conv_uni_to_pc(unicode, 1); + if (rc >= 0) + return rc; + } + if (!isdefault && (rc == -4)) { + rc = conv_uni_to_pc(0xfffd, 0); + } + if ((isdefault || trydefault) && (rc == -4)) { + rc = conv_uni_to_pc(0xfffd, 1); } - rc = conv_uni_to_pc(unicode); - if (rc == -4) - rc = conv_uni_to_pc(0xfffd); - return rc; + return rc; } /* @@ -923,49 +1051,79 @@ PUBLIC int UCTransUniCharStr ARGS5( { int rc, src = 0, ignore_err; int UChndl_out; + int isdefault, trydefault; struct unimapdesc_str * repl; u16 * ut; -if (buflen<2) - return -13; + if (buflen<2) + return -13; - if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) - return -12; + if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if ((UChndl_out = default_UChndl) < 0) + return -12; + isdefault = 1; + } else { + isdefault = UCInfo[UChndl_out].replacedesc.isdefault; + trydefault = UCInfo[UChndl_out].replacedesc.trydefault; + } if (chk_single_flag) { - ut = UCInfo[UChndl_out].unitable; - if (ut != UC_current_unitable) { - src = UC_con_set_unimap(UChndl_out, 1); - if (src < 0) { - return src; - } - } - src = conv_uni_to_pc(unicode); - if (src >= 32) { - outbuf[0] = src; outbuf[1] = '\0'; - return 1; - } + if (!isdefault) { + ut = UCInfo[UChndl_out].unitable; + if (ut != UC_current_unitable) { + src = UC_con_set_unimap(UChndl_out, 1); + if (src < 0) { + return src; + } + } + } + src = conv_uni_to_pc(unicode, isdefault); + if (src >= 32) { + outbuf[0] = src; outbuf[1] = '\0'; + return 1; + } } - repl = &(UCInfo[UChndl_out].replacedesc); - if (repl != UC_current_unitable_str) { - con_clear_unimap_str(); - ignore_err = UC_con_set_unimap_str(repl->entry_ct, repl->entries); - UC_current_unitable_str = repl; + if (!isdefault) { + if (repl != UC_current_unitable_str) { + con_clear_unimap_str(0); + ignore_err = UC_con_set_unimap_str(repl->entry_ct, repl->entries, 0); + UC_current_unitable_str = repl; + } + rc = conv_uni_to_str(outbuf, buflen, unicode, 0); + if (rc >= 0) + return (strlen(outbuf)); + } + if (trydefault && chk_single_flag) { + src = conv_uni_to_pc(unicode, 1); + if (src >= 32) { + outbuf[0] = src; outbuf[1] = '\0'; + return 1; + } + } + if (isdefault || trydefault) { + rc = conv_uni_to_str(outbuf, buflen, unicode, 1); + if (rc >= 0) + return (strlen(outbuf)); + } + if (rc == -4) { + if (!isdefault) + rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 0); + if ((rc == -4) && (isdefault || trydefault)) + rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 1); + if (rc >= 0) + return (strlen(outbuf)); } - rc = conv_uni_to_str(outbuf, buflen, unicode); - if (rc == -4) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd); - if (rc >= 0) - return (strlen(outbuf)); - if (chk_single_flag && src == -4) { - rc = conv_uni_to_pc(0xfffd); - if (rc >= 32) { - outbuf[0] = rc; outbuf[1] = '\0'; - return 1; - } - return rc; + if (!isdefault) + rc = conv_uni_to_pc(0xfffd, 0); + if ((rc == -4) && (isdefault || trydefault)) + rc = conv_uni_to_pc(0xfffd, 1); + if (rc >= 32) { + outbuf[0] = rc; outbuf[1] = '\0'; + return 1; + } + return rc; } return -4; } @@ -976,39 +1134,39 @@ PRIVATE int UC_MapGN ARGS2( int, UChndl, int, update_flag) { - int i,Gn,found,lasthndl; - found = 0; - Gn = -1; - for (i=0; i<4 && Gn<0; i++) { + int i,Gn,found,lasthndl; + found = 0; + Gn = -1; + for (i=0; i<4 && Gn<0; i++) { if (UC_GNhandles[i] < 0) { Gn = i; } else if (UC_GNhandles[i] == UChndl) { - Gn = i; + Gn = i; found = 1; - } + } } if (found) return Gn; - if (Gn >= 0) { - UCInfo[UChndl].GN = Gn; - UC_GNhandles[Gn] = UChndl; + if (Gn >= 0) { + UCInfo[UChndl].GN = Gn; + UC_GNhandles[Gn] = UChndl; } else { if (UC_lastautoGN == GRAF_MAP) { - Gn = IBMPC_MAP; + Gn = IBMPC_MAP; } else { Gn = GRAF_MAP; } - UC_lastautoGN = Gn; - lasthndl = UC_GNhandles[Gn]; - UCInfo[lasthndl].GN = -1; - UCInfo[UChndl].GN = Gn; - UC_GNhandles[Gn] = UChndl; - } - if (TRACE) - fprintf(stderr,"UC_Map...... Using %i <- %i (%s)\n", + UC_lastautoGN = Gn; + lasthndl = UC_GNhandles[Gn]; + UCInfo[lasthndl].GN = -1; + UCInfo[UChndl].GN = Gn; + UC_GNhandles[Gn] = UChndl; + } + if (TRACE) + fprintf(stderr,"UC_Map...... Using %i <- %i (%s)\n", Gn, UChndl, UCInfo[UChndl].MIMEname); - UC_con_set_trans(UChndl,Gn,update_flag); - return Gn; + UC_con_set_trans(UChndl,Gn,update_flag); + return Gn; } PUBLIC int UCTransChar ARGS3( @@ -1016,48 +1174,69 @@ PUBLIC int UCTransChar ARGS3( int, charset_in, int, charset_out) { - int unicode, Gn; - int rc; - int UChndl_in, UChndl_out; - u16 * ut; - int upd = 0; + int unicode, Gn; + int rc = -4; + int UChndl_in, UChndl_out; + int isdefault, trydefault; + u16 * ut; + int upd = 0; #ifndef UC_NO_SHORTCUTS - if (charset_in == charset_out) - return (unsigned char)ch_in; + if (charset_in == charset_out) + return (unsigned char)ch_in; #endif /* UC_NO_SHORTCUTS */ if (charset_in < 0) return -11; - if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) - return -11; - if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) - return -12; - if (!UCInfo[UChndl_in].num_uni) - return -11; + if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) + return -11; + if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if ((UChndl_out = default_UChndl) < 0) + return -12; + isdefault = 1; + } else { + isdefault = UCInfo[UChndl_out].replacedesc.isdefault; + trydefault = UCInfo[UChndl_out].replacedesc.trydefault; + } + if (!UCInfo[UChndl_in].num_uni) + return -11; if ((Gn = UCInfo[UChndl_in].GN) < 0) { Gn = UC_MapGN(UChndl_in,0); upd = 1; + } - ut = UCInfo[UChndl_out].unitable; - if (ut == UC_current_unitable) { - if (upd) { - set_inverse_transl(Gn); + ut = UCInfo[UChndl_out].unitable; + if (!isdefault) { + if (ut == UC_current_unitable) { + if (upd) { + set_inverse_transl(Gn); + } + } else { + rc = UC_con_set_unimap(UChndl_out, 1); + if (rc > 0) { + set_inverse_transl(Gn); + } else if (rc < 0) { + return rc; + } } - } else { - rc = UC_con_set_unimap(UChndl_out, 1); - if (rc > 0) { - set_inverse_transl(Gn); - } else if (rc < 0) { - return rc; - } } - UC_translate = set_translate(Gn); - unicode = UC_translate[(unsigned char)ch_in]; - rc = conv_uni_to_pc(unicode); - if (rc == -4) - rc = conv_uni_to_pc(0xfffd); - return rc; + UC_translate = set_translate(Gn); + unicode = UC_translate[(unsigned char)ch_in]; + if (!isdefault) { + rc = conv_uni_to_pc(unicode, 0); + if (rc >= 0) + return rc; + } + if ((rc == -4) && (isdefault || trydefault)) { + rc = conv_uni_to_pc(unicode, 1); + } + if ((rc == -4) && !isdefault) { + rc = conv_uni_to_pc(0xfffd, 0); + } + if ((rc == -4) && (isdefault || trydefault)) { + rc = conv_uni_to_pc(0xfffd, 1); + } + return rc; } PUBLIC long int UCTransToUni ARGS2( @@ -1102,6 +1281,7 @@ PUBLIC int UCReverseTransChar ARGS3(char, ch_out, int, charset_in, int, charset_ int Gn; int rc; int UChndl_in, UChndl_out; + int isdefault; int i_ch = (unsigned char)ch_out; u16 * ut; @@ -1113,27 +1293,40 @@ PUBLIC int UCReverseTransChar ARGS3(char, ch_out, int, charset_in, int, charset_ return -11; if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) return -11; - if (charset_out < 0) - return -12; - if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) - return -12; if (!UCInfo[UChndl_in].num_uni) return -11; + if (charset_out < 0) + return -12; + if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if ((UChndl_out = default_UChndl) < 0) + return -12; + isdefault = 1; + } else { + isdefault = UCInfo[UChndl_out].replacedesc.isdefault; + } - ut = UCInfo[UChndl_out].unitable; - if (ut == UC_current_unitable) { - if ((Gn = UCInfo[UChndl_in].GN) >= 0) { - UC_translate = set_translate(Gn); - rc = inv_translate[i_ch]; - if (rc >= 32) { - return rc; - } - } else { - Gn = UC_MapGN(UChndl_in,1); - UC_translate = set_translate(Gn); - rc = inv_translate[i_ch]; - if (rc >= 32) { - return rc; + if (!isdefault) { + /* + * Try to use the inverse table if charset_out is not equivalent + * to using just the default table. If it is, it should have + * just ASCII chars and trying to back-translate those should + * not give anything but themselves. - kw + */ + ut = UCInfo[UChndl_out].unitable; + if (ut == UC_current_unitable) { + if ((Gn = UCInfo[UChndl_in].GN) >= 0) { + UC_translate = set_translate(Gn); + rc = inv_translate[i_ch]; + if (rc >= 32) { + return rc; + } + } else { + Gn = UC_MapGN(UChndl_in,1); + UC_translate = set_translate(Gn); + rc = inv_translate[i_ch]; + if (rc >= 32) { + return rc; + } } } } @@ -1151,17 +1344,18 @@ PUBLIC int UCTransCharStr ARGS6( int, charset_out, int, chk_single_flag) { - int unicode, Gn; - int rc, src = 0, ignore_err; - int UChndl_in, UChndl_out; - struct unimapdesc_str * repl; - u16 * ut; - int upd = 0; + int unicode, Gn; + int rc, src = 0, ignore_err; + int UChndl_in, UChndl_out; + int isdefault, trydefault; + struct unimapdesc_str * repl; + u16 * ut; + int upd = 0; -if (buflen<2) - return -13; + if (buflen<2) + return -13; #ifndef UC_NO_SHORTCUTS - if (chk_single_flag && charset_in == charset_out) { + if (chk_single_flag && charset_in == charset_out) { outbuf[0] = ch_in; outbuf[1] = '\0'; return 1; @@ -1169,60 +1363,91 @@ if (buflen<2) #endif /* UC_NO_SHORTCUTS */ if (charset_in < 0) return -11; - if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) - return -11; - if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) - return -12; - if (!UCInfo[UChndl_in].num_uni) - return -11; - if ((Gn = UCInfo[UChndl_in].GN) < 0) + if ((UChndl_in = LYCharSet_UC[charset_in].UChndl) < 0) + return -11; + if (!UCInfo[UChndl_in].num_uni) + return -11; + if ((UChndl_out = LYCharSet_UC[charset_out].UChndl) < 0) { + if ((UChndl_out = default_UChndl) < 0) + return -12; + isdefault = 1; + } else { + isdefault = UCInfo[UChndl_out].replacedesc.isdefault; + trydefault = UCInfo[UChndl_out].replacedesc.trydefault; + } + if ((Gn = UCInfo[UChndl_in].GN) < 0) {Gn = UC_MapGN(UChndl_in,!chk_single_flag); upd=chk_single_flag;} - UC_translate = set_translate(Gn); - unicode = UC_translate[(unsigned char)ch_in]; - - if (chk_single_flag) { - ut = UCInfo[UChndl_out].unitable; - if (ut == UC_current_unitable) { - if (upd) set_inverse_transl(Gn); - } else { - src = UC_con_set_unimap(UChndl_out, 1); - if (src > 0) { - set_inverse_transl(Gn); - } else if (src < 0) { - return src; - } + UC_translate = set_translate(Gn); + unicode = UC_translate[(unsigned char)ch_in]; + + if (chk_single_flag) { + if (!isdefault) { + ut = UCInfo[UChndl_out].unitable; + if (ut == UC_current_unitable) { + if (upd) set_inverse_transl(Gn); + } else { + src = UC_con_set_unimap(UChndl_out, 1); + if (src > 0) { + set_inverse_transl(Gn); + } else if (src < 0) { + return src; + } + } } - src = conv_uni_to_pc(unicode); - if (src >= 32) { - outbuf[0] = src; outbuf[1] = '\0'; + src = conv_uni_to_pc(unicode, isdefault); + if (src >= 32) { + outbuf[0] = src; outbuf[1] = '\0'; return 1; } - } - - repl = &(UCInfo[UChndl_out].replacedesc); - if (repl != UC_current_unitable_str) { - con_clear_unimap_str(); - ignore_err = UC_con_set_unimap_str(repl->entry_ct, repl->entries); - UC_current_unitable_str = repl; - } - rc = conv_uni_to_str(outbuf, buflen, unicode); - if (rc == -4) - rc = conv_uni_to_str(outbuf, buflen, 0xfffd); - if (rc >= 0) - return (strlen(outbuf)); + } - if (chk_single_flag && src == -4) { - rc = conv_uni_to_pc(0xfffd); - if (rc >= 32) { - outbuf[0] = rc; outbuf[1] = '\0'; + repl = &(UCInfo[UChndl_out].replacedesc); + if (!isdefault) { + if (repl != UC_current_unitable_str) { + con_clear_unimap_str(0); + ignore_err = UC_con_set_unimap_str(repl->entry_ct, repl->entries, 0); + UC_current_unitable_str = repl; + } + rc = conv_uni_to_str(outbuf, buflen, unicode, 0); + if (rc >= 0) + return (strlen(outbuf)); + } + if (trydefault && chk_single_flag) { + src = conv_uni_to_pc(unicode, 1); + if (src >= 32) { + outbuf[0] = src; outbuf[1] = '\0'; return 1; + } + } + if (isdefault || trydefault) { + rc = conv_uni_to_str(outbuf, buflen, unicode, 1); + if (rc >= 0) + return (strlen(outbuf)); + } + if (rc == -4) { + if (!isdefault) + rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 0); + if ((rc == -4) && (isdefault || trydefault)) + rc = conv_uni_to_str(outbuf, buflen, 0xfffd, 1); + if (rc >= 0) + return (strlen(outbuf)); + } + if (chk_single_flag && src == -4) { + if (!isdefault) + rc = conv_uni_to_pc(0xfffd, 0); + if ((rc == -4) && (isdefault || trydefault)) + rc = conv_uni_to_pc(0xfffd, 1); + if (rc >= 32) { + outbuf[0] = rc; outbuf[1] = '\0'; + return 1; } else if (rc <= 0) { outbuf[0] = '\0'; return rc; } - } - return -4; + return rc; + } + return -4; } PRIVATE int UC_FindGN_byMIME ARGS1( @@ -1262,10 +1487,10 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1( for (i = 0; (i < MAXCHARSETS && i < LYNumCharsets && LYchar_set_names[i] && LYhndl < 0); i++) { - if (LYCharSet_UC[i].MIMEname && - !strcmp(UC_MIMEcharset,LYCharSet_UC[i].MIMEname)) { - LYhndl = i; - } + if (LYCharSet_UC[i].MIMEname && + !strcmp(UC_MIMEcharset,LYCharSet_UC[i].MIMEname)) { + LYhndl = i; + } } if (LYhndl < 0) { /* @@ -1282,10 +1507,13 @@ PUBLIC int UCGetLYhndl_byMIME ARGS1( return UCGetLYhndl_byMIME("euc-jp"); } else if (!strcmp(UC_MIMEcharset, "iso-2022-kr")) { return UCGetLYhndl_byMIME("euc-kr"); - } else if (!strcmp(UC_MIMEcharset, "gb2312")) { + } else if (!strcmp(UC_MIMEcharset, "gb2312") || + !strncmp(UC_MIMEcharset, "cn-gb", 5)) { return UCGetLYhndl_byMIME("euc-cn"); } else if (!strcmp(UC_MIMEcharset, "iso-2022-cn")) { return UCGetLYhndl_byMIME("euc-cn"); + } else if (!strcmp(UC_MIMEcharset, "cn-big5")) { + return UCGetLYhndl_byMIME("big5"); } else if (!strcmp(UC_MIMEcharset, "windows-1252")) { /* * It's not my fault that Microsoft hasn't registered @@ -1423,7 +1651,7 @@ PRIVATE char ** UC_setup_LYCharSets_repl ARGS2( } /* * Now allocate a new table compatible with LYCharSets[] - * and with the HTMLDTD for entitied. + * and with the HTMLDTD for entities. * We don't know yet whether we'll keep it around. */ p = prepl = (char **) malloc(HTML_dtd.number_of_entities * sizeof(char *)); if (!p) { @@ -1528,7 +1756,7 @@ PRIVATE int UC_Register_with_LYCharSets ARGS4( /* * Do different kinds of searches... - * after all, this is experimental... + * Normally the first should find the match if there is one! */ for (i = 0; i < MAXCHARSETS && LYchar_set_names[i] && LYhndl < 0; i++) { if (!strcmp(UC_LYNXcharset, LYchar_set_names[i])) { @@ -1643,6 +1871,9 @@ PUBLIC void UC_Charset_Setup ARGS8( UCInfo[s].unitable = unitable; UCInfo[s].num_uni = nnuni; UCInfo[s].replacedesc = replacedesc; + if (replacedesc.isdefault) { + default_UChndl = s; + } Gn = UC_FindGN_byMIME(UC_MIMEcharset); if (Gn >= 0) UC_GNhandles[Gn] = s; @@ -1664,8 +1895,10 @@ PRIVATE void UCcleanup_mem NOARGS { int i; UCfree_allocated_LYCharSets(); - con_clear_unimap_str(); - con_clear_unimap(); + con_clear_unimap_str(0); + con_clear_unimap_str(1); + con_clear_unimap(0); + con_clear_unimap(1); for (i = 1; i < 4; i++) { /* first one is static! */ FREE(inverse_translations[i]); } diff --git a/src/chrtrans/Makefile b/src/chrtrans/Makefile.old index 3b75ab08..3b75ab08 100644 --- a/src/chrtrans/Makefile +++ b/src/chrtrans/Makefile.old diff --git a/src/chrtrans/README.format b/src/chrtrans/README.format index e5eca7bf..58f0b1cc 100644 --- a/src/chrtrans/README.format +++ b/src/chrtrans/README.format @@ -12,7 +12,7 @@ There are four kinds of lines: Summary example: # This line is a comment, the next line is a directive - OBrand new Charset! + O Brand new Charset! 0x41 U+0041 U+0391 U+00cd:I' @@ -23,12 +23,25 @@ a) comment lines start with a '#' character. check the examples..) b) directives: - start with a special character, currently recognized are the letters: + start with a keyword which may be abbreviated to one letter (first + letter must be capitalized), followed by space and a value. + Currently recognized: - O The name under which this should appear on the O)ptions screen - M The name for this charset in MIME syntax (one word with digits + OptionName + The name under which this should appear on the O)ptions screen + in the list for Display Character Set + MIMEName + The name for this charset in MIME syntax (one word with digits and some other non-letters allowed, should be IANA registered) - R a number which flags some special property (encoding) for this + Default + This is the default (fallback) translation table, it will be used + for Unicode -> 8bit (or 7bit) translation if no translation is found + in the specific table. + FallBack + Whether to use the default table if no translation is found in + this table. Normally fallback is used, "FallBack NO" disables it. + RawOrEnc + a number which flags some special property (encoding) for this charset [see utf8.uni for example, see UCDefs.h for details]. c) character translation definitions: diff --git a/src/chrtrans/README.tables b/src/chrtrans/README.tables index 8e4366d1..a95d600c 100644 --- a/src/chrtrans/README.tables +++ b/src/chrtrans/README.tables @@ -35,8 +35,9 @@ a) Near the top, you will find a bunch of lines (some may be commented out) #include "chrtrans/<fn>.h" #endif /* VMS */ -Add or comment out as you wish. (But it's probably safest to leave the -first one, referring to "chrtrans/iso01_uni.h", in place...) +Add or comment out as you wish. But it is probably safest to leave the +first two, referring to "chrtrans/def7_uni.h" and "chrtrans/iso01_uni.h", +in place. b) At the bottom, you will find a bunch of lines (again, some may be commented out by default) of the form diff --git a/src/chrtrans/UCkd.h b/src/chrtrans/UCkd.h index 083afe49..1497f298 100644 --- a/src/chrtrans/UCkd.h +++ b/src/chrtrans/UCkd.h @@ -43,6 +43,8 @@ struct unimapdesc { struct unimapdesc_str { u16 entry_ct; struct unipair_str *entries; + int isdefault; + int trydefault; }; diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index dcbb2f01..c4bbef7c 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -17,7 +17,7 @@ D1 U+00a1:! U+00a2:Ct U+00a3:Pd -U+00a4:Cu +U+00a4:CUR U+00a5:Ye U+00a6:| U+00a7:SE @@ -26,15 +26,16 @@ U+00a9:(C) U+00aa:-a U+00ab:<< U+00ac:NO -U+00ad:-- +U+00ad:- U+00ae:(R) -U+00af:'m +U+00af:- U+00b0:DG U+00b1:+- U+00b2:^2 U+00b3:^3 U+00b4:' -U+00b5:My +# My -> u +U+00b6:u U+00b6:PI U+00b7:.M U+00b8:, @@ -56,7 +57,7 @@ U+00d0:D- 0x4e U+00d1 0x4f U+00d2-U+00d5 U+00d6:O: -0x2a U+00d7 +U+00d7: * U+00d8:O/ 0x55 U+00d9-U+00db U+00dc:U: @@ -147,7 +148,7 @@ U+017f:s1 U+0187:C2 U+0188:c2 U+0191:F2 -U+0192:f2 +U+0192: f U+0198:K2 U+0199:k2 U+01a0:O9 @@ -307,7 +308,7 @@ U+02b3:<r> U+02b7:<w> U+02bb:;S 0x60 U+02bc -U+02c6:1> +U+02c6:^ U+02c7:'< U+02c9:1- U+02cb:1! @@ -316,7 +317,7 @@ U+02d8:'( U+02d9:'. U+02da:'0 U+02db:'; -U+02dc:1? +U+02dc:~ U+02dd:'" 0x7e U+0303 U+0334 0x2e U+0322 U+0323 @@ -403,6 +404,9 @@ U+03cc:o% U+03cd:u% U+03ce:w% U+03d0:b3 +U+03d1:theta +U+03d2:\upsih +U+03d6:pi U+03da:T3 U+03db:t3 U+03dc:M3 @@ -924,7 +928,7 @@ U+1349:fu U+134A:fi U+134B:fa U+134C:fE -0x46 U+134D #:f +0x6f U+134D #:f U+134E:fo U+134F:fWa U+1350:pe @@ -1312,8 +1316,11 @@ U+20a9:W= U+2103:oC U+2105:c/o U+2109:oF +U+2111:Im U+2116:No. U+2117:PO +U+2118:P +U+211C:Re U+211e:Rx U+2120:(SM) U+2122:(TM) @@ -1321,6 +1328,7 @@ U+2126:Ohm U+212E:est. 0x4b U+212A # Kelvin sign - K U+212b:Ang. +U+2135:Aleph U+2153: 1/3 U+2154: 2/3 U+2155: 1/5 @@ -1369,30 +1377,34 @@ U+2180:1000RCD U+2181:5000R U+2182:10000R U+2190:<- -U+2191:-! +U+2191:-^ U+2192:-> U+2193:-v -U+2194:<> +U+2194:<-> U+2195:UD U+2196:<!! U+2197://> U+2198:!!> U+2199:<// U+21a8:UD- +U+21B5:RET U+21c0:>V U+21d0:<= +U+21d1:^^ U+21d2:=> -U+21d4:== +U+21d3:vv +U+21d4:<=> U+2200:FA -U+2202:d +U+2202:\partial U+2203:TE U+2205:{} U+2206:decr. U+2207:Nabla U+2208:(- +U+2209:!(- U+220b:-) -U+220f:*P -U+2211:+Z +U+220f:\prod +U+2211:\sum U+2212: - U+2213:-/+ U+2214:.+ @@ -1409,7 +1421,7 @@ U+2227:AND U+2228:OR U+2229:(U U+222a:)U -U+222b:In +U+222b:\int U+222c:DI U+222e:Io U+2234:.: @@ -1433,8 +1445,11 @@ U+226e:!< U+226f:!> U+2282:(C U+2283:)C +U+2282:!(C U+2286:(_ U+2287:)_ +U+2295:(+) +U+2297:(x) U+2299:0. U+229a:02 U+22a5:-T @@ -1687,7 +1702,7 @@ U+266c:M16 U+266d:b U+266e:Mx U+266f:# -0x58 U+2713 U+2717 # check marks +0x58 U+2713 U+2717 # check marks -> x U+2720:-X 0x20 U+3000 # ideographic space U+3001:,_ @@ -2073,12 +2088,12 @@ U+fefa:lh. U+fefb:la- U+fefc:la. # Symbols for C0 and C1 control characters, in case they get through... -U+0000:NU +U+0000:NUL U+0001:SH U+0002:SX U+0003:EX U+0004:ET -U+0005:EQ +U+0005:ENQ U+0006:AK U+0007:BL U+0008:BS @@ -2090,90 +2105,90 @@ U+000d:CR U+000e:SO U+000f:SI U+0010:DL -U+0011:D1 -U+0012:D2 -U+0013:D3 -U+0014:D4 -U+0015:NK -U+0016:SY +U+0011:DC1 +U+0012:DC2 +U+0013:DC3 +U+0014:DC4 +U+0015:NAK +U+0016:SYN U+0017:EB U+0018:CN U+0019:EM U+001a:SB -U+001b:EC +U+001b:ESC U+001c:FS U+001d:GS U+001e:RS U+001f:US U+007f:DT U+0080:PA -U+0081:HO -U+0082:BH -U+0083:NH -U+0084:IN -U+0085:NL -U+0086:SA -U+0087:ES -U+0088:HS -U+0089:HJ -U+008a:VS -U+008b:PD -U+008c:PU +#U+0081:HO +#U+0082:BH +#U+0083:NH +#U+0084:IN +#U+0085:NL +#U+0086:SA +#U+0087:ES +#U+0088:HS +#U+0089:HJ +#U+008a:VS +#U+008b:PD +#U+008c:PU U+008d:RI -U+008e:S2 -U+008f:S3 -U+0090:DC -U+0091:P1 -U+0092:P2 -U+0093:TS -U+0094:CC -U+0095:MW -U+0096:SG -U+0097:EG -U+0098:SS -U+0099:GC -U+009a:SC -U+009b:CI -U+009c:ST -U+009d:OC -U+009e:PM -U+009f:AC +U+008e:SS2 +U+008f:SS3 +U+0090:DCS +#U+0091:P1 +#U+0092:P2 +#U+0093:TS +#U+0094:CC +#U+0095:MW +#U+0096:SG +#U+0097:EG +#U+0098:SS +#U+0099:GC +#U+009a:SC +U+009b:CSI +#U+009c:ST +#U+009d:OC +#U+009e:PM +#U+009f:AC # Unassigned stuff in private zone (?) -U+e000:"3 -U+e001:"1 -U+e002:"! -U+e003:"' -U+e004:"> -U+e005:"? -U+e006:"- -U+e007:"( -U+e008:". -U+e009:": -U+e00a:"0 -U+e00b:", -U+e00c:"_ -U+e00d:"" -U+e00e:"; -U+e00f:"< -U+e010:"= -U+e011:"/ -U+e012:"p -U+e013:"d -U+e014:"i -U+e015:+_ -U+e016:a+: -U+e017:Tel -U+e018:UA -U+e019:UB -U+e01e:Mc -U+e01f:Fl - -U+e020:pm -U+e021:Tel -U+e022:a+: -U+e023:Fl -U+e024:GF -U+e025:>V -U+e026:!* -U+e027:?* -U+e028:J< +#U+e000:"3 +#U+e001:"1 +#U+e002:"! +#U+e003:"' +#U+e004:"> +#U+e005:"? +#U+e006:"- +#U+e007:"( +#U+e008:". +#U+e009:": +#U+e00a:"0 +#U+e00b:", +#U+e00c:"_ +#U+e00d:"" +#U+e00e:"; +#U+e00f:"< +#U+e010:"= +#U+e011:"/ +#U+e012:"p +#U+e013:"d +#U+e014:"i +#U+e015:+_ +#U+e016:a+: +#U+e017:Tel +#U+e018:UA +#U+e019:UB +#U+e01e:Mc +#U+e01f:Fl +# +#U+e020:pm +#U+e021:Tel +#U+e022:a+: +#U+e023:Fl +#U+e024:GF +#U+e025:>V +#U+e026:!* +#U+e027:?* +#U+e028:J< diff --git a/src/chrtrans/iso01_uni.tbl b/src/chrtrans/iso01_uni.tbl index 15dc6f6a..14f71ff3 100644 --- a/src/chrtrans/iso01_uni.tbl +++ b/src/chrtrans/iso01_uni.tbl @@ -20,45 +20,45 @@ OISO Latin 1 # of small letter 'c' to 'c': 0x63 U+0063 U+0107 U+0109 U+010B U+010D 0x64-0x7e idem -0x7f U+2302 0xa0-0xff idem #0x00 U+fffd # don't let failed char lookups return '\0' -# Mappings of cntrl chars, left in from original, just to see what happens... -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +# Mappings of C0 control chars from original, disabled +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC +#0x7f U+2302 0xd0 U+0110 # Dstrok and ETH are nearly the same... @@ -68,360 +68,11 @@ U+202c: # LEFT-TO-RIGHT OVERRIDE 202D U+202d: -# Replacement strings for Ethiopic characters -U+1200:he -U+1201:hu -U+1202:hi -U+1203:ha -U+1204:hE -U+1205:h -U+1206:ho -U+1208:le -U+1209:lu -U+120A:li -U+120B:la -U+120C:lE -U+120D:l -U+120E:lo -U+120F:lWa -U+1210:He -U+1211:Hu -U+1212:Hi -U+1213:Ha -U+1214:HE -U+1215:H -U+1216:Ho -U+1217:HWa -U+1218:me -U+1219:mu -U+121A:mi -U+121B:ma -U+121C:mE -U+121D:m -U+121E:mo -U+121F:mWa -U+1220:`se -U+1221:`su -U+1222:`si -U+1223:`sa -U+1224:`sE -U+1225:`s -U+1226:`so -U+1227:`sWa -U+1228:re -U+1229:ru -U+122A:ri -U+122B:ra -U+122C:rE -U+122D:r -U+122E:ro -U+122F:rWa -U+1230:se -U+1231:su -U+1232:si -U+1233:sa -U+1234:sE -U+1235:s -U+1236:so -U+1237:sWa -U+1238:xe -U+1239:xu -U+123A:xi -U+123B:xa -U+123C:xE -U+123D:xa -U+123E:xo -U+123F:xWa -U+1240:qe -U+1241:qu -U+1242:qi -U+1243:qa -U+1244:qE -U+1245:q -U+1246:qo -U+1248:qWe -U+124A:qWi -U+124B:qWa -U+124C:qWE -U+124D:qW -U+1250:Qe -U+1251:Qu -U+1252:Qi -U+1253:Qa -U+1254:QE -U+1255:Q -U+1256:Qo -U+1258:QWe -U+125A:QWi -U+125B:QWa -U+125C:QWE -U+125D:QW -U+1260:be -U+1261:bu -U+1262:bi -U+1263:ba -U+1264:bE -U+1265:b -U+1266:bo -U+1267:bWa -U+1268:ve -U+1269:vu -U+126A:vi -U+126B:va -U+126C:vE -U+126D:v -U+126E:vo -U+126F:vWa -U+1270:te -U+1271:tu -U+1272:ti -U+1273:ta -U+1274:tE -U+1275:t -U+1276:to -U+1277:tWa -U+1278:ce -U+1279:cu -U+127A:ci -U+127B:ca -U+127C:cE -U+127D:c -U+127E:co -U+127F:cWa -U+1280:`he -U+1281:`hu -U+1282:`hi -U+1283:`ha -U+1284:`hE -U+1285:`h -U+1286:`ho -U+1288:hWe -U+128A:hWi -U+128B:hWa -U+128C:hWE -U+128D:hW -U+1290:na -U+1291:nu -U+1292:ni -U+1293:na -U+1294:nE -U+1295:n -U+1296:no -U+1297:nWa -U+1298:Ne -U+1299:Nu -U+129A:Ni -U+129B:Na -U+129C:NE -U+129D:N -U+129E:No -U+129F:NWa -U+12A0:e -U+12A1:u -U+12A2:i -U+12A3:a -U+12A4:E -U+12A5:I -U+12A6:o -U+12A7:e3 -U+12A8:ke -U+12A9:ku -U+12AA:ki -U+12AB:ka -U+12AC:kE -U+12AD:k -U+12AE:ko -U+12B0:kWe -U+12B2:kWi -U+12B3:kWa -U+12B4:kWE -U+12B5:kW -U+12B8:Ke -U+12B9:Ku -U+12BA:Ki -U+12BB:Ka -U+12BC:KE -U+12BD:K -U+12BE:Ko -U+12C0:KWe -U+12C2:KWi -U+12C3:KWa -U+12C4:KWE -U+12C5:KW -U+12C8:we -U+12C9:wu -U+12CA:wi -U+12CB:wa -U+12CC:wE -U+12CD:w -U+12CE:wo -U+12D0:`e -U+12D1:`u -U+12D2:`i -U+12D3:`a -U+12D4:`E -U+12D5:`I -U+12D6:`o -U+12D8:ze -U+12D9:zu -U+12DA:zi -U+12DB:za -U+12DC:zE -U+12DD:z -U+12DE:zo -U+12DF:zWa -U+12E0:Ze -U+12E1:Zu -U+12E2:Zi -U+12E3:Za -U+12E4:ZE -U+12E5:Z -U+12E6:Zo -U+12E7:ZWa -U+12E8:ye -U+12E9:yu -U+12EA:yi -U+12EB:ya -U+12EC:yE -U+12ED:y -U+12EE:yo -U+12EF:yWa -U+12F0:de -U+12F1:du -U+12F2:di -U+12F3:da -U+12F4:dE -U+12F5:d -U+12F6:do -U+12F7:dWa -U+12F8:De -U+12F9:Du -U+12FA:Di -U+12FB:Da -U+12FC:DE -U+12FD:D -U+12FE:Do -U+12FF:DWa -U+1300:je -U+1301:ju -U+1302:ji -U+1303:ja -U+1304:jE -U+1305:j -U+1306:jo -U+1307:jWa -U+1308:ga -U+1309:gu -U+130A:gi -U+130B:ga -U+130C:gE -U+130D:g -U+130E:go -U+1310:gWu -U+1312:gWi -U+1313:gWa -U+1314:gWE -U+1315:gW -U+1318:Ge -U+1319:Gu -U+131A:Gi -U+131B:Ga -U+131C:GE -U+131D:G -U+131E:Go -U+131F:GWa -U+1320:Te -U+1321:Tu -U+1322:Ti -U+1323:Ta -U+1324:TE -U+1325:T -U+1326:To -U+1327:TWa -U+1328:Ce -U+1329:Ca -U+132A:Cu -U+132B:Ca -U+132C:CE -U+132D:C -U+132E:Co -U+132F:CWa -U+1330:Pe -U+1331:Pu -U+1332:Pi -U+1333:Pa -U+1334:PE -U+1335:P -U+1336:Po -U+1337:PWa -U+1338:SWe -U+1339:SWu -U+133A:SWi -U+133B:SWa -U+133C:SWE -U+133D:SW -U+133E:SWo -U+133F:SWa -U+1340:`Sa -U+1341:`Su -U+1342:`Si -U+1343:`Sa -U+1344:`SE -U+1345:`S -U+1346:`So -U+1348:fa -U+1349:fu -U+134A:fi -U+134B:fa -U+134C:fE -U+134D:f -U+134E:fo -U+134F:fWa -U+1350:pe -U+1351:pu -U+1352:pi -U+1353:pa -U+1354:pE -U+1355:p -U+1356:po -U+1357:pWa -U+1358:mYa -U+1359:rYa -U+135A:fYa -# ETHIOPIC SPACE U+1360 mapped to ASCII space above -U+1361:: -U+1362::: -U+1363:, -U+1364:; -U+1365:-: -U+1366::- -U+1367:`? -U+1368::|: -U+1369:`1 -U+136A:`2 -U+136B:`3 -U+136C:`4 -U+136D:`5 -U+136E:`6 -U+136F:`7 -U+1370:`8 -U+1371:`9 -U+1372:`10 -U+1373:`20 -U+1374:`30 -U+1375:`40 -U+1376:`50 -U+1377:`60 -U+1378:`70 -U+1379:`80 -U+137A:`90 -U+137B:`100 -U+137C:`10000 - - # TRADE MARK SIGN: U+2122:(TM) 0x60 U+2018 # left single quotation mark 0x27 U+2019-U+201b # various single quotation marks 0x22 U+201c-U+201f # various double quotation marks + +U+2297:(×) \ No newline at end of file diff --git a/src/chrtrans/iso02_uni.tbl b/src/chrtrans/iso02_uni.tbl index dec4d843..ac7dd37a 100644 --- a/src/chrtrans/iso02_uni.tbl +++ b/src/chrtrans/iso02_uni.tbl @@ -3,7 +3,6 @@ # [use: unicode_start iso02.f16 iso02] # 0x20-0x7e idem -0x7f U+2302 #The MIME name of this charset. Miso-8859-2 @@ -13,41 +12,42 @@ OISO Latin 2 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC +#0x7f U+2302 # 0xa0 U+00a0 0xa1 U+0104 diff --git a/src/chrtrans/iso03_uni.tbl b/src/chrtrans/iso03_uni.tbl index 875f4d41..2ab5171c 100644 --- a/src/chrtrans/iso03_uni.tbl +++ b/src/chrtrans/iso03_uni.tbl @@ -9,44 +9,44 @@ Miso-8859-3 OISO Latin 3 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # 0xa0 U+00a0 0xa1 U+0126 diff --git a/src/chrtrans/iso04_uni.tbl b/src/chrtrans/iso04_uni.tbl index d0e6f8e2..ed5d469a 100644 --- a/src/chrtrans/iso04_uni.tbl +++ b/src/chrtrans/iso04_uni.tbl @@ -9,44 +9,44 @@ Miso-8859-4 OISO Latin 4 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # 0xa0 U+00a0 0xa1 U+0104 diff --git a/src/chrtrans/iso05_uni.tbl b/src/chrtrans/iso05_uni.tbl index 5179dc8d..f0dfad50 100644 --- a/src/chrtrans/iso05_uni.tbl +++ b/src/chrtrans/iso05_uni.tbl @@ -9,44 +9,44 @@ Miso-8859-5 OISO 8859-5 Cyrillic 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # 0xa0 U+00a0 0xa1 U+0401 diff --git a/src/chrtrans/iso07_uni.tbl b/src/chrtrans/iso07_uni.tbl index 4698888a..62a85b3c 100644 --- a/src/chrtrans/iso07_uni.tbl +++ b/src/chrtrans/iso07_uni.tbl @@ -9,44 +9,44 @@ Miso-8859-7 OISO 8859-7 Greek 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # 0xa0 U+00a0 0xa1 U+0371 diff --git a/src/chrtrans/iso09_uni.tbl b/src/chrtrans/iso09_uni.tbl index 224cc26c..8bcb7660 100644 --- a/src/chrtrans/iso09_uni.tbl +++ b/src/chrtrans/iso09_uni.tbl @@ -9,7 +9,7 @@ Miso-8859-9 OISO 8859-9 (Latin 5) 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 0xa0-0xcf idem 0xd0 U+011e 0xd1-0xdc idem @@ -23,41 +23,41 @@ OISO 8859-9 (Latin 5) 0xff U+00ff # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # TRADE MARK SIGN: U+2122:(TM) diff --git a/src/chrtrans/iso10_uni.tbl b/src/chrtrans/iso10_uni.tbl index f1123e3d..be3c02cd 100644 --- a/src/chrtrans/iso10_uni.tbl +++ b/src/chrtrans/iso10_uni.tbl @@ -13,44 +13,44 @@ Miso-8859-10 OISO 8859-10 0x20-0x7e idem -0x7f U+2302 +#0x7f U+2302 # #0x00 U+fffd -0x01 U+263A -0x02 U+263B -0x03 U+2665 -0x04 U+2666 -0x05 U+2663 -0x06 U+2660 -0x07 U+2022 -0x08 U+25D8 -0x09 U+25CB -0x0A U+25D9 -0x0B U+2642 -0x0C U+2640 -0x0D U+266A -0x0E U+266B -0x0E U+266C -0x0F U+263C -0x10 U+25B6 -0x10 U+25BA -0x11 U+25C0 -0x11 U+25C4 -0x12 U+2195 -0x13 U+203C -0x14 U+00B6 -0x15 U+00A7 -0x16 U+25AC -0x17 U+21A8 -0x18 U+2191 -0x19 U+2193 -0x1A U+2192 -0x1B U+2190 -0x1C U+221F -0x1C U+2319 -0x1D U+2194 -0x1E U+25B2 -0x1F U+25BC +#0x01 U+263A +#0x02 U+263B +#0x03 U+2665 +#0x04 U+2666 +#0x05 U+2663 +#0x06 U+2660 +#0x07 U+2022 +#0x08 U+25D8 +#0x09 U+25CB +#0x0A U+25D9 +#0x0B U+2642 +#0x0C U+2640 +#0x0D U+266A +#0x0E U+266B +#0x0E U+266C +#0x0F U+263C +#0x10 U+25B6 +#0x10 U+25BA +#0x11 U+25C0 +#0x11 U+25C4 +#0x12 U+2195 +#0x13 U+203C +#0x14 U+00B6 +#0x15 U+00A7 +#0x16 U+25AC +#0x17 U+21A8 +#0x18 U+2191 +#0x19 U+2193 +#0x1A U+2192 +#0x1B U+2190 +#0x1C U+221F +#0x1C U+2319 +#0x1D U+2194 +#0x1E U+25B2 +#0x1F U+25BC # 0xa0 U+00a0 0xa1 U+0104 diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index 62ad102d..e0630cc3 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -1,7 +1,8 @@ /* - * makeuctb.c, derived from conmakehash.c + * makeuctb.c, derived from conmakehash.c - kw + * + * Original comments from conmakehash.c: * - * [ original comments: - kw ] * Create arrays for initializing the kernel folded tables (using a hash * table turned out to be to limiting...) Unfortunately we can't simply * preinitialize the tables at compile time since kfree() cannot accept @@ -58,6 +59,28 @@ PRIVATE void usage ARGS1( exit(EX_USAGE); } +/* copied from HTString.c, not everybody has strncasecmp */ +PUBLIC int strncasecomp ARGS3( + CONST char*, a, + CONST char *, b, + int, n) +{ + CONST char *p = a; + CONST char *q = b; + + for (p = a, q = b; ; p++, q++) { + int diff; + if (p == (a+n)) + return 0; /* Match up to n characters */ + if (!(*p && *q)) + return (*p - *q); + diff = TOLOWER(*p) - TOLOWER(*q); + if (diff) + return diff; + } + /*NOTREACHED*/ +} + PRIVATE int getunicode ARGS1( char **, p0) { @@ -184,6 +207,7 @@ char this_MIMEcharset[UC_MAXLEN_MIMECSNAME +1]; char this_LYNXcharset[UC_MAXLEN_LYNXCSNAME +1]; char id_append[UC_MAXLEN_ID_APPEND +1] = "_"; int this_isDefaultMap = -1; +int useDefaultMap = 1; int lowest_eight = 999; PUBLIC int main ARGS2( @@ -267,6 +291,12 @@ PUBLIC int main ARGS2( * processing. One digit code. */ case 'R': + if (p[1] == 'a' || p[1] == 'A') { + buffer[sizeof(buffer) - 1] = '\0'; + if (!strncasecomp(p, "RawOrEnc", 8)) { + p += 8; + } + } p++; while (*p == ' ' || *p == '\t') { p++; @@ -276,17 +306,46 @@ PUBLIC int main ARGS2( continue; /* - * Is this the default display font? + * Is this the default table? */ case 'D': + if (p[1] == 'e' || p[1] == 'E') { + buffer[sizeof(buffer) - 1] = '\0'; + if (!strncasecomp(p, "Default", 7)) { + p += 7; + } + } + p++; + while (*p == ' ' || *p == '\t') { + p++; + } + this_isDefaultMap = (*p == '1' || TOLOWER(*p) == 'y'); + continue; + + /* + * Is this the default table? + */ + case 'F': + if (p[1] == 'a' || p[1] == 'A') { + buffer[sizeof(buffer) - 1] = '\0'; + if (!strncasecomp(p, "FallBack", 8)) { + p += 8; + } + } p++; while (*p == ' ' || *p == '\t') { p++; } - this_isDefaultMap = (*p == '1'); + useDefaultMap = (*p == '1' || tolower(*p) == 'y'); continue; case 'M': + if (p[1] == 'i' || p[1] == 'I') { + buffer[sizeof(buffer) - 1] = '\0'; + if (!strncasecomp(p, "MIMEName", 8)) { + p += 8; + } + } p++; while (*p == ' ' || *p == '\t') { p++; @@ -298,6 +357,12 @@ PUBLIC int main ARGS2( * Display charset name for options screen. */ case 'O': + if (p[1] == 'p' || p[1] == 'P') { + buffer[sizeof(buffer) - 1] = '\0'; + if (!strncasecomp(p, "OptionName", 10)) { + p += 10; + } + } p++; while (*p == ' ' || *p == '\t') { p++; @@ -635,12 +700,17 @@ static struct unipair_str repl_map%s[%d] = \n\ } if (themap_str.entry_ct) { printf("\n\ -static struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s};\n", +static struct unimapdesc_str dfont_replacedesc%s = {%d,repl_map%s,", id_append, themap_str.entry_ct, id_append); } else { printf("\n\ -static struct unimapdesc_str dfont_replacedesc%s = {0,NULL};\n",id_append); +static struct unimapdesc_str dfont_replacedesc%s = {0,NULL,",id_append); } + printf("%d,%d};\n", + this_isDefaultMap ? 1 : 0, + (useDefaultMap && !this_isDefaultMap) ? 1 : 0 + ); + printf("#define UC_CHARSET_SETUP%s UC_Charset_Setup(\ \"%s\",\\\n\"%s\",\\\n\ diff --git a/src/chrtrans/mnemonic_suni.tbl b/src/chrtrans/mnemonic_suni.tbl index 7f08408c..79d374a3 100644 --- a/src/chrtrans/mnemonic_suni.tbl +++ b/src/chrtrans/mnemonic_suni.tbl @@ -1,8 +1,11 @@ #The MIME name of this charset. -Mmnemonic +M mnemonic #Name as a Display Charset (used on Options screen) -ORFC 1345 Mnemonic +O RFC 1345 Mnemonic + +# Don't fall back to default table for unicode -> 8bit +Fallback NO # U+0020:&SP U+0021:! diff --git a/src/chrtrans/rfc_suni.tbl b/src/chrtrans/rfc_suni.tbl index 5df75265..4dd8b3f6 100644 --- a/src/chrtrans/rfc_suni.tbl +++ b/src/chrtrans/rfc_suni.tbl @@ -5,10 +5,13 @@ # mnemonic,ds #The MIME name of this charset. -Mmnemonic+ascii+0 +M mnemonic+ascii+0 #Name as a Display Charset (used on Options screen) -ORFC 1345 w/o Intro +O RFC 1345 w/o Intro + +# Don't fall back to default table for unicode -> 8bit +Fallback NO U+0020:SP U+0021:! diff --git a/src/makefile.dos b/src/makefile.dos index bb9c7f09..89d1c0ef 100644 --- a/src/makefile.dos +++ b/src/makefile.dos @@ -1,55 +1,63 @@ -OBJS= LYClean.o LYShowInfo.o LYEdit.o LYStrings.o \ -LYMail.o HTAlert.o GridText.o LYGetFile.o \ -LYMain.o LYMainLoop.o LYCurses.o LYBookmark.o LYUtils.o \ -LYOptions.o LYReadCFG.o LYSearch.o LYHistory.o \ -LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \ -HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \ -LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \ -LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o HTML.o - -CFLAGS= $(MCFLAGS) -I.. $(SLANGINC) - -CC = gcc -#MCFLAGS = -O -DNCURSES -DFANCY_CURSES -DACCESS_AUTH -DNO_CUSERID -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP -I../WWW/library/implementation -I../djgpp/tcplib/include -I../djgpp/tcplib/include/tcp -I../djgpp/pdcurses/include -MCFLAGS = -DCOLOR_CURSES -DNCURSES -DFANCY_CURSES -DACCESS_AUTH -DNO_CUSERID -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP -I../WWW/library/implementation -I../djgpp/tcplib/include -I../djgpp/tcplib/include/tcp -I../djgpp/pdcurses/include -WWWLIB = ../WWW/library/djgpp/libwww.a ../djgpp/pdcurses/lib/libcurso.a ../djgpp/tcplib/obj/libtcp.a - -all: lynx - -lynx: message $(OBJS) $(WWWLIB) - @echo "Linking and creating Lynx executable" - $(CC) $(CFLAGS) -o lynx $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS) - @echo "Welcome to Lynx!" - -message: - @echo "Compiling Lynx sources" - -dbg: $(OBJS) $(WWWLIB) - @echo "Making Lynx code" - $(CC) -g $(OBJS) $(CFLAGS) $(WWWLIB) $(SLANGLIB) $(LIBS) - -lint: - lint *.c > ../lint.out - -clean: - rm -f lynx core *.[ob] - -LYMain.o: ../userdefs.h -LYMainLoop.o: LYMainLoop.c ../userdefs.h -LYReadCFG.o: LYReadCFG.c ../userdefs.h -HTFWriter.o: HTFWriter.c ../userdefs.h -LYGetFile.o: LYGetFile.c ../userdefs.h -LYOptions.o: LYOptions.c ../userdefs.h -LYReadCFG.o: LYReadCFG.c ../userdefs.h -LYTraversal.o: LYTraversal.c ../userdefs.h -LYCharSets.o: LYCharSets.c ../userdefs.h -LYShowInfo.o: LYShowInfo.c ../userdefs.h -LYStrings.o: LYStrings.c ../userdefs.h -LYBookmark.o: LYBookmark.c ../userdefs.h -LYHistory.o: LYHistory.c ../userdefs.h -LYDownload.o: LYDownload.c ../userdefs.h -DefaultStyle.o: DefaultStyle.c ../userdefs.h -LYEditmap.o: LYEditmap.c ../userdefs.h -LYCharUtils.o: LYCharUtils.c ../userdefs.h -LYExtern.o: LYExtern.c ../userdefs.h - +OBJS= UCdomap.o UCAux.o UCAuto.o \ +LYClean.o LYShowInfo.o LYEdit.o LYStrings.o \ +LYMail.o HTAlert.o GridText.o LYGetFile.o \ +LYMain.o LYMainLoop.o LYCurses.o LYBookmark.o LYUtils.o \ +LYOptions.o LYReadCFG.o LYSearch.o LYHistory.o \ +LYForms.o LYPrint.o LYrcFile.o LYDownload.o LYNews.o LYKeymap.o \ +HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \ +LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \ +LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \ +LYStyle.o LYHash.o + +CFLAGS= $(MCFLAGS) -I.. $(SLANGINC) + +CC = gcc +MCFLAGS = -O3 -DALT_CHAR_SET -DUSE_ZLIB -DUSE_EXTERNALS -DNCURSES_VERSION -DEXP_CHARTRANS -DCOLOR_CURSES -DNCURSES -DFANCY_CURSES -DACCESS_AUTH -DNO_CUSERID -DNOUSERS -DDOSPATH -DNO_TTYTYPE -DNO_UTMP -I../WWW/library/implementation -I../curses -I../djgpp/tcplib/include -I../djgpp/tcplib/include/tcp +WWWLIB = ../WWW/library/djgpp/libwww.a ../curses/pdcurses.a ../djgpp/tcplib/obj/libtcp.a +LIBS=-lz + +all: lynx + +lynx: message $(OBJS) $(WWWLIB) + @echo "Linking and creating Lynx executable" + $(CC) $(CFLAGS) -o lynx $(OBJS) $(WWWLIB) $(SLANGLIB) $(LIBS) + @echo "Welcome to Lynx!" + +message: + @echo "Compiling Lynx sources" + +dbg: $(OBJS) $(WWWLIB) + @echo "Making Lynx code" + $(CC) -g $(OBJS) $(CFLAGS) $(WWWLIB) $(SLANGLIB) $(LIBS) + +lint: + lint *.c > ../lint.out + +clean: + rm -f lynx core *.[ob] + +LYMain.o: ../userdefs.h +LYMainLoop.o: LYMainLoop.c ../userdefs.h +LYReadCFG.o: LYReadCFG.c ../userdefs.h +HTFWriter.o: HTFWriter.c ../userdefs.h +LYGetFile.o: LYGetFile.c ../userdefs.h +LYOptions.o: LYOptions.c ../userdefs.h +LYReadCFG.o: LYReadCFG.c ../userdefs.h +LYTraversal.o: LYTraversal.c ../userdefs.h +LYCharSets.o: LYCharSets.c ../userdefs.h +LYShowInfo.o: LYShowInfo.c ../userdefs.h +LYStrings.o: LYStrings.c ../userdefs.h +LYBookmark.o: LYBookmark.c ../userdefs.h +LYHistory.o: LYHistory.c ../userdefs.h +LYDownload.o: LYDownload.c ../userdefs.h +DefaultStyle.o: DefaultStyle.c ../userdefs.h +LYEditmap.o: LYEditmap.c ../userdefs.h +LYCharUtils.o: LYCharUtils.c ../userdefs.h +LYExtern.o: LYExtern.c ../userdefs.h +LYCookie.o: ../userdefs.h + +#UCdomap.o: UCdomap.c ../userdefs.h lycharsets.h +#UCdomap.o: UCdomap.c chrtrans/UCkd.h chrtrans/makeuctb chrtrans/makeuctb.c \ +# UCdomap.h UCMap.h ../userdefs.h +#UCAux.o : UCAux.c $(CMN)UCAux.h $(CMN)UCDefs.h + |