diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 23 | ||||
-rw-r--r-- | src/HTFWriter.c | 7 | ||||
-rw-r--r-- | src/LYCharUtils.c | 30 | ||||
-rw-r--r-- | src/LYCurses.c | 6 | ||||
-rw-r--r-- | src/LYCurses.h | 2 | ||||
-rw-r--r-- | src/LYHash.h | 1 | ||||
-rw-r--r-- | src/LYKeymap.c | 4 | ||||
-rw-r--r-- | src/LYMain.c | 1 | ||||
-rw-r--r-- | src/LYMainLoop.c | 76 | ||||
-rw-r--r-- | src/LYMap.c | 2 | ||||
-rw-r--r-- | src/LYOptions.c | 10 | ||||
-rw-r--r-- | src/LYUtils.c | 22 | ||||
-rw-r--r-- | src/UCAuto.c | 3 | ||||
-rw-r--r-- | src/UCAux.c | 84 | ||||
-rw-r--r-- | src/UCdomap.c | 8 | ||||
-rw-r--r-- | src/chrtrans/def7_uni.tbl | 1 |
16 files changed, 181 insertions, 99 deletions
diff --git a/src/GridText.c b/src/GridText.c index 8baf4cb6..bf3e690d 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -5138,6 +5138,20 @@ static BOOL HText_endAnchor0(HText *text, int number, /* Find the length taken by the anchor */ l = text->Lines; /* lineno of last */ + + /* the last line of an anchor may contain a trailing blank, + * which will be trimmed later. Discount it from the extent. + */ + if (l > a->line_num) { + for (i = start->size; i > 0; --i) { + if (isspace(UCH(start->data[i - 1]))) { + --extent_adjust; + } else { + break; + } + } + } + while (l > a->line_num) { extent_adjust += start->size; start = start->prev; @@ -5873,8 +5887,7 @@ static void HText_trimHightext(HText *text, * Double check that we have a line pointer, and if so, copy into * highlight text. */ - if (line_ptr2 - && line_ptr2->size) { + if (line_ptr2) { char *hi_string = NULL; int hi_offset = line_ptr2->offset; @@ -6762,7 +6775,7 @@ const char *HText_getSugFname(void) */ void HTCheckFnameForCompression(char **fname, HTParentAnchor *anchor, - BOOL strip_ok) + BOOLEAN strip_ok) { char *fn = *fname; char *dot = NULL; @@ -9706,7 +9719,9 @@ int HText_beginInput(HText *text, BOOL underline, */ if (I->value) StrAllocCopy(IValue, I->value); - if (IValue && HTCJK != NOCJK) { + if (IValue && + HTCJK != NOCJK && + ((I->type == NULL) || strcasecomp(I->type, "hidden"))) { if ((tmp = typecallocn(unsigned char, strlen(IValue) * 2 + 1)) != 0) { if (kanji_code == EUC) { TO_EUC((unsigned char *) IValue, tmp); diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 116360c2..3fe384af 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -50,7 +50,7 @@ static char *FIXED_RECORD_COMMAND = NULL; #define FIXED_RECORD_COMMAND_MASK "@Lynx_Dir:FIXED512 %s" #else #define FIXED_RECORD_COMMAND_MASK "%s" -unsigned long LYVMS_FixedLengthRecords(char *filename); +static unsigned long LYVMS_FixedLengthRecords(char *filename); #endif /* USE_COMMAND_FILE */ #endif /* VMS */ @@ -340,11 +340,12 @@ static void HTFWriter_free(HTStream *me) start_curses(); #endif } - } else + } else { status = HTLoadFile(addr, me->anchor, me->output_format, me->sink); + } if (dump_output_immediately && me->output_format == HTAtom_for("www/present")) { FREE(addr); @@ -1280,7 +1281,7 @@ extern unsigned long sys$open(), sys$qiow(), sys$dassgn(); * Force a file to be marked as having fixed-length, 512 byte records * without implied carriage control, and with best_try_contiguous set. */ -unsigned long LYVMS_FixedLengthRecords(char *filename) +static unsigned long LYVMS_FixedLengthRecords(char *filename) { struct FAB fab; /* RMS file access block */ struct fibdef fib; /* XQP file information block */ diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 2a94aada..82dcb869 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -2607,11 +2607,10 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, while (*cp != '\0' && strncasecomp(cp, "filename", 8)) cp++; if (*cp != '\0') { - cp += 8; - while ((*cp != '\0') && (WHITE(*cp) || *cp == '=')) - cp++; - while (*cp != '\0' && WHITE(*cp)) + cp = LYSkipBlanks(cp + 8); + if (*cp == '=') cp++; + cp = LYSkipBlanks(cp); if (*cp != '\0') { StrAllocCopy(me->node_anchor->SugFname, cp); if (*me->node_anchor->SugFname == '"') { @@ -2619,21 +2618,26 @@ void LYHandleMETA(HTStructured * me, const BOOL *present, '"')) != NULL) { *(cp + 1) = '\0'; HTMIME_TrimDoubleQuotes(me->node_anchor->SugFname); + if (isEmpty(me->node_anchor->SugFname)) { + FREE(me->node_anchor->SugFname); + } } else { FREE(me->node_anchor->SugFname); } - if (me->node_anchor->SugFname != NULL && - *me->node_anchor->SugFname == '\0') { - FREE(me->node_anchor->SugFname); - } } +#if defined(UNIX) && !defined(DOSPATH) + /* + * If blanks are not legal for local filenames, replace them + * with underscores. + */ if ((cp = me->node_anchor->SugFname) != NULL) { - while (*cp != '\0' && !WHITE(*cp)) - cp++; - *cp = '\0'; - if (*me->node_anchor->SugFname == '\0') - FREE(me->node_anchor->SugFname); + while (*cp != '\0') { + if (isspace(UCH(*cp))) + *cp = '_'; + ++cp; + } } +#endif } } /* diff --git a/src/LYCurses.c b/src/LYCurses.c index 439d8d40..d1ad011b 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -450,7 +450,7 @@ void curses_w_style(WINDOW * win, int style, if (style == s_normal && dir) { LYAttrset(win, ds->color, ds->mono); - if (win == LYwin) + if (win == LYwin && CACHE_VALIDATE_YX(YP, XP)) cached_styles[YP][XP] = s_normal; return; } @@ -496,7 +496,7 @@ void curses_w_style(WINDOW * win, int style, && style != s_aedit_arr) { CTRACE2(TRACE_STYLE, (tfp, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP)); - if (win == LYwin) + if (win == LYwin && CACHE_VALIDATE_YX(YP, XP)) cached_styles[YP][XP] = style; } LYAttrset(win, ds->color, ds->mono); @@ -2772,7 +2772,7 @@ long LYgetattrs(WINDOW * win) NCURSES_CONST char *unctrl(chtype ch) { static char result[3]; - unsigned data = (unsigned char)ch; + unsigned data = (unsigned char) ch; if (data < 32) { result[0] = '^'; diff --git a/src/LYCurses.h b/src/LYCurses.h index 547a9117..abe30e7e 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -538,7 +538,7 @@ extern "C" { buf = (ch) | (Current_Attr << 4); \ SLsmg_write_raw (&buf, 1); \ } while (0) -#endif /* SLANG_VERSION >= 20000 */ +#endif /* SLANG_VERSION >= 20000 */ #define echo() #define printw SLsmg_printf diff --git a/src/LYHash.h b/src/LYHash.h index f8aaf4a2..448fe42c 100644 --- a/src/LYHash.h +++ b/src/LYHash.h @@ -80,6 +80,7 @@ extern "C" { #define CACHEH 64 extern unsigned cached_styles[CACHEH][CACHEW]; +#define CACHE_VALIDATE_YX(y, x) ((y) >= 0 && (x) >= 0 && (y) < CACHEH && (x) < CACHEW) #ifdef __cplusplus } diff --git a/src/LYKeymap.c b/src/LYKeymap.c index a9e41625..4cb45b8d 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -1761,8 +1761,8 @@ char *key_for_func_ext(int lac, * This function returns TRUE if the ch is non-alphanumeric and maps to KeyName * (LYK_foo in the keymap[] array). - FM */ -BOOL LYisNonAlnumKeyname(int ch, - int KeyName) +BOOLEAN LYisNonAlnumKeyname(int ch, + int KeyName) { if (ch < 0 || ch >= KEYMAP_SIZE) return (FALSE); diff --git a/src/LYMain.c b/src/LYMain.c index b9cc453f..f7375bc3 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -3167,7 +3167,6 @@ static int version_fun(char *next_arg GCC_UNUSED) puts(gettext("See http://lynx.isc.org/ and the online help for more information.")); puts(""); #ifdef USE_SSL - puts("See http://www.moxienet.com/lynx/ for information about SSL for Lynx."); #ifdef OPENSSL_VERSION_TEXT puts("See http://www.openssl.org/ for information about OpenSSL."); #endif /* OPENSSL_VERSION_TEXT */ diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 27ec6c65..95c9026b 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -2197,17 +2197,18 @@ static int handle_LYK_DOWNLOAD(int *cmd, return 0; } -static void handle_LYK_DOWN_HALF(int *old_c, - int real_c) +static void handle_LYK_DOWN_xxx(int *old_c, + int real_c, + int scroll_by) { int i; if (more_text) { - Newline += (display_lines / 2); + Newline += scroll_by; if (nlinks > 0 && curdoc.link > -1 && - links[curdoc.link].ly > display_lines / 2) { + links[curdoc.link].ly > scroll_by) { newdoc.link = curdoc.link; - for (i = 0; links[i].ly <= (display_lines / 2); i++) + for (i = 0; links[i].ly <= scroll_by; i++) --newdoc.link; } } else if (*old_c != real_c) { @@ -2216,6 +2217,12 @@ static void handle_LYK_DOWN_HALF(int *old_c, } } +static void handle_LYK_DOWN_HALF(int *old_c, + int real_c) +{ + handle_LYK_DOWN_xxx(old_c, real_c, display_lines / 2); +} + static void handle_LYK_DOWN_LINK(int *follow_col, int *old_c, int real_c) @@ -2254,20 +2261,7 @@ static void handle_LYK_DOWN_LINK(int *follow_col, static void handle_LYK_DOWN_TWO(int *old_c, int real_c) { - int i; - - if (more_text) { - Newline += 2; - if (nlinks > 0 && curdoc.link > -1 && - links[curdoc.link].ly > 2) { - newdoc.link = curdoc.link; - for (i = 0; links[i].ly <= 2; i++) - --newdoc.link; - } - } else if (*old_c != real_c) { - *old_c = real_c; - HTInfoMsg(ALREADY_AT_END); - } + handle_LYK_DOWN_xxx(old_c, real_c, 2); } static int handle_LYK_DWIMEDIT(int *cmd, @@ -4587,22 +4581,21 @@ static void handle_LYK_UPLOAD(void) } #endif /* DIRED_SUPPORT */ -static void handle_LYK_UP_HALF(int *arrowup, - int *old_c, - int real_c) +static void handle_LYK_UP_xxx(int *arrowup, + int *old_c, + int real_c, + int scroll_by) { if (LYGetNewline() > 1) { - int scrollamount = display_lines / 2; - - if (LYGetNewline() - scrollamount < 1) - scrollamount = LYGetNewline() - 1; - Newline -= scrollamount; + if (LYGetNewline() - scroll_by < 1) + scroll_by = LYGetNewline() - 1; + Newline -= scroll_by; if (nlinks > 0 && curdoc.link > -1) { - if (links[curdoc.link].ly + scrollamount <= display_lines) { + if (links[curdoc.link].ly + scroll_by <= display_lines) { newdoc.link = curdoc.link + HText_LinksInLines(HTMainText, LYGetNewline(), - scrollamount); + scroll_by); } else { *arrowup = TRUE; } @@ -4613,6 +4606,13 @@ static void handle_LYK_UP_HALF(int *arrowup, } } +static void handle_LYK_UP_HALF(int *arrowup, + int *old_c, + int real_c) +{ + handle_LYK_UP_xxx(arrowup, old_c, real_c, display_lines / 2); +} + static void handle_LYK_UP_LINK(int *follow_col, int *arrowup, int *old_c, @@ -4668,23 +4668,7 @@ static void handle_LYK_UP_TWO(int *arrowup, int *old_c, int real_c) { - if (LYGetNewline() > 1) { - int scrollamount = (LYGetNewline() > 2 ? 2 : 1); - - Newline -= scrollamount; - if (nlinks > 0 && curdoc.link > -1) { - if (links[curdoc.link].ly + scrollamount <= display_lines) { - newdoc.link = curdoc.link + - HText_LinksInLines(HTMainText, - LYGetNewline(), scrollamount); - } else { - *arrowup = TRUE; - } - } - } else if (*old_c != real_c) { - *old_c = real_c; - HTInfoMsg(ALREADY_AT_BEGIN); - } + handle_LYK_UP_xxx(arrowup, old_c, real_c, 2); } static void handle_LYK_VIEW_BOOKMARK(BOOLEAN *refresh_screen, diff --git a/src/LYMap.c b/src/LYMap.c index 9fd0e073..53384d9b 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -625,7 +625,7 @@ void LYPrintImgMaps(FILE *fp) while (NULL != (elt = (LYMapElement *) HTList_nextObject(inner))) { fprintf(fp, "%4d. %s", ++count, elt->address); #ifndef DONT_TRACK_INTERNAL_LINKS - if (map->intern_flag) + if (elt->intern_flag) fprintf(fp, " TYPE=\"internal link\""); #endif fprintf(fp, "\n"); diff --git a/src/LYOptions.c b/src/LYOptions.c index fffa9011..85ec2390 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -33,16 +33,20 @@ BOOLEAN term_options; #define MARGIN_STR (no_margins ? "" : " ") #define MARGIN_LEN (no_margins ? 0 : 2) -static int LYChosenShowColor = SHOW_COLOR_UNKNOWN; /* whether to show and save */ - static void terminate_options(int sig); #define COL_OPTION_VALUES 36 /* display column where option values start */ +#ifndef NO_OPTION_MENU + #if defined(USE_SLANG) || defined(COLOR_CURSES) static BOOLEAN can_do_colors = FALSE; #endif +static int LYChosenShowColor = SHOW_COLOR_UNKNOWN; /* whether to show and save */ + +#endif /* NO_OPTION_MENU */ + BOOLEAN LYCheckUserAgent(void) { if (non_empty(LYUserAgent)) { @@ -56,6 +60,7 @@ BOOLEAN LYCheckUserAgent(void) return TRUE; } +#ifndef NO_OPTION_MENU static void SetupChosenShowColor(void) { #if defined(USE_SLANG) || defined(COLOR_CURSES) @@ -123,7 +128,6 @@ static void summarize_x_display(char *display_option) } } -#ifndef NO_OPTION_MENU static int boolean_choice(int status, int line, int column, diff --git a/src/LYUtils.c b/src/LYUtils.c index 5bb16f50..10d6442c 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -958,7 +958,7 @@ static int find_cached_style(int cur, * change saved at just the right position, we look at preceding * positions in the same line until we find one. */ - if (LYP >= 0 && LYP < CACHEH && LXP >= 0 && LXP < CACHEW) { + if (CACHE_VALIDATE_YX(LYP, LXP)) { CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.off: cached style @(%d,%d): ", LYP, LXP)); @@ -3356,22 +3356,24 @@ static int fmt_tempname(char *result, * support long filenames. */ counter = MAX_TEMPNAME; - while (names_used < MAX_TEMPNAME) { + if (names_used < MAX_TEMPNAME) { counter = (unsigned) (((float) MAX_TEMPNAME * lynx_rand()) / LYNX_RAND_MAX + 1); - counter %= SIZE_TEMPNAME; /* just in case... */ /* * Avoid reusing a temporary name, since there are places in the code * which can refer to a temporary filename even after it has been * closed and removed from the filesystem. */ - offset = counter / BITS_PER_CHAR; - mask = 1 << (counter % BITS_PER_CHAR); - if ((used_tempname[offset] & mask) == 0) { - names_used++; - used_tempname[offset] |= mask; - break; - } + do { + counter %= MAX_TEMPNAME; + offset = counter / BITS_PER_CHAR; + mask = 1 << (counter % BITS_PER_CHAR); + if ((used_tempname[offset] & mask) == 0) { + names_used++; + used_tempname[offset] |= mask; + break; + } + } while ((used_tempname[offset] & mask) == 0); } if (names_used >= MAX_TEMPNAME) HTAlert(gettext("Too many tempfiles")); diff --git a/src/UCAuto.c b/src/UCAuto.c index 12f82b69..5898c212 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -244,7 +244,8 @@ void UCChangeTerminalCodepage(int newcs, char *tmpbuf2 = NULL; int status = 0; - if (!on_console()) return; + if (!on_console()) + return; #ifdef HAVE_USE_LEGACY_CODING if (newcs < 0) { diff --git a/src/UCAux.c b/src/UCAux.c index d0817260..f7114fd4 100644 --- a/src/UCAux.c +++ b/src/UCAux.c @@ -6,6 +6,7 @@ #include <HTStream.h> #include <UCAux.h> #include <LYCharSets.h> +#include <LYCurses.h> BOOL UCCanUniTranslateFrom(int from) { @@ -338,16 +339,83 @@ void UCSetBoxChars(int cset, * confuse curses. */ #ifdef EXP_CHARTRANS_AUTOSWITCH - if (linedrawing_char_set >= 0) { - /* US-ASCII vs Latin-1 is safe (usually) */ - if (cset == US_ASCII && linedrawing_char_set == LATIN1) { - ; - } else if (cset == LATIN1 && linedrawing_char_set == US_ASCII) { - ; - } else if (cset != linedrawing_char_set) { - fix_lines = TRUE; + /* US-ASCII vs Latin-1 is safe (usually) */ + if (cset == US_ASCII && linedrawing_char_set == LATIN1) { + ; + } else if (cset == LATIN1 && linedrawing_char_set == US_ASCII) { + ; + } +#if defined(NCURSES_VERSION) || defined(HAVE_TIGETSTR) + else { + static BOOL first = TRUE; + static int last_cset = -99; + static BOOL last_result = TRUE; + /* *INDENT-OFF* */ + static struct { + int mapping; + int internal; + int external; + } table[] = { + { 'j', 0x2518, 0 }, /* BOX DRAWINGS LIGHT UP AND LEFT */ + { 'k', 0x2510, 0 }, /* BOX DRAWINGS LIGHT DOWN AND LEFT */ + { 'l', 0x250c, 0 }, /* BOX DRAWINGS LIGHT DOWN AND RIGHT */ + { 'm', 0x2514, 0 }, /* BOX DRAWINGS LIGHT UP AND RIGHT */ + { 'n', 0x253c, 0 }, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */ + { 'q', 0x2500, 0 }, /* BOX DRAWINGS LIGHT HORIZONTAL */ + { 't', 0x251c, 0 }, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT */ + { 'u', 0x2524, 0 }, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT */ + { 'v', 0x2534, 0 }, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL */ + { 'w', 0x252c, 0 }, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */ + { 'x', 0x2502, 0 }, /* BOX DRAWINGS LIGHT VERTICAL */ + }; + /* *INDENT-ON* */ + + unsigned n; + + if (first) { + char *map = tigetstr("acsc"); + + if (map != 0) { + CTRACE((tfp, "check terminal line-drawing map\n")); + while (map[0] != 0 && map[1] != 0) { + for (n = 0; n < TABLESIZE(table); ++n) { + if (table[n].mapping == map[0]) { + table[n].external = UCH(map[1]); + CTRACE((tfp, " map[%c] %#x -> %#x\n", + table[n].mapping, + table[n].internal, + table[n].external)); + break; + } + } + map += 2; + } + } + first = FALSE; + } + + if (cset == last_cset) { + fix_lines = last_result; + } else { + for (n = 0; n < TABLESIZE(table); ++n) { + int test = UCTransUniChar(table[n].internal, cset); + + if (test != table[n].external) { + CTRACE((tfp, "line-drawing map %c mismatch\n", + table[n].mapping)); + fix_lines = TRUE; + break; + } + } + last_result = fix_lines; + last_cset = cset; } } +#else + else if (cset != linedrawing_char_set && linedrawing_char_set >= 0) { + fix_lines = TRUE; + } +#endif #endif } if (fix_lines) { diff --git a/src/UCdomap.c b/src/UCdomap.c index febd348e..ec1a6dcb 100644 --- a/src/UCdomap.c +++ b/src/UCdomap.c @@ -941,6 +941,7 @@ int UCTransUniCharStr(char *outbuf, iconv_t cd; char str[3], *pin, *pout; size_t inleft, outleft; + char *tocode = NULL; str[0] = unicode >> 8; str[1] = unicode & 0xFF; @@ -948,9 +949,10 @@ int UCTransUniCharStr(char *outbuf, pin = str; inleft = 2; pout = outbuf, outleft = buflen; - cd = iconv_open(LYCharSet_UC[charset_out].MIMEname, - "UTF-16BE//TRANSLIT"); - rc = iconv(cd, &pin, &inleft, &pout, &outleft); + HTSprintf0(&tocode, "%s//TRANSLIT", LYCharSet_UC[charset_out].MIMEname); + cd = iconv_open(tocode, "UTF-16BE"); + FREE(tocode) + rc = iconv(cd, &pin, &inleft, &pout, &outleft); iconv_close(cd); if ((pout - outbuf) == 3) { CTRACE((tfp, diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index 211e2614..e7e0799b 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -1457,6 +1457,7 @@ U+2135 "Aleph " U+2136 "Bet " U+2137 "Gimel " U+2138 "Dalet " +U+213B: FAX U+2153: 1/3 U+2154: 2/3 U+2155: 1/5 |