diff options
| author | Thomas E. Dickey <dickey@invisible-island.net> | 1997-05-25 00:16:10 -0400 |
|---|---|---|
| committer | Thomas E. Dickey <dickey@invisible-island.net> | 1997-05-25 00:16:10 -0400 |
| commit | 945e8eb6bb07f64aaca42207af3311220ff2e4ba (patch) | |
| tree | 6afb50262b844dd069bd4f7234da68008c48677c /src | |
| parent | e4409c408eedf320b8845cafdd62b664bec1afd8 (diff) | |
| download | lynx-snapshots-945e8eb6bb07f64aaca42207af3311220ff2e4ba.tar.gz | |
snapshot of project "lynx", label v2-7-1ac_0-28
Diffstat (limited to 'src')
60 files changed, 6155 insertions, 935 deletions
diff --git a/src/AttrList.h b/src/AttrList.h new file mode 100644 index 00000000..d0a95c3c --- /dev/null +++ b/src/AttrList.h @@ -0,0 +1,65 @@ +#if !defined(__ATTRLIST_H) +#define __ATTRLIST_H + +#include "HText.h" +#include "HTMLDTD.h" + +#define TEMPSTRINGSIZE 256 + +enum { + ABS_OFF = 0, + STACK_OFF = 0, + STACK_ON, + ABS_ON +}; + +#define STARTAT 8 + +enum { + DSTYLE_LINK = HTML_A+STARTAT, + DSTYLE_STATUS = HTML_ELEMENTS+STARTAT, + DSTYLE_ALINK, /* active link */ + DSTYLE_NORMAL, /* default attributes */ + DSTYLE_OPTION, /* option on the option screen */ + DSTYLE_VALUE, /* value on the option screen */ + DSTYLE_HIGH, + DSTYLE_CANDY, /* possibly going to vanish */ + DSTYLE_ELEMENTS +}; + +enum { + MSTYLE_NORMAL = 0, + MSTYLE_EM = 1, + MSTYLE_STRONG = 2, + MSTYLE_PHYSICAL = 3, + MSTYLE_A = 4, + MSTYLE_A_OFF = 4, + MSTYLE_A_ON, + MSTYLE_BOLD, + MSTYLE_UL, + MSTYLE_STATUS, + MSTYLE_CANDY, + MSTYLE_NOMORE +}; + +typedef struct { + int color; /* color highlighting to be done */ + int mono; /* mono highlighting to be done */ + int cattr; /* attributes to go with the color */ +} HTCharStyle; + +typedef struct _linkedlist { + char name[64]; + struct _linkedlist *next; +} linked_list; + +#define HText_characterStyle if(TRACE)fprintf(stderr,"HTC called from %s/%d\n",__FILE__,__LINE__);_internal_HTC + +#undef HText_characterStyle +#define HText_characterStyle _internal_HTC + +#if defined(USE_COLOR_STYLE) +extern void _internal_HTC PARAMS((HText * text, int style, int dir)); +#endif + +#endif diff --git a/src/DefaultStyle.c b/src/DefaultStyle.c index b4ee349a..974a27db 100644 --- a/src/DefaultStyle.c +++ b/src/DefaultStyle.c @@ -284,7 +284,7 @@ PRIVATE HTStyle HTStylePreformatted = { &HTStyleExample, "Preformatted", "PRE", HT_FONT, 1.0, HT_BLACK, 0, 0, 0, 0, 0, HT_LEFT, 1, 0, tabs_8, - NO, YES, 0, 0, 0 + NO, NO, 0, 0, 0 }; PRIVATE HTStyle HTStyleListing = { diff --git a/src/GridText.c b/src/GridText.c index ef0c7de5..179cbeed 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -13,6 +13,7 @@ #include "GridText.h" #include "HTFont.h" #include "HTAccess.h" +#include "HTAnchor.h" #include "HTParse.h" #include "HTTP.h" #include "HTAlert.h" @@ -44,6 +45,26 @@ #endif /* SYSLOG_REQUESTED_URLS */ #endif /* !VMS */ +#ifdef USE_COLOR_STYLE +#include "AttrList.h" +#include "LYHash.h" + +unsigned cached_styles[CACHEH][CACHEW]; + +#endif + +#ifdef USE_COLOR_STYLE_UNUSED +void LynxClearScreenCache NOARGS +{ + int i,j; +if (TRACE) + fprintf(stderr, "flushing cached screen styles\n"); + for (i=0;i<CACHEH;i++) + for (j=0;j<CACHEW;j++) + cached_styles[i][j]=s_a; +} +#endif /* USE_COLOR_STYLE */ + struct _HTStream { /* only know it as object */ CONST HTStreamClass * isa; /* ... */ @@ -86,6 +107,17 @@ PUBLIC char * unchecked_radio = "( )"; PUBLIC BOOLEAN underline_on = OFF; PUBLIC BOOLEAN bold_on = OFF; +#if defined(USE_COLOR_STYLE) || defined(SLCS) +#define MAX_STYLES_ON_LINE 64 + +typedef struct _stylechange { + int horizpos; /* horizontal position of this change */ + int style; /* which style to change to */ + int direction; /* on or off */ + int previous; /* previous style */ +} HTStyleChange; +#endif + typedef struct _line { struct _line *next; struct _line *prev; @@ -93,6 +125,10 @@ typedef struct _line { int unsigned size; /* Number of characters */ BOOL split_after; /* Can we split after? */ BOOL bullet; /* Do we bullet? */ +#if defined(USE_COLOR_STYLE) || defined(SLCS) + HTStyleChange styles[MAX_STYLES_ON_LINE]; + int numstyles; +#endif char data[1]; /* Space for terminator at least! */ } HTLine; @@ -102,13 +138,13 @@ typedef struct _TextAnchor { struct _TextAnchor * next; int number; /* For user interface */ int start; /* Characters */ - int line_pos; /* Position in text */ - int extent; /* Characters */ + int line_pos; /* Position in text */ + int extent; /* Characters */ int line_num; /* Place in document */ - char * hightext; /* The link text */ - char * hightext2; /* A second line*/ - int hightext2offset;/* offset from left */ - int link_type; /* Normal or form? */ + char * hightext; /* The link text */ + char * hightext2; /* A second line*/ + int hightext2offset;/* offset from left */ + int link_type; /* Normal, internal, or form? */ FormInfo * input_field; /* Info for form links */ BOOL show_anchor; /* Show the anchor? */ HTChildAnchor * anchor; @@ -136,6 +172,7 @@ struct _HText { BOOL source; /* Is the text source? */ BOOL toolbar; /* Toolbar set? */ HTList * tabs; /* TAB IDs */ + HTList * hidden_links; /* Content-less links */ BOOL no_cache; /* Always refresh? */ char LastChar; /* For aborbing white space */ BOOL IgnoreExcess; /* Ignore chars at wrap point */ @@ -149,24 +186,28 @@ struct _HText { int permissible_split; /* in last line */ BOOL in_line_1; /* of paragraph */ BOOL stale; /* Must refresh */ + BOOL page_has_target; /* has target on screen */ - HTkcode kcode; /* Kanji code? */ - enum grid_state { S_text, S_esc, S_dollar, S_paren, + HTkcode kcode; /* Kanji code? */ + enum grid_state { S_text, S_esc, S_dollar, S_paren, S_nonascii_text, S_dollar_paren, S_jisx0201_text } state; /* Escape sequence? */ char kanji_buf; /* Lead multibyte */ int in_sjis; /* SJIS flag */ - HTStream* target; /* Output stream */ - HTStreamClass targetClass; /* Output routines */ + HTStream* target; /* Output stream */ + HTStreamClass targetClass; /* Output routines */ #ifdef EXP_CHARTRANS - LYUCcharset * UCI; /* pointer to node_anchor's UCInfo */ - int UCLYhndl; /* tells us what charset we are fed */ - UCTransParams T; + LYUCcharset * UCI; /* pointer to node_anchor's UCInfo */ + int UCLYhndl; /* tells us what charset we are fed */ + UCTransParams T; + BOOL have_8bit_chars; /* Any non-ASCII characters? */ #endif }; +PRIVATE void HText_AddHiddenLink PARAMS((HText *text, TextAnchor *textanchor)); + /* * Boring static variable used for moving cursor across */ @@ -275,6 +316,9 @@ PUBLIC HText * HText_new ARGS1( outofmem(__FILE__, "HText_New"); line->next = line->prev = line; line->offset = line->size = 0; +#ifdef USE_COLOR_STYLE + line->numstyles = 0; +#endif self->Lines = self->chars = 0; self->first_anchor = self->last_anchor = NULL; self->style = &default_style; @@ -284,6 +328,7 @@ PUBLIC HText * HText_new ARGS1( self->stale = YES; self->toolbar = NO; self->tabs = NULL; + self->hidden_links = NULL; self->no_cache = ((anchor->no_cache || anchor->post_data) ? YES : NO); self->LastChar = '\0'; @@ -302,6 +347,7 @@ PUBLIC HText * HText_new ARGS1( self->state = S_text; self->kanji_buf = '\0'; self->in_sjis = 0; + self->have_8bit_chars = NO; #ifdef EXP_CHARTRANS htext_get_chartrans_info(self); @@ -454,6 +500,20 @@ PUBLIC void HText_free ARGS1( FREE(Tab->name); } HTList_delete(self->tabs); + self->tabs = NULL; + } + + /* + * Free the hidden links list. - FM + */ + if (self->hidden_links) { + char * href = NULL; + HTList * cur = self->hidden_links; + + while (NULL != (href = (char *)HTList_nextObject(cur))) + FREE(href); + HTList_delete(self->hidden_links); + self->hidden_links = NULL; } /* @@ -467,7 +527,11 @@ PUBLIC void HText_free ARGS1( HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_HTEXT, UCT_SETBY_NONE); #endif /* EXP_CHARTRANS */ - HTAnchor_delete(self->node_anchor); + if (HTAnchor_delete(self->node_anchor)) + /* + * Make sure HTMainAnchor won't point to an invalid structure. - kw + */ + HTMainAnchor = NULL; } FREE(self); @@ -489,7 +553,11 @@ PRIVATE int display_line ARGS2( char buffer[7]; char *data; #ifdef EXP_CHARTRANS - int utf_extra = 0; + size_t utf_extra = 0; +#endif +#ifdef USE_COLOR_STYLE + int current_style = 0; + int real_position = 0; #endif buffer[0] = buffer[1] = buffer[2] = '\0'; @@ -511,39 +579,51 @@ PRIVATE int display_line ARGS2( /* add data */ data = line->data; i++; +#ifdef USE_COLOR_STYLE + real_position = i; +#endif while ((i < LYcols) && ((buffer[0] = *data) != '\0')) { data++; - i++; +#if defined(USE_COLOR_STYLE) || defined(SLSC) +#define CStyle line->styles[current_style] + + while (current_style < line->numstyles && + i >= CStyle.horizpos + line->offset + 1) + { + (void) LynxChangeStyle (CStyle.style,CStyle.direction,CStyle.previous); + current_style++; + } +#endif switch (buffer[0]) { +#ifndef USE_COLOR_STYLE case LY_UNDERLINE_START_CHAR: - if (!(dump_output_immediately && use_underscore)) { - start_underline(); - i--; + if (dump_output_immediately && use_underscore) { + addch ('_'); + i++; } else { - addch('_'); + lynx_start_underline_color (); } break; case LY_UNDERLINE_END_CHAR: - if (!(dump_output_immediately && use_underscore)) { - stop_underline(); - i--; + if (dump_output_immediately && use_underscore) { + addch ('_'); + i++; } else { - addch('_'); + lynx_stop_underline_color (); } break; case LY_BOLD_START_CHAR: - start_bold(); - i--; + lynx_start_bold_color (); break; case LY_BOLD_END_CHAR: - stop_bold (); - i--; + lynx_stop_bold_color (); break; +#endif case LY_SOFT_HYPHEN: if (*data != '\0') { @@ -551,16 +631,17 @@ PRIVATE int display_line ARGS2( * Ignore the soft hyphen if it is not * the last character in the line. - FM */ - i--; break; } else { /* * Make it a hard hyphen and fall through. - FM */ buffer[0] = '-'; + i++; } default: + i++; #ifdef EXP_CHARTRANS if (text->T.output_utf8 && !isascii(buffer[0])) { if ((*buffer & 0xe0) == 0xc0) { @@ -604,8 +685,17 @@ PRIVATE int display_line ARGS2( /* add the return */ addch('\n'); - stop_underline(); - stop_bold(); +#ifndef USE_COLOR_STYLE + lynx_stop_underline_color (); + lynx_stop_bold_color (); +#else + while (current_style < line->numstyles) + { + (void) LynxChangeStyle (CStyle.style, CStyle.direction, CStyle.previous); + current_style++; + } +#undef CStyle +#endif return(0); } @@ -616,7 +706,10 @@ PRIVATE void display_title ARGS1( HText *, text) { char *title = NULL; - char percent[20], format[20]; + char percent[20]; +#ifdef NOTDEFINED + char format[20]; +#endif char *cp = NULL; unsigned char *tmp = NULL; int i = 0, j = 0; @@ -627,6 +720,8 @@ PRIVATE void display_title ARGS1( if (!text) return; + lynx_start_title_color (); + /* * Load the title field. - FM */ @@ -670,12 +765,18 @@ PRIVATE void display_title ARGS1( /* * Generate format string. */ +#ifdef NOTDEFINED + /* Using this kind of format string, sprintf() didn't always get it + right at least on solaris if the title string contained some 8-bit + characters. - kw + */ sprintf(format, "%s%%%d.%ds%%s\n", ((text->top_of_screen > 0 && HText_hasToolbar(text)) ? "#" : " "), (LYcols-2)-strlen(percent), (LYcols-2)-strlen(percent)); +#endif /* NOTDEFINED */ /* * Generate and display the complete title string. @@ -697,18 +798,39 @@ PRIVATE void display_title ARGS1( } } } - sprintf(cp, format, tmp, percent); - FREE(tmp); - } else { - sprintf(cp, format, title, percent); + FREE(title); + title = tmp; } - } else { - sprintf(cp, format, title, percent); } + move(0,0); + clrtoeol(); + if (text->top_of_screen > 0 && HText_hasToolbar(text)) { + addch('#'); + } + + i = (LYcols-2)-strlen(percent); + if ((i = (LYcols-1) - strlen(percent) - strlen(title)) > 0) { + move(0,i); + } else { + title[LYcols - 2 - strlen(percent)] = '\0'; + move(0,1); + } + sprintf(cp, "%s%s\n", title, percent); +#ifdef USE_COLOR_STYLE +/* turn the TITLE style on */ + LynxChangeStyle(s_title, ABS_ON, 0); + addstr(cp); +/* turn the TITLE style off */ + LynxChangeStyle(s_title, ABS_OFF, 0); +#else addstr(cp); +#endif FREE(cp); FREE(title); + + lynx_stop_title_color (); + return; } @@ -728,11 +850,15 @@ PRIVATE void display_page ARGS3( TextAnchor *Anchor_ptr = NULL; FormInfo *FormInfo_ptr; BOOL display_flag = FALSE; - HTAnchor *link_dest; + HTAnchor *link_dest, *link_dest_intl = NULL; static int last_nlinks = 0; #ifdef EXP_CHARTRANS int utf_found = 0; +#ifdef EXP_CHARTRANS_AUTOSWITCH +#ifdef LINUX static int charset_last_displayed = -1; +#endif +#endif #endif /* EXP_CHARTRANS */ lynx_mode = NORMAL_LYNX_MODE; @@ -755,6 +881,7 @@ PRIVATE void display_page ARGS3( } tmp[0] = tmp[1] = tmp[2] = '\0'; + text->page_has_target = NO; last_screen = text->Lines - (display_lines-2); line = text->last_line->prev; @@ -784,8 +911,20 @@ PRIVATE void display_page ARGS3( LYCursesON) { charset_last_displayed = current_char_set; stop_curses(); + if (LYTraceLogFP) + /* + * Set stderr back to its original value, + * because the current UCChangeTerminalCodepage() + * writes escape sequences to stderr. - kw + */ + *stderr = LYOrigStderr; UCChangeTerminalCodepage(current_char_set, - &LYCharSet_UC[current_char_set]); + &LYCharSet_UC[current_char_set]); + if (LYTraceLogFP) + /* + * Set stderr back to the log file on return. + */ + *stderr = *LYTraceLogFP; start_curses(); } #endif /* LINUX */ @@ -846,12 +985,12 @@ PRIVATE void display_page ARGS3( int x_pos=(int)line->offset + (int)(cp - line->data); int len = strlen(target); #ifdef EXP_CHARTRANS - int utf_extra = 0; + size_t utf_extra = 0; #endif /* EXP_CHARTRANS */ - start_bold(); - start_reverse(); - start_underline(); + text->page_has_target = YES; + + lynx_start_target_color (); /* underline string */ for (; written < len && (tmp[0] = line->data[itmp]) != '\0'; itmp++) { @@ -946,9 +1085,7 @@ PRIVATE void display_page ARGS3( } } - stop_underline(); - stop_reverse(); - stop_bold(); + lynx_stop_target_color (); move(i+2, 0); } @@ -986,7 +1123,7 @@ PRIVATE void display_page ARGS3( /* load normal hypertext anchors */ if (Anchor_ptr->show_anchor && Anchor_ptr->hightext && strlen(Anchor_ptr->hightext)>0 && - Anchor_ptr->link_type == HYPERTEXT_ANCHOR) { + (Anchor_ptr->link_type & HYPERTEXT_ANCHOR)) { links[nlinks].hightext = Anchor_ptr->hightext; links[nlinks].hightext2 = Anchor_ptr->hightext2; @@ -1004,9 +1141,31 @@ PRIVATE void display_page ARGS3( auto char *cp_AnchorAddress = NULL; if (traversal) cp_AnchorAddress = stub_HTAnchor_address(link_dest); - else - cp_AnchorAddress = HTAnchor_address(link_dest); - + else { + if (Anchor_ptr->link_type == INTERNAL_LINK_ANCHOR) { + link_dest_intl = HTAnchor_followTypedLink( + (HTAnchor *)Anchor_ptr->anchor, LINK_INTERNAL); + if (link_dest_intl && link_dest_intl != link_dest) { + if (TRACE) + fprintf(stderr, + "display_page: unexpected typed link to %s!\n", + link_dest_intl->parent->address); + link_dest_intl = NULL; + } + } else + link_dest_intl = NULL; + if (link_dest_intl) { + char *cp2 = HTAnchor_address(link_dest_intl); + cp = strchr(cp2, '#'); + if (cp && cp != cp2 && + 0!=strncmp(cp2, "LYNXIMGMAP:", 11)) { + StrAllocCopy(cp_AnchorAddress, cp); + FREE(cp2); + } else + cp_AnchorAddress = cp2; + } else + cp_AnchorAddress = HTAnchor_address(link_dest); + } FREE(links[nlinks].lname); if (cp_AnchorAddress != NULL) @@ -1017,8 +1176,12 @@ PRIVATE void display_page ARGS3( links[nlinks].lx = Anchor_ptr->line_pos; links[nlinks].ly = (Anchor_ptr->line_num+1)-line_number; - links[nlinks].type = WWW_LINK_TYPE; + if (link_dest_intl) + links[nlinks].type = WWW_INTERN_LINK_TYPE; + else + links[nlinks].type = WWW_LINK_TYPE; links[nlinks].target = empty_string; + links[nlinks].form = NULL; nlinks++; display_flag = TRUE; @@ -1060,6 +1223,7 @@ PRIVATE void display_page ARGS3( /* never a second line on form types */ links[nlinks].hightext2 = NULL; + links[nlinks].hightext2_offset = 0; nlinks++; /* bold the link after incrementing nlinks */ @@ -1197,6 +1361,23 @@ PRIVATE void split_line ARGS2( previous->next->prev = line; line->prev = previous; line->next = previous->next; +#if defined(USE_COLOR_STYLE) || defined(SLCS) +#define LastStyle (previous->numstyles-1) + line->numstyles = 0; + /* FIXME: RJP - shouldn't use 0xffffffff for largest integer */ + line->styles[0].horizpos = 0xffffffff; + if (previous->numstyles && previous->styles[LastStyle].direction) + { + line->numstyles = 1; + line->styles[0].horizpos = 0; + line->styles[0].direction = ON; + line->styles[0].style = previous->styles[LastStyle].style; + previous->styles[previous->numstyles].style = line->styles[0].style; + previous->styles[previous->numstyles].direction = ABS_OFF; + previous->styles[previous->numstyles].horizpos = previous->size; + previous->numstyles++; + } +#endif previous->next = line; text->last_line = line; line->size = 0; @@ -1502,6 +1683,12 @@ PUBLIC void HText_appendCharacter ARGS2( */ if (ch == '\033' && HTCJK == NOCJK) /* decimal 27 */ return; +#ifdef EXP_CHARTRANS + 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 */ if ((unsigned char)ch == 155 && HTCJK == NOCJK) { /* octal 233 */ if (!HTPassHighCtrlRaw && #ifdef EXP_CHARTRANS @@ -1633,6 +1820,7 @@ PUBLIC void HText_appendCharacter ARGS2( } if (ch != LY_SOFT_HYPHEN && IsSpecialAttrChar(ch)) { +#ifndef USE_COLOR_STYLE if (ch == LY_UNDERLINE_START_CHAR) { line->data[line->size++] = LY_UNDERLINE_START_CHAR; line->data[line->size] = '\0'; @@ -1660,6 +1848,9 @@ PUBLIC void HText_appendCharacter ARGS2( ctrl_chars_on_this_line++; return; } +#else + return; +#endif } #ifdef EXP_CHARTRANS @@ -1821,6 +2012,9 @@ check_IgnoreExcess: ch = ' '; } + if (ch & 0x80) + text->have_8bit_chars = YES; + { HTLine * line = text->last_line; /* May have changed */ HTFont font = style->font; @@ -1878,6 +2072,35 @@ check_IgnoreExcess: } } +#ifdef USE_COLOR_STYLE +/* Insert a style change into the current line +** ------------------------------------------- +*/ +PUBLIC void _internal_HTC ARGS3(HText *,text, int,style, int,dir) +{ + HTLine* line; + static int last_style = -1; + static int last_dir = -1; + + /* can't change style if we have no text to change style with */ + if (!text) return; + + line = text->last_line; + + if ((style != last_style || dir != last_dir) && line->numstyles < MAX_STYLES_ON_LINE) + { + line->styles[line->numstyles].horizpos = line->size; + line->styles[line->numstyles].style = style; + line->styles[line->numstyles].direction = dir; + line->numstyles++; + } + last_style = style; + last_dir = dir; +} +#endif + + + /* Set LastChar element in the text object. ** ---------------------------------------- */ @@ -1945,20 +2168,25 @@ PUBLIC void HText_beginAnchor ARGS2( a->next = 0; a->anchor = anc; a->extent = 0; - a->link_type = HYPERTEXT_ANCHOR; text->last_anchor = a; - if (HTAnchor_followMainLink((HTAnchor*)anc)) { + 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)) { a->number = ++(text->last_anchor_number); + a->link_type = HYPERTEXT_ANCHOR; } else { a->number = 0; + a->link_type = HYPERTEXT_ANCHOR; } /* if we are doing link_numbering add the link number */ if (keypad_mode == LINKS_ARE_NUMBERED && a->number > 0) { sprintf(marker,"[%d]", a->number); HText_appendText(text, marker); - a->start += strlen(marker); + a->start = text->chars + text->last_line->size; + a->line_pos = text->last_line->size; } } @@ -1971,28 +2199,300 @@ PUBLIC void HText_endAnchor ARGS1( /* * If it goes somewhere... */ - a->extent += text->chars + text->last_line->size - a->start; - if (a->extent <= 2) { + int i, j, k; + BOOL remove_numbers_on_empty = + (keypad_mode == LINKS_ARE_NUMBERED && + (LYHiddenLinks != HIDDENLINKS_MERGE || + (LYNoISMAPifUSEMAP && + HTAnchor_isISMAPScript( + HTAnchor_followMainLink((HTAnchor *)a->anchor))))); + HTLine *last = text->last_line; + HTLine *prev = text->last_line->prev; + + /* + * Check if the anchor content has only + * white and special characters. - FM + */ + a->extent += text->chars + last->size - a->start; + if (a->extent > last->size) { + /* + * It extends over more than one line, so + * set up to check the last line. - FM + */ + i = last->size; + } else { + i = a->extent; + } + j = (last->size - i); + while (j < last->size) { + if (!IsSpecialAttrChar(last->data[j]) && + !isspace((unsigned char)last->data[j]) && + last->data[j] != HT_NON_BREAK_SPACE && + last->data[j] != HT_EM_SPACE) + break; + i--; + j++; + } + if (i == 0 && a->extent > last->size) { + /* + * The last line had only white and special + * characters, and it extends over more than + * one line, so check the next to last. - FM + */ + j = prev->size - a->extent + last->size + 1; + if (j < 0) { + /* + * It extends over more than two lines, + * so check all of the previous line. - FM + */ + j = 0; + i = prev->size; + } else { + i = a->extent - last->size - 1; + } + while (j < prev->size) { + if (!IsSpecialAttrChar(prev->data[j]) && + !isspace((unsigned char)prev->data[j]) && + prev->data[j] != HT_NON_BREAK_SPACE && + prev->data[j] != HT_EM_SPACE) + break; + i--; + j++; + } + if (i == 0 && a->extent > (last->size + prev->size + 1)) { + /* + * It extends over more than two lines, and the + * last two have only white and special characters, + * so check the second to last line. - FM + */ + prev = prev->prev; + j = prev->size - a->extent + last->size + prev->next->size + 2; + if (j < 0) { + /* + * It extends over more than three lines, + * so check all of the second to last. - FM + */ + j = 0; + i = prev->size; + } else { + i = a->extent - last->size - prev->next->size - 2; + } + while (j < prev->size) { + if (!IsSpecialAttrChar(prev->data[j]) && + !isspace((unsigned char)prev->data[j]) && + prev->data[j] != HT_NON_BREAK_SPACE && + prev->data[j] != HT_EM_SPACE) + break; + i--; + j++; + } + if (i == 0 && + a->extent > + (last->size + prev->size + prev->prev->size + 2)) { + /* + * It extends over more than three lines, and the + * last three have only white and special characters, + * so for now, we'll assume it should be shown. - FM + */ + i = a->extent; + } + } + } + if (i == 0) { /* - * Might be a blank anchor from an ALT="". - FM + * It's an invisible anchor probably from an ALT="" + * or an ignored ISMAP attribute due to a companion + * USEMAP. - FM */ - int j; a->show_anchor = NO; - for (j = (text->last_line->size - a->extent); - text->last_line->data[j] != '\0'; j++) { - if (!IsSpecialAttrChar(text->last_line->data[j])) { + prev = last->prev; + + /* + * If links are numbered, then try to get rid of the + * numbered bracket and adjust the anchor count. - FM + * + * Well, let's do this only if -hiddenlinks=merged is not in + * effect, or if we can be reasonably sure that + * this is the result of an intentional non-generation of + * anchor text via NO_ISMAP_IF_USEMAP. In other cases it can + * actually be a feature that numbered links alert the viewer + * to the presence of a link which is otherwise not selectable - + * possibly caused by HTML errors. - kw + */ + if (remove_numbers_on_empty) { + j = (last->size - a->extent - 1); + if (j < 0) + j = 0; + i = j; + if (last->data[j] == ']') { + j--; + while (j >= 0 && isdigit((unsigned char)last->data[j])) + j--; + if (j < 0) + j = 0; + if (last->data[j] == '[') { + /* + * The numbered bracket is on the last line. - FM + */ + HText_AddHiddenLink(text, a); + a->number = 0; + text->last_anchor_number--; + k = (i + 1); + while (k < last->size) { + if (last->data[k] == LY_UNDERLINE_START_CHAR || + last->data[k] == LY_UNDERLINE_END_CHAR || + last->data[k] == LY_BOLD_START_CHAR || + last->data[k] == LY_BOLD_END_CHAR || + last->data[k] == LY_SOFT_HYPHEN) + ctrl_chars_on_this_line--; + k++; + } + last->size = j; + last->data[j] = '\0'; + } else if (prev && prev->size > 1) { + k = (i + 1); + i = prev->size; + j = (prev->size - 1); + while ((j >= 0) && + (prev->data[j] == LY_BOLD_START_CHAR || + prev->data[j] == LY_BOLD_END_CHAR || + prev->data[j] == LY_UNDERLINE_START_CHAR || + prev->data[j] == LY_UNDERLINE_END_CHAR || + prev->data[j] == LY_SOFT_HYPHEN)) + j--; + while (j >= 0 && isdigit((unsigned char)prev->data[j])) + j--; + if (j < 0) + j = 0; + if (prev->data[j] == '[') { + /* + * The numbered bracket started on the + * previous line, and part of it was + * wrapped to the last line. - FM + */ + HText_AddHiddenLink(text, a); + a->number = 0; + text->last_anchor_number--; + prev->size = j; + prev->data[j] = '\0'; + text->chars -= (i - j); + while (k < last->size) { + if (last->data[k] == LY_UNDERLINE_START_CHAR || + last->data[k] == LY_UNDERLINE_END_CHAR || + last->data[k] == LY_BOLD_START_CHAR || + last->data[k] == LY_BOLD_END_CHAR || + last->data[k] == LY_SOFT_HYPHEN) + ctrl_chars_on_this_line--; + k++; + } + last->size = 0; + last->data[0] = '\0'; + for (j = 1; j < k; j++) + last->data[j] = '\0'; + } + } + } else if (prev && prev->size > 2) { + i = (prev->size - 1); + while ((i >= 0) && + (prev->data[i] == LY_BOLD_START_CHAR || + prev->data[i] == LY_BOLD_END_CHAR || + prev->data[i] == LY_UNDERLINE_START_CHAR || + prev->data[i] == LY_UNDERLINE_END_CHAR || + prev->data[i] == LY_SOFT_HYPHEN)) + i--; + if (i < 0) + i = 0; + j = i; + i++; + if ((j > 2) && + (prev->data[j] == ']' && + isdigit((unsigned char)prev->data[j - 1]))) { + k = (j + 1); + j--; + while (j >=0 && isdigit((unsigned char)prev->data[j])) + j--; + if (j < 0) + j = 0; + if (prev->data[j] == '[') { + /* + * The numbered bracket is all on the + * previous line, and the anchor content + * was wrapped to the last line. - FM + */ + HText_AddHiddenLink(text, a); + a->number = 0; + text->last_anchor_number--; + while (k < prev->size) { + if (prev->data[k] == LY_UNDERLINE_START_CHAR || + prev->data[k] == LY_UNDERLINE_END_CHAR || + prev->data[k] == LY_BOLD_START_CHAR || + prev->data[k] == LY_BOLD_END_CHAR || + prev->data[k] == LY_SOFT_HYPHEN) + prev->data[j++] = prev->data[k++]; + i++; + } + prev->size = j; + prev->data[j] = '\0'; + text->chars -= (i - j); + k = 0; + while (k < last->size) { + if (last->data[k] == LY_UNDERLINE_START_CHAR || + last->data[k] == LY_UNDERLINE_END_CHAR || + last->data[k] == LY_BOLD_START_CHAR || + last->data[k] == LY_BOLD_END_CHAR || + last->data[k] == LY_SOFT_HYPHEN) + ctrl_chars_on_this_line--; + k++; + } + last->data[0] = '\0'; + last->size = 0; + } else { + /* + * Shucks! We didn't find the + * numbered bracket. - FM + */ + a->show_anchor = YES; + } + } else { + /* + * Shucks! We didn't find the + * numbered bracket. - FM + */ + a->show_anchor = YES; + } + } else { + /* + * Shucks! We didn't find the + * numbered bracket. - FM + */ a->show_anchor = YES; - break; } + } else if (LYHiddenLinks != HIDDENLINKS_MERGE) { + HText_AddHiddenLink(text, a); + a->number = 0; + text->last_anchor_number--; } } else { + /* + * The anchor content does not contain only + * white and special characters (or extends + * over more than three lines and we're punting, + * for now), so we'll show it as a link. - FM + */ a->show_anchor = YES; } + if (a->show_anchor == NO) { + a->extent = 0; + } } else { + /* + * It's a named anchor without an HREF, so it + * should be registered but not shown as a + * link. - FM + */ a->show_anchor = NO; a->extent = 0; } - } @@ -2071,11 +2571,11 @@ PUBLIC void HText_endAppend ARGS1( FREE(text->last_line); text->last_line = next_to_the_last_line; text->Lines--; - +#ifdef NOTUSED_BAD_FOR_SCREEN if (TRACE) fprintf(stderr, "GridText: New bottom line: %s\n", text->last_line->data); - +#endif } if (TRACE) @@ -2110,7 +2610,7 @@ re_parse: * Strip off any spaces or SpecialAttrChars at the beginning, * if they exist, but only on HYPERTEXT_ANCHORS. */ - if (anchor_ptr->link_type == HYPERTEXT_ANCHOR) { + if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { ch = (unsigned char)line_ptr->data[anchor_ptr->line_pos]; while (isspace(ch) || IsSpecialAttrChar(ch)) { @@ -2122,11 +2622,11 @@ re_parse: if (anchor_ptr->extent < 0) anchor_ptr->extent = 0; - +#ifdef NOTUSED_BAD_FOR_SCREEN if (TRACE) fprintf(stderr, "anchor text: '%s' pos: %d\n", line_ptr->data, anchor_ptr->line_pos); - +#endif /* * If the link begins with a end of line and we have more * lines, then start the highlighting on the next line. @@ -2139,11 +2639,11 @@ re_parse: fprintf(stderr, "found anchor at end of line\n"); goto re_parse; } - +#ifdef NOTUSED_BAD_FOR_SCREEN if (TRACE) fprintf(stderr, "anchor text: '%s' pos: %d\n", line_ptr->data, anchor_ptr->line_pos); - +#endif /* * Copy the link name into the data structure. */ @@ -2247,38 +2747,171 @@ PUBLIC HTChildAnchor * HText_childNumber ARGS1( /* * HTGetLinkInfo returns some link info based on the number. + * + * If go_line is not NULL, caller requests to know a line number for + * the link indicated by number. It will be returned in *go_line, and + * *linknum will be set to an index into the links[] array, to use after + * the line in *line has been made the new top screen line. + * *hightext and *lname are unchanged. - KW + * + * If go_line is NULL, info on the link indicated by number is deposited + * in *hightext and *lname. */ -PUBLIC int HTGetLinkInfo ARGS3( +PUBLIC int HTGetLinkInfo ARGS5( int, number, + int *, go_line, + int *, linknum, char **, hightext, char **, lname) { TextAnchor * a; - HTAnchor *link_dest; + HTAnchor *link_dest, *link_dest_intl = NULL; + int anchors_this_line = 0, anchors_this_screen = 0; + int prev_anchor_line = -1, prev_prev_anchor_line = -1; if (!HTMainText) return(NO); for (a = HTMainText->first_anchor; a; a = a->next) { - if (a->number == number) { - *hightext= a->hightext; - link_dest = HTAnchor_followMainLink( - (HTAnchor *)a->anchor); - { + /* + * Count anchors, first on current line if there is more + * than one. We have to count all links, including form + * field anchors and others with a->number==0, because + * they are or will be included in the links[] array. + * The exception are hidden form fields and anchors with + * show_anchor not set, because they won't appear in links[] + * and don't count towards nlinks. - KW + */ + if ((go_line && a->show_anchor) && + (a->link_type != INPUT_ANCHOR || + a->input_field->type != F_HIDDEN_TYPE)) { + if (a->line_num == prev_anchor_line) { + anchors_this_line++; + } else { /* - * Memory Leak fixed. - * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe - */ - auto char *cp_freeme = NULL; - if (traversal) - cp_freeme = stub_HTAnchor_address(link_dest); - else - cp_freeme = HTAnchor_address(link_dest); - StrAllocCopy(*lname, cp_freeme); - FREE(cp_freeme); + * This anchor is on a different line than the previous one. + * Remember which was the line number of the previous anchor, + * for use in screen positioning later. - KW + */ + anchors_this_line = 1; + prev_prev_anchor_line = prev_anchor_line; + prev_anchor_line = a->line_num; + } + if (a->line_num >= HTMainText->top_of_screen) { + /* + * Count all anchors starting with the top line of the + * currently displayed screen. Just keep on counting + * beyound this screen's bottom line - we'll know whether + * a found anchor is below the current screen by a check + * against nlinks later. - KW + */ + anchors_this_screen++; } - return(YES); } + + if (a->number == number) { + /* + * We found it. Now process it, depending + * on what kind of info is requested. - KW + */ + if (go_line) { + if (a->show_anchor == NO) { + /* + * The number requested has been assigned to an anchor + * without any selectable text, so we cannot position + * on it. The code for suppressing such anchors in + * HText_endAnchor() may not have applied, or it may + * have failed. Return a failure indication so that + * the user will notice that something is wrong, + * instead of positioning on some other anchor which + * might result in inadvertant activation. - KW + */ + return(NO); + } + if (anchors_this_screen > 0 && + anchors_this_screen <= nlinks && + a->line_num >= HTMainText->top_of_screen && + a->line_num < HTMainText->top_of_screen+(display_lines)) { + /* + * If the requested anchor is within the current screen, + * just set *go_line so that the screen window won't move + * (keep it as it is), and set *linknum to the index of + * this link in the current links[] array. - KW + */ + *go_line = HTMainText->top_of_screen; + if (linknum) + *linknum = anchors_this_screen - 1; + } else { + /* + * if the requested anchor is not within the currently + * displayed screen, set *go_line such that the top line + * will be either + * (1) the line immediately below the previous + * anchor, or + * (2) about one third of a screenful above the line + * with the target, or + * (3) the first line of the document - + * whichever comes last. In all cases the line with our + * target will end up being the first line with any links + * on the new screen, so that we can use the + * anchors_this_line counter to point to the anchor in + * the new links[] array. - kw + */ + int max_offset = SEARCH_GOAL_LINE - 1; + if (max_offset < 0) + max_offset = 0; + else if (max_offset >= display_lines) + max_offset = display_lines - 1; + *go_line = prev_anchor_line - max_offset; + if (*go_line <= prev_prev_anchor_line) + *go_line = prev_prev_anchor_line + 1; + if (*go_line < 0) + *go_line = 0; + if (linknum) + *linknum = anchors_this_line - 1; + } + return(LINK_LINE_FOUND); + } else { + *hightext= a->hightext; + link_dest = HTAnchor_followMainLink((HTAnchor *)a->anchor); + { + char *cp_freeme = NULL; + if (traversal) + cp_freeme = stub_HTAnchor_address(link_dest); + else { + if (a->link_type == INTERNAL_LINK_ANCHOR) { + link_dest_intl = HTAnchor_followTypedLink( + (HTAnchor *)a->anchor, LINK_INTERNAL); + if (link_dest_intl && link_dest_intl != link_dest) { + if (TRACE) + fprintf(stderr, + "HTGetLinkInfo: unexpected typed link to %s!\n", + link_dest_intl->parent->address); + link_dest_intl = NULL; + } + } + if (link_dest_intl) { + char *cp2 = HTAnchor_address(link_dest_intl); + char *cp = strchr(cp2, '#'); + if (cp && cp != cp2 && + 0!=strncmp(cp2, "LYNXIMGMAP:", 11)) { + StrAllocCopy(*lname, cp); + FREE(cp2); + return(WWW_INTERN_LINK_TYPE); + } else { + FREE(*lname); + *lname = cp2; + return(WWW_INTERN_LINK_TYPE); + } + } else + cp_freeme = HTAnchor_address(link_dest); + } + StrAllocCopy(*lname, cp_freeme); + FREE(cp_freeme); + } + return(WWW_LINK_TYPE); + } + } } return(NO); } @@ -2302,6 +2935,14 @@ PUBLIC char * HText_getTitle NOARGS (char *) HTAnchor_title(HTMainText->node_anchor) : NULL); } +#ifdef USEHASH +PUBLIC char *HText_getStyle NOARGS +{ + return(HTMainText ? + (char *) HTAnchor_style(HTMainText->node_anchor) : NULL); +} +#endif + /* * HText_getSugFname returns the suggested filename of the current * document (normally derived from a Content-Disposition header with @@ -2358,6 +2999,18 @@ PUBLIC void HText_pageDisplay ARGS2( } /* + * Return YES if we have a whereis search target on the displayed + * page. - kw + */ +PUBLIC BOOL HText_pageHasPrevTarget NOARGS +{ + if (!HTMainText) + return NO; + else + return HTMainText->page_has_target; +} + +/* * HText_LinksInLines returns the number of links in the * 'Lines' number of lines beginning with 'line_num'-1. - FM */ @@ -2379,7 +3032,9 @@ PUBLIC int HText_LinksInLines ARGS3( Anchor_ptr = Anchor_ptr->next) { if (Anchor_ptr->line_num >= start && Anchor_ptr->line_num < end && - Anchor_ptr->show_anchor) + Anchor_ptr->show_anchor && + (Anchor_ptr->link_type != INPUT_ANCHOR || + Anchor_ptr->input_field->type != F_HIDDEN_TYPE)) ++total; if (Anchor_ptr == text->last_anchor) break; @@ -2475,6 +3130,13 @@ PUBLIC BOOL HText_select ARGS1( if (text != HTMainText) { HTMainText = text; HTMainAnchor = text->node_anchor; + + /* + * Reset flag for whereis search string - cannot be true here + * since text is not our HTMainText. - kw + */ + if (text) + text->page_has_target = NO; /* * Make this text the most current in the loaded texts list. - FM */ @@ -3085,12 +3747,88 @@ PUBLIC void print_crawl_to_fd ARGS3( #endif /* VMS */ } -PUBLIC void www_user_search ARGS2( +PRIVATE void adjust_search_result ARGS3( + document *, doc, + int, tentative_result, + int, start_line) +{ + if (tentative_result > 0) { + int anch_line = -1; + TextAnchor * a; + int nl_closest = -1; + int goal = SEARCH_GOAL_LINE; + int max_offset; + BOOL on_screen = (tentative_result > HTMainText->top_of_screen && + tentative_result <= HTMainText->top_of_screen+display_lines); + if (goal < 1) + goal = 1; + else if (goal > display_lines) + goal = display_lines; + max_offset = goal - 1; + + if (on_screen && nlinks > 0) { + int i; + for (i = 0; i < nlinks; i++) { + if (doc->line + links[i].ly - 1 <= tentative_result) + nl_closest = i; + if (doc->line + links[i].ly - 1 >= tentative_result) + break; + } + if (nl_closest >= 0 && + doc->line + links[nl_closest].ly - 1 == tentative_result) { + www_search_result = doc->line; + doc->link = nl_closest; + return; + } + } + + /* find last anchor before or on target line */ + for (a = HTMainText->first_anchor; + a && a->line_num <= tentative_result-1; a = a->next) { + anch_line = a->line_num + 1; + } + /* position such that the anchor found is on first screen line, + if it is not too far above the target line; but also try to + make sure we move forward. */ + if (anch_line >= 0 && + anch_line >= tentative_result - max_offset && + (anch_line > start_line || + tentative_result <= HTMainText->top_of_screen)) { + www_search_result = anch_line; + } else + if (tentative_result - start_line > 0 && + tentative_result - (start_line + 1) <= max_offset) { + www_search_result = start_line + 1; + } else + if (tentative_result > HTMainText->top_of_screen && + tentative_result <= start_line && /* have wrapped */ + tentative_result <= HTMainText->top_of_screen+goal) { + www_search_result = HTMainText->top_of_screen + 1; + } else + if (tentative_result <= goal) + www_search_result = 1; + else + www_search_result = tentative_result - max_offset; + if (www_search_result == doc->line) { + if (nl_closest >= 0) { + doc->link = nl_closest; + return; + } + } + } +} + +PUBLIC void www_user_search ARGS3( int, start_line, + document *, doc, char *, target) { register HTLine * line; register int count; + int tentative_result = -1; + TextAnchor *a; + OptionType *option; + char *stars = NULL, *cp; extern BOOLEAN case_sensitive; if (!HTMainText) { @@ -3108,15 +3846,148 @@ PUBLIC void www_user_search ARGS2( break; } } + a = HTMainText->first_anchor; + while (a && a->line_num < count - 1) { + a = a->next; + } for (;;) { + while ((a != NULL) && a->line_num == (count - 1)) { + if (a->show_anchor && + (a->link_type != INPUT_ANCHOR || + a->input_field->type != F_HIDDEN_TYPE)) { + if (((a->hightext != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(a->hightext, target)) || + ((a->hightext != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->hightext, target))) { + adjust_search_result(doc, count, start_line); + return; + } + if (((a->hightext2 != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(a->hightext2, target)) || + ((a->hightext2 != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->hightext2, target))) { + adjust_search_result(doc, count, start_line); + return; + } + + /* + * Search the relevant form fields, taking the + * case_sensitive setting into account. - FM + */ + if ((a->input_field != NULL && a->input_field->value != NULL) && + a->input_field->type != F_HIDDEN_TYPE) { + if (a->input_field->type == F_PASSWORD_TYPE) { + /* + * Check the actual, hidden password, and then + * the displayed string. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(a->input_field->value, + target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->input_field->value, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + StrAllocCopy(stars, a->input_field->value); + for (cp = stars; *cp != '\0'; cp++) + *cp = '*'; + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(stars, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(stars, target))) { + FREE(stars); + adjust_search_result(doc, count, start_line); + return; + } + FREE(stars); + } else if (a->input_field->type == F_OPTION_LIST_TYPE) { + /* + * Search the option strings that are displayed + * when the popup is invoked. - FM + */ + option = a->input_field->select_list; + while (option != NULL) { + if (((option->name != NULL && + case_sensitive == TRUE) && + LYno_attr_char_strstr(option->name, + target)) || + ((option->name != NULL && + case_sensitive == FALSE) && + LYno_attr_char_case_strstr(option->name, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + option = option->next; + } + } else if (a->input_field->type == F_RADIO_TYPE) { + /* + * Search for checked or unchecked parens. - FM + */ + if (a->input_field->num_value) { + cp = checked_radio; + } else { + cp = unchecked_radio; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, target))) { + adjust_search_result(doc, count, start_line); + return; + } + } else if (a->input_field->type == F_CHECKBOX_TYPE) { + /* + * Search for checked or unchecked + * square brackets. - FM + */ + if (a->input_field->num_value) { + cp = checked_box; + } else { + cp = unchecked_box; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, target))) { + adjust_search_result(doc, count, start_line); + return; + } + } else { + /* + * Check the values intended for display. + * May have been found already via the + * hightext search, but make sure here + * that the entire value is searched. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(a->input_field->value, + target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->input_field->value, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + } + } + } + a = a->next; + } + if (a != NULL && a->line_num <= (count - 1)) { + a = a->next; + } + if (case_sensitive && LYno_attr_char_strstr(line->data, target)) { - www_search_result=count; - return; + tentative_result=count; + break; } else if (!case_sensitive && LYno_attr_char_case_strstr(line->data, target)) { - www_search_result=count; - return; + tentative_result=count; + break; } else if (line == HTMainText->last_line) { /* next line */ break; } else { /* end */ @@ -3124,19 +3995,158 @@ PUBLIC void www_user_search ARGS2( count++; } } + if (tentative_result > 0) { + adjust_search_result(doc, tentative_result, start_line); + return; + } - /* search from the beginning */ + /* + * Search from the beginning. + */ line = HTMainText->last_line->next; /* set to first line */ count = 1; + a = HTMainText->first_anchor; + while (a && a->line_num < count - 1) { + a = a->next; + } for (;;) { + while ((a != NULL) && a->line_num == (count - 1)) { + if (a->show_anchor && + (a->link_type != INPUT_ANCHOR || + a->input_field->type != F_HIDDEN_TYPE)) { + if (((a->hightext != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(a->hightext, target)) || + ((a->hightext != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->hightext, target))) { + adjust_search_result(doc, count, start_line); + return; + } + if (((a->hightext2 != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(a->hightext2, target)) || + ((a->hightext2 != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->hightext2, target))) { + adjust_search_result(doc, count, start_line); + return; + } + + /* + * Search the relevant form fields, taking the + * case_sensitive setting into account. - FM + */ + if ((a->input_field != NULL && a->input_field->value != NULL) && + a->input_field->type != F_HIDDEN_TYPE) { + if (a->input_field->type == F_PASSWORD_TYPE) { + /* + * Check the actual, hidden password, and then + * the displayed string. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(a->input_field->value, + target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->input_field->value, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + StrAllocCopy(stars, a->input_field->value); + for (cp = stars; *cp != '\0'; cp++) + *cp = '*'; + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(stars, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(stars, target))) { + FREE(stars); + adjust_search_result(doc, count, start_line); + return; + } + FREE(stars); + } else if (a->input_field->type == F_OPTION_LIST_TYPE) { + /* + * Search the option strings that are displayed + * when the popup is invoked. - FM + */ + option = a->input_field->select_list; + while (option != NULL) { + if (((option->name != NULL && + case_sensitive == TRUE) && + LYno_attr_char_strstr(option->name, + target)) || + ((option->name != NULL && + case_sensitive == FALSE) && + LYno_attr_char_case_strstr(option->name, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + option = option->next; + } + } else if (a->input_field->type == F_RADIO_TYPE) { + /* + * Search for checked or unchecked parens. - FM + */ + if (a->input_field->num_value) { + cp = checked_radio; + } else { + cp = unchecked_radio; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, target))) { + adjust_search_result(doc, count, start_line); + return; + } + } else if (a->input_field->type == F_CHECKBOX_TYPE) { + /* + * Search for checked or unchecked + * square brackets. - FM + */ + if (a->input_field->num_value) { + cp = checked_box; + } else { + cp = unchecked_box; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, target))) { + adjust_search_result(doc, count, start_line); + return; + } + } else { + /* + * Check the values intended for display. + * May have been found already via the + * hightext search, but make sure here + * that the entire value is searched. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(a->input_field->value, + target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(a->input_field->value, + target))) { + adjust_search_result(doc, count, start_line); + return; + } + } + } + } + a = a->next; + } + if (a != NULL && a->line_num <= (count - 1)) { + a = a->next; + } + if (case_sensitive && LYno_attr_char_strstr(line->data, target)) { - www_search_result=count; - return; + tentative_result=count; + break; } else if (!case_sensitive && LYno_attr_char_case_strstr(line->data, target)) { - www_search_result=count; - return; + tentative_result=count; + break; } else if (count > start_line) { /* next line */ _user_message(STRING_NOT_FOUND, target); sleep(MessageSecs); @@ -3144,7 +4154,10 @@ PUBLIC void www_user_search ARGS2( } else { line = line->next; count++; - } + } + } + if (tentative_result > 0) { + adjust_search_result(doc, tentative_result, start_line); } } @@ -3234,10 +4247,29 @@ PUBLIC void HTuncache_current_document NOARGS * Should remove current document from memory. */ if (HTMainText) { + HTParentAnchor * htmain_anchor = HTMainText->node_anchor; +#ifdef EXP_CHARTRANS + if (htmain_anchor) { + if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) { + FREE(htmain_anchor->UCStages); + } + } +#endif /* EXP_CHARTRANS */ + if (TRACE) { + fprintf(stderr, "\rHTuncache.. freeing document for %s %s\n", + (htmain_anchor && htmain_anchor->address) ? + htmain_anchor->address : "unknown anchor", + (htmain_anchor && htmain_anchor->post_data) ? + "with POST data" : "" + ); + } HTList_removeObject(loaded_texts, HTMainText); HText_free(HTMainText); HTMainText = NULL; - } + } else + if (TRACE) { + fprintf(stderr, "HTuncache.. HTMainText already is NULL!\n"); + } } PUBLIC int HTisDocumentSource NOARGS @@ -3311,6 +4343,14 @@ PUBLIC char * HTLoadedDocumentCharset NOARGS return (NULL); } +PUBLIC BOOL HTLoadedDocumentEightbit NOARGS +{ + if (!HTMainText) + return (NO); + else + return (HTMainText->have_8bit_chars); +} + PUBLIC void HText_setNodeAnchorBookmark ARGS1( CONST char *, bookmark) { @@ -3354,7 +4394,8 @@ PUBLIC int HText_PreviousLineSize ARGS1( PRIVATE int HText_TrueLineSize ARGS2(HTLine *,line, HText *,text) { - int i, true_size = 0; + size_t i; + int true_size = 0; if (!line || !line->size) return 0; @@ -3497,6 +4538,81 @@ PUBLIC int HText_getTabIDColumn ARGS2( return column; } +/* + * This function is for saving the address of a link + * which had an attribute in the markup that resolved + * to a URL (i.e., not just a NAME or ID attribute), + * but was found in HText_endAnchor() to have no visible + * content for use as a link name. It loads the address + * into text->hidden_links, whose count can be determined + * via HText_HiddenLinks(), below. The addresses can be + * retrieved via HText_HiddenLinkAt(), below, based on + * count. - FM + */ +PRIVATE void HText_AddHiddenLink ARGS2( + HText *, text, + TextAnchor *, textanchor) +{ + HTAnchor *dest; + + /* + * Make sure we have an HText structure and anchor. - FM + */ + if (!(text && textanchor && textanchor->anchor)) + return; + + /* + * Create the hidden links list + * if it hasn't been already. - FM + */ + if (text->hidden_links == NULL) + text->hidden_links = HTList_new(); + + /* + * Store the address, in reverse list order + * so that first in will be first out on + * retrievals. - FM + */ + if ((dest = HTAnchor_followMainLink((HTAnchor *)textanchor->anchor)) && + (LYHiddenLinks != HIDDENLINKS_IGNORE || + HTList_isEmpty(text->hidden_links))) + HTList_appendObject(text->hidden_links, HTAnchor_address(dest)); + + return; +} + +/* + * This function returns the number of addresses + * that are loaded in text->hidden_links. - FM + */ +PUBLIC int HText_HiddenLinkCount ARGS1( + HText *, text) +{ + int count = 0; + + if (text && text->hidden_links) + count = HTList_count((HTList *)text->hidden_links); + + return(count); +} + +/* + * This function returns the address, corresponding to + * a hidden link, at the position (zero-based) in the + * text->hidden_links list of the number argument. - FM + */ +PUBLIC char * HText_HiddenLinkAt ARGS2( + HText *, text, + int, number) +{ + char *href = NULL; + + if (text && text->hidden_links && number >= 0) + href = (char *)HTList_objectAt((HTList *)text->hidden_links, number); + + return(href); +} + /* * Form methods @@ -4129,8 +5245,6 @@ PUBLIC int HText_beginInput ARGS2( StrAllocCopy(f->value, "[IMAGE]-Submit"); f->size = 14; } else { - StrAllocCopy(f->value, "[IMAGE]-Submit"); - f->size = 14; StrAllocCopy(f->value, "Submit"); f->size = 6; } @@ -4167,8 +5281,42 @@ PUBLIC int HText_beginInput ARGS2( /* * Restrict SIZE to maximum allowable size. */ - if (f->size > LYcols-10) - f->size = LYcols-10; /* maximum */ + switch (f->type) { + int MaximumSize; + + case F_SUBMIT_TYPE: + case F_IMAGE_SUBMIT_TYPE: + case F_RESET_TYPE: + /* + * For submit and reset buttons, we limit the size + * element to that of one line for the current style + * because that's the most we could highlight on + * overwrites- FM + */ + MaximumSize = (LYcols - 1) - + (int)text->style->leftIndent - + (int)text->style->rightIndent; + if (f->size > MaximumSize) + f->size = MaximumSize; + /* + * Save value for submit/reset buttons so they + * will be visible when printing the page. - LE + */ + I->value = f->value; + break; + + default: + /* + * For all other fields we limit the size element + * to 10 less than the screen width, because either + * they are types with small placeholders, or are a + * type which can be scrolled horizontally within + * an editing window. - FM + */ + if (f->size > LYcols-10) + f->size = LYcols-10; /* maximum */ + break; + } /* * Add this anchor to the anchor list @@ -5167,3 +6315,118 @@ PUBLIC void HText_setKcode ARGS2( return; } +/* +** Set a permissible split at the current end of the last line. - FM +*/ +PUBLIC void HText_setBreakPoint ARGS1( + HText *, text) +{ + if (!text) + return; + + text->permissible_split = (int)text->last_line->size; /* Can split here */ + + return; +} + +/* +** This function determines whether a document which +** would be sought via the a URL that has a fragment +** directive appended is otherwise identical to the +** currently loaded document, and if so, returns +** FALSE, so that any no_cache directives can be +** overridden "safely", on the grounds that we are +** simply acting on the equivalent of a paging +** command. Otherwise, it returns TRUE, i.e, that +** the target document might differ from the current, +** based on any caching directives or analyses which +** claimed or suggested this. - FM +*/ +PUBLIC BOOL HText_AreDifferent ARGS2( + HTParentAnchor *, anchor, + CONST char *, full_address) +{ + HTParentAnchor *MTanc; + char *pound; + + /* + * Do we have a loaded document and both + * arguments for this function? + */ + if (!(HTMainText && anchor && full_address)) + return TRUE; + + /* + * Do we have both URLs? + */ + MTanc = HTMainText->node_anchor; + if (!(MTanc->address && anchor->address)) + return (TRUE); + + /* + * Do we have a fragment associated with the target? + */ + if ((pound = strchr(full_address, '#')) == NULL) + return (TRUE); + + /* + * Always treat client-side image map menus + * as potentially stale. + */ + if (!strncasecomp(anchor->address, "LYNXIMGMAP:", 11)) + return (TRUE); + + /* + * Do they differ in the type of request? + */ + if (MTanc->isHEAD != anchor->isHEAD) + return (TRUE); + + /* + * Are the actual URLs different? + */ + if (strcmp(MTanc->address, anchor->address)) + return(TRUE); + + /* + * Do the docs have different contents? + */ + if (MTanc->post_data) { + if (anchor->post_data) { + if (strcmp(MTanc->post_data, anchor->post_data)) { + /* + * Both have contents, and they differ. + */ + return(TRUE); + } + } else { + /* + * The loaded document has content, but the + * target doesn't, so they're different. + */ + return(TRUE); + } + } else if (anchor->post_data) { + /* + * The loaded document does not have content, but + * the target does, so they're different. + */ + return(TRUE); + } + + /* + * Are we seeking a position in the loaded document + * based on a fragment? + */ + if (!strncmp(MTanc->address, full_address, (pound - full_address))) + return(FALSE); + + /* + * We'll assume the loaded document and target should be + * treated as different, either because we are reloading, + * or because we had header, META, or other directives not + * to use a cached rendition. - FM + */ + return(TRUE); + +} diff --git a/src/GridText.h b/src/GridText.h index e027c17c..d606c16f 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -57,6 +57,7 @@ extern void HText_scrollDown PARAMS((HText * text)); /* One page */ extern void HText_scrollTop PARAMS((HText * text)); extern void HText_scrollBottom PARAMS((HText * text)); extern void HText_pageDisplay PARAMS((int line_num, char *target)); +extern BOOL HText_pageHasPrevTarget NOPARAMS; extern int HText_LinksInLines PARAMS((HText *text, int line_num, int Lines)); @@ -75,16 +76,25 @@ extern char * HText_getServer NOPARAMS; extern char * HText_getOwner NOPARAMS; extern char * HText_getContentBase NOPARAMS; extern char * HText_getContentLocation NOPARAMS; +#ifdef USEHASH +extern char * HText_getStyle NOPARAMS; +#endif extern void HText_setMainTextOwner PARAMS((CONST char * owner)); extern char * HText_getRevTitle NOPARAMS; extern void print_wwwfile_to_fd PARAMS((FILE * fp, int is_reply)); extern BOOL HText_select PARAMS((HText *text)); extern BOOL HText_POSTReplyLoaded PARAMS((document *doc)); extern BOOL HTFindPoundSelector PARAMS((char *selector)); -extern int HTGetLinkInfo PARAMS((int number, char **hightext, char **lname)); +extern int HTGetLinkInfo PARAMS(( + int number, + int * go_line, + int * linknum, + char ** hightext, + char ** lname)); extern int HTisDocumentSource NOPARAMS; extern void HTuncache_current_document NOPARAMS; extern int HText_getTopOfScreen NOPARAMS; +extern int HText_getLines PARAMS((HText * text)); extern int HText_getNumOfLines NOPARAMS; extern int do_www_search PARAMS((document *doc)); extern char * HTLoadedDocumentURL NOPARAMS; @@ -93,6 +103,7 @@ extern char * HTLoadedDocumentTitle NOPARAMS; extern BOOLEAN HTLoadedDocumentIsHEAD NOPARAMS; extern BOOLEAN HTLoadedDocumentIsSafe NOPARAMS; extern char * HTLoadedDocumentCharset NOPARAMS; +extern BOOL HTLoadedDocumentEightbit NOPARAMS; extern void HText_setNodeAnchorBookmark PARAMS((CONST char *bookmark)); extern char * HTLoadedDocumentBookmark NOPARAMS; extern int HText_LastLineSize PARAMS((HText *me)); @@ -103,29 +114,33 @@ extern int HText_getCurrentColumn PARAMS((HText *text)); extern int HText_getMaximumColumn PARAMS((HText *text)); extern void HText_setTabID PARAMS((HText *text, CONST char *name)); extern int HText_getTabIDColumn PARAMS((HText *text, CONST char *name)); +extern int HText_HiddenLinkCount PARAMS((HText *text)); +extern char * HText_HiddenLinkAt PARAMS((HText *text, int number)); /* forms stuff */ -extern void HText_beginForm PARAMS((char *action, - char *method, - char *enctype, - char *title)); +extern void HText_beginForm PARAMS(( + char * action, + char * method, + char * enctype, + char * title)); extern void HText_endForm PARAMS((HText *text)); extern void HText_beginSelect PARAMS((char *name, BOOLEAN multiple, char *len)); -extern char * HText_setLastOptionValue PARAMS((HText *text, char *value, - char *submit_value, - int order, BOOLEAN checked)); +extern char * HText_setLastOptionValue PARAMS(( + HText * text, + char * value, + char * submit_value, + int order, + BOOLEAN checked)); extern int HText_beginInput PARAMS((HText *text, InputFieldData *I)); -extern void HText_SubmitForm PARAMS((FormInfo *submit_item, document *doc, - char *link_name, char *link_value)); +extern void HText_SubmitForm PARAMS(( + FormInfo * submit_item, + document * doc, + char * link_name, + char * link_value)); extern void HText_DisableCurrentForm NOPARAMS; extern void HText_ResetForm PARAMS((FormInfo *form)); extern void HText_activateRadioButton PARAMS((FormInfo *form)); -#ifdef CURSES -extern int HText_getTopOfScreen NOPARAMS; -extern int HText_getLines PARAMS((HText * text)); -#endif /* CURSES */ - extern HTList * search_queries; /* Previous isindex and whereis queries */ extern void HTSearchQueries_free NOPARAMS; extern void HTAddSearchQuery PARAMS((char *query)); @@ -134,10 +149,12 @@ extern void user_message PARAMS((char * message, char * argument)); #define _user_message(msg, arg) mustshow = TRUE, user_message(msg, arg) -extern void www_user_search PARAMS((int start_line, char *target)); +extern void www_user_search PARAMS((int start_line, document *doc, char *target)); -extern void print_crawl_to_fd PARAMS((FILE * fp, char * thelink, - char * thetitle)); +extern void print_crawl_to_fd PARAMS(( + FILE * fp, + char * thelink, + char * thetitle)); extern char * stub_HTAnchor_address PARAMS((HTAnchor *me)); extern void HText_setToolbar PARAMS((HText *text)); @@ -148,4 +165,10 @@ extern BOOL HText_hasNoCacheSet PARAMS((HText *text)); extern void HText_setKcode PARAMS((HText *text, CONST char *charset)); +extern void HText_setBreakPoint PARAMS((HText *text)); + +extern BOOL HText_AreDifferent PARAMS(( + HTParentAnchor * anchor, + CONST char * full_address)); + #endif /* LYGRIDTEXT_H */ diff --git a/src/HTFWriter.c b/src/HTFWriter.c index 55e5d932..24bbb136 100644 --- a/src/HTFWriter.c +++ b/src/HTFWriter.c @@ -195,6 +195,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me) * so the uncompression failed. - FM */ fclose(fp); + fp = NULL; if (!dump_output_immediately) { clearok(curscr, TRUE); refresh(); @@ -453,14 +454,16 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( if (anchor->FileCache) { strcpy(fnam, anchor->FileCache); FREE(anchor->FileCache); - if ((fp=fopen(fnam, "r")) != NULL) { + if ((fp = fopen(fnam, "r")) != NULL) { fclose(fp); + fp = NULL; remove(fnam); } } else { /* * Lynx routine to create a temporary filename */ +SaveAndExecute_tempname: tempname (fnam, NEW_FILE); /* * Check for a suffix. @@ -483,6 +486,15 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3( strcat(fnam, ".bin"); } else if ((suffix = HTFileSuffix(pres->rep)) && *suffix == '.') { strcat(fnam, suffix); + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto SaveAndExecute_tempname; + } } else { *cp = '.'; } @@ -630,14 +642,16 @@ PUBLIC HTStream* HTSaveToFile ARGS3( if (anchor->FileCache) { strcpy(fnam, anchor->FileCache); FREE(anchor->FileCache); - if ((fp=fopen(fnam, "r")) != NULL) { + if ((fp = fopen(fnam, "r")) != NULL) { fclose(fp); + fp = NULL; remove(fnam); } } else { /* * Lynx routine to create a temporary filename */ +SaveToFile_tempname: tempname(fnam, NEW_FILE); /* * Check for a suffix. @@ -660,6 +674,15 @@ PUBLIC HTStream* HTSaveToFile ARGS3( strcat(fnam, ".bin"); } else if ((suffix = HTFileSuffix(pres->rep)) && *suffix == '.') { strcat(fnam, suffix); + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto SaveToFile_tempname; + } } else { *cp = '.'; } @@ -884,6 +907,7 @@ PUBLIC HTStream* HTCompressed ARGS3( /* * Get a new temporary filename and substitute a suitable suffix. - FM */ +Compressed_tempname: tempname(fnam, NEW_FILE); if ((cp = strchr(fnam, '.')) != NULL) { *cp = '\0'; @@ -922,7 +946,16 @@ PUBLIC HTStream* HTCompressed ARGS3( strcat(fnam, "."); } strcat(fnam, compress_suffix); - + /* + * It's not one of the suffixes checked for a + * spoof in tempname(), so check it now. - FM + */ + if ((fp = fopen(fnam, "r")) != NULL) { + fclose(fp); + fp = NULL; + goto Compressed_tempname; + } + /* * Open the file for receiving the compressed input stream. - FM */ diff --git a/src/HTForms.h b/src/HTForms.h index 612bbb89..c152f0a9 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -76,6 +76,7 @@ typedef struct _FormInfo { #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 */ #define F_TEXT_TYPE 1 #define F_PASSWORD_TYPE 2 @@ -94,6 +95,9 @@ typedef struct _FormInfo { #define WWW_FORM_LINK_TYPE 1 #define WWW_LINK_TYPE 2 +#define WWW_INTERN_LINK_TYPE 6 /* can be used as a bitflag... - kw */ +#define LINK_LINE_FOUND 8 /* used in follow_link_number - kw */ + /* #define different lynx modes */ #define NORMAL_LYNX_MODE 1 #define FORMS_LYNX_MODE 2 diff --git a/src/HTInit.c b/src/HTInit.c index adc9a64e..e8c74065 100644 --- a/src/HTInit.c +++ b/src/HTInit.c @@ -278,7 +278,9 @@ PRIVATE char *Cleanse ARGS1(char *,s) PRIVATE int ProcessMailcapEntry ARGS2(FILE *,fp, struct MailcapEntry *,mc) { - int i, j, rawentryalloc = 2000, len; + int i, j; + size_t rawentryalloc = 2000; + size_t len; char *rawentry, *s, *t, *LineBuf; LineBuf = malloc(LINE_BUF_SIZE); @@ -815,7 +817,7 @@ PUBLIC void HTFileInit NOARGS HTSetSuffix(".xwd", "image/x-xwindowdump", "binary", 1.0); HTSetSuffix(".rtx", "text/richtext", "8bit", 1.0); - HTSetSuffix(".tsv", "text/tab-separated-values", "8-bit", 1.0); + HTSetSuffix(".tsv", "text/tab-separated-values", "8bit", 1.0); HTSetSuffix(".etx", "text/x-setext", "8bit", 1.0); HTSetSuffix(".mpg", "video/mpeg", "binary", 1.0); @@ -22,8 +22,10 @@ #include "HTCJK.h" #include "HTAtom.h" +#include "HTAnchor.h" #include "HTMLGen.h" #include "HTParse.h" +#include "HTList.h" #include "LYGlobalDefs.h" #include "LYCharUtils.h" @@ -42,6 +44,7 @@ #include "LYSignal.h" #include "LYUtils.h" #include "LYMap.h" +#include "LYList.h" #include "LYBookmark.h" #ifdef VMS @@ -49,6 +52,15 @@ #include "HTVMSUtils.h" #endif /* VMS */ +#ifdef USE_COLOR_STYLE +#include "AttrList.h" +#include "LYHash.h" +#include "LYStyle.h" +#undef SELECTED_STYLES +#define pHText_changeStyle(X,Y,Z) {} +char Style_className[16384]; +#endif + #include "LYexit.h" #include "LYLeaks.h" @@ -96,6 +108,19 @@ PRIVATE void change_paragraph_style PARAMS((HTStructured * me, */ #define UPDATE_STYLE if (me->style_change) { actually_set_style(me); } +/* Set an internal flag that the next call to a stack-affecting method +** is only internal and the stack manipulation should be skipped. - kw +*/ +#define SET_SKIP_STACK(el_num) if (HTML_dtd.tags[el_num].contents != SGML_EMPTY) \ + { me->skip_stack++; } + +extern int hash_code PARAMS((char* i)); + +PUBLIC void strtolower ARGS1(char*, i) +{ + if (!i) return; + while (*i) { *i=tolower(*i); i++; } +} /* Flattening the style structure ** ------------------------------ @@ -212,6 +237,7 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) return; case HTML_SELECT: + case HTML_OPTION: HTChunkPutc(&me->option, c); return; @@ -332,7 +358,7 @@ PUBLIC void HTML_put_character ARGS2(HTStructured *, me, char, c) /* String handling ** --------------- ** -** This is written separately from put_character becuase the loop can +** This is written separately from put_character because the loop can ** in some cases be promoted to a higher function call level for speed. */ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s) @@ -376,6 +402,7 @@ PUBLIC void HTML_put_string ARGS2(HTStructured *, me, CONST char *, s) break; case HTML_SELECT: + case HTML_OPTION: HTChunkPuts(&me->option, s); break; @@ -455,6 +482,25 @@ PUBLIC void HTML_write ARGS3(HTStructured *, me, CONST char*, s, int, l) HTML_put_character(me, *p); } +/* 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 + (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) + +#ifdef USE_COLOR_STYLE +char class_string[TEMPSTRINGSIZE]; +char prevailing_class[TEMPSTRINGSIZE]; +#endif + +#ifdef USE_COLOR_STYLE + char myHash[128]; + int hcode; +#endif /* Start Element ** ------------- */ @@ -474,32 +520,99 @@ PRIVATE void HTML_start_element ARGS5( #ifdef EXP_CHARTRANS int dest_char_set = -1; #endif - static BOOLEAN first_option = TRUE; /* is this the first option tag? */ - HTParentAnchor *dest = NULL; /* an anchor's destination */ - BOOL dest_ismap = FALSE; /* is dest an image map script? */ + HTParentAnchor *dest = NULL; /* An anchor's destination */ + BOOL dest_ismap = FALSE; /* Is dest an image map script? */ HTChildAnchor *ID_A = NULL; /* HTML_foo_ID anchor */ int url_type = 0, i = 0; + BOOL intern_flag = FALSE; char *cp = NULL; if (LYMapsOnly) { - if (!(element_number == HTML_MAP || element_number == HTML_AREA)) { + if (!(element_number == HTML_MAP || element_number == HTML_AREA || + element_number == HTML_BASE)) { return; } } +/* this should be done differently */ +#if defined(USE_COLOR_STYLE) + strcat (Style_className, ";"); + strcat (Style_className, HTML_dtd.tags[element_number].name); + strcpy (myHash, HTML_dtd.tags[element_number].name); + if (class_string[0]) + { + strcat (Style_className, "."); + strcat (Style_className, class_string); + strcat (myHash, "."); + strcat (myHash, class_string); +#if !defined(PREVAIL) + } +#else /* PREVAIL */ + strcpy (prevailing_class, class_string); + } + else if (prevailing_class[0]) + { + strcat (Style_className, "."); + strcat (Style_className, prevailing_class); + strcat (myHash, "."); + strcat (myHash, prevailing_class); + } +#endif /* !PREVAIL */ + class_string[0]='\0'; + strtolower(myHash); + hcode=hash_code(myHash); + strtolower(Style_className); + + if (TRACE) + { + fprintf(stderr, "CSSTRIM:%s -> %d", myHash, hcode); + if (hashStyles[hcode].code!=hcode) + { + char *rp=strrchr(myHash, '.'); + fprintf(stderr, " (undefined) %s\n", myHash); + if (rp) + { + int hcode; + *rp='\0'; /* trim the class */ + hcode=hash_code(myHash); + fprintf(stderr, "CSS:%s -> %d", myHash, hcode); + if (hashStyles[hcode].code!=hcode) + fprintf(stderr, " (undefined) %s\n", myHash); + else + fprintf(stderr, " ca=%d\n", hashStyles[hcode].color); + } + } + else + fprintf(stderr, " ca=%d\n", hashStyles[hcode].color); + } + + if (displayStyles[element_number].color > -2) /* actually set */ + { + if (TRACE) + fprintf(stderr, "CSSTRIM: start_element: top <%s>\n", HTML_dtd.tags[element_number].name); + HText_characterStyle(me->text, hcode, 1); + } +#endif /* USE_COLOR_STYLE */ + +#if 0 + me->inStyle[element_number]=1; /* this is a goodthing(tm) */ +#endif + switch (element_number) { case HTML_HTML: - UPDATE_STYLE; - if (me->inUnderline) { + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } break; case HTML_HEAD: - UPDATE_STYLE; - if (me->inUnderline) { + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } @@ -512,7 +625,8 @@ PRIVATE void HTML_start_element ARGS5( char *related = NULL; StrAllocCopy(base, (char *)value[HTML_BASE_HREF]); - if (!(url_type = LYLegitimizeHREF(me, (char**)&base, TRUE))) { + if (!(url_type = LYLegitimizeHREF(me, (char**)&base, + TRUE, TRUE))) { if (TRACE) fprintf(stderr, "HTML: BASE '%s' is not an absolute URL.\n", @@ -592,17 +706,21 @@ PRIVATE void HTML_start_element ARGS5( break; case HTML_TITLE: + if (!me->text) + UPDATE_STYLE; HTChunkClear(&me->title); - if (me->inUnderline) { - if (!me->text) - UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } break; case HTML_LINK: + intern_flag = FALSE; + if (!me->text) + UPDATE_STYLE; if (present && present[HTML_LINK_HREF]) { + CHECK_FOR_INTERN(value[HTML_LINK_HREF]); /* * Prepare to do housekeeping on the reference. - FM */ @@ -614,7 +732,7 @@ PRIVATE void HTML_start_element ARGS5( } } else { StrAllocCopy(href, value[HTML_LINK_HREF]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); } /* @@ -701,13 +819,45 @@ PRIVATE void HTML_start_element ARGS5( /* * Ignore style sheets, for now. - FM */ - if (!strcasecomp(value[HTML_LINK_REL], "StyleSheet")) { + if (!strcasecomp(value[HTML_LINK_REL], "StyleSheet") || + !strcasecomp(value[HTML_LINK_REL], "Style")) { if (TRACE) { fprintf(stderr, "HTML: StyleSheet link found.\n"); - fprintf(stderr, - " StyleSheets not yet implemented.\n"); } +#ifdef LINKEDSTYLES + if (href && *href != '\0') + { + int res = -999; + if ((url_type = is_url(href)) == 0 || + (url_type == FILE_URL_TYPE && LYisLocalFile(href))) { + if (url_type == FILE_URL_TYPE) { + temp = HTParse(href, "", PARSE_PATH+PARSE_PUNCTUATION); + HTUnEscape(temp); + if (temp && *temp != '\0') { + res = style_readFromFile(temp); + if (res != 0) + StrAllocCopy(href, temp); + } + FREE(temp); + } else { + res = style_readFromFile(href); + } + } + if (TRACE) + fprintf(stderr, "CSS: StyleSheet=%s %d\n", href, res); + if (res == 0) + HTAnchor_setStyle (me->node_anchor, href); + } + else + if (TRACE) + fprintf(stderr, + " non-local StyleSheets not yet implemented.\n"); +#else + if (TRACE) + fprintf(stderr, + " StyleSheets not yet implemented.\n"); +#endif FREE(href); break; } @@ -824,7 +974,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0); /* Type */ + INTERN_LT); /* Type */ if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) )) != 0) { @@ -838,7 +988,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ LYToolbarName, /* Tag */ NULL, /* Addresss */ - (void *)0))) { /* Type */ + (HTLinkType*)0))) { /* Type */ HText_appendCharacter(me->text, '#'); HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); @@ -847,7 +997,27 @@ PRIVATE void HTML_start_element ARGS5( HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); +#if USE_COLOR_STYLE + if (present && present[HTML_LINK_CLASS] && + value && *value[HTML_LINK_CLASS]!='\0') + { + char tmp[1024]; + sprintf(tmp, "link.%s.%s.%s", value[HTML_LINK_CLASS], title, value[HTML_LINK_CLASS]); + if (TRACE) + fprintf(stderr, "CSSTRIM:link=%s\n", tmp); + + HText_characterStyle(me->text, hash_code(tmp), 1); + HTML_put_string(me, title); + HTML_put_string(me, " ("); + HTML_put_string(me, value[HTML_LINK_CLASS]); + HTML_put_string(me, ")"); + HText_characterStyle(me->text, hash_code(tmp), 0); + } + else + HTML_put_string(me, title); +#else HTML_put_string(me, title); +#endif if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_END_CHAR); HText_endAnchor(me->text); @@ -857,6 +1027,8 @@ PRIVATE void HTML_start_element ARGS5( break; case HTML_ISINDEX: + if (!me->text) + UPDATE_STYLE; if (((present)) && ((present[HTML_ISINDEX_HREF] && value[HTML_ISINDEX_HREF]) || (present[HTML_ISINDEX_ACTION] && value[HTML_ISINDEX_ACTION]))) { @@ -873,7 +1045,8 @@ PRIVATE void HTML_start_element ARGS5( StrAllocCopy(isindex_href, value[HTML_ISINDEX_HREF]); else StrAllocCopy(isindex_href, value[HTML_ISINDEX_ACTION]); - url_type = LYLegitimizeHREF(me, (char**)&isindex_href, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&isindex_href, + TRUE, TRUE); /* * Check whether a base tag is in effect. @@ -960,8 +1133,9 @@ PRIVATE void HTML_start_element ARGS5( break; case HTML_BODY: - UPDATE_STYLE; - if (me->inUnderline) { + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } @@ -993,7 +1167,8 @@ PRIVATE void HTML_start_element ARGS5( if (present && present[HTML_FRAME_SRC] && value[HTML_FRAME_SRC] && *value[HTML_FRAME_SRC] != '\0') { StrAllocCopy(href, value[HTML_FRAME_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a base tag is in effect. - FM @@ -1019,7 +1194,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0); /* Type */ + INTERN_LT); /* Type */ LYEnsureSingleSpace(me); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR); @@ -1059,7 +1234,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ LYToolbarName, /* Tag */ NULL, /* Addresss */ - (void *)0))) { /* Type */ + (HTLinkType*)0))) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); HText_setToolbar(me->text); @@ -1069,7 +1244,7 @@ PRIVATE void HTML_start_element ARGS5( case HTML_CENTER: case HTML_DIV: - if (me->Division_Level < MAX_NESTING) { + if (me->Division_Level < (MAX_NESTING - 1)) { me->Division_Level++; } else if (TRACE) { fprintf(stderr, @@ -1235,7 +1410,7 @@ PRIVATE void HTML_start_element ARGS5( /* * Mark that we are starting a new paragraph - * and don't have any of it's text yet. - FM + * and don't have any of its text yet. - FM * */ me->inP = FALSE; @@ -1253,6 +1428,19 @@ PRIVATE void HTML_start_element ARGS5( me->inP = FALSE; break; + case HTML_WBR: + UPDATE_STYLE; + LYCheckForID(me, present, value, (int)HTML_GEN_ID); + HText_setBreakPoint(me->text); + break; + + case HTML_HY: + case HTML_SHY: + UPDATE_STYLE; + LYCheckForID(me, present, value, (int)HTML_GEN_ID); + HText_appendCharacter(me->text, LY_SOFT_HYPHEN); + break; + case HTML_HR: { int width; @@ -1456,6 +1644,30 @@ PRIVATE void HTML_start_element ARGS5( case HTML_FONT: if (!me->text) UPDATE_STYLE; + + /* + * FONT *may* have been declared SGML_EMPTY in HTMLDTD.c, and + * SGML_character() in SGML.c *may* check for a FONT end + * tag to call HTML_end_element() directly (with a + * check in that to bypass decrementing of the HTML + * parser's stack). Or this may have been really a </FONT> + * end tag, for which some incarnations of SGML.c would fake + * a <FONT> start tag instead. - fm & kw + * + * But if we have an open FONT, DON'T close that one now, + * since FONT tags can be legally nested AFAIK, and Lynx + * currently doesn't do anything with them anyway... - kw + */ +#ifdef NOTUSED_FOTEMODS + if (me->inFONT == TRUE) + HTML_end_element(me, HTML_FONT, (char **)&include); +#endif /* NOTUSED_FOTEMODS */ + + /* + * Set flag to know we are in a FONT container, and + * add code to do something about it, someday. - FM + */ + me->inFONT = TRUE; break; case HTML_B: /* Physical character highlighting */ @@ -1676,19 +1888,19 @@ PRIVATE void HTML_start_element ARGS5( } me->inP = FALSE; break; - + case HTML_DD: if (!me->text) UPDATE_STYLE; LYCheckForID(me, present, value, (int)HTML_GEN_ID); HText_setLastChar(me->text, ' '); /* absorb white space */ - if (!me->style_change) - HText_appendCharacter(me->text, '\r'); - else - { + if (!me->style_change) { + if (HText_LastLineSize(me->text)) + HText_appendCharacter(me->text, '\r'); + } else { UPDATE_STYLE; HText_appendCharacter(me->text, '\t'); - } + } me->sp->style->alignment = HT_LEFT; me->in_word = NO; me->inP = FALSE; @@ -1865,7 +2077,8 @@ PRIVATE void HTML_start_element ARGS5( UPDATE_STYLE; /* update to the new style */ HText_appendParagraph(me->text); LYCheckForID(me, present, value, (int)HTML_GEN_ID); - HText_appendCharacter(me->text, ' '); + HTML_put_character(me, HT_NON_BREAK_SPACE); + HText_setLastChar(me->text, ' '); me->in_word = NO; break; @@ -1937,28 +2150,33 @@ PRIVATE void HTML_start_element ARGS5( } me->Last_OL_Count = seqnum; me->Last_OL_Type = seqtype; - /* hack, because there is no append string! */ + /* + * Hack, because there is no append string! + */ for (i = 0; number_string[i] != '\0'; i++) if (number_string[i] == ' ') - HText_appendCharacter(me->text, number_string[i]); + HTML_put_character(me, HT_NON_BREAK_SPACE); else HTML_put_character(me, number_string[i]); - /* use HTML_put_character so that any other spaces - * coming through will be collapsed + /* + * Use HTML_put_character so that any other spaces + * coming through will be collapsed. We'll use + * nbsp, so it won't break at the spacing character + * if there are no spaces in the subsequent text up + * to the right margin, but will declare it as a + * normal space to ensure collapsing if a normal + * space does immediately follow it. - FM */ - HTML_put_character(me, ' '); /* the spacing charactor */ + HTML_put_character(me, HT_NON_BREAK_SPACE); + HText_setLastChar(me->text, ' '); } else if (me->sp[0].tag_number == HTML_UL) { /* * Hack, because there is no append string! */ - HText_appendCharacter(me->text, ' '); - HText_appendCharacter(me->text, ' '); - /* - * Use HTML_put_character so that any other spaces - * comming through will be collapsed - */ + HTML_put_character(me, HT_NON_BREAK_SPACE); + HTML_put_character(me, HT_NON_BREAK_SPACE); switch(me->List_Nesting_Level % 7) { case 0: HTML_put_character(me, '*'); @@ -1983,13 +2201,24 @@ PRIVATE void HTML_start_element ARGS5( break; } - HTML_put_character(me, ' '); + /* + * Keep using HTML_put_character so that any other + * spaces coming through will be collapsed. We use + * nbsp, so we won't wrap at the spacing character + * if there are no spaces in the subsequent text up + * to the right margin, but will declare it as a + * normal space to ensure collapsing if a normal + * space does immediately follow it. - FM + */ + HTML_put_character(me, HT_NON_BREAK_SPACE); + HText_setLastChar(me->text, ' '); } else { /* * Hack, because there is no append string! */ - HText_appendCharacter(me->text, ' '); - HText_appendCharacter(me->text, ' '); + HTML_put_character(me, HT_NON_BREAK_SPACE); + HTML_put_character(me, HT_NON_BREAK_SPACE); + HText_setLastChar(me->text, ' '); } me->in_word = NO; me->inP = FALSE; @@ -2041,6 +2270,18 @@ PRIVATE void HTML_start_element ARGS5( break; case HTML_A: + /* + * A may have been declared SGML_EMPTY in HTMLDTD.c, and + * SGML_character() in SGML.c may check for an A end + * tag to call HTML_end_element() directly (with a + * check in that to bypass decrementing of the HTML + * parser's stack), so if we have an open A, close + * that one now. - FM & kw + */ + if (me->inA == TRUE) { + SET_SKIP_STACK(HTML_A); + HTML_end_element(me, HTML_A, (char **)&include); + } /* * Set to know we are in an anchor. */ @@ -2067,6 +2308,11 @@ PRIVATE void HTML_start_element ARGS5( * Handle the reference. - FM */ if (present && present[HTML_A_HREF]) { + + if (present[HTML_A_ISMAP]) + intern_flag = FALSE; + else + CHECK_FOR_INTERN(value[HTML_A_HREF]); /* * Prepare to do housekeeping on the reference. - FM */ @@ -2080,7 +2326,7 @@ PRIVATE void HTML_start_element ARGS5( } else { StrAllocCopy(href, value[HTML_A_HREF]); } - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Deal with our ftp gateway kludge. - FM @@ -2121,22 +2367,31 @@ PRIVATE void HTML_start_element ARGS5( me->inBoldA = TRUE; } } + if (present && present[HTML_A_TYPE] && value[HTML_A_TYPE]) { + StrAllocCopy(temp, value[HTML_A_TYPE]); + if (!intern_flag && href && + !strcasecomp(value[HTML_A_TYPE], HTAtom_name(LINK_INTERNAL)) && + 0 != strcmp(me->node_anchor->address, LYlist_temp_url()) && + 0 != strncmp(me->node_anchor->address, "LYNXIMGMAP:", 11)) { + /* Some kind of spoof? + ** Found TYPE="internal link" but not in a valid context + ** where we have written it. - kw + */ + if (TRACE) + fprintf(stderr, + "HTML: Found invalid HREF=\"%s\" TYPE=\"%s\"!\n", + href, temp); + FREE(temp); + } + } me->CurrentA = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ id_string, /* Tag */ href, /* Address */ - (present && - present[HTML_A_TYPE] && - value[HTML_A_TYPE]) ? - (HTLinkType*)HTAtom_for(value[HTML_A_TYPE]) : (HTLinkType *)0); /* Type */ - - /* - * Get rid of href since no longer needed. - * Memory leak fixed - * 06-16-94 Lynx 2-3-1 Garrett Arch Blythe - */ - FREE(href); + temp ? + (HTLinkType*)HTAtom_for(temp) : INTERN_LT); /* Type */ + FREE(temp); FREE(id_string); if (me->CurrentA && present) { @@ -2190,15 +2445,26 @@ PRIVATE void HTML_start_element ARGS5( HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldA == TRUE && me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); +#ifdef NOTUSED_FOTEMODS + /* + * Close an HREF-less NAMED-ed now if we aren't making their + * content bold, and let the check in HTML_end_element() deal + * with any dangling end tag this creates. - FM + */ + if (href == NULL && me->inBoldA == FALSE) + HTML_end_element(me, HTML_A, (char **)&include); +#endif /* NOTUSED_FOTEMODS */ + FREE(href); break; case HTML_IMG: /* Images */ if (!me->text) UPDATE_STYLE; /* - * If it's a clickable image for the current anchor, - * set our flags for faking a 0,0 coordinate pair, - * which typically returns the image's default. - FM + * If we're in an anchor, get the destination, and if it's a + * clickable image for the current anchor, set our flags for + * faking a 0,0 coordinate pair, which typically returns the + * image's default. - FM */ if (me->inA && me->CurrentA) { if ((dest = HTAnchor_parent( @@ -2208,7 +2474,7 @@ PRIVATE void HTML_start_element ARGS5( dest_ismap = TRUE; if (TRACE) fprintf(stderr, - "HTML: '%s' as an ISMAP script\n", + "HTML: '%s' is an ISMAP script\n", dest->address); } else if (present && present[HTML_IMG_ISMAP]) { dest_ismap = TRUE; @@ -2221,13 +2487,15 @@ PRIVATE void HTML_start_element ARGS5( } } + intern_flag = FALSE; /* unless set below - kw */ /* * If there's a USEMAP, resolve it. - FM */ if (present && present[HTML_IMG_USEMAP] && value[HTML_IMG_USEMAP] && *value[HTML_IMG_USEMAP]) { StrAllocCopy(map_href, value[HTML_IMG_USEMAP]); - url_type = LYLegitimizeHREF(me, (char**)&map_href, TRUE); + CHECK_FOR_INTERN(map_href); + url_type = LYLegitimizeHREF(me, (char**)&map_href, TRUE, TRUE); if (*map_href == '\0') { FREE(map_href); } @@ -2274,6 +2542,15 @@ PRIVATE void HTML_start_element ARGS5( } /* + * Check whether we want to suppress the server-side + * ISMAP link if a client-side MAP is present. - FM + */ + if (LYNoISMAPifUSEMAP && map_href) { + dest_ismap = FALSE; + dest = NULL; + } + + /* * Check for a TITLE attribute. - FM */ if (present && present[HTML_IMG_TITLE] && @@ -2318,10 +2595,10 @@ PRIVATE void HTML_start_element ARGS5( LYTrimHead(alt_string); LYTrimTail(alt_string); if (*alt_string == '\0') { - if (map_href) + if (map_href) { StrAllocCopy(alt_string, (title ? title : "[USEMAP]")); - else if (dest_ismap || present[HTML_IMG_ISMAP]) { + } else if (dest_ismap) { StrAllocCopy(alt_string, (title ? title : "[ISMAP]")); } else if (me->inA == TRUE && dest) { @@ -2367,9 +2644,7 @@ PRIVATE void HTML_start_element ARGS5( fprintf(stderr, "HTML IMG: USEMAP=%d ISMAP=%d ANCHOR=%d PARA=%d\n", map_href ? 1 : 0, - ((dest_ismap == TRUE) || - (me->inA && present && present[HTML_IMG_ISMAP])) ? - 1 : 0, + (dest_ismap == TRUE) ? 1 : 0, me->inA, me->inP); } @@ -2392,7 +2667,7 @@ PRIVATE void HTML_start_element ARGS5( present && present[HTML_IMG_SRC] && value[HTML_IMG_SRC] && *value[HTML_IMG_SRC] != '\0') { StrAllocCopy(href, value[HTML_IMG_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* * Check whether a base tag is in effect. - FM @@ -2424,9 +2699,9 @@ PRIVATE void HTML_start_element ARGS5( * start a new one for the client-side MAP. - FM */ if (map_href) { - if (dest_ismap || (present && present[HTML_IMG_ISMAP])) { + if (dest_ismap) { HTML_put_string(me, "[ISMAP]"); - } else { + } else if (dest) { HTML_put_string(me, "[LINK]"); } if (me->inBoldA == TRUE && me->inBoldH == FALSE) { @@ -2434,13 +2709,14 @@ PRIVATE void HTML_start_element ARGS5( } me->inBoldA = FALSE; HText_endAnchor(me->text); - HText_appendCharacter(me->text, '-'); + if (dest_ismap || dest) + HText_appendCharacter(me->text, '-'); if (id_string) { if ((ID_A = HTAnchor_findChildAndLink( me->node_anchor, /* Parent */ id_string, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } @@ -2449,7 +2725,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ map_href, /* Addresss */ - (void *)0); /* Type */ + INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) @@ -2481,7 +2757,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ id_string, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } @@ -2494,7 +2770,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ id_string, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } @@ -2503,7 +2779,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ map_href, /* Addresss */ - (void *)0); /* Type */ + INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) @@ -2535,7 +2811,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ id_string, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } @@ -2549,7 +2825,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0); /* Type */ + (HTLinkType*)0); /* Type */ FREE(href); HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) @@ -2570,7 +2846,9 @@ PRIVATE void HTML_start_element ARGS5( * We're in an anchor and have a USEMAP, so end the anchor * and start a new one for the client-side MAP. - FM */ - if (!(dest_ismap || (present && present[HTML_IMG_ISMAP]))) { + if (dest_ismap) { + HTML_put_string(me, "[ISMAP]"); + } else if (dest) { HTML_put_string(me, "[LINK]"); } if (me->inBoldA == TRUE && me->inBoldH == FALSE) { @@ -2578,7 +2856,7 @@ PRIVATE void HTML_start_element ARGS5( } me->inBoldA = FALSE; HText_endAnchor(me->text); - if (!(dest_ismap || (present && present[HTML_IMG_ISMAP]))) + if (dest_ismap || dest) HText_appendCharacter(me->text, '-'); } else { HTML_put_character(me, ' '); @@ -2588,7 +2866,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ map_href, /* Addresss */ - (void *)0); /* Type */ + INTERN_LT); /* Type */ if (me->CurrentA && title) { if ((dest = HTAnchor_parent( HTAnchor_followMainLink((HTAnchor*)me->CurrentA) @@ -2625,7 +2903,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ id_string, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } @@ -2666,11 +2944,13 @@ PRIVATE void HTML_start_element ARGS5( * Load map_address. - FM */ if (id_string) { - if (me->inBASE && me->base_href && *me->base_href) { - StrAllocCopy(me->map_address, me->base_href); - } else { - StrAllocCopy(me->map_address, me->node_anchor->address); - } + /* + * The MAP must be in the current stream, even if it + * had a BASE tag, so we'll use its address here, but + * still use the BASE, if present, when resolving the + * AREA elements in its content. - FM && KW + */ + StrAllocCopy(me->map_address, me->node_anchor->address); if ((cp = strrchr(me->map_address, '#')) != NULL) *cp = '\0'; StrAllocCat(me->map_address, "#"); @@ -2701,13 +2981,16 @@ PRIVATE void HTML_start_element ARGS5( present && present[HTML_AREA_HREF] && value[HTML_AREA_HREF] && *value[HTML_AREA_HREF]) { /* - * Resolve the HREF. - FM + * Resolve the HREF. - FM */ StrAllocCopy(href, value[HTML_AREA_HREF]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); /* - * Check whether a base tag is in effect. - FM + * Check whether a BASE tag is in effect, and use it + * for resolving, even though we used this stream's + * address for locating the MAP itself. - FM */ if ((me->inBASE && *href != '\0' && *href != '#') && (temp = HTParse(href, me->base_href, PARSE_ALL)) && @@ -2773,7 +3056,7 @@ PRIVATE void HTML_start_element ARGS5( StrAllocCopy(alt_string, href); } - LYAddMapElement(me->map_address, href, alt_string); + LYAddMapElement(me->map_address, href, alt_string, intern_flag); FREE(href); FREE(alt_string); } @@ -2823,7 +3106,8 @@ PRIVATE void HTML_start_element ARGS5( if (clickable_images && present && present[HTML_FIG_SRC] && value[HTML_FIG_SRC] && *value[HTML_FIG_SRC] != '\0') { StrAllocCopy(href, value[HTML_FIG_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -2849,7 +3133,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + INTERN_LT))) { /* Type */ HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); @@ -2996,7 +3280,8 @@ PRIVATE void HTML_start_element ARGS5( present && present[HTML_OVERLAY_SRC] && value[HTML_OVERLAY_SRC] && *value[HTML_OVERLAY_SRC] != '\0') { StrAllocCopy(href, value[HTML_OVERLAY_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -3022,7 +3307,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + INTERN_LT))) { /* Type */ if (!me->text) { UPDATE_STYLE; } else { @@ -3124,7 +3409,7 @@ PRIVATE void HTML_start_element ARGS5( StrAllocCopy(base, "/"); if (base[strlen(base)-1] != '/') StrAllocCat(base, "/"); - url_type = LYLegitimizeHREF(me, (char**)&base, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&base, TRUE, FALSE); /* * Check whether to fill in localhost. - FM @@ -3155,7 +3440,7 @@ PRIVATE void HTML_start_element ARGS5( } StrAllocCopy(code, value[HTML_APPLET_CODE]); - url_type = LYLegitimizeHREF(me, (char**)&code, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&code, TRUE, FALSE); href = HTParse(code, base, PARSE_ALL); FREE(base); FREE(code); @@ -3165,7 +3450,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + (HTLinkType*)0))) { /* Type */ HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); @@ -3196,7 +3481,8 @@ PRIVATE void HTML_start_element ARGS5( if (clickable_images && present && present[HTML_BGSOUND_SRC] && value[HTML_BGSOUND_SRC] && *value[HTML_BGSOUND_SRC] != '\0') { StrAllocCopy(href, value[HTML_BGSOUND_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href == '\0') { FREE(href); break; @@ -3228,7 +3514,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + INTERN_LT))) { /* Type */ HTML_put_character(me, ' '); /* space char may be ignored */ me->in_word = NO; HText_beginAnchor(me->text, me->CurrentA); @@ -3307,7 +3593,8 @@ PRIVATE void HTML_start_element ARGS5( if (clickable_images && present && present[HTML_EMBED_SRC] && value[HTML_EMBED_SRC] && *value[HTML_EMBED_SRC] != '\0') { StrAllocCopy(href, value[HTML_EMBED_SRC]); - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + CHECK_FOR_INTERN(href); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href != '\0') { /* * Check whether a base tag is in effect. - FM @@ -3333,7 +3620,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + INTERN_LT))) { /* Type */ HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); @@ -3432,7 +3719,8 @@ PRIVATE void HTML_start_element ARGS5( HTChildAnchor * source; HTAnchor *link_dest; - UPDATE_STYLE; + if (!me->text) + UPDATE_STYLE; /* * FORM was declared SGML_EMPTY in HTMLDTD.c, and * SGML_character() in SGML.c checks for a FORM end @@ -3446,6 +3734,7 @@ PRIVATE void HTML_start_element ARGS5( fprintf(stderr, "HTML: Missing FORM end tag. Faking it!\n"); } + SET_SKIP_STACK(HTML_FORM); HTML_end_element(me, HTML_FORM, (char **)&include); } @@ -3460,7 +3749,7 @@ PRIVATE void HTML_start_element ARGS5( * Prepare to do housekeeping on the reference. - FM */ StrAllocCopy(action, value[HTML_FORM_ACTION]); - url_type = LYLegitimizeHREF(me, (char**)&action, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&action, TRUE, TRUE); /* * Check whether a base tag is in effect. @@ -3496,8 +3785,8 @@ PRIVATE void HTML_start_element ARGS5( source = HTAnchor_findChildAndLink(me->node_anchor, NULL, action, - (void *)0); - if ((link_dest = HTAnchor_followMainLink((HTAnchor *)source)) != 0) { + (HTLinkType*)0); + if ((link_dest = HTAnchor_followMainLink((HTAnchor *)source)) != NULL) { /* * Memory leak fixed. * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe @@ -3562,8 +3851,6 @@ PRIVATE void HTML_start_element ARGS5( FREE(enctype); FREE(title); } - if (!me->text) - UPDATE_STYLE; LYCheckForID(me, present, value, (int)HTML_FORM_ID); break; @@ -3585,6 +3872,7 @@ PRIVATE void HTML_start_element ARGS5( int chars; BOOL UseALTasVALUE = FALSE; BOOL HaveSRClink = FALSE; + BOOL IsSubmitOrReset = FALSE; /* * Make sure we're in a form. @@ -3626,10 +3914,22 @@ PRIVATE void HTML_start_element ARGS5( UPDATE_STYLE; /* - * Before any input field add a space if necessary + * Before any input field, add a collapsible space if + * we're not in a PRE block, to promote a wrap there + * for any long values that would extent past the right + * margin from our current position in the line. If + * we are in a PRE block, start a new line if the last + * line already is within 6 characters of the wrap point + * for PRE blocks. - FM */ - HTML_put_character(me, ' '); - me->in_word = NO; + if (me->sp[0].tag_number != HTML_PRE && !me->inPRE && + me->sp->style->freeFormat) { + HTML_put_character(me, ' '); + me->in_word = NO; + } else if (HText_LastLineSize(me->text) > (LYcols - 7)) { + HTML_put_character(me, '\n'); + me->in_word = NO; + } if (present && present[HTML_INPUT_NAME] && value[HTML_INPUT_NAME]) I.name = (char *)value[HTML_INPUT_NAME]; @@ -3699,7 +3999,7 @@ PRIVATE void HTML_start_element ARGS5( * SRC's value a link if it's still not zero-length * legitiimizing it. - FM */ - url_type = LYLegitimizeHREF(me, (char**)&href, TRUE); + url_type = LYLegitimizeHREF(me, (char**)&href, TRUE, TRUE); if (*href) { /* * Check whether a base tag is in effect. - FM @@ -3726,7 +4026,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ NULL, /* Tag */ href, /* Addresss */ - (void *)0))) { /* Type */ + (HTLinkType*)0))) { /* Type */ HText_beginAnchor(me->text, me->CurrentA); if (me->inBoldH == FALSE) HText_appendCharacter(me->text, LY_BOLD_START_CHAR); @@ -3848,20 +4148,127 @@ PRIVATE void HTML_start_element ARGS5( I.md = (char *)value[HTML_INPUT_MD]; chars = HText_beginInput(me->text, &I); - if (me->sp[0].tag_number == HTML_PRE && chars > 20) { + /* + * Submit and reset buttons have values which don't change, + * so HText_beginInput() sets I.value to the string which + * should be displayed, and we'll enter that instead of + * underscore placeholders into the HText structure to + * see it instead of underscores when dumping or printing. + * We also won't worry about a wrap in PRE blocks, because + * the line editor never is invoked for submit or reset + * buttons. - LE & FM + */ + if (I.type && + (!strcasecomp(I.type,"submit") || + !strcasecomp(I.type,"reset") || + !strcasecomp(I.type,"image"))) + IsSubmitOrReset = TRUE; + + if (I.type && chars == 3 && + !strcasecomp(I.type, "radio")) { + /* + * Put a (_) placeholder, and one space + * (collapsible) before the label that is + * expected to follow. - FM + */ + HTML_put_string(me, "(_)"); + chars = 0; + me->in_word = YES; + if (me->sp[0].tag_number != HTML_PRE && + !me->sp->style->freeFormat) { + HTML_put_character(me, ' '); + me->in_word = NO; + } + } else if (I.type && chars == 3 && + !strcasecomp(I.type, "checkbox")) { + /* + * Put a [_] placeholder, and one space + * (collapsible) before the label that is + * expected to follow. - FM + */ + HTML_put_string(me, "[_]"); + chars = 0; + me->in_word = YES; + if (me->sp[0].tag_number != HTML_PRE && + !me->sp->style->freeFormat) { + HTML_put_character(me, ' '); + me->in_word = NO; + } + } else if ((me->sp[0].tag_number == HTML_PRE || + !me->sp->style->freeFormat) + && chars > 6 && + IsSubmitOrReset == FALSE) { /* - * The code inadequately handles INPUT fields in PRE tags. - * We'll put up a minimum of 20 underscores, and if any - * more would exceed the wrap column, we'll ignore them. + * This is not a submit or reset button, and we are + * in a PRE block with a field intended to exceed 6 + * character widths. The code inadequately handles + * INPUT fields in PRE tags if wraps occur (at the + * right margin) for the underscore placeholders. + * We'll put up a minimum of 6 underscores, since we + * should have wrapped artificially, above, if the + * INPUT begins within 6 columns of the right margin, + * and if any more would exceed the wrap column, we'll + * ignore them. Note that if we somehow get tripped + * up and a wrap still does occur before all 6 of the + * underscores are output, the wrapped ones won't be + * treated as part of the editing window, nor be + * highlighted when not editing (Yuk!). - FM */ - for (i = 0; i < 20; i++) { + for (i = 0; i < 6; i++) { HTML_put_character(me, '_'); chars--; } HText_setIgnoreExcess(me->text, TRUE); } - for (; chars > 0; chars--) - HTML_put_character(me, '_'); + if (IsSubmitOrReset == FALSE) { + /* + * This is not a submit or reset button, + * so output the rest of the underscore + * placeholders, if any more are needed. - FM + */ + for (; chars > 0; chars--) + HTML_put_character(me, '_'); + } else { + if (me->sp[0].tag_number == HTML_PRE || + !me->sp->style->freeFormat) { + /* + * We have a submit or reset button in a PRE block, + * so output the entire value from the markup. If + * it extends to the right margin, it will wrap + * there, and only the portion before that wrap will + * be hightlighted on screen display (Yuk!) but we + * may as well show the rest of the full value on + * the next or more lines. - FM + */ + while (I.value[i]) + HTML_put_character(me, I.value[i++]); + } else { + /* + * The submit or reset button is not in a PRE block. + * Note that if a wrap occurs before outputting the + * entire value, the wrapped portion will not be + * highlighted or clearly indicated as part of the + * link for submission or reset (Yuk!). + * We'll replace any spaces in the submit or reset + * button value with nbsp, to promote a wrap at the + * space we ensured would be present before the start + * of the string, as when we use all underscores + * instead of the INPUT's actual value, but we could + * still get a wrap at the right margin, instead, if + * the value is greater than a line width for the + * current style. Also, if chars somehow ended up + * longer than the length of the actual value + * (shouldn't have), we'll continue padding with nbsp + * up to the length of chars. - FM + */ + for (i = 0; I.value[i]; i++) + HTML_put_character(me, + (I.value[i] == ' ' ? + HT_NON_BREAK_SPACE : I.value[i])); + while (i < chars) + HTML_put_character(me, HT_NON_BREAK_SPACE); + } + } HText_setIgnoreExcess(me->text, FALSE); } break; @@ -3925,10 +4332,10 @@ PRIVATE void HTML_start_element ARGS5( LYUnEscapeToLatinOne(&id_string, TRUE); if ((id_string != '\0') && (ID_A = HTAnchor_findChildAndLink( - me->node_anchor, /* Parent */ - id_string, /* Tag */ - NULL, /* Addresss */ - (void *)0))) { /* Type */ + me->node_anchor, /* Parent */ + id_string, /* Tag */ + NULL, /* Addresss */ + (HTLinkType*)0))) { /* Type */ if (!me->text) UPDATE_STYLE; HText_beginAnchor(me->text, ID_A); @@ -4029,13 +4436,29 @@ PRIVATE void HTML_start_element ARGS5( me->inUnderline = FALSE; } + if ((multiple == NO && LYSelectPopups == TRUE) && + (me->sp[0].tag_number == HTML_PRE || me->inPRE == TRUE || + !me->sp->style->freeFormat) && + HText_LastLineSize(me->text) > (LYcols - 8)) { + /* + * Force a newline when we're using a popup in + * a PRE block and are within 7 columns from the + * right margin. This will allow for the '[' + * popup designater and help avoid a wrap in the + * underscore placeholder for the retracted popup + * entry in the HText structure. - FM + */ + HTML_put_character(me, '\n'); + me->in_word = NO; + } + LYCheckForID(me, present, value, (int)HTML_SELECT_ID); HText_beginSelect(name, multiple, size); FREE(name); FREE(size); - first_option = TRUE; + me->first_option = TRUE; } break; @@ -4067,7 +4490,7 @@ PRIVATE void HTML_start_element ARGS5( if (!me->text) UPDATE_STYLE; - if (!first_option) { + if (!me->first_option) { /* * Finish the data off. */ @@ -4088,7 +4511,7 @@ PRIVATE void HTML_start_element ARGS5( * are enabled, then don't use the checkbox/button method, * and don't put anything on the screen yet. */ - if (first_option || + if (me->first_option || HTCurSelectGroupType == F_CHECKBOX_TYPE || LYSelectPopups == FALSE) { if (HTCurSelectGroupType == F_CHECKBOX_TYPE || @@ -4117,7 +4540,7 @@ PRIVATE void HTML_start_element ARGS5( I.type = "OPTION"; if ((present && present[HTML_OPTION_SELECTED]) || - (first_option && LYSelectPopups == FALSE && + (me->first_option && LYSelectPopups == FALSE && HTCurSelectGroupType == F_RADIO_TYPE)) I.checked=YES; @@ -4159,7 +4582,7 @@ PRIVATE void HTML_start_element ARGS5( me->node_anchor, /* Parent */ value[HTML_OPTION_ID], /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (HTLinkType*)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); I.id = (char *)value[HTML_OPTION_ID]; @@ -4168,13 +4591,26 @@ PRIVATE void HTML_start_element ARGS5( HText_beginInput(me->text, &I); - if (HTCurSelectGroupType == F_CHECKBOX_TYPE || - LYSelectPopups == FALSE) { + if (HTCurSelectGroupType == F_CHECKBOX_TYPE) { + /* + * Put a "[_]" placeholder, and one space + * (collapsible) before the label that is + * expected to follow. - FM + */ + HText_appendCharacter(me->text, '['); + HText_appendCharacter(me->text, '_'); + HText_appendCharacter(me->text, ']'); + HText_appendCharacter(me->text, ' '); + me->in_word = NO; + } else if (LYSelectPopups == FALSE) { /* - * Put 3 underscores and one space before each option. + * Put a "(_)" placeholder, and one space + * (collapsible) before the label that is + * expected to follow. - FM */ - for (i = 0; i < 3; i++) - HText_appendCharacter(me->text, '_'); + HText_appendCharacter(me->text, '('); + HText_appendCharacter(me->text, '_'); + HText_appendCharacter(me->text, ')'); HText_appendCharacter(me->text, ' '); me->in_word = NO; } @@ -4185,12 +4621,12 @@ PRIVATE void HTML_start_element ARGS5( */ HTChunkClear(&me->option); if ((present && present[HTML_OPTION_SELECTED]) || - (first_option && LYSelectPopups == FALSE && + (me->first_option && LYSelectPopups == FALSE && HTCurSelectGroupType == F_RADIO_TYPE)) me->LastOptionChecked = TRUE; else me->LastOptionChecked = FALSE; - first_option = FALSE; + me->first_option = FALSE; if (present && present[HTML_OPTION_VALUE] && @@ -4275,11 +4711,27 @@ PRIVATE void HTML_start_element ARGS5( } /* end switch */ - if (HTML_dtd.tags[element_number].contents!= SGML_EMPTY) { + if (HTML_dtd.tags[element_number].contents != SGML_EMPTY) { + if (me->skip_stack > 0) { + if (TRACE) + fprintf(stderr, + "HTML:begin_element: internal call (level %d), leaving on stack - %s\n", + me->skip_stack, me->sp->style->name); + me->skip_stack--; + return; + } if (me->sp == me->stack) { - fprintf(stderr, - "HTML: ****** Maximum nesting of %d tags exceeded!\n", - MAX_NESTING); + if (me->stack_overrun == FALSE) { + if (TRACE) { + fprintf(stderr, + "HTML: ****** Maximum nesting of %d tags exceeded!\n", + MAX_NESTING); + + } else { + HTAlert(HTML_STACK_OVERRUN); + } + me->stack_overrun = TRUE; + } return; } @@ -4291,6 +4743,49 @@ PRIVATE void HTML_start_element ARGS5( fprintf(stderr,"HTML:begin_element: adding style to stack - %s\n", me->new_style->name); } + +#if defined(USE_COLOR_STYLE) +/* end empty tags straight away */ + if (HTML_dtd.tags[element_number].contents == SGML_EMPTY) + { + if (TRACE) + fprintf(stderr, "STYLE:begin_element:ending EMPTY element style\n"); +#if !defined(USEHASH) + HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); +#else + HText_characterStyle(me->text, hcode, STACK_OFF); +#endif /* USEHASH */ + { + char *end, *start=NULL, *lookfrom; + char tmp[64]; + sprintf(tmp, ";%s", HTML_dtd.tags[element_number].name); + strtolower(tmp); + + lookfrom = Style_className; + do + { + end = start; + start = strstr(lookfrom, tmp); + lookfrom = start + 1; + } + while (start); + if (end) + *end='\0'; + +#if defined(PREVAIL) + start=strrchr(Style_className, '.'); + if (start) + strcpy(prevailing_class, (char*)(start+1)); + else + strcpy(prevailing_class, ""); +#endif + + + if (TRACE) + fprintf(stderr, "CSS:%s (trimmed %s, SGML_EMPTY)\n", Style_className, tmp); + } + } +#endif /* USE_COLOR_STYLE */ } /* End Element @@ -4317,7 +4812,7 @@ PRIVATE void HTML_end_element ARGS3( #ifdef CAREFUL /* parser assumed to produce good nesting */ if (element_number != me->sp[0].tag_number && - HTML_dtd.tags[element_number].contents != SGML_EMPTY) { + HTML_dtd.tags[element_number].contents != SGML_EMPTY) { fprintf(stderr, "HTMLText: end of element %s when expecting end of %s\n", HTML_dtd.tags[element_number].name, @@ -4337,10 +4832,31 @@ PRIVATE void HTML_end_element ARGS3( } /* - * Pop state off stack if it's not a FORM end tag. - FM + * Pop state off stack if we didn't declare the element + * SGML_EMPTY in HTMLDTD.c. - FM & KW */ if (HTML_dtd.tags[element_number].contents != SGML_EMPTY) { - if (me->sp < me->stack + MAX_NESTING+1) { + if (me->skip_stack > 0) { + if (TRACE) + fprintf(stderr, + "HTML:end_element: Internal call (level %d), leaving on stack - %s\n", + me->skip_stack, me->sp->style->name); + me->skip_stack--; + } else if (me->stack_overrun == TRUE && + element_number != me->sp[0].tag_number) { + /* + * Ignore non-corresponding tags if we had + * a stack overrun. This is not a completely + * fail-safe strategy for protection against + * any seriously adverse consequences of a + * stack overrun, and the rendering of the + * document will not be as intended, but we + * expect overruns to be rare, and this should + * offer reasonable protection against crashes + * if an overrun does occur. - FM + */ + return; + } else if (me->sp < (me->stack + MAX_NESTING - 1)) { (me->sp)++; if (TRACE) fprintf(stderr, @@ -4371,24 +4887,27 @@ PRIVATE void HTML_end_element ARGS3( switch(element_number) { case HTML_HTML: - if (me->inUnderline) { - if (!me->text) - UPDATE_STYLE; + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } - if (me->inA || me->inFORM || me->inSELECT || me->inTEXTAREA) - if (TRACE) + if (me->inA || me->inSELECT || me->inTEXTAREA) + if (TRACE) { fprintf(stderr, "HTML: Something not closed before HTML close-tag\n"); - else if (!me->inBadHTML) { + } else if (!me->inBadHTML) { _statusline(BAD_HTML_USE_TRACE); + me->inBadHTML = TRUE; + sleep(MessageSecs); } break; case HTML_HEAD: - UPDATE_STYLE; - if (me->inUnderline) { + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } @@ -4396,17 +4915,12 @@ PRIVATE void HTML_end_element ARGS3( HText_appendParagraph(me->text); break; -#ifdef NOT_DEFINED /* BASE will be a container in HTML+ */ - case HTML_BASE: - FREE(me->base_href); - me->inBASE = FALSE; - break; -#endif /* NOT_DEFINED */ - case HTML_TITLE: HTChunkTerminate(&me->title); HTAnchor_setTitle(me->node_anchor, me->title.data); HTChunkClear(&me->title); + if (!me->text) + UPDATE_STYLE; /* * Check if it's a bookmark file, and if so, and multiple * bookmark support is on, or it's off but this isn't the @@ -4481,18 +4995,20 @@ PRIVATE void HTML_end_element ARGS3( break; case HTML_BODY: - if (me->inUnderline) { - if (!me->text) - UPDATE_STYLE; + if (!me->text) + UPDATE_STYLE; + if (me->inUnderline) { /* This block could go away(?) - kw */ HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; } - if (me->inA || me->inFORM || me->inSELECT || me->inTEXTAREA) - if (TRACE) + if (me->inA || me->inSELECT || me->inTEXTAREA) + if (TRACE) { fprintf(stderr, "HTML: Something not closed before BODY close-tag\n"); - else if (!me->inBadHTML) { + } else if (!me->inBadHTML) { _statusline(BAD_HTML_USE_TRACE); + me->inBadHTML = TRUE; + sleep(MessageSecs); } break; @@ -4575,10 +5091,83 @@ PRIVATE void HTML_end_element ARGS3( } break; -#ifdef NOTDEFINED + case HTML_P: + UPDATE_STYLE; + /* + * In general, treat </P> as an instruction to + * end the current line if it has been started, + * and ensure spacing as required by the current + * paragraph style's spaceAfter. Don't insert + * spacing required for starting the next paragraph + * as required by its style->spaceBefore, since we + * don't know yet whether the next structure element + * (if any) will be. If it is a another P, it will + * take care of its leading space on its own. - kw + */ + if (me->List_Nesting_Level >= 0) { + /* + * We're in a list. Treat </P> as an instruction to + * end the current line if it has been started, + * and set "second line" margins. + */ + if (me->inP) { + if (me->inFIG || me->inAPPLET || + me->inCAPTION || me->inCREDIT || + me->sp->style->spaceAfter > 0) { + LYEnsureDoubleSpace(me); + } else { + LYEnsureSingleSpace(me); + } + } + } else if (me->sp[0].tag_number == HTML_ADDRESS) { + /* + * We're in an ADDRESS. Treat </P> as an instruction + * to start a newline, if needed. - kw + */ + if (HText_LastLineSize(me->text)) { + HText_appendCharacter(me->text, '\r'); + } + } else { + if (me->sp->style->spaceAfter > 0) { + LYEnsureDoubleSpace(me); + } else { + LYEnsureSingleSpace(me); + } + me->inLABEL = FALSE; + } + me->in_word = NO; + + /* + * If the P ending here had an ALIGN attribute, we have to + * revert to whatever is in effect for outer elements or + * the default. - kw + */ + if (LYoverride_default_alignment(me)) { + me->sp->style->alignment = styles[me->sp[0].tag_number]->alignment; + } else if (me->List_Nesting_Level >= 0 || + ((me->Division_Level < 0) && + (!strcmp(me->sp->style->name, "Normal") || + !strcmp(me->sp->style->name, "Preformatted")))) { + me->sp->style->alignment = HT_LEFT; + } else { + me->sp->style->alignment = me->current_default_alignment; + } + + /* + * Mark that we have to start a new paragraph + * and don't have any of its text yet. - kw + * + */ + me->inP = FALSE; + break; -#endif /* NOTDEFINED */ + + case HTML_FONT: + if (!me->text) + UPDATE_STYLE; + me->inFONT = FALSE; + break; case HTML_B: /* Physical character highlighting */ case HTML_BLINK: @@ -4590,9 +5179,19 @@ PRIVATE void HTML_end_element ARGS3( case HTML_STRONG: if (!me->text) UPDATE_STYLE; - if (me->Underline_Level > 0) - me->Underline_Level--; - if (me->inUnderline == TRUE && me->Underline_Level < 1) { + /* + * Ignore any emphasis end tags if the + * Underline_Level is not set. - FM + */ + if (me->Underline_Level <= 0) + break; + + /* + * Adjust the Underline level counter, and + * turn off underlining if appropriate. - FM + */ + me->Underline_Level--; + if (me->inUnderline && me->Underline_Level < 1) { HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; if (TRACE) @@ -4617,6 +5216,8 @@ PRIVATE void HTML_end_element ARGS3( case HTML_SUP: case HTML_TT: case HTML_VAR: + if (!me->text) + UPDATE_STYLE; break; case HTML_DEL: @@ -4648,6 +5249,8 @@ PRIVATE void HTML_end_element ARGS3( break; case HTML_Q: + if (!me->text) + UPDATE_STYLE; if (me->Quote_Level > 0) me->Quote_Level--; /* @@ -4664,6 +5267,7 @@ PRIVATE void HTML_end_element ARGS3( break; case HTML_PRE: /* Formatted text */ + me->inPRE = FALSE; case HTML_LISTING: /* Litteral text */ case HTML_XMP: case HTML_PLAINTEXT: @@ -4672,6 +5276,10 @@ PRIVATE void HTML_end_element ARGS3( if (me->comment_start) HText_appendText(me->text, me->comment_start); change_paragraph_style(me, me->sp->style); /* Often won't really change */ + if (me->List_Nesting_Level >= 0) { + UPDATE_STYLE; + HText_NegateLineOne(me->text); + } break; case HTML_NOTE: @@ -4716,9 +5324,16 @@ PRIVATE void HTML_end_element ARGS3( * attributes, and the me->node_anchor->charset and/or * yet to be added structure elements. - FM */ + if (!me->text) + UPDATE_STYLE; break; case HTML_A: + /* + * Ignore any spurious A end tags. - FM + */ + if (me->inA == FALSE) + break; /* * Set to know that we are no longer in an anchor. */ @@ -5108,9 +5723,9 @@ End_Object: case HTML_FORM: /* * Check if we had a FORM start tag, and issue a - * message if not, but fall through to ensure that - * the FORM-related globals in GridText.c are - * initialized. - FM + * message if not, but fall through to check for + * an open SELECT and ensure that the FORM-related + * globals in GridText.c are initialized. - FM */ if (!me->inFORM) { if (TRACE) { @@ -5123,13 +5738,46 @@ End_Object: } /* + * Check if we still have a SELECT element open. + * FORM may have been declared SGML_EMPTY in HTMLDTD.c, + * and in that case SGML_character() in SGML.c is + * not able to ensure correct nesting; or it may have + * failed to enforce valid nesting. If a SELECT is open, + * issue a message, then + * call HTML_end_element() directly (with a + * check in that to bypass decrementing of the HTML + * parser's stack) to close the SELECT. - kw + */ + if (me->inSELECT) { + if (TRACE) { + fprintf(stderr, + "HTML: Open SELECT at FORM end. Faking SELECT end tag.\n"); + } else if (!me->inBadHTML) { + _statusline(BAD_HTML_USE_TRACE); + me->inBadHTML = TRUE; + sleep(MessageSecs); + } + SET_SKIP_STACK(HTML_SELECT); + HTML_end_element(me, HTML_SELECT, (char **)&include); + } + + /* * Set to know that we are no longer in an form. */ me->inFORM = FALSE; - UPDATE_STYLE; + if (!me->text) + UPDATE_STYLE; HText_endForm(me->text); - HText_appendCharacter(me->text, '\r'); + /* + * If we are in a list and are on the first line + * with no text following a bullet or number, + * don't force a newline. This could happen if + * we were called from HTML_start_element() due + * to a missing FORM end tag. - FM + */ + if (!(me->List_Nesting_Level >= 0 && !me->inP)) + LYEnsureSingleSpace(me); break; case HTML_FIELDSET: @@ -5266,6 +5914,26 @@ End_Object: me->select_disabled = FALSE; /* + * Make sure we're in a form. + */ + if (!me->inFORM) { + if (TRACE) { + fprintf(stderr, + "HTML: SELECT end tag not within FORM tag\n"); + } else if (!me->inBadHTML) { + _statusline(BAD_HTML_USE_TRACE); + me->inBadHTML = TRUE; + sleep(MessageSecs); + } + + /* + * Too likely to cause a crash, so we'll ignore it. - kw + */ + HTChunkClear(&me->option); + break; + } + + /* * Finish the data off. */ HTChunkTerminate(&me->option); @@ -5291,13 +5959,15 @@ End_Object: * but use non-breaking spaces for output. */ if (ptr && - me->sp[0].tag_number == HTML_PRE && strlen(ptr) > 20) { + (me->sp[0].tag_number == HTML_PRE || me->inPRE == TRUE || + !me->sp->style->freeFormat) && + strlen(ptr) > 6) { /* * The code inadequately handles OPTION fields in PRE tags. - * We'll put up a minimum of 20 characters, and if any + * We'll put up a minimum of 6 characters, and if any * more would exceed the wrap column, we'll ignore them. */ - for (i = 0; i < 20; i++) { + for (i = 0; i < 6; i++) { if (*ptr == ' ') HText_appendCharacter(me->text,HT_NON_BREAK_SPACE); else @@ -5338,7 +6008,7 @@ End_Object: me->inTABLE = FALSE; break; -#ifdef NOTDEFINED /* These are SGML_EMPTY for now. - FM */ +/* These TABLE related elements may now not be SGML_EMPTY. - kw */ case HTML_TR: break; @@ -5355,7 +6025,14 @@ End_Object: case HTML_TD: break; -#endif /* NOTDEFINED */ + +/* More stuff that may now not be SGML_EMPTY any more: */ + case HTML_DT: + case HTML_DD: + case HTML_LH: + case HTML_LI: + case HTML_OVERLAY: + break; case HTML_MATH: if (!me->text) @@ -5388,6 +6065,48 @@ End_Object: break; } /* switch */ +#ifdef USE_COLOR_STYLE + { + char *end, *start=NULL, *lookfrom; + char tmp[64]; + sprintf(tmp, ";%s", HTML_dtd.tags[element_number].name); + strtolower(tmp); + + lookfrom = Style_className; + do + { + end = start; + start = strstr(lookfrom, tmp); + lookfrom = start + 1; + } + while (start); +/* trim the last matching element off the end +** - should match classes here as well (rp) +*/ + if (end) + *end='\0'; + if (TRACE) + fprintf(stderr, "CSS:%s (trimmed %s, END_ELEMENT)\n", Style_className, tmp); + } + + if (HTML_dtd.tags[element_number].contents != SGML_EMPTY) + { + if (TRACE) + fprintf(stderr, "STYLE:end_element: ending non-EMPTY style\n"); +#if !defined(USEHASH) + HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF); +#else + HText_characterStyle(me->text, hcode, STACK_OFF); +#endif /* USEHASH */ +#if defined(PREVAIL) + /* reset the prevailing class to the previous one */ + { + char *dot=strrchr(Style_className,'.'); + strcpy (prevailing_class, dot ? (char*)(dot+1) : ""); + } +#endif + } +#endif /* USE_COLOR_STYLE */ } /* Expanding entities @@ -5440,28 +6159,54 @@ PRIVATE void HTML_free ARGS1(HTStructured *, me) { char *include = NULL; + if (LYMapsOnly && !me->text) { + /* + * We only handled MAP, AREA and BASE tags, and didn't + * create an HText structure for the document nor want + * one now, so just make sure we free anything that might + * have been allocated. - FM + */ + FREE(me->base_href); + FREE(me->map_address); + FREE(me); + return; + } + UPDATE_STYLE; /* Creates empty document here! */ if (me->comment_end) HTML_put_string(me, me->comment_end); if (me->text) { - /* - * Emphasis containers should have been closed via - * the SGML_free() wind-down, but let's play it - * safe. - FM + /* + * Emphasis containters, A, FONT, and FORM may be declared + * SGML_EMPTY in HTMLDTD.c, and SGML_character() in SGML.c + * may check for their end tags to call HTML_end_element() + * directly (with a check in that to bypass decrementing + * of the HTML parser's stack). So if we still have the + * emphasis (Underline) on, or any open A, FONT, or FORM + * containers, turn it off or close them now. - FM & kw + * + * IF those tags are not declared SGML_EMPTY, but we let + * the SGML.c parser take care of correctly stacked ordering, + * and of correct wind-down on end-of-stream (in SGML_free + * SGML_abort), + * THEN these and other checks here in HTML.c should not be + * necessary. Still it can't hurt to include them. - kw */ if (me->inUnderline) { HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; + me->Underline_Level = 0; + if (TRACE) + fprintf(stderr,"HTML_free: Ending underline\n"); + } + if (me->inA) { + HTML_end_element(me, HTML_A, (char **)&include); + me->inA = FALSE; + } + if (me->inFONT) { + HTML_end_element(me, HTML_FONT, (char **)&include); + me->inFONT = FALSE; } - - /* - * FORM was declared SGML_EMPTY in HTMLDTD.c, and - * SGML_character() in SGML.c checks for a FORM end - * tag to call HTML_end_element() directly (with a - * check in that to bypass decrementing of the HTML - * parser's stack), so if we still have an open FORM, - * close it now. - FM - */ if (me->inFORM) { HTML_end_element(me, HTML_FORM, (char **)&include); me->inFORM = FALSE; @@ -5501,16 +6246,22 @@ PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e) if (me->text) { /* - * If we have an open emphasis container, close it now. - FM + * If we have emphasis on, or open A, FONT, or FORM + * containers, turn it off or close them now. - FM */ if (me->inUnderline) { HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); me->inUnderline = FALSE; + me->Underline_Level = 0; + } + if (me->inA) { + HTML_end_element(me, HTML_A, (char **)&include); + me->inA = FALSE; + } + if (me->inFONT) { + HTML_end_element(me, HTML_FONT, (char **)&include); + me->inFONT = FALSE; } - - /* - * If we have an open FORM container, close it now. - FM - */ if (me->inFORM) { HTML_end_element(me, HTML_FORM, (char **)&include); me->inFORM = FALSE; @@ -5714,6 +6465,7 @@ PUBLIC HTStructured* HTML_new ARGS3( me->option.growby = 128; me->option.allocated = 0; me->option.data = NULL; + me->first_option = TRUE; me->LastOptionValue = NULL; me->LastOptionChecked = FALSE; me->select_disabled = FALSE; @@ -5748,10 +6500,12 @@ PUBLIC HTStructured* HTML_new ARGS3( me->new_style = default_style; me->old_style = 0; me->current_default_alignment = HT_LEFT; - me->sp = me->stack + MAX_NESTING - 1; + me->sp = (me->stack + MAX_NESTING - 1); + me->skip_stack = 0; me->sp->tag_number = -1; /* INVALID */ me->sp->style = default_style; /* INVALID */ me->sp->style->alignment = HT_LEFT; + me->stack_overrun = FALSE; me->Division_Level = -1; me->Underline_Level = 0; @@ -5773,6 +6527,7 @@ PUBLIC HTStructured* HTML_new ARGS3( me->inAPPLET = FALSE; me->inAPPLETwithP = FALSE; me->inBadBASE = FALSE; + me->inBadHREF = FALSE; me->inBadHTML = FALSE; me->inBASE = FALSE; me->inBoldA = FALSE; @@ -5781,6 +6536,7 @@ PUBLIC HTStructured* HTML_new ARGS3( me->inCREDIT = FALSE; me->inFIG = FALSE; me->inFIGwithP = FALSE; + me->inFONT = FALSE; me->inFORM = FALSE; me->inLABEL = FALSE; me->inP = FALSE; @@ -69,6 +69,7 @@ struct _HTStructured { char * object_codetype; char * object_name; HTChunk option; /* Grow by 128 */ + BOOL first_option; /* First OPTION in SELECT? */ char * LastOptionValue; BOOL LastOptionChecked; BOOL select_disabled; @@ -111,6 +112,8 @@ struct _HTStructured { BOOL in_word; /* Have just had a non-white char */ stack_element stack[MAX_NESTING]; stack_element *sp; /* Style stack pointer */ + BOOL stack_overrun; /* Was MAX_NESTING exceeded? */ + int skip_stack; /* flag to skip next style stack operation */ /* ** Track if we are in an anchor, paragraph, address, base, etc. @@ -119,6 +122,7 @@ struct _HTStructured { BOOL inAPPLET; BOOL inAPPLETwithP; BOOL inBadBASE; + BOOL inBadHREF; BOOL inBadHTML; BOOL inBASE; BOOL inBoldA; @@ -127,6 +131,7 @@ struct _HTStructured { BOOL inCREDIT; BOOL inFIG; BOOL inFIGwithP; + BOOL inFONT; BOOL inFORM; BOOL inLABEL; BOOL inP; @@ -159,6 +164,8 @@ extern void HTML_write PARAMS((HTStructured *me, CONST char *s, int l)); extern int HTML_put_entity PARAMS((HTStructured *me, int entity_number)); #endif /* Lynx_HTML_Handler */ +extern void strtolower PARAMS((char* i)); + /* P U B L I C */ diff --git a/src/LYBookmark.c b/src/LYBookmark.c index 79e61df9..caf859a1 100644 --- a/src/LYBookmark.c +++ b/src/LYBookmark.c @@ -345,16 +345,19 @@ PUBLIC void save_bookmark_link ARGS2( * If we created a new bookmark file, write the headers. - FM */ if (first_time) { - fprintf(fp,"<head>\n<title>%s</title>\n</head>\n",BOOKMARK_TITLE); + fprintf(fp,"<head>\n"); +#ifdef EXP_CHARTRANS + add_META_charset_to_fd(fp, -1); +#endif + fprintf(fp,"<title>%s</title>\n</head>\n",BOOKMARK_TITLE); fprintf(fp,"\ - You can delete links using the remove bookmark command. It\n\ - is usually the 'R' key but may have been remapped by you or\n\ - your system administrator.<br>\n\ - This file may also be edited with a standard text editor.\n\ - Outdated or invalid links may be removed by simply deleting\n\ - the line the link appears on in this file.\n\ - Please refer to the Lynx documentation or help files\n\ - for the HTML link syntax.\n\n<p>\n<ol>\n"); + You can delete links using the remove bookmark command. It is usually\n\ + the 'R' key but may have been remapped by you or your system\n\ + administrator.<br>\n\ + This file also may be edited with a standard text editor to delete\n\ + outdated or invalid links, or to change their order, but you should\n\ + not change the format within the lines or add other HTML markup.\n\n\ + <p>\n<ol>\n"); } /* @@ -755,8 +758,7 @@ draw_bookmark_choices: */ clear(); move(1, 5); - if (bold_H1 || bold_headers) - start_bold(); + lynx_start_h1_color (); if (MBM_screens > 1) { sprintf(shead_buffer, MULTIBOOKMARKS_SHEAD_MASK, MBM_current, MBM_screens); @@ -764,8 +766,8 @@ draw_bookmark_choices: } else { addstr(MULTIBOOKMARKS_SHEAD); } - if (bold_H1 || bold_headers) - stop_bold(); + + lynx_stop_h1_color (); MBM_tmp_count = 0; for (c = MBM_from; c <= MBM_to; c++) { diff --git a/src/LYCgi.c b/src/LYCgi.c index fce4596a..531c237e 100644 --- a/src/LYCgi.c +++ b/src/LYCgi.c @@ -309,6 +309,13 @@ PRIVATE int LYLoadCGI ARGS4( buf[(sizeof(buf) - 1)] = '\0'; add_environment_value(buf); + if (pref_charset) { + sprintf(buf, "HTTP_ACCEPT_CHARSET=%.*s", + (sizeof(buf) - 21), pref_charset); + buf[(sizeof(buf) - 1)] = '\0'; + add_environment_value(buf); + } + if (anAnchor->post_data) { /* post script, read stdin */ close(fd1[1]); dup2(fd1[0], fileno(stdin)); diff --git a/src/LYCharSets.c b/src/LYCharSets.c index 6f3b7123..016d24c4 100644 --- a/src/LYCharSets.c +++ b/src/LYCharSets.c @@ -2176,6 +2176,34 @@ PUBLIC int current_char_set = 0; /* Index for tranaslation */ */ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) { +#ifdef EXP_CHARTRANS + if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { + int chndl = 0; + if (UCAssume_MIMEcharset) + chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + HTCJK = NOCJK; + kanji_code = NOKANJI; + if (i == (chndl < 0 ? 0 : chndl)) + LYRawMode = LYUseDefaultRawMode ? TRUE : FALSE; + else + LYRawMode = LYUseDefaultRawMode ? FALSE : TRUE; + if (LYRawMode) + HTPassEightBitRaw = (LYlowest_eightbit[i] <= 160); + else + HTPassEightBitRaw = FALSE; + + HTPassEightBitNum = + ((LYCharSet_UC[i].codepoints & UCT_CP_SUPERSETOF_LAT1) || + (LYCharSet_UC[i].like8859 & UCT_R_HIGH8BIT)); + + if (LYRawMode || i == chndl) + HTPassHighCtrlRaw = (LYlowest_eightbit[i] <= 130); + else + HTPassHighCtrlRaw = FALSE; + + HTPassHighCtrlNum = FALSE; + } else +#endif if (!strncmp(LYchar_set_names[i], "ISO Latin 1", 11)) { HTCJK = NOCJK; kanji_code = NOKANJI; @@ -2258,7 +2286,7 @@ PUBLIC void HTMLSetCharacterHandling ARGS1(int,i) int chndl = 0; if (UCAssume_MIMEcharset) chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); - if (chndl != i || chndl != UCLYhndl_for_unspec) + if (chndl != i) UCLYhndl_for_unspec = chndl < 0 ? 0 : chndl; else UCLYhndl_for_unspec = 0; @@ -2303,6 +2331,17 @@ PUBLIC void HTMLSetRawModeDefault ARGS1(int,i) */ PUBLIC void HTMLSetUseDefaultRawMode ARGS2(int,i, BOOLEAN,modeflag) { +#ifdef EXP_CHARTRANS + if (LYCharSet_UC[i].enc != UCT_ENC_CJK) { + int chndl = 0; + if (UCAssume_MIMEcharset) + chndl = UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + if (i == chndl) + LYUseDefaultRawMode = modeflag; + else + LYUseDefaultRawMode = (!modeflag); + } else +#endif /* EXP_CHARTRANS */ if (!strncmp(LYchar_set_names[i], "ISO Latin 1", 11) || !strncmp(LYchar_set_names[i], "Chinese", 7) || !strncmp(LYchar_set_names[i], "Japanese (EUC)", 14) || diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c index 6a3a3858..cf1ecfb8 100644 --- a/src/LYCharUtils.c +++ b/src/LYCharUtils.c @@ -35,9 +35,9 @@ #include "LYUtils.h" #include "LYMap.h" #include "LYBookmark.h" +#include "LYCurses.h" #ifdef VMS -#include "LYCurses.h" #include "HTVMSUtils.h" #endif /* VMS */ #ifdef DOSPATH @@ -208,16 +208,6 @@ PUBLIC char * LYUnEscapeEntities ARGS3( isdigit((unsigned char)*p)) p++; /* - ** Make sure we had a valid terminator. - FM - */ - if ((unsigned char)*p >= 127 || - isalnum((unsigned char)*p)) { - *q++ = '&'; - *q++ = '#'; - p = cp; - continue; - } - /* ** Save the terminator and isolate the digit(s). - FM */ cpe = *p; @@ -681,10 +671,10 @@ PUBLIC void LYUnEscapeToLatinOne ARGS2( */ if (*p == '#' && len > 2 && (unsigned char)*(p+1) < 127 && - isalnum((unsigned char)*(p+1))) { + isdigit((unsigned char)*(p+1))) { cp = ++p; while (*p && (unsigned char)*p < 127 && - isalnum((unsigned char)*p)) + isdigit((unsigned char)*p)) p++; cpe = *p; if (*p) @@ -1000,6 +990,7 @@ PUBLIC void LYEntify ARGS2( } } StrAllocCopy(*str, cp); + FREE(cp); } /* @@ -1609,6 +1600,53 @@ PUBLIC void html_get_chartrans_info ARGS1(HTStructured *, me) } me->UCI = HTAnchor_getUCInfoStage(me->node_anchor,UCT_STAGE_STRUCTURED); } + +/* +** This function writes a line with a META tag to an open file, +** which will specify a charset parameter to use when the file is +** read back in. It is meant for temporary HTML files used by the +** various special pages which may show titles of documents. When those +** files are created, the title strings normally have been translated and +** expanded to the display character set, so we have to make sure the +** don't get translated again. +** If the user has changed the display character set during the lifetime +** of the Lynx session (or, more exactly, during the time the title +** strings to be written were generated), the may now have different +** character encodings and there is currently no way to get it all right. +** To change this, we would have to add a variable for each string which +** keeps track of its character encoding... +** But at least we can try to ensure that reading the file after future +** display character set changes will give reasonable output. +** +** The META tag is not written if the display character set (passed as +** disp_chndl) already corresponds to the charset assumption that +** would be made when the file is read. -kw +*/ +PUBLIC void add_META_charset_to_fd ARGS2( + FILE *, fp, + int, disp_chndl + ) +{ + if (disp_chndl == -1) /* -1 means use current_char_set */ + disp_chndl = current_char_set; + if (fp == NULL || disp_chndl < 0) + return; /* should not happen */ + if (UCLYhndl_HTFile_for_unspec == disp_chndl) + return; /* not need to do, so we don't */ + if (LYCharSet_UC[disp_chndl].enc == UCT_ENC_7BIT) + return; /* There shouldn't be any 8-bit characters + in this case. */ + /* + * In other cases we don't know because UCLYhndl_for_unspec may + * change during the lifetime of the file (by toggling raw mode + * or changing the display character set), so proceed. + */ + + fprintf(fp,"<META %s content=\"text/html;charset=%s\">\n", + "http-equiv=\"content-type\"", + LYCharSet_UC[disp_chndl].MIMEname); +} + #endif /* EXP_CHARTRANS */ /* @@ -1622,7 +1660,7 @@ PUBLIC void LYHandleMETA ARGS4( { char *http_equiv = NULL, *name = NULL, *content = NULL; char *href = NULL, *id_string = NULL, *temp = NULL; - char *cp, *cp0, *cp1 = 0; + char *cp, *cp0, *cp1 = NULL; int url_type = 0, i; if (!me || !present) @@ -1692,8 +1730,8 @@ PUBLIC void LYHandleMETA ARGS4( * Check for a no-cache Pragma * or Cache-Control directive. - FM */ - if (!strcasecomp((http_equiv ? http_equiv : name), "Pragma") || - !strcasecomp((http_equiv ? http_equiv : name), "Cache-Control")) { + if (!strcasecomp((http_equiv ? http_equiv : ""), "Pragma") || + !strcasecomp((http_equiv ? http_equiv : ""), "Cache-Control")) { LYUnEscapeToLatinOne(&content, FALSE); LYTrimHead(content); LYTrimTail(content); @@ -1710,7 +1748,7 @@ PUBLIC void LYHandleMETA ARGS4( * should. - FM */ if ((!me->node_anchor->cache_control) && - !strcasecomp((http_equiv ? http_equiv : name), "Cache-Control")) { + !strcasecomp((http_equiv ? http_equiv : ""), "Cache-Control")) { for (i = 0; content[i]; i++) content[i] = TOLOWER(content[i]); StrAllocCopy(me->node_anchor->cache_control, content); @@ -1757,9 +1795,9 @@ PUBLIC void LYHandleMETA ARGS4( /* * Check for an Expires directive. - FM */ - } else if (!strcasecomp((http_equiv ? http_equiv : name), "Expires")) { + } else if (!strcasecomp((http_equiv ? http_equiv : ""), "Expires")) { /* - * If we didn't get a Expires MIME header, + * If we didn't get an Expires MIME header, * store it in the anchor element, and if we * haven't yet set no_cache, check whether we * should. - FM @@ -1782,7 +1820,7 @@ PUBLIC void LYHandleMETA ARGS4( * the charset via a server's header. - AAC & FM */ } else if (!(me->node_anchor->charset && *me->node_anchor->charset) && - !strcasecomp((http_equiv ? http_equiv : name), "Content-Type")) { + !strcasecomp((http_equiv ? http_equiv : ""), "Content-Type")) { LYUnEscapeToLatinOne(&content, FALSE); LYTrimHead(content); LYTrimTail(content); @@ -1958,7 +1996,7 @@ PUBLIC void LYHandleMETA ARGS4( /* * Check for a Refresh directive. - FM */ - } else if (!strcasecomp((http_equiv ? http_equiv : name), "Refresh")) { + } else if (!strcasecomp((http_equiv ? http_equiv : ""), "Refresh")) { char *Seconds = NULL; /* @@ -1971,9 +2009,9 @@ PUBLIC void LYHandleMETA ARGS4( cp1 = cp; while (*cp1 && isdigit(*cp1)) cp1++; - *cp1 = '\0'; + if (*cp1) + *cp1++ = '\0'; StrAllocCopy(Seconds, cp); - cp1++; } if (Seconds) { /* @@ -1999,7 +2037,8 @@ PUBLIC void LYHandleMETA ARGS4( /* * We found a URL field, so check it out. - FM */ - if (!(url_type = LYLegitimizeHREF(me, (char**)&href, TRUE))) { + if (!(url_type = LYLegitimizeHREF(me, (char**)&href, + TRUE, FALSE))) { /* * The specs require a complete URL, * but this is a Netscapism, so don't @@ -2087,7 +2126,7 @@ PUBLIC void LYHandleMETA ARGS4( */ } else if (!(me->node_anchor->SugFname && *me->node_anchor->SugFname) && !strcasecomp((http_equiv ? - http_equiv : name), "Content-Disposition")) { + http_equiv : ""), "Content-Disposition")) { cp = content; while (*cp != '\0' && strncasecomp(cp, "file;", 5)) cp++; @@ -2112,7 +2151,7 @@ PUBLIC void LYHandleMETA ARGS4( /* * Check for a Set-Cookie directive. - AK */ - } else if (!strcasecomp((http_equiv ? http_equiv : name), "Set-Cookie")) { + } else if (!strcasecomp((http_equiv ? http_equiv : ""), "Set-Cookie")) { /* * We're using the Request-URI as the second argument, * regardless of whether a Content-Base header or BASE @@ -2137,10 +2176,11 @@ free_META_copies: ** are to be treated as partial or absolute ** URLs. - FM */ -PUBLIC int LYLegitimizeHREF ARGS3( +PUBLIC int LYLegitimizeHREF ARGS4( HTStructured *, me, char **, href, - BOOL, force_slash) + BOOL, force_slash, + BOOL, strip_dots) { int url_type = 0; @@ -2173,7 +2213,7 @@ PUBLIC int LYLegitimizeHREF ARGS3( "file:", 5)) { /* * The Fielding RFC/ID for resolving partial HREFs says - * that a slash should be on the end or the preceding + * that a slash should be on the end of the preceding * symbolic element for "." and "..", but all tested * browsers only do that for an explicit "./" or "../", * so we'll respect the RFC/ID only if force_slash was @@ -2181,6 +2221,61 @@ PUBLIC int LYLegitimizeHREF ARGS3( */ StrAllocCat(*href, "/"); } + if ((!url_type && LYStripDotDotURLs && strip_dots && *(*href) == '.') && + !strncasecomp((me->inBASE ? + me->base_href : me->node_anchor->address), + "http", 4)) { + /* + * We will be resolving a partial reference versus an http + * or https URL, and it has lead dots, which are retained + * when resolving, in compliance with the URL specs, but + * the request would fail if the first element of the + * resultant path is two dots, because no http or https + * server accepts such paths, so if that's the case, and + * strip_dots is TRUE, we'll strip that element now, but + * issue a message about this as "immediate feedback", + * such that the bad partial reference might get corrected + * by the document provider. Note that if the second and + * further symbolic elements also contain(s) only dots, + * those will still be retained, and the resolved URL may + * still fail, but it should, IMHO, if the partial reference + * is that much out of compliance with the URL specs. - FM + */ + int i = 0, j = 0; + char *temp = NULL, *str = ""; + + if (((temp = HTParse((me->inBASE ? + me->base_href : me->node_anchor->address), + "", PARSE_PATH + PARSE_PUNCTUATION)) == NULL) || + *temp == '\0' || + strchr(&temp[1], '/') == NULL) { + FREE(temp); + temp = *href; + if ((me->inBASE ? + me->base_href[4] : me->node_anchor->address[4]) == 's') + str = "s"; + while (temp[j] == '.') + j++; + if ((j == 2) && (temp[j] == '/' || temp[j] == '\0')) { + if (TRACE) { + fprintf(stderr, + "LYLegitimizeHREF: Bad value '%s' for http%s URL.\n", + *href, str); + fprintf(stderr, + " Stripping lead dots.\n"); + } else if (!me->inBadHREF) { + _statusline(BAD_PARTIAL_REFERENCE); + me->inBadHREF = TRUE; + sleep(AlertSecs); + } + while (temp[j] != '\0') + temp[i++] = temp[j++]; + temp[i] = '\0'; + } + temp = NULL; + } + FREE(temp); + } return(url_type); } @@ -2316,7 +2411,7 @@ PUBLIC void LYHandleID ARGS2( me->node_anchor, /* Parent */ id, /* Tag */ NULL, /* Addresss */ - (void *)0)) != 0) { /* Type */ + (void *)0)) != NULL) { /* Type */ HText_beginAnchor(me->text, ID_A); HText_endAnchor(me->text); } diff --git a/src/LYCharUtils.h b/src/LYCharUtils.h index 8c71b5c0..b6b0d892 100644 --- a/src/LYCharUtils.h +++ b/src/LYCharUtils.h @@ -41,7 +41,6 @@ extern char *LYUppercaseI_OL_String PARAMS(( int seqnum)); extern char *LYLowercaseI_OL_String PARAMS(( int seqnum)); -extern void html_get_chartrans_info PARAMS((HTStructured * me)); extern void LYHandleMETA PARAMS(( HTStructured * me, CONST BOOL* present, @@ -50,7 +49,8 @@ extern void LYHandleMETA PARAMS(( extern int LYLegitimizeHREF PARAMS(( HTStructured * me, char ** href, - BOOL force_slash)); + BOOL force_slash, + BOOL strip_dots)); extern void LYCheckForContentBase PARAMS(( HTStructured * me)); extern void LYCheckForID PARAMS(( @@ -74,4 +74,13 @@ extern BOOLEAN LYCheckForCSI PARAMS(( char ** url)); #endif /* Lynx_HTML_Handler */ +#ifdef EXP_CHARTRANS +#ifdef HTML_H +extern void html_get_chartrans_info PARAMS((HTStructured * me)); +#endif +extern void add_META_charset_to_fd PARAMS(( + FILE * fp, + int disp_chndl)); +#endif /* EXP_CHARTRANS */ + #endif /* LYCHARUTILS_H */ diff --git a/src/LYClean.c b/src/LYClean.c index bfdaa98f..1b411319 100644 --- a/src/LYClean.c +++ b/src/LYClean.c @@ -59,9 +59,10 @@ PUBLIC void cleanup_sig ARGS1( _statusline(REALLY_EXIT); c = LYgetch(); #ifdef QUIT_DEFAULT_YES - if(TOUPPER(c) == 'N') + if (TOUPPER(c) == 'N' || + c == 7) #else - if(TOUPPER(c) != 'Y') + if (TOUPPER(c) != 'Y') #endif /* QUIT_DEFAULT_YES */ return; } @@ -109,7 +110,7 @@ PUBLIC void cleanup_sig ARGS1( #endif /* NOSIGHUP */ #ifndef NOSIGHUP - (void) signal(SIGHUP, SIG_IGN); + (void) signal(SIGHUP, SIG_DFL); #endif /* NOSIGHUP */ (void) signal(SIGTERM, SIG_DFL); #ifndef VMS @@ -162,9 +163,7 @@ PUBLIC void cleanup NOARGS move(LYlines-1, 0); clrtoeol(); - stop_bold(); - stop_underline(); - stop_reverse(); + lynx_stop_all_colors (); refresh(); stop_curses(); @@ -184,4 +183,8 @@ PUBLIC void cleanup NOARGS #endif /* VMS */ fflush(stdout); + fflush(stderr); + if (LYTraceLogFP != NULL) { + fclose(LYTraceLogFP); + } } diff --git a/src/LYCookie.c b/src/LYCookie.c index 17690dc0..d43a6664 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -152,11 +152,10 @@ PRIVATE void LYCookieJar_free NOARGS cl = de->cookie_list; while (cl) { next = cl->next; + co = cl->object; if (co) { - co = cl->object; HTList_removeObject(de->cookie_list, co); freeCookie(co); - co = NULL; } cl = next; } @@ -166,6 +165,19 @@ PRIVATE void LYCookieJar_free NOARGS } dl = dl->next; } + if (dump_output_immediately) { + cl = cookie_list; + while (cl) { + next = cl->next; + co = cl->object; + if (co) { + HTList_removeObject(cookie_list, co); + freeCookie(co); + } + cl = next; + } + HTList_delete(cookie_list); + } cookie_list = NULL; HTList_delete(domain_list); domain_list = NULL; @@ -431,8 +443,8 @@ PRIVATE char * scan_cookie_sublist ARGS6( next = hl->next; if (TRACE && co) { - fprintf(stderr, "Checking cookie %x %s=%s\n", - hl, + fprintf(stderr, "Checking cookie %lx %s=%s\n", + (long) hl, (co->name ? co->name : "(no name)"), (co->value ? co->value : "(no value)")); fprintf(stderr, "%s %s %i %s %s %i%s\n", @@ -750,8 +762,8 @@ PUBLIC void LYSetCookie ARGS2( cur_cookie->expires = (time(NULL) + temp); if (TRACE) fprintf(stderr, - "LYSetCooke: expires %i, %s", - cur_cookie->expires, + "LYSetCooke: expires %ld, %s", + (long) cur_cookie->expires, ctime(&cur_cookie->expires)); } } @@ -777,8 +789,8 @@ PUBLIC void LYSetCookie ARGS2( if (cur_cookie->expires > 0) { if (TRACE) fprintf(stderr, - "LYSetCooke: expires %i, %s", - cur_cookie->expires, + "LYSetCooke: expires %ld, %s", + (long) cur_cookie->expires, ctime(&cur_cookie->expires)); } } @@ -849,10 +861,20 @@ PUBLIC void LYSetCookie ARGS2( /* * Store the final cookie if within length limit. - FM */ - if (length <= 4096) { + if (length <= 4096 && cur_cookie != NULL) { /* - * Force the secure flag on if it's not - * set but this is an https URL. - FM + * Force the secure flag on if it's not set but this + * is an https URL. This ensures that cookies from + * https servers will not be shared with ones for + * http (non-SSL) servers and thus be transmitted + * unencrypted, and is redundant with the current, + * blanket port restriction. However, this seemed + * a side-effect rather than conscious intent within + * the port restriction. A port attribute is likely + * to be added, and we can independently regulate + * sharing based on port versus scheme, with user + * configuration and run time options, "when the + * time is right". - FM */ if (!strncasecomp(address, "https:", 6) && !(cur_cookie->flags & COOKIE_FLAG_SECURE)) { diff --git a/src/LYCurses.c b/src/LYCurses.c index cc3f423d..968c23d5 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,6 +1,7 @@ #include "HTUtils.h" #include "tcp.h" #include "LYCurses.h" +#include "LYStyle.h" #include "LYUtils.h" #include "LYGlobalDefs.h" #include "LYSignal.h" @@ -31,6 +32,12 @@ extern int _NOSHARE(LINES); extern int _NOSHARE(COLS); #endif /* VMS && __GNUC__ */ +#ifdef USE_COLOR_STYLE +#include "AttrList.h" +#include "LYHash.h" +int has_color = 0; +#endif + /* * These are routines to start and stop curses and to cleanup * the screen at the end. @@ -39,7 +46,7 @@ extern int _NOSHARE(COLS); PRIVATE int dumbterm PARAMS((char *terminal)); BOOLEAN LYCursesON = FALSE; -#if defined(USE_SLANG) || defined(COLOR_CURSES) +#if USE_COLOR_TABLE || USE_SLANG PRIVATE int Current_Attr; #endif @@ -62,6 +69,12 @@ PUBLIC void LY_SLrefresh NOARGS return; } +PUBLIC void LY_SLclear NOARGS +{ + SLsmg_gotorc (0, 0); + SLsmg_erase_eos (); +} + #ifdef VMS PUBLIC void VTHome NOARGS { @@ -111,13 +124,16 @@ PUBLIC void lynx_setup_colors NOARGS SLtt_set_mono(7, NULL, SLTT_ULINE_MASK | SLTT_BOLD_MASK | SLTT_REV_MASK); } + + PRIVATE void sl_suspend ARGS1( int, sig) { -#ifndef VMS #ifdef SIGSTOP +#ifndef VMS int r, c; - + + lynx_enable_mouse (0); if (sig == SIGTSTP) SLsmg_suspend_smg(); SLang_reset_tty(); @@ -142,14 +158,191 @@ PRIVATE void sl_suspend ARGS1( if ((r != SLtt_Screen_Rows) || (c != SLtt_Screen_Cols)) { recent_sizechange = TRUE; } -#endif /* SIGSTOP */ + lynx_enable_mouse (1); #endif /* !VMS */ +#endif /* SIGSTOP */ return; } #endif /* USE_SLANG */ +#if defined(USE_COLOR_STYLE) || defined(SLCS) +PRIVATE int last_styles[128]; +PRIVATE int last_ptr=0; +#endif + +#if defined(USE_COLOR_STYLE) +/* Ok, explanation of the USE_COLOR_STYLE styles. The basic styles (ie non + * HTML) are set the same as the SLANG version for ease of programming. The + * other styles are simply the HTML enum from HTMLDTD.h + 16. + */ +PUBLIC HTCharStyle displayStyles[DSTYLE_ELEMENTS]; + +/* + * set a style's attributes - RP + */ +PUBLIC void setStyle ARGS4(int,style,int,color,int,cattr,int,mono) +{ + displayStyles[style].color=color; + displayStyles[style].cattr=cattr; + displayStyles[style].mono=mono; +} + +PUBLIC void setHashStyle ARGS5(int,style,int,color,int,cattr,int,mono,char*,element) +{ + bucket* ds=&hashStyles[style]; + if (TRACE) + fprintf(stderr, "CSS(SET): <%s> hash=%d, ca=%d, ma=%d\n", element, style, color, mono); + ds->color=color; + ds->cattr=cattr; + ds->mono=mono; + ds->code=style; + ds->name=malloc(sizeof(char)*(strlen(element)+2)); + strcpy(ds->name, element); +} -#ifdef COLOR_CURSES +/* + * set the curses attributes to be color or mono - RP + */ +PRIVATE int LYAttrset ARGS3(WINDOW*,win,int,color,int,mono) +{ + if (TRACE) + fprintf(stderr, "CSS:LYAttrset (%d, %d)\n", color, mono); + if (has_color && color > -1) + { + wattrset(win,color); +#if 0 + //wbkgdset(win,color); +#endif + return color; + } + if (mono > -1) + { + wattrset(win,mono); +#if 0 + //wbkgdset(win,mono); +#endif + return mono; + } + wattrset(win,A_NORMAL); +#if 0 + //wbkgdset(win,A_NORMAL); +#endif + return A_NORMAL; +} + +PUBLIC void curses_w_style ARGS4(WINDOW*,win,int,style,int,dir,int,previous) +{ + int YP,XP; + bucket* ds=&hashStyles[style]; + + if (!ds->name) + { + if (TRACE) + fprintf(stderr, "CSS.CS:Style %d not configured\n",style); + return; + } + if (TRACE) + fprintf(stderr, "CSS.CS:<%s%s> (%d)\n",(dir?"":"/"),ds->name,ds->code); + + getyx (win, YP, XP); + + if (style == s_normal && dir) + { + wattrset(win,A_NORMAL); + if (win==stdscr) cached_styles[YP][XP]=s_normal; + return; + } + + switch (dir) + { + /* ABS_OFF is the same as STACK_OFF for the moment */ + case STACK_OFF: + if (last_ptr) + LYAttrset(win,last_styles[--last_ptr],-1); + else + LYAttrset(win,A_NORMAL,-1); + return; + + case STACK_ON: /* remember the current attributes */ +#ifndef _NCURSES_H + last_styles[last_ptr++] = getattrs(stdscr); +#else + last_styles[last_ptr++] = attr_get(); +#endif + /* don't cache style changes for active links */ + if (style != s_alink) + { + if (TRACE) + fprintf(stderr, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); + if (win==stdscr) cached_styles[YP][XP]=style; + LYAttrset(win, ds->color, ds->mono); + } + else + { + LYAttrset(win, ds->color, ds->mono); + } + return; + + case ABS_ON: /* change without remembering the previous style */ + /* don't cache style changes for active links */ + if (style != s_alink) + { + if (TRACE) + fprintf(stderr, "CACHED: <%s> @(%d,%d)\n", ds->name, YP, XP); + if (win==stdscr) cached_styles[YP][XP]=style; + LYAttrset(win, ds->color, ds->mono); + } + else + { + LYAttrset(win, ds->color, ds->mono); + } + return; + } +} + +/* + * wrapper function to set on-screen styles - RP + */ +PUBLIC void wcurses_css ARGS3(WINDOW *,win,char*,name,int,dir) +{ + int try_again=1; + while (try_again) + { + int tmpHash=hash_code(name); + if (TRACE) + fprintf(stderr, "CSSTRIM:trying to set [%s] style - ", name); + if (tmpHash==NOSTYLE) { + char *class=strrchr(name, '.'); + if (TRACE) fprintf(stderr, "undefined, trimming at %p\n", class); + if (class) *class='\0'; + else try_again=0; + } else { + if (TRACE) fprintf(stderr, "ok (%d)\n", hash_code(name)); + curses_w_style(win, hash_code(name), dir, 0); + try_again=0; + } + } +} + +PUBLIC void curses_css ARGS2(char *,name,int,dir) +{ + wcurses_css(stdscr, name, dir); +} + +PUBLIC void curses_style ARGS3(int,style,int,dir,int,previous) +{ + curses_w_style(stdscr, style, dir, previous); +} + +#if UNUSED +void attribute ARGS2(int,style,int,dir) +{ + curses_style(style, dir, 0); +} +#endif +#endif /* USE_COLOR_STYLE */ + +#if USE_COLOR_TABLE && defined(COLOR_CURSES) /* * This block of code is designed to produce the same color effects using SVr4 * curses as the slang library's implementation in this module. That maps the @@ -346,9 +539,9 @@ PUBLIC void lynx_setup_colors NOARGS for (n = 0; n < 8; n++) lynx_map_color(n); } -#endif /* COLOR_CURSES */ +#endif /* USE_COLOR_TABLE */ -#if defined (DJGPP) && !defined (SLANG) +#if defined (DJGPP) && !defined (USE_SLANG) /* * Sorry about making a completely new function, * but the real one is messy! WB @@ -368,11 +561,17 @@ PUBLIC void start_curses NOARGS fflush(stdout); lynx_init_colors(); lynx_called_initscr = TRUE; + + /* Inform pdcurses that we're interested in knowing when mouse + buttons are clicked. Maybe someday pdcurses will support it. + */ + if (LYUseMouse) + lynx_enable_mouse (1); + } else sock_init(); LYCursesON = TRUE; clear(); - } #else PUBLIC void start_curses NOARGS @@ -420,11 +619,14 @@ PUBLIC void start_curses NOARGS SLtty_set_suspend_state(1); #endif /* _WINDOWS */ #ifdef SIGTSTP - signal(SIGTSTP, sl_suspend); + if (!no_suspend) + signal(SIGTSTP, sl_suspend); #endif /* SIGTSTP */ signal(SIGINT, cleanup_sig); #endif /* !VMS */ + lynx_enable_mouse (1); + #else /* Using curses: */ #ifdef VMS @@ -455,15 +657,21 @@ PUBLIC void start_curses NOARGS #endif /* SIGTSTP */ exit (-1); } +#ifdef USE_COLOR_STYLE + has_color = has_colors(); + if (has_color) + start_color(); + parse_userstyles(); +#endif first_time = FALSE; -#if defined(COLOR_CURSES) +#if USE_COLOR_TABLE lynx_init_colors(); lynx_called_initscr = TRUE; #endif /* USE_SLANG */ } #endif /* VMS */ - /* nonl(); *//* seems to slow things down */ + /* nonl(); */ /* seems to slow things down */ #ifdef VMS crmode(); @@ -483,25 +691,49 @@ PUBLIC void start_curses NOARGS keypad(stdscr,TRUE); #endif /* HAVE_KEYPAD */ -#ifdef NCURSES_MOUSE_VERSION - /* Inform ncurses that we're interested in knowing when mouse - button 1 is clicked */ - if (LYUseMouse) - mousemask(BUTTON1_CLICKED, NULL); -#endif /* NCURSES_MOUSE_VERSION */ + lynx_enable_mouse (1); fflush(stdin); fflush(stdout); + fflush(stderr); #endif /* USE_SLANG */ #ifdef _WINDOWS - clear(); + clear(); #endif LYCursesON = TRUE; } -#endif /* defined (DJGPP) && !defined (SLANG) */ +#endif /* defined (DJGPP) && !defined (USE_SLANG) */ +PUBLIC void lynx_enable_mouse ARGS1(int,state) +{ + if (LYUseMouse == 0) + return; + +#ifdef USE_SLANG_MOUSE + SLtt_set_mouse_mode (state, 0); + SLtt_flush_output (); +#else +#ifdef NCURSES_MOUSE_VERSION + /* Inform ncurses that we're interested in knowing when mouse + button 1 is clicked */ +#ifndef _WINDOWS + if (state) + mousemask(BUTTON1_CLICKED, NULL); + else + mousemask(0, NULL); +#else + if (state) mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED); +#endif /* _WINDOWS */ +#endif /* NCURSES_MOUSE_VERSION */ + +#if defined(DJGPP) && !defined(USE_SLANG) + if (state) + mouse_set(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED); +#endif +#endif /* NOT USE_SLANG_MOUSE */ +} PUBLIC void stop_curses NOARGS { @@ -509,7 +741,7 @@ PUBLIC void stop_curses NOARGS #ifdef DJGPP sock_exit(); #endif -#if defined (DOSPATH) && !defined (SLANG) +#if defined (DOSPATH) && !defined (USE_SLANG) clrscr(); /* clear(); @@ -522,18 +754,21 @@ PUBLIC void stop_curses NOARGS * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe */ if(LYCursesON == TRUE) { -#ifdef NCURSES_MOUSE_VERSION - mousemask(0, NULL); -#endif - endwin(); /* stop curses */ + lynx_enable_mouse (0); + endwin(); /* stop curses */ } fflush(stdout); #endif /* DJGPP */ + fflush(stderr); LYCursesON = FALSE; #ifndef VMS +#ifdef SIGTSTP + if (!no_suspend) + signal(SIGTSTP, SIG_DFL); +#endif /* SIGTSTP */ signal(SIGINT, SIG_DFL); #endif /* !VMS */ } @@ -818,8 +1053,10 @@ PUBLIC void VMSexit NOARGS fprintf(stderr, "TRACEBACK if it can be captured, and any other relevant information.\n"); - fprintf(stderr,"\nPress RETURN to clean up: "); - (void) getchar(); + if (LYTraceLogFP == NULL) { + fprintf(stderr,"\nPress RETURN to clean up: "); + (void) getchar(); + } } else if (LYCursesON) { _statusline(MEMORY_EXHAUSTED_ABORT); sleep(AlertSecs); @@ -829,6 +1066,7 @@ PUBLIC void VMSexit NOARGS if (LYOutOfMemory == TRUE) { printf("\r\n%s\r\n\r\n", MEMORY_EXHAUSTED_ABORT); fflush(stdout); + fflush(stderr); } } @@ -1202,3 +1440,140 @@ PUBLIC void VMSbox ARGS3( } #endif /* !USE_SLANG */ #endif /* VMS */ + + + +PUBLIC void lynx_start_underline_color NOARGS +{ + start_underline (); +} + +PUBLIC void lynx_stop_underline_color NOARGS +{ + stop_underline (); +} + +PUBLIC void lynx_start_bold_color NOARGS +{ + start_bold (); +} + +PUBLIC void lynx_stop_bold_color NOARGS +{ + stop_bold (); +} + +PUBLIC void lynx_start_title_color NOARGS +{ +} + +PUBLIC void lynx_stop_title_color NOARGS +{ +} + +PUBLIC void lynx_start_link_color ARGS1(int, flag) +{ + if (flag) { + /* makes some terminals work wrong because + * they can't handle two attributes at the + * same time + */ + /* start_bold(); */ + start_reverse(); +#if defined(USE_SLANG) || defined(FANCY_CURSES) + start_underline (); +#endif /* USE_SLANG */ + } else { + start_bold(); + } +} + +PUBLIC void lynx_stop_link_color ARGS1(int, flag) +{ +#ifdef USE_COLOR_STYLE + LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_OFF, 0); +#else + if (flag) { + stop_reverse(); +#if defined(USE_SLANG) || defined(FANCY_CURSES) + stop_underline (); +#endif /* USE_SLANG */ + } else + stop_bold(); +#endif +} + + +PUBLIC void lynx_stop_target_color NOARGS +{ + stop_underline(); + stop_reverse(); + stop_bold(); +} + +PUBLIC void lynx_start_target_color NOARGS +{ + start_bold(); + start_reverse(); + start_underline(); +} + + +PUBLIC void lynx_start_status_color NOARGS +{ +#if USE_COLOR_TABLE && defined(COLOR_CURSES) + lynx_set_color (2); +#else + start_reverse (); +#endif +} + +PUBLIC void lynx_stop_status_color NOARGS +{ +#if USE_COLOR_TABLE && defined(COLOR_CURSES) + lynx_set_color (0); +#else + stop_reverse (); +#endif +} + +PUBLIC void lynx_start_h1_color NOARGS +{ + if (bold_H1 || bold_headers) + start_bold(); +} + +PUBLIC void lynx_stop_h1_color NOARGS +{ + if (bold_H1 || bold_headers) + stop_bold(); +} + +PUBLIC void lynx_start_prompt_color NOARGS +{ + start_reverse (); +} + +PUBLIC void lynx_stop_prompt_color NOARGS +{ + stop_reverse (); +} + +PUBLIC void lynx_start_radio_color NOARGS +{ + start_bold (); +} + +PUBLIC void lynx_stop_radio_color NOARGS +{ + stop_bold (); +} + +PUBLIC void lynx_stop_all_colors NOARGS +{ + stop_underline (); + stop_reverse (); + stop_bold (); +} + + diff --git a/src/LYCurses.h b/src/LYCurses.h index ea4d3b82..82efadc9 100644 --- a/src/LYCurses.h +++ b/src/LYCurses.h @@ -1,6 +1,18 @@ #ifndef LYCURSES_H #define LYCURSES_H +/* + * The simple color scheme maps the 8 combinations of bold/underline/reverse + * to the standard 8 ANSI colors (with some variations based on context). + */ +#undef USE_COLOR_TABLE + +#ifndef USE_COLOR_STYLE +#if defined(USE_SLANG) || defined(COLOR_CURSES) +#define USE_COLOR_TABLE 1 +#endif +#endif + #ifdef TRUE #undef TRUE /* to prevent parse error :( */ #endif /* TRUE */ @@ -108,7 +120,20 @@ extern void VMSbox PARAMS((WINDOW *win, int height, int width)); #endif /* !USE_SLANG */ #endif /* VMS */ -#if defined(USE_SLANG) || defined(COLOR_CURSES) +#if defined(USE_COLOR_STYLE) +extern void curses_css PARAMS((char * name,int dir)); +extern void curses_style PARAMS((int style,int dir,int previous)); +extern void curses_w_style PARAMS((WINDOW* win,int style,int dir,int previous)); +extern void setHashStyle PARAMS((int style,int color,int cattr,int mono,char* element)); +extern void setStyle PARAMS((int style,int color,int cattr,int mono)); +extern void wcurses_css PARAMS((WINDOW * win,char* name,int dir)); +#define LynxChangeStyle curses_style +#else +extern int slang_style PARAMS((int style,int dir,int previous)); +#define LynxChangeStyle slang_style +#endif /* USE_COLOR_STYLE */ + +#if USE_COLOR_TABLE extern void lynx_add_attr PARAMS((int a)); extern void lynx_sub_attr PARAMS((int a)); extern void lynx_setup_colors NOPARAMS; @@ -116,6 +141,10 @@ extern unsigned int Lynx_Color_Flags; #endif #ifdef USE_SLANG +#if !defined(VMS) && !defined(DJGPP) +#define USE_SLANG_MOUSE 1 +#endif + #define SL_LYNX_USE_COLOR 1 #define SL_LYNX_USE_BLINK 2 #define start_bold() lynx_add_attr(1) @@ -140,7 +169,8 @@ extern int PHYSICAL_SLtt_Screen_Cols; #define LINES SLtt_Screen_Rows #define move SLsmg_gotorc #define addstr SLsmg_write_string -#define clear SLsmg_cls +extern void LY_SLclear NOPARAMS; +#define clear LY_SLclear #define standout SLsmg_reverse_video #define standend SLsmg_normal_video #define clrtoeol SLsmg_erase_eol @@ -192,7 +222,7 @@ extern void VTHome NOPARAMS; #else /* NOT VMS: */ -#ifdef COLOR_CURSES +#if USE_COLOR_TABLE extern void lynx_add_wattr PARAMS((WINDOW *, int)); extern void lynx_sub_wattr PARAMS((WINDOW *, int)); extern void lynx_set_color PARAMS((int)); @@ -247,4 +277,26 @@ extern int lynx_chg_color PARAMS((int, int, int)); #endif /* FANCY_CURSES */ #endif /* USE_SLANG */ +extern void lynx_enable_mouse PARAMS((int)); +extern void lynx_start_underline_color NOPARAMS; +extern void lynx_stop_underline_color NOPARAMS; +extern void lynx_start_bold_color NOPARAMS; +extern void lynx_stop_bold_color NOPARAMS; +extern void lynx_start_title_color NOPARAMS; +extern void lynx_stop_title_color NOPARAMS; +extern void lynx_start_link_color PARAMS((int)); +extern void lynx_stop_link_color PARAMS((int)); +extern void lynx_stop_target_color NOPARAMS; +extern void lynx_start_target_color NOPARAMS; +extern void lynx_start_status_color NOPARAMS; +extern void lynx_stop_status_color NOPARAMS; +extern void lynx_start_h1_color NOPARAMS; +extern void lynx_stop_h1_color NOPARAMS; +extern void lynx_start_prompt_color NOPARAMS; +extern void lynx_stop_prompt_color NOPARAMS; +extern void lynx_start_radio_color NOPARAMS; +extern void lynx_stop_radio_color NOPARAMS; +extern void lynx_stop_all_colors NOPARAMS; + + #endif /* LYCURSES_H */ diff --git a/src/LYExtern.c b/src/LYExtern.c new file mode 100644 index 00000000..7ec3f5d8 --- /dev/null +++ b/src/LYExtern.c @@ -0,0 +1,87 @@ +/* + External application support. + This feature allows lynx to pass a given URL to an external program. + It was written for three reasons. + 1) To overcome the deficiency of Lynx_386 not supporting ftp and news. + External programs can be used instead by passing the URL. + + 2) To allow for background transfers in multitasking systems. + I use wget for http and ftp transfers via the external command. + + 3) To allow for new URLs to be used through lynx. + URLs can be made up such as mymail: to spawn desired applications + via the external command. + + See lynx.cfg for other info. +*/ + +#ifdef USE_EXTERNALS +#include "tcp.h" +#include "LYGlobalDefs.h" +#include "LYUtils.h" +#include "LYExtern.h" + +#include "LYLeaks.h" + +#define FREE(x) if (x) {free(x); x = NULL;} + +void run_external(char * c) +{ + char command[1024]; + lynx_html_item_type *externals2=0; + + if (externals == NULL) return; + + for(externals2=externals; externals2 != NULL; + externals2=externals2->next) + { + +#ifdef _WINDOWS + if (!strnicmp(externals2->name,c,strlen(externals2->name))) +#else + if (!strncasecomp(externals2->name,c,strlen(externals2->name))) +#endif + { + char *cp; + + if(no_externals && !externals2->always_enabled) + { + statusline(EXTERNALS_DISABLED); + sleep(MessageSecs); + return; + } + + /* Too dangerous to leave any URL that may come along unquoted. + * They often contain '&', ';', and '?' chars, and who knows + * what else may occur. + * Prevent spoofing of the shell. + * Dunno how this needs to be modified for VMS or DOS. - kw + */ +#if defined(VMS) || defined(DOSPATH) + sprintf(command, externals2->command, c); +#else /* Unix or DOS/Win: */ + cp = quote_pathname(c); + sprintf(command, externals2->command, cp); + FREE(cp); +#endif /* VMS */ + + if (*command != '\0') + { + + statusline(command); + sleep(MessageSecs); + + stop_curses(); + fflush(stdout); + system(command); + fflush(stdout); + start_curses(); + } + + return; + } + } + + return; +} +#endif /* USE_EXTERNALS */ diff --git a/src/LYExtern.h b/src/LYExtern.h new file mode 100644 index 00000000..be9d1562 --- /dev/null +++ b/src/LYExtern.h @@ -0,0 +1,10 @@ +#ifndef EXTERNALS_H
+#define EXTERNALS_H + +#ifndef LYSTRUCTS_H +#include "LYStructs.h"
+#endif /* LYSTRUCTS_H */
+ +void run_external(char * c); + +#endif /* EXTERNALS_H */
diff --git a/src/LYForms.c b/src/LYForms.c index 6385fc02..3aba947a 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -14,6 +14,11 @@ #include "LYLeaks.h" +#ifdef USE_COLOR_STYLE +#include "AttrList.h" +#include "LYHash.h" +#endif + #ifdef ALT_CHAR_SET #define BOXVERT 0 /* use alt char set for popup window vertical borders */ #define BOXHORI 0 /* use alt char set for popup window vertical borders */ @@ -76,7 +81,7 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, dummy = popup_options(form->num_value, form->select_list, form_link->ly, form_link->lx, form->size, form->size_l, form->disabled); - c = 12; /* CTRL-R for repaint */ + c = 12; /* CTRL-L for repaint */ break; } form->num_value = popup_options(form->num_value, form->select_list, @@ -91,7 +96,12 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, form->value = opt_ptr->name; /* set the name */ form->cp_submit_value = opt_ptr->cp_submit_value; /* set the value */ } - c = 12; /* CTRL-R for repaint */ +#if defined(FANCY_CURSES) || defined(USE_SLANG) + if (!enable_scrollback) + c = DO_NOTHING; + else +#endif + c = 12; /* CTRL-L for repaint */ break; case F_RADIO_TYPE: @@ -109,7 +119,7 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, /* run though list of the links on the screen and * unselect any that are selected. :) */ - start_bold(); + lynx_start_radio_color (); for (i = 0; i < nlinks; i++) if (links[i].type == WWW_FORM_LINK_TYPE && links[i].form->type == F_RADIO_TYPE && @@ -122,7 +132,7 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, addstr(unchecked_radio); links[i].hightext = unchecked_radio; } - stop_bold(); + lynx_stop_radio_color (); /* will unselect other button and select this one */ HText_activateRadioButton(form); /* now highlight this one */ @@ -175,9 +185,11 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, } if (form->submit_method == URL_MAIL_METHOD) *refresh_screen = TRUE; - else + else { /* returns new document URL */ newdoc->link = 0; + newdoc->internal_link = FALSE; + } c = DO_NOTHING; break; } else { @@ -197,9 +209,11 @@ PUBLIC int change_form_link ARGS6(struct link *, form_link, int, mode, HText_SubmitForm(form, newdoc, link_name, link_value); if (form->submit_method == URL_MAIL_METHOD) *refresh_screen = TRUE; - else + else { /* returns new document URL */ newdoc->link = 0; + newdoc->internal_link = FALSE; + } break; } @@ -535,8 +549,10 @@ PRIVATE int popup_options ARGS7( #define getbkgd(w) wgetbkgd(w) /* workaround pre-1.9.9g bug */ #endif LYsubwindow(form_window); +#ifdef getbkgd /* not defined in ncurses 1.8.7 */ wbkgd(form_window, getbkgd(stdscr)); #endif +#endif #else SLsmg_fill_region (top, lx - 1, bottom - top, width + 4, ' '); #endif /* !USE_SLANG */ @@ -577,7 +593,13 @@ redraw: #ifdef VMS VMSbox(form_window, (bottom - top), (width + 4)); #else +#ifdef CSS + 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); +#endif #endif /* VMS */ wrefresh(form_window); #else @@ -623,12 +645,15 @@ redraw: #endif /* !USE_SLANG */ c = LYgetch(); - cmd = keymap[c+1]; + if (c == 3 || c == 7) /* Control-C or Control-G */ + cmd = LYK_QUIT; + else + cmd = keymap[c+1]; #ifdef VMS - if (HadVMSInterrupt) { - HadVMSInterrupt = FALSE; - cmd = 7; - } + if (HadVMSInterrupt) { + HadVMSInterrupt = FALSE; + cmd = LYK_QUIT; + } #endif /* VMS */ switch(cmd) { @@ -821,6 +846,28 @@ redraw: break; case LYK_NEXT: + if (recall && *prev_target_buffer == '\0') { + /* + * We got a 'n'ext command with no prior query + * specified within the popup window. See if + * one was entered when the popup was retracted, + * and if so, assume that's what's wanted. Note + * that it will become the default within popups, + * unless another is entered within a popup. If + * the within popup default is to be changed at + * that point, use WHEREIS ('/') and enter it, + * or the up- or down-arrow keys to seek any of + * the previously entered queries, regardless of + * whether they were entered within or outside + * of a popup window. - FM + */ + if ((cp = (char *)HTList_objectAt(search_queries, + 0)) != NULL) { + strcpy(prev_target_buffer, cp); + QueryNum = 0; + FirstRecall = FALSE; + } + } strcpy(prev_target, prev_target_buffer); case LYK_WHEREIS: if (*prev_target == '\0' ) { @@ -1064,8 +1111,6 @@ restore_popup_statusline: case LYK_QUIT: case LYK_ABORT: case LYK_PREV_DOC: - case 7: /* Control-G */ - case 3: /* Control-C */ cur_selection = orig_selection; cmd = LYK_ACTIVATE; /* to exit */ break; diff --git a/src/LYGetFile.c b/src/LYGetFile.c index dd0b5376..9abe48d8 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -47,6 +47,7 @@ PRIVATE int fix_http_urls PARAMS((document *doc)); extern char * WWW_Download_File; extern BOOL redirect_post_content; +extern BOOL reloading; #ifdef VMS extern BOOLEAN LYDidRename; #endif /* VMS */ @@ -321,6 +322,9 @@ Try_Redirected_URL: WWWDoc.bookmark = doc->bookmark; WWWDoc.isHEAD = doc->isHEAD; WWWDoc.safe = doc->safe; + if (doc->internal_link && !reloading) { + LYoverride_no_cache = TRUE; + } if (!HTLoadAbsolute(&WWWDoc)) { HTMLSetCharacterHandling(current_char_set); @@ -751,6 +755,7 @@ Try_Redirected_URL: LYAddVisitedLink(doc); StrAllocCopy(doc->address, fname); FREE(fname); + doc->internal_link = FALSE; WWWDoc.address = doc->address; FREE(doc->post_data); WWWDoc.post_data = NULL; @@ -814,49 +819,96 @@ Try_Redirected_URL: } /* - * The user wants to select a link by number. + * The user wants to select a link or a page by number. * If follow_link_number returns DO_LINK_STUFF do_link - * will be run immeditely following its execution. + * will be run immediately following its execution. + * If follow_link_number returns DO_GOTOLINK_STUFF + * it has updated the passed in doc for positioning on a link. + * If follow_link_number returns DO_GOTOPAGE_STUFF + * it has set doc->line to the top line of the desired page + * for displaying that page. * If follow_link_number returns PRINT_ERROR an error message * will be given to the user. * If follow_link_number returns DO_FORMS_STUFF some forms stuff - * will be done. + * will be done. (Not yet implemented.) * If follow_link_number returns DO_NOTHING nothing special * will run after it. */ -PUBLIC int follow_link_number ARGS2( +PUBLIC int follow_link_number ARGS4( int, c, - int, cur) + int, cur, + document *, doc, + int *, num) { char temp[120]; - int link_number; + int new_top, new_link; + BOOL want_go; temp[0] = c; temp[1] = '\0'; + *num = -1; _statusline(FOLLOW_LINK_NUMBER); /* - * Get the number from the user. + * Get the number, possibly with a letter suffix, from the user. */ if (LYgetstr(temp, VISIBLE, sizeof(temp), NORECALL) < 0 || *temp == 0) { _statusline(CANCELLED); sleep(InfoSecs); return(DO_NOTHING); } + *num = atoi(temp); - link_number = atoi(temp); + /* + * Check if we had a 'p' or 'P' following the number as + * a flag for displaying the page with that number. - FM + */ + if (strchr(temp, 'p') != NULL || strchr(temp, 'P') != NULL) { + int nlines = HText_getNumOfLines(); + int npages = ((nlines + 1) > display_lines) ? + (((nlines + 1) + (display_lines - 1))/(display_lines)) + : 1; + if (*num < 1) + *num = 1; + doc->line = (npages <= 1) ? + 1 : + ((*num <= npages) ? (((*num - 1) * display_lines) + 1) + : (((npages - 1) * display_lines) + 1)); + return(DO_GOTOPAGE_STUFF); + } - if (link_number > 0) { + /* + * Check if we want to make the link corresponding to the + * number the current link, rather than ACTIVATE-ing it. + */ + want_go = (strchr(temp, 'g') != NULL || strchr(temp, 'G') != NULL); + + /* + * If we have a valid number, act on it. + */ + if (*num > 0) { + int info; /* - * Get the lname, and hightext, direct from - * www structures and add it to the cur link - * so that we can pass it transparently on to - * get_file(). This is done so that you may select a link - * anywhere in the document, whether it is displayed - * on the screen or not! + * Get the lname, and hightext, directly from www + * structures and add it to the cur link so that + * we can pass it transparently on to getfile(), + * and load new_top and new_link if we instead want + * to make the link number current. These things + * are done so that a link can be selected anywhere + * in the current document, whether it is displayed + * on the screen or not! */ - if (HTGetLinkInfo(link_number, + if ((info = HTGetLinkInfo(*num, + want_go ? &new_top : NULL, + want_go ? &new_link : NULL, &links[cur].hightext, - &links[cur].lname)) { + &links[cur].lname)) == WWW_INTERN_LINK_TYPE) { + links[cur].type = WWW_INTERN_LINK_TYPE; + return(DO_LINK_STUFF); + } else if (info == LINK_LINE_FOUND) { + doc->line = new_top + 1; + doc->link = new_link; + return(DO_GOTOLINK_STUFF); + } else if (info) { links[cur].type = WWW_LINK_TYPE; return(DO_LINK_STUFF); } else { diff --git a/src/LYGetFile.h b/src/LYGetFile.h index 2e4faede..8ddfb999 100644 --- a/src/LYGetFile.h +++ b/src/LYGetFile.h @@ -7,14 +7,20 @@ #define NULLFILE 3 extern BOOLEAN getfile PARAMS((document *doc)); -extern int follow_link_number PARAMS((int c, int cur)); +extern int follow_link_number PARAMS(( + int c, + int cur, + document * doc, + int * num)); extern void add_trusted PARAMS((char *str, int type)); extern BOOLEAN exec_ok PARAMS((CONST char *source, CONST char *linkpath, int type)); -/* values for follow_link_number.c */ -#define DO_FORMS_STUFF 1 -#define DO_LINK_STUFF 2 -#define PRINT_ERROR 3 +/* values for follow_link_number() */ +#define DO_LINK_STUFF 1 +#define DO_GOTOLINK_STUFF 2 +#define DO_GOTOPAGE_STUFF 3 +#define DO_FORMS_STUFF 4 +#define PRINT_ERROR 5 /* values for add_trusted() and exec_ok() */ #define EXEC_PATH 0 diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h index 5a46b095..0877cfec 100644 --- a/src/LYGlobalDefs.h +++ b/src/LYGlobalDefs.h @@ -82,6 +82,10 @@ extern BOOLEAN local_exec_on_local_files; /* TRUE to enable local program * #define NUMBERS_AS_ARROWS 0 #define LINKS_ARE_NUMBERED 1 +#define HIDDENLINKS_MERGE 0 +#define HIDDENLINKS_SEPARATE 1 +#define HIDDENLINKS_IGNORE 2 + #define NOVICE_MODE 0 #define INTERMEDIATE_MODE 1 #define ADVANCED_MODE 2 @@ -277,6 +281,13 @@ extern int LYStatusLine; /* Line for statusline() or -1 */ extern BOOLEAN LYCollapseBRs; /* Collapse serial BRs? */ extern BOOLEAN LYSetCookies; /* Process Set-Cookie headers? */ extern char *XLoadImageCommand; /* Default image viewer for X */ +#ifdef USE_EXTERNALS +extern BOOLEAN no_externals; /* don't allow the use of externals */ +#endif +extern BOOLEAN LYNoISMAPifUSEMAP; /* Omit ISMAP link if MAP present? */ +extern int LYHiddenLinks; + +extern BOOL New_DTD; #define BOOKMARK_TITLE "Bookmark file" #define MOSAIC_BOOKMARK_TITLE "Converted Mosaic Hotlist" @@ -287,4 +298,10 @@ extern char *XLoadImageCommand; /* Default image viewer for X */ */ extern char *MBM_A_subbookmark[MBM_V_MAXFILES+1]; extern char *MBM_A_subdescript[MBM_V_MAXFILES+1]; +extern FILE *LYTraceLogFP; /* Pointer for TRACE log */ +extern char *LYTraceLogPath; /* Path for TRACE log */ +extern BOOLEAN LYUseTraceLog; /* Use a TRACE log? */ +extern FILE LYOrigStderr; /* Original stderr pointer */ +extern BOOLEAN LYStripDotDotURLs; /* Try to fix ../ in some URLs? */ + #endif /* LYGLOBALDEFS_H */ diff --git a/src/LYHash.c b/src/LYHash.c new file mode 100644 index 00000000..49a0696a --- /dev/null +++ b/src/LYHash.c @@ -0,0 +1,33 @@ +/* A hash table for the (fake) CSS support in Lynx-rp +** (c) 1996 Rob Partington +*/ + +#include "LYStructs.h" +#include "LYCurses.h" +#include "AttrList.h" +#include "SGML.h" +#include "HTMLDTD.h" + +#include "LYHash.h" + +PUBLIC int hash_table[HASHSIZE]; /* 32K should be big enough */ + +#if UNUSED +PUBLIC int hash_code_rp ARGS1(char*,string) +{ + char* hash_ptr = string; + int hash_tmp = 0xC00A | ((*hash_ptr) << 4); + + while (*hash_ptr++) + { + hash_tmp ^= (((*hash_ptr)<<4) ^ ((*hash_ptr)<<12)); + hash_tmp >>= 1; + } + return (hash_tmp % HASHSIZE); +} +#endif + +PUBLIC int hash_code ARGS1 (char*, string) +{ + return HASH_FUNCTION(string); +} diff --git a/src/LYHash.h b/src/LYHash.h new file mode 100644 index 00000000..474a2cae --- /dev/null +++ b/src/LYHash.h @@ -0,0 +1,33 @@ +#if !defined(_LYHASH_H_) +#define _LYHASH_H_ 1 + +struct _hashbucket { + char *name; /* name of this item */ + int code; /* code of this item */ + int color; /* color highlighting to be done */ + int mono; /* mono highlighting to be done */ + int cattr; /* attributes to go with the color */ + struct _hashbucket *next; /* next item */ +}; + +typedef struct _hashbucket bucket; + +#if !defined(HASHSIZE) +#define HASHSIZE 32768 +#endif + +#define NOSTYLE -1 + +extern bucket hashStyles[HASHSIZE]; +extern int hash_code PARAMS((char*)); +extern int hash_table[HASHSIZE]; /* 32K should be big enough */ + +extern int s_alink, s_a, s_status, + s_label, s_value, s_high, + s_normal, s_alert, s_title; +#define CACHEW 128 +#define CACHEH 64 + +extern unsigned cached_styles[CACHEH][CACHEW]; + +#endif /* _LYHASH_H_ */ diff --git a/src/LYHistory.c b/src/LYHistory.c index 9b6daabc..b54d8778 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -78,7 +78,8 @@ PUBLIC void LYAddVisitedLink ARGS1( !strcmp((doc->title ? doc->title : ""), LIST_PAGE_TITLE) || !strcmp((doc->title ? doc->title : ""), SHOWINFO_TITLE) || !strcmp((doc->title ? doc->title : ""), COOKIE_JAR_TITLE) || - !strcmp((doc->title ? doc->title : ""), VISITED_LINKS_TITLE)) { + !strcmp((doc->title ? doc->title : ""), VISITED_LINKS_TITLE) || + !strcmp((doc->title ? doc->title : ""), LYNX_TRACELOG_TITLE)) { return; } @@ -168,9 +169,21 @@ PUBLIC void LYpush ARGS2( history[nhist-1].bookmark : "", doc->bookmark ? doc->bookmark : "") && - history[nhist-1].isHEAD == doc->isHEAD) - return; + history[nhist-1].isHEAD == doc->isHEAD) { + if (history[nhist-1].internal_link == doc->internal_link) { + /* But it is nice to have the last position remembered! + - kw */ + history[nhist].link = doc->link; + history[nhist].page = doc->line; + return; + } + } +#ifdef NOT_USED + /* The following segment not used any more - What's it good for, + anyway?? Doing a pop when a push is requested is confusing, + also to the user. Moreover, the way it was done seems to cause + a memory leak. - kw */ /* * If file is identical to one two before it, don't push it. */ @@ -191,6 +204,7 @@ PUBLIC void LYpush ARGS2( nhist--; return; } +#endif /* NOT_USED */ /* * OK, push it if we have stack space. @@ -210,9 +224,101 @@ PUBLIC void LYpush ARGS2( StrAllocCopy(history[nhist].bookmark, doc->bookmark); history[nhist].isHEAD = doc->isHEAD; history[nhist].safe = doc->safe; + + history[nhist].internal_link = FALSE; /* by default */ + history[nhist].intern_seq_start = -1; /* by default */ + if (doc->internal_link) { + /* Now some tricky stuff: if the caller thinks that the doc + to push was the result of following an internal + (fragment) link, we check whether we believe it. + It is only accepted as valid if the immediately preceding + item on the history stack is actually the same document + except for fragment and location info. I.e. the Parent + Anchors are the same. + Also of course this requires that this is not the first + history item. - kw */ + if (nhist > 0) { + DocAddress WWWDoc; + HTParentAnchor *thisparent, *thatparent = NULL; + WWWDoc.address = doc->address; + WWWDoc.post_data = doc->post_data; + WWWDoc.post_content_type = doc->post_content_type; + WWWDoc.bookmark = doc->bookmark; + WWWDoc.isHEAD = doc->isHEAD; + WWWDoc.safe = doc->safe; + thisparent = + HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); + /* Now find the ParentAnchor for the previous history + ** item - kw + */ + if (thisparent) { + /* If the last-pushed item is a LYNXIMGMAP but THIS one + ** isn't, compare the physical URLs instead. - kw + */ + if (0==strncmp(history[nhist-1].address,"LYNXIMGMAP:",11) && + 0!=strncmp(doc->address,"LYNXIMGMAP:",11)) { + WWWDoc.address = history[nhist-1].address + 11; + /* + ** If THIS item is a LYNXIMGMAP but the last-pushed one + ** isn't, fake it by using THIS item's address for + ** thatparent... - kw + */ + } else if ((0==strncmp(doc->address,"LYNXIMGMAP:",11) && + 0!=strncmp(history[nhist-1].address,"LYNXIMGMAP:",11))) { + char *temp = NULL; + StrAllocCopy(temp, "LYNXIMGMAP:"); + StrAllocCat(temp, doc->address+11); + WWWDoc.address = temp; + WWWDoc.post_content_type = history[nhist-1].post_content_type; + WWWDoc.bookmark = history[nhist-1].bookmark; + WWWDoc.isHEAD = history[nhist-1].isHEAD; + WWWDoc.safe = history[nhist-1].safe; + thatparent = + HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); + FREE(temp); + } else { + WWWDoc.address = history[nhist-1].address; + } + if (!thatparent) { /* if not yet done */ + WWWDoc.post_data = history[nhist-1].post_data; + WWWDoc.post_content_type = history[nhist-1].post_content_type; + WWWDoc.bookmark = history[nhist-1].bookmark; + WWWDoc.isHEAD = history[nhist-1].isHEAD; + WWWDoc.safe = history[nhist-1].safe; + thatparent = + HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); + } + /* In addition to equality of the ParentAnchors, require + ** that IF we have a HTMainText (i.e. it wasn't just + ** HTuncache'd by mainloop), THEN it has to be consistent + ** with what we are trying to push. + ** This may be overkill... - kw + */ + if (thatparent == thisparent && + (!HTMainText || HTMainAnchor == thisparent) + ) { + history[nhist].internal_link = TRUE; + history[nhist].intern_seq_start = + history[nhist-1].intern_seq_start >= 0 ? + history[nhist-1].intern_seq_start : nhist-1; + if (TRACE) { + fprintf(stderr, + "\nLYpush: pushed as internal link, OK\n"); + } + } + } + } + if (!history[nhist].internal_link) { + if (TRACE) { + fprintf(stderr, + "\nLYpush: push as internal link requested, %s\n", + "but didn't check out!"); + } + } + } nhist++; - if (TRACE) { - fprintf(stderr, + if (TRACE) { + fprintf(stderr, "\nLYpush: address:%s\n title:%s\n", doc->address, doc->title); } @@ -251,6 +357,7 @@ PUBLIC void LYpop ARGS1( doc->bookmark = history[nhist].bookmark; /* will be freed later */ doc->isHEAD = history[nhist].isHEAD; doc->safe = history[nhist].safe; + doc->internal_link = history[nhist].internal_link; if (TRACE) { fprintf(stderr, "LYpop: address:%s\n title:%s\n", @@ -278,6 +385,7 @@ PUBLIC void LYpop_num ARGS2( StrAllocCopy(doc->bookmark, history[number].bookmark); doc->isHEAD = history[number].isHEAD; doc->safe = history[number].safe; + doc->internal_link = history[number].internal_link; /* ?? */ } } @@ -320,7 +428,11 @@ PUBLIC int showhistory ARGS1( LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ - fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + fprintf(fp0, "<head>\n"); +#ifdef EXP_CHARTRANS + add_META_charset_to_fd(fp0, -1); +#endif + fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", HISTORY_PAGE_TITLE); fprintf(fp0, "<h1>You have reached the History Page</h1>\n"); @@ -339,7 +451,7 @@ PUBLIC int showhistory ARGS1( } fprintf(fp0, "%s<em>%d</em>. <tab id=t%d><a href=\"LYNXHIST:%d\">%s</a>\n", - (x > 99 ? "" : x < 9 ? " " : " "), + (x > 99 ? "" : x < 10 ? " " : " "), x, x, x, Title); if (history[x].address != NULL) { StrAllocCopy(Title, history[x].address); @@ -347,6 +459,12 @@ PUBLIC int showhistory ARGS1( } else { StrAllocCopy(Title, "(no address)"); } + if (history[x].internal_link) { + if (history[x].intern_seq_start == history[nhist-1].intern_seq_start) + StrAllocCat(Title, " (internal)"); + else + StrAllocCat(Title, " (was internal)"); + } fprintf(fp0, "<tab to=t%d>%s\n", x, Title); } @@ -357,6 +475,8 @@ PUBLIC int showhistory ARGS1( return(0); } +extern BOOL reloading; + /* * This function makes the history page seem like any other type of * file since more info is needed than can be provided by the normal @@ -370,6 +490,7 @@ PUBLIC BOOLEAN historytarget ARGS1( DocAddress WWWDoc; HTParentAnchor *tmpanchor; HText *text; + BOOLEAN treat_as_intern = FALSE; if ((!newdoc || !newdoc->address) || strlen(newdoc->address) < 10 || !isdigit(*(newdoc->address+9))) @@ -379,7 +500,14 @@ 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) { + LYforce_no_cache = FALSE; + LYoverride_no_cache = TRUE; + treat_as_intern = TRUE; + } else { + newdoc->internal_link = FALSE; + } /* * If we have POST content, and have LYresubmit_posts set * or have no_cache set or do not still have the text cached, @@ -394,9 +522,10 @@ PUBLIC BOOLEAN historytarget ARGS1( WWWDoc.safe = newdoc->safe; tmpanchor = HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); text = (HText *)HTAnchor_document(tmpanchor); - if (((LYresubmit_posts == TRUE) || - (LYforce_no_cache == TRUE && - LYoverride_no_cache == FALSE) || + if (((((LYresubmit_posts == TRUE) || + (LYforce_no_cache == TRUE && + LYoverride_no_cache == FALSE)) && + !(treat_as_intern && !reloading)) || text == NULL) && HTConfirm(CONFIRM_POST_RESUBMISSION) == TRUE) { LYforce_no_cache = TRUE; @@ -462,7 +591,11 @@ PUBLIC int LYShowVisitedLinks ARGS1( LYforce_HTML_mode = TRUE; /* force this file to be HTML */ LYforce_no_cache = TRUE; /* force this file to be new */ - fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + fprintf(fp0, "<head>\n"); +#ifdef EXP_CHARTRANS + add_META_charset_to_fd(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"); @@ -487,12 +620,12 @@ PUBLIC int LYShowVisitedLinks ARGS1( LYEntify(&Address, FALSE); fprintf(fp0, "%s<em>%d</em>. <tab id=t%d><a href=\"%s\">%s</a>\n", - (x > 99 ? "" : x < 9 ? " " : " "), + (x > 99 ? "" : x < 10 ? " " : " "), x, x, Address, Title); } else { fprintf(fp0, "%s<em>%d</em>. <tab id=t%d><em>%s</em>\n", - (x > 99 ? "" : x < 9 ? " " : " "), + (x > 99 ? "" : x < 10 ? " " : " "), x, x, Title); } if (Address != NULL) { diff --git a/src/LYJump.c b/src/LYJump.c index e5e67871..739c1e2f 100644 --- a/src/LYJump.c +++ b/src/LYJump.c @@ -378,7 +378,7 @@ PRIVATE unsigned LYRead_Jumpfile ARGS1(struct JumpTable *,jtp) BOOL IsStream_LF = TRUE; #endif /* VMS */ char *cp; - int i; + unsigned i; if (jtp->file == NULL || *(jtp->file) == '\0') return 0; diff --git a/src/LYKeymap.c b/src/LYKeymap.c index af1e19de..d3dee733 100644 --- a/src/LYKeymap.c +++ b/src/LYKeymap.c @@ -43,7 +43,7 @@ LYK_UP_TWO, 0, LYK_RELOAD, 0, LYK_TRACE_TOGGLE, 0, LYK_VERSION, LYK_REFRESH, /* ^T */ /* ^U */ /* ^V */ /* ^W */ #endif /* NOT_USED */ -LYK_TRACE_TOGGLE, 0, 0, LYK_REFRESH, +LYK_TRACE_TOGGLE, 0, LYK_SWITCH_DTD, LYK_REFRESH, /* ^T */ /* ^U */ /* ^V */ /* ^W */ 0, 0, 0, 0, @@ -61,16 +61,21 @@ LYK_NEXT_PAGE, LYK_SHELL, LYK_SOFT_DQUOTES, LYK_TOOLBAR, LYK_UP_HALF, LYK_DOWN_HALF, LYK_IMAGE_TOGGLE, LYK_NEXT_PAGE, /* ( */ /* ) */ /* * */ /* + */ +#ifndef USE_EXTERNALS LYK_NEXT_PAGE, LYK_PREV_PAGE, 0, LYK_WHEREIS, /* , */ /* - */ /* . */ /* / */ +#else +LYK_NEXT_PAGE, LYK_PREV_PAGE, LYK_EXTERN, LYK_WHEREIS, +/* , */ /* - */ /* . */ /* / */ +#endif -0, LYK_1, LYK_2, LYK_3, +LYK_F_LINK_NUM, LYK_1, LYK_2, LYK_3, /* 0 */ /* 1 */ /* 2 */ /* 3 */ LYK_4, LYK_5, LYK_6, LYK_7, /* 4 */ /* 5 */ /* 6 */ /* 7 */ -LYK_8, LYK_9, 0, 0, +LYK_8, LYK_9, 0, LYK_TRACE_LOG, /* 8 */ /* 9 */ /* : */ /* ; */ LYK_UP_LINK, LYK_INFO, LYK_DOWN_LINK, LYK_HELP, @@ -166,7 +171,7 @@ LYK_NOCACHE, 0, LYK_INTERRUPT, 0, LYK_PIPE, 0, 0, LYK_HISTORY, /* | */ /* } */ /* ~ */ /* del */ -/* 80..99 (illegal ISO-8859-1) 8-bit characters. */ +/* 80..9F (illegal ISO-8859-1) 8-bit characters. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -267,17 +272,17 @@ char override[] = { 0, 0, LYK_TAG_LINK, 0, /* , */ /* - */ /* . */ /* / */ - 0, 0, 0, 0, -/* 0 */ /* 1 */ /* 2 */ /* 3 */ + 0, 0, 0, 0, +/* 0 */ /* 1 */ /* 2 */ /* 3 */ - 0, 0, 0, 0, -/* 4 */ /* 5 */ /* 6 */ /* 7 */ + 0, 0, 0, 0, +/* 4 */ /* 5 */ /* 6 */ /* 7 */ - 0, 0, 0, 0, -/* 8 */ /* 9 */ /* : */ /* ; */ + 0, 0, 0, 0, +/* 8 */ /* 9 */ /* : */ /* ; */ - 0, 0, 0, 0, -/* < */ /* = */ /* > */ /* ? */ + 0, 0, 0, 0, +/* < */ /* = */ /* > */ /* ? */ 0, 0, 0, LYK_CREATE, /* @ */ /* A */ /* B */ /* C */ @@ -327,7 +332,7 @@ LYK_TAG_LINK, LYK_UPLOAD, 0, 0, 0, 0, 0, 0, /* | */ /* } */ /* ~ */ /* del */ -/* 80..99 (illegal ISO-8859-1) 8-bit characters. */ +/* 80..9F (illegal ISO-8859-1) 8-bit characters. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -441,6 +446,7 @@ PRIVATE struct rmap revmap[] = { { "SHELL", "escape from the browser to the system" }, { "DOWNLOAD", "download the current link to your computer" }, { "TRACE_TOGGLE", "toggle tracing of browser operations" }, +{ "TRACE_LOG", "view trace log if started in the current session" }, { "IMAGE_TOGGLE", "toggle handling of all images as links" }, { "INLINE_TOGGLE", "toggle pseudo-ALTs for inlines with no ALT string" }, { "HEAD", "send a HEAD request for the current document or link" }, @@ -454,7 +460,12 @@ PRIVATE struct rmap revmap[] = { { "MINIMAL", "toggle minimal vs. valid comment parsing" }, { "SOFT_DQUOTES", "toggle valid vs. soft double-quote parsing" }, { "RAW_TOGGLE", "toggle raw 8-bit translations or CJK mode ON or OFF" }, -{ "COOKIE_JAR", "Examine the Cookie Jar" }, +{ "COOKIE_JAR", "examine the Cookie Jar" }, +{ "F_LINK_NUM", "invoke the 'Follow link (or page) number:' prompt" }, +{ "SWITCH_DTD", "switch between old and new parsing of HTML" }, +#ifdef USE_EXTERNALS +{ "EXTERN", "run external program with url" }, +#endif #ifdef VMS { "DIRED_MENU", "invoke File/Directory Manager, if available" }, #else @@ -559,6 +570,7 @@ PRIVATE int LYLoadKeymap ARGS4 ( HTAlert(buf); return(HT_NOT_LOADED); } + anAnchor->no_cache = TRUE; sprintf(buf, "<head>\n<title>%s</title>\n</head>\n<body>\n", CURRENT_KEYMAP_TITLE); @@ -698,52 +710,59 @@ static BOOLEAN did_number_keys; PUBLIC void set_numbers_as_arrows NOARGS { - saved_number_keys[0] = keymap['4'+1]; - keymap['4'+1] = LYK_PREV_DOC; - saved_number_keys[1] = keymap['2'+1]; - keymap['2'+1] = LYK_NEXT_LINK; - saved_number_keys[2] = keymap['8'+1]; - keymap['8'+1] = LYK_PREV_LINK; - saved_number_keys[3] = keymap['6'+1]; - keymap['6'+1] = LYK_ACTIVATE; - saved_number_keys[4] = keymap['7'+1]; - keymap['7'+1] = LYK_HOME; - saved_number_keys[5] = keymap['1'+1]; - keymap['1'+1] = LYK_END; - saved_number_keys[6] = keymap['9'+1]; - keymap['9'+1] = LYK_PREV_PAGE; - saved_number_keys[7] = keymap['3'+1]; - keymap['3'+1] = LYK_NEXT_PAGE; - - /* disable the 5 */ - saved_number_keys[8] = keymap['5'+1]; - keymap['5'+1] = LYK_DO_NOTHING; - - did_number_keys = TRUE; + /* + * Map numbers to functions as labeled on the + * IBM Enhanced keypad, and save their original + * mapping for reset_numbers_as_arrows(). - FM + */ + saved_number_keys[0] = keymap['4'+1]; + keymap['4'+1] = LYK_PREV_DOC; + saved_number_keys[1] = keymap['2'+1]; + keymap['2'+1] = LYK_NEXT_LINK; + saved_number_keys[2] = keymap['8'+1]; + keymap['8'+1] = LYK_PREV_LINK; + saved_number_keys[3] = keymap['6'+1]; + keymap['6'+1] = LYK_ACTIVATE; + saved_number_keys[4] = keymap['7'+1]; + keymap['7'+1] = LYK_HOME; + saved_number_keys[5] = keymap['1'+1]; + keymap['1'+1] = LYK_END; + saved_number_keys[6] = keymap['9'+1]; + keymap['9'+1] = LYK_PREV_PAGE; + saved_number_keys[7] = keymap['3'+1]; + keymap['3'+1] = LYK_NEXT_PAGE; + + /* + * Disable the 5. + */ + saved_number_keys[8] = keymap['5'+1]; + keymap['5'+1] = LYK_DO_NOTHING; + + did_number_keys = TRUE; } PUBLIC void reset_numbers_as_arrows NOARGS { - if (!did_number_keys) - return; - - keymap['4'+1] = saved_number_keys[0]; - keymap['2'+1] = saved_number_keys[1]; - keymap['8'+1] = saved_number_keys[2]; - keymap['6'+1] = saved_number_keys[3]; - keymap['7'+1] = saved_number_keys[4]; - keymap['1'+1] = saved_number_keys[5]; - keymap['9'+1] = saved_number_keys[6]; - keymap['3'+1] = saved_number_keys[7]; - keymap['5'+1] = saved_number_keys[8]; - - did_number_keys = FALSE; + if (!did_number_keys) + return; + + keymap['4'+1] = saved_number_keys[0]; + keymap['2'+1] = saved_number_keys[1]; + keymap['8'+1] = saved_number_keys[2]; + keymap['6'+1] = saved_number_keys[3]; + keymap['7'+1] = saved_number_keys[4]; + keymap['1'+1] = saved_number_keys[5]; + keymap['9'+1] = saved_number_keys[6]; + keymap['3'+1] = saved_number_keys[7]; + keymap['5'+1] = saved_number_keys[8]; + + did_number_keys = FALSE; } PUBLIC char *key_for_func ARGS1 (int,func) { static char buf[512]; - int i; + size_t i; buf[0] = '\0'; for (i = 1; i < sizeof(keymap); i++) { diff --git a/src/LYKeymap.h b/src/LYKeymap.h index c5b42c19..b704c2d3 100644 --- a/src/LYKeymap.h +++ b/src/LYKeymap.h @@ -76,37 +76,46 @@ extern char override[]; #define LYK_SHELL 52 #define LYK_DOWNLOAD 53 #define LYK_TRACE_TOGGLE 54 -#define LYK_IMAGE_TOGGLE 55 -#define LYK_INLINE_TOGGLE 56 -#define LYK_HEAD 57 -#define LYK_DO_NOTHING 58 -#define LYK_TOGGLE_HELP 59 -#define LYK_JUMP 60 -#define LYK_KEYMAP 61 -#define LYK_LIST 62 -#define LYK_TOOLBAR 63 -#define LYK_HISTORICAL 64 -#define LYK_MINIMAL 65 -#define LYK_SOFT_DQUOTES 66 -#define LYK_RAW_TOGGLE 67 -#define LYK_COOKIE_JAR 68 +#define LYK_TRACE_LOG 55 +#define LYK_IMAGE_TOGGLE 56 +#define LYK_INLINE_TOGGLE 57 +#define LYK_HEAD 58 +#define LYK_DO_NOTHING 59 +#define LYK_TOGGLE_HELP 60 +#define LYK_JUMP 61 +#define LYK_KEYMAP 62 +#define LYK_LIST 63 +#define LYK_TOOLBAR 64 +#define LYK_HISTORICAL 65 +#define LYK_MINIMAL 66 +#define LYK_SOFT_DQUOTES 67 +#define LYK_RAW_TOGGLE 68 +#define LYK_COOKIE_JAR 69 +#define LYK_F_LINK_NUM 70 +#define LYK_SWITCH_DTD 71 -#ifdef VMS -#define LYK_DIRED_MENU 69 -#endif /* VMS */ +#ifdef USE_EXTERNALS +#define LYK_EXTERN 72 +#if defined(VMS) || defined(DIRED_SUPPORT) +#define LYK_DIRED_MENU 73 +#endif /* VMS || DIRED_SUPPORT */ +#else /* USE_EXTERNALS */ +#if defined(VMS) || defined(DIRED_SUPPORT) +#define LYK_DIRED_MENU 72 +#endif /* VMS || DIRED_SUPPORT */ +#endif /* !defined(USE_EXTERNALS) */ #ifdef DIRED_SUPPORT -#define LYK_DIRED_MENU 69 -#define LYK_CREATE 70 -#define LYK_REMOVE 71 -#define LYK_MODIFY 72 -#define LYK_TAG_LINK 73 -#define LYK_UPLOAD 74 -#define LYK_INSTALL 75 +#define LYK_CREATE (LYK_DIRED_MENU+1) +#define LYK_REMOVE (LYK_DIRED_MENU+2) +#define LYK_MODIFY (LYK_DIRED_MENU+3) +#define LYK_TAG_LINK (LYK_DIRED_MENU+4) +#define LYK_UPLOAD (LYK_DIRED_MENU+5) +#define LYK_INSTALL (LYK_DIRED_MENU+6) #endif /* DIRED_SUPPORT */ #ifdef NOT_USED -#define LYK_VERSION 76 -#define LYK_FORM_UP 77 -#define LYK_FORM_DOWN 78 +#define LYK_VERSION 80 +#define LYK_FORM_UP 81 +#define LYK_FORM_DOWN 82 #endif /* NOT_USED */ #endif /* LYKEYMAP_H */ diff --git a/src/LYLeaks.c b/src/LYLeaks.c index 7ce360b4..8bdc8694 100644 --- a/src/LYLeaks.c +++ b/src/LYLeaks.c @@ -98,7 +98,7 @@ PUBLIC void LYLeaks NOARGS { } } else { - int i_counter; + size_t i_counter; /* * Increment the count of total memory lost and diff --git a/src/LYList.c b/src/LYList.c index 59f6d497..66c02dbb 100644 --- a/src/LYList.c +++ b/src/LYList.c @@ -34,18 +34,31 @@ ** Clear: we only get addresses. */ +static char list_filename[256] = "\0"; + +PUBLIC char * LYlist_temp_url NOARGS +{ + return list_filename; +} + PUBLIC int showlist ARGS2(char **, newfile, BOOLEAN, titles) { int cnt; - int refs; + int refs, hidden_links; static char tempfile[256]; static BOOLEAN first = TRUE; - static char list_filename[256]; FILE *fp0; char *Address = NULL, *Title = NULL, *cp = NULL; refs = HText_sourceAnchors(HTMainText); - if (refs <= 0) { + hidden_links = HText_HiddenLinkCount(HTMainText); + if (refs <= 0 && hidden_links > 0 && + LYHiddenLinks != HIDDENLINKS_SEPARATE) { + _statusline(NO_VISIBLE_REFS_FROM_DOC); + sleep(MessageSecs); + return(-1); + } + if (refs <= 0 && hidden_links <= 0) { _statusline(NO_REFS_FROM_DOC); sleep(MessageSecs); return(-1); @@ -60,7 +73,7 @@ PUBLIC int showlist ARGS2(char **, newfile, BOOLEAN, titles) #endif /* VMS */ } - if ((fp0 = fopen(tempfile,"w")) == NULL) { + if ((fp0 = fopen(tempfile, "w")) == NULL) { _statusline(CANNOT_OPEN_TEMP); sleep(MessageSecs); return(-1); @@ -75,34 +88,53 @@ PUBLIC int showlist ARGS2(char **, newfile, BOOLEAN, titles) sprintf(list_filename, "file://localhost%s", tempfile); #endif /* VMS */ StrAllocCopy(*newfile, list_filename); - LYforce_HTML_mode=TRUE; /* force this file to be HTML */ - LYforce_no_cache=TRUE; /* force this file to be new */ + LYforce_HTML_mode = TRUE; /* force this file to be HTML */ + LYforce_no_cache = TRUE; /* force this file to be new */ - fprintf(fp0,"<head>\n<title>%s</title>\n</head>\n<body>\n", - LIST_PAGE_TITLE); - fprintf(fp0,"<h1>You have reached the List Page</h1>\n"); - fprintf(fp0,"<h2>%s Version %s</h2>\n", LYNX_NAME, LYNX_VERSION); + fprintf(fp0, "<head>\n"); +#ifdef EXP_CHARTRANS + add_META_charset_to_fd(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"); + fprintf(fp0, "<h2>%s Version %s</h2>\n", LYNX_NAME, LYNX_VERSION); fprintf(fp0, " References in this document:<p>\n"); fprintf(fp0, "<%s compact>\n", (keypad_mode == LINKS_ARE_NUMBERED) ? "ul" : "ol"); + if (hidden_links > 0) { + fprintf(fp0, "<lh><em>Visible links:</em>\n"); + if (LYHiddenLinks == HIDDENLINKS_IGNORE) + hidden_links = 0; + } for (cnt=1; cnt<=refs; cnt++) { - HTAnchor *dest = HTAnchor_followMainLink((HTAnchor *) - HText_childNumber(cnt)); + HTChildAnchor *child = HText_childNumber(cnt); + HTAnchor *dest_intl = HTAnchor_followTypedLink((HTAnchor *)child, + LINK_INTERNAL); + HTAnchor *dest = dest_intl ? + dest_intl : HTAnchor_followMainLink((HTAnchor *)child); HTParentAnchor *parent = HTAnchor_parent(dest); char *address = HTAnchor_address(dest); CONST char *title = titles ? HTAnchor_title(parent) : NULL; StrAllocCopy(Address, address); FREE(address); - LYEntify(&Address, FALSE); - if (title) { + LYEntify(&Address, TRUE); + if (title && *title) { StrAllocCopy(Title, title); - LYEntify(&Title, TRUE); + if (*Title) + LYEntify(&Title, TRUE); + else + FREE(Title); cp = strchr(Address, '#'); } - fprintf(fp0, "<li><a href=\"%s\">%s%s%s%s</a>\n", Address, + + fprintf(fp0, "<li><a href=\"%s\"%s>%s%s%s%s%s</a>\n", Address, + dest_intl ? " TYPE=\"internal link\"" : "", + dest_intl ? "(internal) " : "", ((HTAnchor*)parent != dest) && Title ? "in " : "", (char *)(Title ? Title : Address), (Title && cp) ? " - " : "", @@ -112,6 +144,28 @@ PUBLIC int showlist ARGS2(char **, newfile, BOOLEAN, titles) FREE(Title); } + if (hidden_links > 0) { + if (refs > 0) + fprintf(fp0, "\n</%s>\n\n<p>\n", + (keypad_mode == LINKS_ARE_NUMBERED) ? + "ul" : "ol"); + fprintf(fp0, "<%s compact>\n", (keypad_mode == LINKS_ARE_NUMBERED) ? + "ul" : "ol continue"); + fprintf(fp0, "<lh><em>Hidden links:</em>\n"); + } + + for (cnt = 0; cnt < hidden_links; cnt++) { + StrAllocCopy(Address, HText_HiddenLinkAt(HTMainText, cnt)); + LYEntify(&Address, FALSE); + if (!(Address && *Address)) { + FREE(Address); + continue; + } + fprintf(fp0, "<li><a href=\"%s\">%s</a>\n", Address, Address); + + FREE(Address); + } + fprintf(fp0,"\n</%s>\n</body>\n", (keypad_mode == LINKS_ARE_NUMBERED) ? "ul" : "ol"); @@ -130,27 +184,40 @@ PUBLIC int showlist ARGS2(char **, newfile, BOOLEAN, titles) ** Clear: we only get addresses. */ -PUBLIC void printlist ARGS2(FILE *, fp, BOOLEAN, titles) +PUBLIC void printlist ARGS2( + FILE *, fp, + BOOLEAN, titles) { #ifdef VMS extern BOOLEAN HadVMSInterrupt; #endif /* VMS */ int cnt; - int refs; + int refs, hidden_links; + char *address = NULL; + refs = HText_sourceAnchors(HTMainText); - if (refs <= 0) { + if (refs <= 0 && LYHiddenLinks != HIDDENLINKS_SEPARATE) + return; + hidden_links = HText_HiddenLinkCount(HTMainText); + if (refs <= 0 && hidden_links <= 0) { return; } else { fprintf(fp, "\n%s\n\n", "References"); - for (cnt=1; cnt<=refs; cnt++) { + if (hidden_links > 0) { + fprintf(fp, " Visible links:\n"); + if (LYHiddenLinks == HIDDENLINKS_IGNORE) + hidden_links = 0; + } + for (cnt = 1; cnt <= refs; cnt++) { HTAnchor *dest = HTAnchor_followMainLink((HTAnchor *) HText_childNumber(cnt)); HTParentAnchor * parent = HTAnchor_parent(dest); - char * address = HTAnchor_address(dest); CONST char * title = titles ? HTAnchor_title(parent) : NULL; + + address = HTAnchor_address(dest); fprintf(fp, "%4d. %s%s\n", cnt, - ((HTAnchor*)parent!=dest) && title ? "in " : "", + ((HTAnchor*)parent != dest) && title ? "in " : "", (char *)(title ? title : address)); FREE(address); #ifdef VMS @@ -158,6 +225,22 @@ PUBLIC void printlist ARGS2(FILE *, fp, BOOLEAN, titles) break; #endif /* VMS */ } + + if (hidden_links > 0) + fprintf(fp, "%s Hidden links:\n", ((refs > 0) ? "\n" : "")); + for (cnt = 0; cnt < hidden_links; cnt++) { + StrAllocCopy(address, HText_HiddenLinkAt(HTMainText, cnt)); + if (!(address && *address)) { + FREE(address); + continue; + } + fprintf(fp, "%4d. %s\n", ((cnt + 1) + refs), address); + FREE(address); +#ifdef VMS + if (HadVMSInterrupt) + break; +#endif /* VMS */ + } } return; } diff --git a/src/LYList.h b/src/LYList.h index 1d14c687..e1e0b8de 100644 --- a/src/LYList.h +++ b/src/LYList.h @@ -2,6 +2,7 @@ #ifndef LYLIST_H #define LYLIST_H +extern char * LYlist_temp_url NOPARAMS; extern int showlist PARAMS((char **newfile, BOOLEAN titles)); extern void printlist PARAMS((FILE *fp, BOOLEAN titles)); diff --git a/src/LYMail.c b/src/LYMail.c index b943efb2..271d2af3 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -11,6 +11,10 @@ #include "LYGlobalDefs.h" #include "HTParse.h" #include "LYMail.h" +#ifdef EXP_CHARTRANS +#include "LYCharSets.h" /* to get current charset for mail header */ +extern BOOLEAN LYHaveCJKCharacterSet; +#endif #include "LYLeaks.h" @@ -713,6 +717,28 @@ PUBLIC void reply_by_mail ARGS3( sprintf(buf,"To: %s\n", address); StrAllocCopy(header, buf); #endif + +#ifdef EXP_CHARTRANS + /* + * Put the Mime-Version, Content-Type and + * Content-Transfer-Encoding in the header. + * This assumes that the same character set is used + * for composing the mail which is currently selected + * as display character set... + * Don't send a charset if we have a CJK character set + * selected, since it may not be appropriate for mail... + * Also don't use an inofficial "x-" charset. - kw + */ + StrAllocCat(header, "Mime-Version: 1.0\n"); + if (!LYHaveCJKCharacterSet && + strncasecomp(LYCharSet_UC[current_char_set].MIMEname, "x-", 2) + != 0) { + sprintf(buf,"Content-Type: text/plain; charset=%s\n", + LYCharSet_UC[current_char_set].MIMEname); + StrAllocCat(header, buf); + } + StrAllocCat(header, "Content-Transfer-Encoding: 8bit\n"); +#endif /* * Put the X-URL and X-Mailer lines in the header. */ diff --git a/src/LYMain.c b/src/LYMain.c index b6a36167..85d7d55e 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -9,6 +9,7 @@ #endif /* VMS */ #include "HTInit.h" #include "LYCurses.h" +#include "LYStyle.h" #include "HTML.h" #include "LYUtils.h" #include "LYGlobalDefs.h" @@ -26,6 +27,7 @@ #include "LYKeymap.h" #include "LYList.h" #include "LYJump.h" +#include "LYMainLoop.h" #include "LYBookmark.h" #ifdef DOSPATH #include "HTDOS.h" @@ -143,6 +145,10 @@ PUBLIC lynx_printer_item_type *printers = NULL; /* linked list of download options */ PUBLIC lynx_html_item_type *downloaders = NULL; /* linked list of upload options */ +#ifdef USE_EXTERNALS +PUBLIC lynx_html_item_type *externals = NULL; + /* linked list of external options */ +#endif PUBLIC lynx_html_item_type *uploaders = NULL; PUBLIC int port_syntax = 1; PUBLIC BOOLEAN LYShowCursor = SHOW_CURSOR; /* to show or not to show */ @@ -180,6 +186,9 @@ PUBLIC BOOLEAN news_ok = TRUE; PUBLIC BOOLEAN rlogin_ok = TRUE; PUBLIC BOOLEAN ftp_ok = TRUE; PUBLIC BOOLEAN system_editor = FALSE; +#ifdef USE_EXTERNALS +PUBLIC BOOLEAN no_externals = FALSE; +#endif PUBLIC BOOLEAN no_inside_telnet = FALSE; PUBLIC BOOLEAN no_outside_telnet = FALSE; PUBLIC BOOLEAN no_telnet_port = FALSE; @@ -328,6 +337,15 @@ PUBLIC int LYStatusLine = -1; /* Line for statusline() if > -1 */ PUBLIC BOOLEAN LYCollapseBRs = COLLAPSE_BR_TAGS; /* Collapse serial BRs? */ PUBLIC BOOLEAN LYSetCookies = SET_COOKIES; /* Process Set-Cookie headers? */ PUBLIC char *XLoadImageCommand = NULL; /* Default image viewer for X */ +PUBLIC BOOLEAN LYNoISMAPifUSEMAP = FALSE; /* Omit ISMAP link if MAP present? */ +PUBLIC int LYHiddenLinks = HIDDENLINKS_SEPARATE; /* Show hidden links? */ + +PUBLIC BOOL New_DTD = YES; +PUBLIC FILE *LYTraceLogFP = NULL; /* Pointer for TRACE log */ +PUBLIC char *LYTraceLogPath = NULL; /* Path for TRACE log */ +PUBLIC BOOLEAN LYUseTraceLog = USE_TRACE_LOG; /* Use a TRACE log? */ +PUBLIC FILE LYOrigStderr; /* Original stderr pointer */ +PUBLIC BOOLEAN LYStripDotDotURLs = FALSE; /* Try to fix ../ in some URLs? */ /* These are declared in cutil.h for current freeWAIS libraries. - FM */ #ifdef DECLARE_WAIS_LOGFILES @@ -425,6 +443,7 @@ PRIVATE void free_lynx_globals NOARGS FREE(URLDomainPrefixes); FREE(URLDomainSuffixes); FREE(XLoadImageCommand); + FREE(LYTraceLogPath); for (i = 0; i < nlinks; i++) { FREE(links[i].lname); } @@ -433,6 +452,37 @@ PRIVATE void free_lynx_globals NOARGS return; } +#if defined(USEHASH) + char *lynx_lss_file=NULL; +#endif + +PRIVATE char *make_homedir_lynxrc_filename ARGS1(char *, name) +{ + char *home = NULL; + + if (name == NULL) + { +#if defined(UNIX) && !defined(DJGPP) + name = "/.lynxrc"; +#else + name = "/lynx.rc"; +#endif + } + +#ifdef DOSPATH + StrAllocCopy(home, HTDOS_wwwName((char *)Home_Dir())); +#else +#ifdef VMS + StrAllocCopy(home, HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCopy(home, Home_Dir()); +#endif /* VMS */ +#endif /* DOSPATH */ + + StrAllocCat(home, name); + return home; +} + /* * Wow! Someone wants to start up Lynx. */ @@ -474,7 +524,7 @@ WSADATA WSAData; #endif #ifdef DOSPATH - terminal = "vt100"; + terminal = "vt100"; #endif /* @@ -549,23 +599,6 @@ WSADATA WSAData; HTUnEscapeSome(startfile, " \r\n\t"); convert_to_spaces(startfile, TRUE); } - StrAllocCopy(jumpprompt, JUMP_PROMPT); -#ifdef JUMPFILE - StrAllocCopy(jumpfile, JUMPFILE); - { - temp = (char *)malloc(strlen(jumpfile) + 10); - if (!temp) { - outofmem(__FILE__, "main"); - } else { - sprintf(temp, "JUMPFILE:%s", jumpfile); - if (!LYJumpInit(temp)) { - if (TRACE) - fprintf(stderr, "Failed to register %s\n", temp); - } - FREE(temp); - } - } -#endif /* JUMPFILE */ StrAllocCopy(indexfile, DEFAULT_INDEX_FILE); StrAllocCopy(global_type_map, GLOBAL_MAILCAP); StrAllocCopy(personal_type_map, PERSONAL_MAILCAP); @@ -683,17 +716,30 @@ WSADATA WSAData; no_newspost = (LYNewsPosting == FALSE); /* - * Set up trace, the anonymous account defaults, and/or - * the nosocks flag, if requested, and an alternate - * configuration file, if specified, NOW. Also, if - * we only want the help menu, output that and exit. - FM + * Set up trace, the anonymous account defaults, + * validate restrictions, and/or the nosocks flag, + * if requested, and an alternate configuration + * file, if specified, NOW. Also, if we only want + * the help menu, output that and exit. - FM */ - for (i=1; i<argc; i++) { + for (i = 1; i < argc; i++) { if (strncmp(argv[i], "-trace", 6) == 0) { WWW_TraceFlag = TRUE; + } else if (strncmp(argv[i], "-tlog", 5) == 0) { + if (LYUseTraceLog) { + LYUseTraceLog = FALSE; + } else { + LYUseTraceLog = TRUE; + } } else if (strncmp(argv[i], "-anonymous", 10) == 0) { - parse_restrictions("default"); + if (!LYValidate) + parse_restrictions("default"); anon_restrictions_set = TRUE; + } else if (strcmp(argv[0], "-validate") == 0) { + /* + * Follow only http URLs. + */ + LYValidate = TRUE; #ifdef SOCKS } else if (strncmp(argv[i], "-nosocks", 8) == 0) { socks_flag = FALSE; @@ -715,11 +761,22 @@ WSADATA WSAData; #endif /* SOCKS */ /* - * If we didn't get and act on an -anonymous switch, - * but can verify that this is the anonymous account, - * set the default restrictions for that account NOW. - FM + * If we had -validate set all of the restrictions + * and disallow a TRACE log NOW. - FM + */ + if (LYValidate == TRUE) { + parse_restrictions("all"); + LYUseTraceLog = FALSE; + } + + /* + * If we didn't get and act on a -validate or -anonymous + * switch, but can verify that this is the anonymous account, + * set the default restrictions for that account and disallow + * a TRACE log NOW. - FM */ - if (!anon_restrictions_set && strlen((char *)ANONYMOUS_USER) > 0 && + if (!LYValidate && !anon_restrictions_set && + strlen((char *)ANONYMOUS_USER) > 0 && #if defined (VMS) || defined (NOUSERS) !strcasecomp(((char *)getenv("USER")==NULL ? " " : getenv("USER")), ANONYMOUS_USER)) { @@ -732,12 +789,76 @@ WSADATA WSAData; #endif /* VMS */ parse_restrictions("default"); anon_restrictions_set = TRUE; + LYUseTraceLog = FALSE; } + + /* + * Set up the TRACE log path, and logging if appropriate. - FM + */ +#ifdef VMS + StrAllocCopy(LYTraceLogPath, "sys$login:Lynx.trace"); +#else + StrAllocCopy(LYTraceLogPath, (Home_Dir() ? Home_Dir() : "")); + StrAllocCat(LYTraceLogPath, "/Lynx.trace"); +#endif /* VMS */ + LYOrigStderr = *stderr; + if (TRACE && LYUseTraceLog) { + /* + * If we can't open it for writing, give up. + * Otherwise, on VMS close it, delete it and any + * versions from previous sessions so they don't + * accumulate, and open it again. - FM + */ + if ((LYTraceLogFP = fopen(LYTraceLogPath, "w")) == NULL) { + WWW_TraceFlag = FALSE; + fprintf(stderr, "%s\n", TRACELOG_OPEN_FAILED); + exit(-1); + } +#ifdef VMS + fclose(LYTraceLogFP); + while (remove(LYTraceLogPath) == 0) + ; + if ((LYTraceLogFP = fopen(LYTraceLogPath, "w", + "shr=get")) == NULL) { + WWW_TraceFlag = FALSE; + printf("%s\n", TRACELOG_OPEN_FAILED); + exit(-1); + } +#endif /* VMS */ + *stderr = *LYTraceLogFP; + fprintf(stderr, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); + } + + /* + * If TRACE is on, indicate whether the + * anonymous restrictions are set. - FM + */ if (TRACE && anon_restrictions_set) { fprintf(stderr, "LYMain: Anonymous restrictions set.\n"); } /* + * Set up the default jump file stuff. - FM + */ + StrAllocCopy(jumpprompt, JUMP_PROMPT); +#ifdef JUMPFILE + StrAllocCopy(jumpfile, JUMPFILE); + { + temp = (char *)malloc(strlen(jumpfile) + 10); + if (!temp) { + outofmem(__FILE__, "main"); + } else { + sprintf(temp, "JUMPFILE:%s", jumpfile); + if (!LYJumpInit(temp)) { + if (TRACE) + fprintf(stderr, "Failed to register %s\n", temp); + } + FREE(temp); + } + } +#endif /* JUMPFILE */ + + /* * If no alternate configuration file was specified on * the command line, see if it's in the environment. */ @@ -747,6 +868,21 @@ WSADATA WSAData; StrAllocCopy(lynx_cfg_file, cp); } + /* If we still have no config file, check one in home directory */ + if (NULL == lynx_cfg_file) + { + temp = make_homedir_lynxrc_filename (NULL); + if (temp != NULL) + { + if (NULL != (fp = fopen (temp, "r"))) + { + fclose (fp); + StrAllocCopy (lynx_cfg_file, temp); + } + FREE(temp); + } + } + /* * If we still don't have a configuration file, * use the userdefs.h definition. @@ -758,25 +894,15 @@ WSADATA WSAData; * Convert a '~' in the configuration file path to $HOME. */ #ifndef _WINDOWS /* avoid the whole ~ thing for now */ - if ((cp = strchr(lynx_cfg_file, '~'))) { - *(cp++) = '\0'; - StrAllocCopy(temp, lynx_cfg_file); - if (((len = strlen(temp)) > 0) && temp[len-1] == '/') - temp[len-1] = '\0'; -#ifdef DOSPATH - StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); -#else -#ifdef VMS - StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); -#else - StrAllocCat(temp, Home_Dir()); -#endif /* VMS */ -#endif /* DOSPATH */ - StrAllocCat(temp, cp); - StrAllocCopy(lynx_cfg_file, temp); - FREE(temp); - } -#endif /* _WINDOWS */ + /* I think this should only be performed if lynx_cfg_file starts with ~/ */ + if ((lynx_cfg_file[0] == '~') && (lynx_cfg_file[1] == '/')) + { + temp = make_homedir_lynxrc_filename (lynx_cfg_file + 2); + FREE(lynx_cfg_file); + lynx_cfg_file = temp; + temp = NULL; + } +#endif /* * If the configuration file is not available, @@ -800,6 +926,59 @@ WSADATA WSAData; } #endif /* EXP_CHARTRANS */ +#if defined(USEHASH) + /* + * If no alternate lynxile file was specified on + * the command line, see if it's in the environment. + */ + if (!lynx_lss_file) { + if (((cp=getenv("LYNX_LSS")) != NULL) || + (cp=getenv("lynx_lss")) != NULL) + StrAllocCopy(lynx_lss_file, cp); + } + + /* + * If we still don't have a lynxile file, + * use the userdefs.h definition. + */ + if (!lynx_lss_file) + StrAllocCopy(lynx_lss_file, LYNX_LSS_FILE); + + /* + * Convert a '~' in the lynxile file path to $HOME. + */ + if ((cp = strchr(lynx_lss_file, '~'))) { + char *temp = NULL; + int len; + + *(cp++) = '\0'; + StrAllocCopy(temp, lynx_lss_file); + if ((len=strlen(temp)) > 0 && temp[len-1] == '/') + temp[len-1] = '\0'; +#ifdef VMS + StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); +#else + StrAllocCat(temp, Home_Dir()); +#endif /* VMS */ + StrAllocCat(temp, cp); + StrAllocCopy(lynx_lss_file, temp); + FREE(temp); + } + /* + * If the lynxile file is not available, + * inform the user and exit. + */ + if ((fp = fopen(lynx_lss_file, "r")) == NULL) { + fprintf(stderr, "\nLynxile file %s is not available.\n\n", + lynx_lss_file); + } + else + { + fclose(fp); + style_readFromFile(lynx_lss_file); + } +#endif + /* * Make sure we have the edit map declared. - FM */ @@ -808,7 +987,7 @@ WSADATA WSAData; exit(-1); } -#if defined(USE_SLANG) || defined(COLOR_CURSES) +#if USE_COLOR_TABLE /* * Set up default foreground and background colors. */ @@ -837,6 +1016,8 @@ WSADATA WSAData; read_cfg(lynx_cfg_file); FREE(lynx_cfg_file); + HTSwitchDTD(New_DTD); + /* * Check for a save space path in the environment. * If one was set in the configuration file, that @@ -858,7 +1039,7 @@ WSADATA WSAData; if (((len = strlen(temp)) > 0) && temp[len-1] == '/') temp[len-1] = '\0'; #ifdef DOSPATH - StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); + StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir())); #else #ifdef VMS StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir())); @@ -1654,6 +1835,19 @@ PRIVATE void parse_arg ARGS3( */ HEAD_request = TRUE; + } else if (strncmp(argv[0], "-hiddenlinks", 7) == 0) { + if (nextarg) { + if (strncasecomp(cp, "merge", 1) == 0) + LYHiddenLinks = HIDDENLINKS_MERGE; + else if (strncasecomp(cp, "listonly", 1) == 0) + LYHiddenLinks = HIDDENLINKS_SEPARATE; + else if (strncasecomp(cp, "ignore", 1) == 0) + LYHiddenLinks = HIDDENLINKS_IGNORE; + else + goto Output_Error_and_Help_List; + } else + LYHiddenLinks = HIDDENLINKS_MERGE; + } else if (strncmp(argv[0], "-historical", 11) == 0) { if (historical_comments) historical_comments = FALSE; @@ -1693,6 +1887,12 @@ PRIVATE void parse_arg ARGS3( if (nextarg) StrAllocCopy(indexfile, cp); + } else if (strncmp(argv[0], "-ismap", 6) == 0) { + if (LYNoISMAPifUSEMAP) + LYNoISMAPifUSEMAP = FALSE; + else + LYNoISMAPifUSEMAP = TRUE; + } else { goto Output_Error_and_Help_List; } @@ -1702,6 +1902,16 @@ PRIVATE void parse_arg ARGS3( if (strncmp(argv[0], "-link", 5) == 0) { if (nextarg) ccount = atoi(cp); +#if defined(USEHASH) + } else if (strncmp(argv[0], "-lss", 4) == 0) { + fprintf(stderr, "***********************\n"); + if ((cp=strchr(argv[0],'=')) != NULL) + StrAllocCopy(lynx_lss_file, cp+1); + else { + StrAllocCopy(lynx_lss_file, argv[1]); + i++; + } +#endif } else if (strncmp(argv[0], "-localhost", 10) == 0) { local_host_only = TRUE; @@ -1908,12 +2118,17 @@ PRIVATE void parse_arg ARGS3( dired_support disallow local file management\n"); #endif /* DIRED_SUPPORT */ printf("\ - disk_save disallow saving binary files to disk in the download menu\n\ + disk_save disallow saving to disk in the download and print menus\n\ dotfiles disallow access to, or creation of, hidden (dot) files\n\ download disallow downloaders in the download menu\n\ editor disallow editing\n\ exec disable execution scripts\n\ - exec_frozen disallow the user from changing the execution link\n\ + exec_frozen disallow the user from changing the execution link\n"); +#ifdef USE_EXTERNALS + printf("\ + externals disable passing URLs to external programs\n"); +#endif + printf("\ file_url disallow using G)oto, served links or bookmarks for\n\ file: URL's\n\ goto disable the 'g' (goto) command\n"); @@ -2005,6 +2220,16 @@ PRIVATE void parse_arg ARGS3( HTAtom_for("www/download") : HTAtom_for("www/dump")); LYcols=999; +#if defined(USEHASH) + } else if (strncmp(argv[0], "-lss", 4) == 0) { + /* + * Already read the alternate lynxile file + * so just check whether we need to increment i + */ + if (nextarg) + ; /* do nothing */ +#endif + } else if (strncmp(argv[0], "-stack_dump", 11) == 0) { stack_dump = TRUE; @@ -2032,8 +2257,17 @@ PRIVATE void parse_arg ARGS3( if (nextarg) terminal = cp; + } else if (strncmp(argv[0], "-tlog", 5) == 0) { + /* + * Already handled. - FM + */ + break; + } else if (strncmp(argv[0], "-trace", 6) == 0) { - WWW_TraceFlag = TRUE; + /* + * Already handled. - FM + */ + break; } else if (strncmp(argv[0], "-traversal", 10) == 0) { traversal = TRUE; @@ -2055,7 +2289,7 @@ PRIVATE void parse_arg ARGS3( else use_underscore = TRUE; -#ifdef NCURSES_MOUSE_VERSION +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) } else if (strncmp(argv[0], "-use_mouse", 9) == 0) { LYUseMouse = TRUE; #endif @@ -2068,9 +2302,9 @@ PRIVATE void parse_arg ARGS3( if (strcmp(argv[0], "-validate") == 0) { /* * Follow only http URLs. + * Already handled. - FM */ - LYValidate = TRUE; - parse_restrictions("all"); + break; } else if (strncmp(argv[0], "-version", 8) == 0) { printf("\n%s Version %s (1997)\n", LYNX_NAME, LYNX_VERSION); @@ -2096,7 +2330,12 @@ Output_Error_and_Help_List: #ifdef VMS printf(" LYNX: Invalid Option: %s\n", argv[0]); #else - printf("%s: Invalid Option: %s\n", pgm, argv[0]); +#ifdef UNIX + if (strncmp(argv[0], "-help", 5) != 0) + fprintf(stderr, "%s: Invalid Option: %s\n", pgm, argv[0]); + else +#endif /* UNIX */ + printf("%s: Invalid Option: %s\n", pgm, argv[0]); #endif /* VMS */ Output_Help_List: #ifdef VMS @@ -2152,12 +2391,18 @@ Output_Help_List: printf(" terminated by '---' on a line\n"); printf(" -head send a HEAD request\n"); printf(" -help print this usage message\n"); + printf(" -hiddenlinks=[option] hidden links: options are merge, listonly, or ignore\n"); printf(" -historical toggles use of '>' or '-->' as a terminator for comments\n"); printf(" -homepage=URL set homepage separate from start page\n"); printf(" -image_links toggles inclusion of links for all images\n"); printf(" -index=URL set the default index file to URL\n"); + printf(" -ismap toggles inclusion of ISMAP links when client-side\n"); + 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) + 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"); printf(" -minimal toggles minimal versus valid comment parsing\n"); printf(" -newschunksize=NUMBER number of articles in chunked news listings\n"); @@ -2204,10 +2449,11 @@ Output_Help_List: #endif /* !VMS */ printf(" -telnet disable telnets\n"); printf(" -term=TERM set terminal type to TERM\n"); - printf(" -trace turns on WWW trace mode\n"); + printf(" -tlog toggles use of a Lynx Trace Log for the current session\n"); + printf(" -trace turns on Lynx trace mode\n"); printf(" -traversal traverse all http links derived from startfile\n"); printf(" -underscore toggles use of _underline_ format in dumps\n"); -#ifdef NCURSES_MOUSE_VERSION +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) printf(" -use_mouse enable use of the mouse\n"); #endif printf(" -validate accept only http URLs (for validation)\n"); @@ -2229,7 +2475,7 @@ PRIVATE void FatalProblem ARGS1( * Ignore further interrupts. - mhc: 11/2/91 */ #ifndef NOSIGHUP - (void) signal(SIGHUP, SIG_DFL); + (void) signal(SIGHUP, SIG_IGN); #endif /* NOSIGHUP */ (void) signal (SIGTERM, SIG_IGN); (void) signal (SIGINT, SIG_IGN); diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index 50fcbffb..a721ea4b 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -7,6 +7,7 @@ #include "HTFile.h" #include "HTTP.h" #include "LYCurses.h" +#include "LYStyle.h" #include "LYGlobalDefs.h" #include "HTAlert.h" #include "LYUtils.h" @@ -34,10 +35,15 @@ #include "LYCharSets.h" #include "LYCharUtils.h" #include "LYCookie.h" +#include "LYMainLoop.h" #ifdef DOSPATH #include "HTDOS.h" #endif +#ifdef USE_EXTERNALS +#include "LYExtern.h" +#endif + #ifdef VMS #include "HTVMSUtils.h" #endif /* VMS */ @@ -53,6 +59,7 @@ extern BOOL reloading; /* For Flushing Cache on Proxy Server */ PRIVATE int are_different PARAMS((document *doc1, document *doc2)); +PRIVATE int are_phys_different PARAMS((document *doc1, document *doc2)); PUBLIC void HTGotoURLs_free NOPARAMS; PUBLIC void HTAddGotoURL PARAMS((char *url)); @@ -79,6 +86,8 @@ PRIVATE document curdoc; PRIVATE char *traversal_host = NULL; PRIVATE char *traversal_link_to_add = NULL; PRIVATE char *CurrentUserAgent = NULL; +PRIVATE char *CurrentNegoLanguage = NULL; +PRIVATE char *CurrentNegoCharset = NULL; /* * Function for freeing allocated mainloop() variables. - FM @@ -95,9 +104,15 @@ PRIVATE void free_mainloop_variables NOARGS FREE(curdoc.post_data); FREE(curdoc.post_content_type); FREE(curdoc.bookmark); +#ifdef USEHASH + FREE(curdoc.style); + FREE(newdoc.style); +#endif FREE(traversal_host); FREE(traversal_link_to_add); FREE(CurrentUserAgent); + FREE(CurrentNegoLanguage); + FREE(CurrentNegoCharset); #ifdef DIRED_SUPPORT clear_tags(); #endif /* DIRED_SUPPORT */ @@ -116,7 +131,8 @@ PRIVATE void free_mainloop_variables NOARGS int mainloop NOARGS { - int c = 0, real_c = 0, old_c = 0, cmd; + int c = 0, real_c = 0, old_c = 0, cmd, real_cmd = LYK_DO_NOTHING; + int getresult; int arrowup = FALSE, show_help = FALSE; int lines_in_file = -1; int Newline = 0; @@ -127,6 +143,7 @@ int mainloop NOARGS BOOLEAN first_file = TRUE; BOOLEAN refresh_screen = FALSE; BOOLEAN force_load = FALSE; + BOOLEAN try_internal = FALSE; BOOLEAN crawl_ok = FALSE; BOOLEAN rlink_exists; BOOLEAN rlink_allowed; @@ -139,6 +156,7 @@ int mainloop NOARGS BOOLEAN show_dotfiles_flag = show_dotfiles; BOOLEAN LYRawMode_flag = LYRawMode; BOOLEAN LYSelectPopups_flag = LYSelectPopups; + BOOLEAN trace_mode_flag = FALSE; char cfile[128]; FILE *cfp; char *cp, *toolbar; @@ -179,12 +197,20 @@ int mainloop NOARGS curdoc.post_data = NULL; curdoc.post_content_type = NULL; curdoc.bookmark = NULL; +#ifdef USEHASH + curdoc.style = NULL; + newdoc.style = NULL; +#endif nhist = 0; user_input_buffer[(sizeof(user_input_buffer) - 1)] = '\0'; *prev_target = '\0'; *user_input_buffer = '\0'; StrAllocCopy(CurrentUserAgent, (LYUserAgent ? LYUserAgent : "")); + StrAllocCopy(CurrentNegoLanguage, (language ? + language : "")); + StrAllocCopy(CurrentNegoCharset, (pref_charset ? + pref_charset : "")); atexit(free_mainloop_variables); initialize: StrAllocCopy(newdoc.address, startfile); @@ -192,6 +218,7 @@ initialize: StrAllocCopy(newdoc.title, "Entry into main screen"); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; newdoc.line = 1; newdoc.link = 0; @@ -259,6 +286,9 @@ initialize: display_lines = LYlines-2; while (TRUE) { +#ifdef USEHASH + if (curdoc.style != NULL) force_load = TRUE; +#endif /* * If newdoc.address is different then curdoc.address then * we need to go out and find and load newdoc.address. @@ -289,7 +319,18 @@ try_again: * and LYresubmit_posts is set. - FM */ LYpop(&newdoc); - if ((newdoc.bookmark != NULL) || + /* + ** If curdoc had been reached via an internal + ** (fragment) link from what we now have just + ** popped into newdoc, then override non-caching in + ** all cases. - kw + */ + if (curdoc.internal_link && + !are_phys_different(&curdoc, &newdoc)) { + LYoverride_no_cache = TRUE; + LYforce_no_cache = FALSE; + try_internal = TRUE; + } else if ((newdoc.bookmark != NULL) || (newdoc.post_data != NULL && LYresubmit_posts)) { LYoverride_no_cache = FALSE; } else { @@ -304,9 +345,61 @@ try_again: if (newdoc.address && !strncmp(newdoc.address, "http", 4)) newdoc.isHEAD = TRUE; + try_internal = FALSE; HEAD_request = FALSE; } + /* + * If we're getting the TRACE log and it's not new, + * check whether its HText structure has been dumped, + * and if so, fflush() and fclose() it to ensure it is + * fully updated, and then fopen() it again. - FM + */ + if (LYUseTraceLog == TRUE && + trace_mode_flag == FALSE && + LYTraceLogFP != NULL && + !strcmp((newdoc.title ? newdoc.title : ""), + LYNX_TRACELOG_TITLE)) { + DocAddress WWWDoc; + HTParentAnchor *tmpanchor; + + WWWDoc.address = newdoc.address; + WWWDoc.post_data = newdoc.post_data; + WWWDoc.post_content_type = newdoc.post_content_type; + WWWDoc.bookmark = newdoc.bookmark; + WWWDoc.isHEAD = newdoc.isHEAD; + WWWDoc.safe = newdoc.safe; + tmpanchor = HTAnchor_parent(HTAnchor_findAddress(&WWWDoc)); + if ((HText *)HTAnchor_document(tmpanchor) == NULL) { + if (TRACE) + fprintf(stderr, + "\nTurning off TRACE for fetch of log.\n"); + fflush(stderr); + fclose(LYTraceLogFP); + *stderr = LYOrigStderr; +#ifdef VMS + if ((LYTraceLogFP = fopen(LYTraceLogPath, + "a+", "shr=get")) == NULL) +#else + if ((LYTraceLogFP = fopen(LYTraceLogPath, + "a+")) == NULL) +#endif /* VMS */ + { + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); + old_c = 0; + cmd = LYK_PREV_DOC; + goto new_cmd; + } + *stderr = *LYTraceLogFP; + if (TRACE) { + WWW_TraceFlag = FALSE; + trace_mode_flag = TRUE; + } + } + } + LYRequestTitle = newdoc.title; if (newdoc.bookmark) LYforce_HTML_mode = TRUE; @@ -317,7 +410,55 @@ try_again: !strcmp(newdoc.address, homepage))) { LYPermitURL = TRUE; } - switch(getfile(&newdoc)) { + + if (try_internal) { + if (newdoc.address && + 0==strncmp(newdoc.address, "LYNXIMGMAP:", 11)) { + try_internal = FALSE; + } else if (curdoc.address && + 0==strncmp(curdoc.address, "LYNXIMGMAP:", 11)) { + try_internal = FALSE; + } + } + if (try_internal) { + char *cp = strchr(newdoc.address,'#'); + if (cp) { + HTFindPoundSelector(cp+1); + } + getresult = (HTMainText != NULL) ? NORMAL : NOT_FOUND; + try_internal = FALSE; /* done */ + /* fix up newdoc.address which may have been fragment-only */ + if (getresult == NORMAL && (!cp || cp == newdoc.address)) { + if (!cp) { + StrAllocCopy(newdoc.address, HTLoadedDocumentURL()); + } else { + StrAllocCopy(temp, HTLoadedDocumentURL()); + StrAllocCat(temp, cp); /* append fragment */ + StrAllocCopy(newdoc.address, temp); + FREE(temp); + } + } + } else { + if (newdoc.internal_link && newdoc.address && + *newdoc.address == '#' && nhist > 0) { + char *cp; + if (0==strncmp(history[nhist-1].address, "LYNXIMGMAP:", 11)) + cp = history[nhist-1].address + 11; + else + cp = history[nhist-1].address; + StrAllocCopy(temp, cp); + cp = strchr(temp, '#'); + if (cp) + *cp = '\0'; + StrAllocCat(temp, newdoc.address); + FREE(newdoc.address); + newdoc.address = temp; + temp = NULL; + } + getresult = getfile(&newdoc); + } + + switch(getresult) { case NOT_FOUND: /* @@ -325,6 +466,11 @@ try_again: * Do any error logging, if appropriate. */ LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */ + if (trace_mode_flag == TRUE) { + WWW_TraceFlag = TRUE; + trace_mode_flag = FALSE; + fprintf(stderr, "Turning TRACE back on.\n\n"); + } if (error_logging && first_file && owner_address && !LYCancelledFetch) { /* @@ -379,7 +525,13 @@ try_again: */ if (!dump_output_immediately) cleanup(); - printf("\nlynx: Can't access startfile %s\n", +#ifdef UNIX + if (dump_output_immediately) + fprintf(stderr,"\nlynx: Can't access startfile %s\n", + startfile); + else +#endif /* UNIX */ + printf("\nlynx: Can't access startfile %s\n", startfile); if (!dump_output_immediately) { #ifndef NOSIGHUP @@ -403,6 +555,11 @@ try_again: * Not supposed to return any file. */ LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */ + if (trace_mode_flag == TRUE) { + WWW_TraceFlag = TRUE; + trace_mode_flag = FALSE; + fprintf(stderr, "Turning TRACE back on.\n\n"); + } FREE(newdoc.address); /* to pop last doc */ FREE(newdoc.bookmark); LYJumpFileURL = FALSE; @@ -410,6 +567,7 @@ try_again: LYPermitURL = FALSE; LYCancelledFetch = FALSE; ForcePush = FALSE; + LYforce_HTML_mode = FALSE; if (traversal) { crawl_ok = FALSE; if (traversal_link_to_add) { @@ -456,12 +614,22 @@ try_again: StrAllocCopy(startfile, homepage); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; } else { if (!dump_output_immediately) cleanup(); - printf( +#ifdef UNIX + if (dump_output_immediately) { + fprintf(stderr, + "\nlynx: Start file could not be found or is not text/html or text/plain\n"); + fprintf(stderr," Exiting...\n"); + } else +#endif /* UNIX */ + { + printf( "\nlynx: Start file could not be found or is not text/html or text/plain\n"); - printf(" Exiting...\n"); + printf(" Exiting...\n"); + } if (!dump_output_immediately) { #ifndef NOSIGHUP (void) signal(SIGHUP, SIG_DFL); @@ -488,6 +656,11 @@ try_again: * Marvelously, we got the document! */ LYoverride_no_cache = FALSE; /* Was TRUE if popped. - FM */ + if (trace_mode_flag == TRUE) { + WWW_TraceFlag = TRUE; + trace_mode_flag = FALSE; + fprintf(stderr, "Turning TRACE back on.\n\n"); + } *prev_target = '\0'; /* Reset for this document. - FM */ /* @@ -583,6 +756,10 @@ try_again: (BookmarkPage + 2))); StrAllocCopy(newdoc.title, BOOKMARK_TITLE); StrAllocCopy(newdoc.bookmark, BookmarkPage); +#ifdef USEHASH + if (curdoc.style) + StrAllocCopy(newdoc.style, curdoc.style); +#endif StrAllocCopy(startrealm, newdoc.address); FREE(newdoc.post_data); FREE(newdoc.post_content_type); @@ -633,12 +810,14 @@ try_again: */ if (newdoc.address && curdoc.title && !strncmp(newdoc.address, "LYNXDOWNLOAD:", 13) && - !strcmp(curdoc.title, DOWNLOAD_OPTIONS_TITLE)) { + !strcmp((curdoc.title ? curdoc.title : ""), + DOWNLOAD_OPTIONS_TITLE)) { StrAllocCopy(newdoc.address, curdoc.address); StrAllocCopy(newdoc.title, curdoc.title); StrAllocCopy(newdoc.bookmark, curdoc.bookmark); newdoc.line = curdoc.line; newdoc.link = curdoc.link; + newdoc.internal_link = FALSE; /* can't be true. - kw */ } /* @@ -674,7 +853,13 @@ 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 + StrAllocCopy(curdoc.style, HText_getStyle()); + if (curdoc.style != NULL) + style_readFromFile (curdoc.style); +#endif curdoc.isHEAD = newdoc.isHEAD; + curdoc.internal_link = newdoc.internal_link; /* * Set the remaining document elements and add to @@ -713,6 +898,7 @@ try_again: HEAD_request = FALSE; /* only set for HEAD requests */ LYPermitURL = FALSE; /* only set for LYValidate */ ForcePush = FALSE; /* only set for some PRINT requests. */ + LYforce_HTML_mode = FALSE; } /* end if (STREQ(newdoc.address, curdoc.address) */ @@ -734,8 +920,8 @@ try_again: start_curses(); clear(); refresh_screen = TRUE; /* to force a redraw */ - recent_sizechange=FALSE; - if (user_mode==NOVICE_MODE) { + recent_sizechange = FALSE; + if (user_mode == NOVICE_MODE) { display_lines = LYlines-4; } else { display_lines = LYlines-2; @@ -905,7 +1091,7 @@ try_again: } /* - * Refesh the screen if neccessary. + * Refresh the screen if neccessary. */ if (refresh_screen) { clear(); @@ -917,7 +1103,7 @@ try_again: #endif /* DIRED_SUPPORT */ if (user_mode == NOVICE_MODE) noviceline(more); /* print help message */ - refresh_screen=FALSE; + refresh_screen = FALSE; } @@ -955,11 +1141,11 @@ try_again: #else #ifdef NORMAL_NON_FORM_LINK_STATUSLINES_FOR_ALL_USER_MODES } else if (lynx_mode == FORMS_LYNX_MODE && nlinks > 0 && - links[curdoc.link].type != WWW_LINK_TYPE) { + !(links[curdoc.link].type & WWW_LINK_TYPE)) { #else } else if (lynx_mode == FORMS_LYNX_MODE && nlinks > 0 && !(user_mode == ADVANCED_MODE && - links[curdoc.link].type == WWW_LINK_TYPE)) { + (links[curdoc.link].type & WWW_LINK_TYPE))) { #endif /* NORMAL_NON_FORM_LINK_STATUSLINES_FOR_ALL_USER_MODES */ #endif /* INDICATE_FORMS_MODE_FOR_ALL_LINKS_ON_PAGE */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) @@ -1106,7 +1292,13 @@ try_again: } else { if (!dump_output_immediately) cleanup(); - printf( +#ifdef UNIX + if (dump_output_immediately) + fprintf(stderr, + "Fatal error - could not open output file %s\n",cfile); + else +#endif + printf( "Fatal error - could not open output file %s\n",cfile); if (!dump_output_immediately) { #ifndef NOSIGHUP @@ -1229,7 +1421,7 @@ new_keyboard_input: if (lookup(links[curdoc.link].lname)) { if (more_links || (curdoc.link > -1 && curdoc.link < nlinks -1)) - c=DNARROW; + c= DNARROW; else { if (STREQ(curdoc.title,"Entry into main screen") || (nhist <= 0 )) { @@ -1250,7 +1442,7 @@ new_keyboard_input: } return(-1); } - c=LTARROW; + c = LTARROW; } } else { StrAllocCopy(traversal_link_to_add, @@ -1265,7 +1457,7 @@ new_keyboard_input: add_to_reject_list(links[curdoc.link].lname); if (more_links || (curdoc.link > -1 && curdoc.link < nlinks-1)) - c=DNARROW; + c = DNARROW; else { /* * curdoc.title doesn't always work, so @@ -1290,18 +1482,20 @@ new_keyboard_input: } return(-1); } - c=LTARROW; + c = LTARROW; } } /* right link not NULL or link to another site*/ } /* traversal */ - cmd=keymap[c+1]; /* add 1 to map EOF to 0 */ + cmd = keymap[c+1]; /* add 1 to map EOF to 0 */ #if defined(DIRED_SUPPORT) && defined(OK_OVERRIDE) if (lynx_edit_mode && override[c+1] && !no_dired_support) cmd = override[c+1]; #endif /* DIRED_SUPPORT && OK_OVERRIDE */ + real_cmd = cmd; + new_cmd: /* * A goto point for new input without going * back through the getch() loop. @@ -1329,6 +1523,8 @@ new_cmd: /* */ break; + case LYK_F_LINK_NUM: + c = '\0'; case LYK_1: case LYK_2: case LYK_3: @@ -1338,22 +1534,36 @@ new_cmd: /* case LYK_7: case LYK_8: case LYK_9: + { /* * Get a number from the user and follow that link number. */ - switch(follow_link_number(c, ((nlinks > 0) ? curdoc.link : 0))) { + int lindx = ((nlinks > 0) ? curdoc.link : 0); + int number; + + switch (follow_link_number(c, lindx, &newdoc, &number)) { case DO_LINK_STUFF: /* * Follow a normal link. */ - if (nlinks > 0) - StrAllocCopy(newdoc.address, links[curdoc.link].lname); - else - StrAllocCopy(newdoc.address, links[0].lname); + StrAllocCopy(newdoc.address, links[lindx].lname); + StrAllocCopy(newdoc.title, links[lindx].hightext); /* * Might be an anchor in the same doc from a POST * form. If so, don't free the content. -- FM */ + if (links[lindx].type == WWW_INTERN_LINK_TYPE) { + LYoverride_no_cache = TRUE; + newdoc.internal_link = TRUE; + if (0==strcmp(curdoc.address, LYlist_temp_url()) && + 0==strcmp((curdoc.title ? curdoc.title : ""), + LIST_PAGE_TITLE)) { + FREE(curdoc.address); + } else + try_internal = TRUE; + force_load = TRUE; + break; + } if (are_different(&curdoc, &newdoc)) { FREE(newdoc.post_data); FREE(newdoc.post_content_type); @@ -1361,18 +1571,88 @@ new_cmd: /* newdoc.isHEAD = FALSE; newdoc.safe = FALSE; } + newdoc.internal_link = FALSE; force_load = TRUE; /* force MainLoop to reload */ break; + case DO_GOTOLINK_STUFF: + /* + * Position on a normal link, don't follow it. - KW + */ + Newline = newdoc.line; + newdoc.line = 1; + if (Newline == curdoc.line) { + /* + * It's a link in the current page. - FM + */ + if (nlinks > 0 && curdoc.link > -1) { + if (curdoc.link == newdoc.link) { + /* + * It's the current link, and presumeably + * reflects a typo in the statusline entry, + * so issue a statusline message for the + * typo-prone users (like me 8-). - FM + */ + StrAllocCopy(temp, user_input_buffer); + sprintf(user_input_buffer, + LINK_ALREADY_CURRENT, number); + _statusline(user_input_buffer); + sleep(MessageSecs); + strcpy(user_input_buffer, temp); + FREE(temp); + } else { + /* + * It's a different link on this page, + * so turn the highlighting off, set the + * current link to the new link value from + * follow_link_number(), and re-initialize + * the new link value. - FM + */ + highlight(OFF, curdoc.link); + curdoc.link = newdoc.link; + newdoc.link = 0; + } + } + } + break; /* nothing more to do */ + + case DO_GOTOPAGE_STUFF: + /* + * Position on a page in this document. - FM + */ + Newline = newdoc.line; + newdoc.line = 1; + if (Newline == curdoc.line) { + /* + * It's the current page, so issue a + * statusline message for the typo-prone + * users (like me 8-). - FM + */ + if (Newline <= 1) { + _statusline(ALREADY_AT_BEGIN); + } else if (!more) { + _statusline(ALREADY_AT_END); + } else { + StrAllocCopy(temp, user_input_buffer); + sprintf(user_input_buffer, + ALREADY_AT_PAGE, number); + _statusline(user_input_buffer); + sleep(MessageSecs); + strcpy(user_input_buffer, temp); + FREE(temp); + } + sleep(MessageSecs); + } + break; + case PRINT_ERROR: - if (old_c == real_c) - break; old_c = real_c; _statusline(BAD_LINK_NUM_ENTERED); sleep(MessageSecs); break; } break; + } case LYK_SOURCE: /* toggle view source mode */ /* @@ -1452,7 +1732,13 @@ new_cmd: /* * Reload should force a cache refresh on a proxy. * -- Ari L. <luotonen@dxcern.cern.ch> */ - reloading = TRUE; + /* - but only if this was really a reload requested by + * the user, not if we jumped here to handle reloading for + * INLINE_TOGGLE, IMAGE_TOGGLE, RAW_TOGGLE, etc. + * - kw + */ + if (real_cmd == LYK_RELOAD) + reloading = TRUE; break; case LYK_HISTORICAL: @@ -1542,6 +1828,40 @@ new_cmd: /* sleep(MessageSecs); break; + case LYK_SWITCH_DTD: + /* + * Check if this is a reply from a POST, and if so, + * seek confirmation of reload if the safe element + * is not set. - FM, kw + */ + if ((curdoc.post_data != NULL && + curdoc.safe != TRUE) && + HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { + _statusline(WILL_NOT_RELOAD_DOC); + sleep(InfoSecs); + } else { + HTuncache_current_document(); + StrAllocCopy(newdoc.address, curdoc.address); + FREE(curdoc.address); + } +#ifdef NO_ASSUME_SAME_DOC + newdoc.line=1; + newdoc.link=0; +#else + newdoc.line = ((curdoc.line > 0) ? curdoc.line : 1); + newdoc.link = ((curdoc.link > -1) ? curdoc.link : 0); +#endif /* NO_ASSUME_SAME_DOC */ + if (New_DTD) + New_DTD = NO; + else + New_DTD = YES; + HTSwitchDTD(New_DTD); + _statusline(New_DTD ? + "Now using the experimental DTD!" : "Now using the old Lynx DTD."); +/* SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF);*/ + sleep(MessageSecs); + break; + #ifdef NOT_DONE_YET case LYK_PIPE: /* ignore for now */ @@ -1552,7 +1872,8 @@ new_cmd: /* _statusline(REALLY_QUIT); c = LYgetch(); #ifdef QUIT_DEFAULT_YES - if (TOUPPER(c) != 'N') + if (TOUPPER(c) != 'N' && + c != 7) #else if (TOUPPER(c) == 'Y') #endif /* QUIT_DEFAULT_YES */ @@ -1585,7 +1906,7 @@ new_cmd: /* Newline -= display_lines; } else if (curdoc.link > 0) { highlight(OFF,curdoc.link); - curdoc.link = 0; /* put on last link */ + curdoc.link = 0; /* put on first link */ } else if (old_c != real_c) { old_c = real_c; _statusline(ALREADY_AT_BEGIN); @@ -1665,10 +1986,10 @@ new_cmd: /* break; case LYK_REFRESH: - refresh_screen=TRUE; -#ifdef VMS + refresh_screen = TRUE; +#if defined(VMS) || defined(USE_SLANG) clearok(curscr, TRUE); -#endif /* VMS */ +#endif /* VMS || USE_SLANG */ break; case LYK_HOME: @@ -1875,13 +2196,15 @@ new_cmd: /* /* * Don't do if already viewing the cookie jar. */ - if (strcmp(curdoc.title, COOKIE_JAR_TITLE)) { + if (strcmp((curdoc.title ? curdoc.title : ""), + COOKIE_JAR_TITLE)) { StrAllocCopy(newdoc.address, "LYNXCOOKIE:/"); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; LYforce_no_cache = TRUE; if (LYValidate || check_realm) { LYPermitURL = TRUE; @@ -1904,7 +2227,7 @@ new_cmd: /* * contains the current file for printing purposes. * Pop the file afterwards to prevent multiple copies. */ - if (TRACE && LYCursesON) { + if (TRACE && !LYUseTraceLog && LYCursesON) { move(LYlines-1, LYcols-1); /* make sure cursor is down */ #ifdef USE_SLANG addstr("\n"); @@ -1920,11 +2243,13 @@ new_cmd: /* LYpop(&curdoc); break; } + StrAllocCopy(newdoc.title, HISTORY_PAGE_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; FREE(curdoc.address); /* so it doesn't get pushed */ refresh_screen = TRUE; @@ -1969,8 +2294,13 @@ new_cmd: /* if (HTAnchor_safe(tmpanchor)) { break; } - if ((LYresubmit_posts || - (HText *)HTAnchor_document(tmpanchor) == NULL) && + if (((HText *)HTAnchor_document(tmpanchor) == NULL || + (LYresubmit_posts && + !(curdoc.internal_link && + !are_phys_different((document *)&history[(nhist - 1)], + &curdoc)) + ) + ) && HTConfirm(CONFIRM_POST_RESUBMISSION) == FALSE) { if (nhist == 1) { _statusline(CANCELLED); @@ -2130,6 +2460,7 @@ new_cmd: /* StrAllocCopy(newdoc.bookmark, curdoc.bookmark); newdoc.isHEAD = curdoc.isHEAD; newdoc.safe = curdoc.safe; + newdoc.internal_link = curdoc.internal_link; break; } } @@ -2157,6 +2488,26 @@ new_cmd: /* StrAllocCopy(newdoc.address, links[curdoc.link].lname); StrAllocCopy(newdoc.title, links[curdoc.link].hightext); /* + * Might be an internal link anchor in the same doc. + * If so, take the try_internal shortcut if we didn't + * fall through from LYK_NOCACHE. - kw + */ + newdoc.internal_link = + (links[curdoc.link].type == WWW_INTERN_LINK_TYPE); + if (newdoc.internal_link && cmd != LYK_NOCACHE) { + if (0==strcmp(curdoc.address, LYlist_temp_url()) && + 0==strcmp((curdoc.title ? curdoc.title : ""), + LIST_PAGE_TITLE)) { + FREE(curdoc.address); + } else + 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; + } + /* * Might be an anchor in the same doc from a POST * form. If so, dont't free the content. -- FM */ @@ -2556,6 +2907,7 @@ check_goto_URL: FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.safe = FALSE; + newdoc.internal_link = FALSE; force_load = TRUE; LYUserSpecifiedURL = TRUE; #ifdef DIRED_SUPPORT @@ -2582,6 +2934,7 @@ check_goto_URL: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; } break; @@ -2606,6 +2959,7 @@ check_goto_URL: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; } /* end else */ } /* end if */ break; @@ -2670,6 +3024,7 @@ check_goto_URL: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; highlight(OFF,curdoc.link); #ifdef DIRED_SUPPORT if (lynx_edit_mode) @@ -2709,9 +3064,14 @@ check_goto_URL: CurrentCharSet_flag != current_char_set || LYRawMode_flag != LYRawMode || LYSelectPopups_flag != LYSelectPopups || - (strcmp(CurrentUserAgent, (LYUserAgent ? - LYUserAgent : "")) && - !strncmp(curdoc.address, "http", 4))) { + ((strcmp(CurrentUserAgent, (LYUserAgent ? + LYUserAgent : "")) || + strcmp(CurrentNegoLanguage, (language ? + language : "")) || + strcmp(CurrentNegoCharset, (pref_charset ? + pref_charset : "")) + ) && (strncmp(curdoc.address, "http", 4) == 0 || + strncmp(curdoc.address, "lynxcgi:", 8) == 0))) { /* * Check if this is a reply from a POST, and if so, * seek confirmation of reload if the safe element @@ -2726,7 +3086,42 @@ check_goto_URL: } else { LYforce_no_cache = TRUE; StrAllocCopy(newdoc.address, curdoc.address); - if (keypad_mode_flag != keypad_mode || + if (((strcmp(CurrentNegoLanguage, + (language ? language : "")) || + strcmp(CurrentNegoCharset, + (pref_charset ? pref_charset : ""))) && + (strncmp(curdoc.address, "http", 4) == 0 || + strncmp(curdoc.address, "lynxcgi:", 8) == 0))) { + /* + * An option has changed which may influence + * content negotiation, and the resource is from + * a http or https or lynxcgi URL (the only protocols + * which currently do anything with this information). + * Set reloading=TRUE so that proxy caches will be + * flushed, which is necessary until the time when + * all proxies understand HTTP 1.1 Vary: and all + * Servers properly use it... Treat like + * case LYK_RELOAD (see comments there). - kw + */ + if (HTisDocumentSource()) { + HTOutputFormat = WWW_SOURCE; + } + HEAD_request = HTLoadedDocumentIsHEAD(); + HTuncache_current_document(); +#ifdef NO_ASSUME_SAME_DOC + newdoc.line=1; + newdoc.link=0; +#else + if (lynx_mode == FORMS_LYNX_MODE) { + _statusline(RELOADING_FORM); + sleep(AlertSecs); + } + newdoc.line = ((curdoc.line > 0) ? curdoc.line : 1); + newdoc.link = ((curdoc.link > -1) ? curdoc.link : 0); +#endif /* NO_ASSUME_SAME_DOC */ + FREE(curdoc.address); + reloading = TRUE; + } else if (keypad_mode_flag != keypad_mode || (user_mode_flag != user_mode && (user_mode_flag == NOVICE_MODE || user_mode == NOVICE_MODE)) || @@ -2739,7 +3134,7 @@ check_goto_URL: !strncmp(curdoc.address, "ftp:", 4))) || LYSelectPopups_flag != LYSelectPopups || (strcmp(CurrentUserAgent, (LYUserAgent ? - LYUserAgent : "")) && + LYUserAgent : "")) && !strncmp(curdoc.address, "http", 4))) { HTuncache_current_document(); FREE(curdoc.address); @@ -2756,6 +3151,10 @@ check_goto_URL: StrAllocCopy(CurrentUserAgent, (LYUserAgent ? LYUserAgent : "")); } + StrAllocCopy(CurrentNegoLanguage, (language ? + language : "")); + StrAllocCopy(CurrentNegoCharset, (pref_charset ? + pref_charset : "")); refresh_screen = TRUE; /* to repaint screen */ break; @@ -2774,7 +3173,7 @@ check_goto_URL: /* * Yah, the search succeeded. */ - if (TRACE && LYCursesON) { + if (TRACE && !LYUseTraceLog && LYCursesON) { /* * Make sure cursor is down. */ @@ -2792,6 +3191,7 @@ check_goto_URL: */ StrAllocCopy(curdoc.address, newdoc.address); StrAllocCopy(newdoc.post_data, curdoc.post_data); + newdoc.internal_link = FALSE; curdoc.line = -1; Newline = 0; refresh_screen = TRUE; /* redisplay it */ @@ -2811,6 +3211,7 @@ check_goto_URL: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; FREE(use_this_url_instead); force_load = TRUE; break; @@ -2825,6 +3226,7 @@ check_goto_URL: StrAllocCopy(newdoc.bookmark, curdoc.bookmark); newdoc.isHEAD = curdoc.isHEAD; newdoc.safe = curdoc.safe; + newdoc.internal_link = curdoc.internal_link; } } else if (old_c != real_c) { old_c = real_c; @@ -2836,6 +3238,17 @@ check_goto_URL: case LYK_WHEREIS: /* search within the document */ case LYK_NEXT: /* search for the next occurrence in the document */ /* user search */ + { + BOOLEAN have_target_onscreen = (*prev_target != '\0' && + HText_pageHasPrevTarget()); + BOOL found; + int oldcur = curdoc.link; /* temporarily remember */ + char *remember_old_target = NULL; + if (have_target_onscreen) + StrAllocCopy(remember_old_target, prev_target); + else + StrAllocCopy(remember_old_target, ""); + if (cmd != LYK_NEXT) { /* * Reset prev_target to force prompting @@ -2844,7 +3257,7 @@ check_goto_URL: * is entered by the user. */ *prev_target = '\0'; - textsearch(&curdoc, prev_target, FALSE); + found = textsearch(&curdoc, prev_target, FALSE); } else { /* * When the third argument is TRUE, the previous @@ -2856,7 +3269,7 @@ check_goto_URL: * after prev_target was reset on fetch of that * document. */ - textsearch(&curdoc, prev_target, TRUE); + found = textsearch(&curdoc, prev_target, TRUE); } /* @@ -2865,7 +3278,29 @@ check_goto_URL: * of highlighting is the default search string * was erased without replacement. - FM */ - refresh_screen = TRUE; + /* + ** Well let's try to avoid it at least in a few cases + ** where it is not needed. - kw + */ + if (www_search_result >= 0 && www_search_result != curdoc.line) { + refresh_screen = TRUE; /* doesn't really matter */ + } else if (!found) { + refresh_screen = have_target_onscreen; + } else if (!have_target_onscreen && found) { + refresh_screen = TRUE; + } else if (www_search_result == curdoc.line && + curdoc.link == oldcur && + curdoc.link >= 0 && nlinks > 0 && + links[curdoc.link].ly >= (display_lines/3)) { + refresh_screen = TRUE; + } else if ((case_sensitive && 0!=strcmp(prev_target, + remember_old_target)) || + (!case_sensitive && 0!=strcasecomp(prev_target, + remember_old_target))) { + refresh_screen = TRUE; + } + FREE(remember_old_target); + } break; case LYK_COMMENT: /* reply by mail */ @@ -2931,6 +3366,7 @@ check_goto_URL: * The address is a URL. Just follow the link. */ StrAllocCopy(newdoc.address, owner_address); + newdoc.internal_link = FALSE; } else { /* * The owner_address is a mailto: URL. @@ -2947,7 +3383,7 @@ check_goto_URL: reply_by_mail(owner_address, curdoc.address, (cp ? cp : "")); - refresh_screen=TRUE; /* to force a showpage */ + refresh_screen = TRUE; /* to force a showpage */ } } } @@ -3007,7 +3443,7 @@ check_goto_URL: ret = local_modify(&curdoc, &newdoc.address); if (ret == PERMIT_FORM_RESULT) { /* Permit form thrown up */ - refresh_screen=TRUE; + refresh_screen = TRUE; } else if (ret) { HTuncache_current_document(); StrAllocCopy(newdoc.address, curdoc.address); @@ -3017,6 +3453,7 @@ check_goto_URL: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; newdoc.line = curdoc.line; newdoc.link = curdoc.link; clear(); @@ -3185,15 +3622,18 @@ check_goto_URL: /* * Don't do if already viewing info page. */ - if (strcmp((curdoc.title ? curdoc.title : ""), SHOWINFO_TITLE)) { + if (strcmp((curdoc.title ? curdoc.title : ""), + SHOWINFO_TITLE)) { if (!showinfo(&curdoc, lines_in_file, &newdoc, owner_address)) break; + StrAllocCopy(newdoc.title, SHOWINFO_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; LYforce_no_cache = TRUE; if (LYValidate || check_realm) LYPermitURL = TRUE; @@ -3224,8 +3664,7 @@ check_goto_URL: if (print_options(&newdoc.address, lines_in_file) < 0) break; - if (!strcmp((curdoc.title ? curdoc.title : ""), - HISTORY_PAGE_TITLE)) + StrAllocCopy(newdoc.title, PRINT_OPTIONS_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); @@ -3234,7 +3673,7 @@ check_goto_URL: ForcePush = TRUE; if (check_realm) LYPermitURL = TRUE; - refresh_screen=TRUE; /* redisplay */ + refresh_screen = TRUE; /* redisplay */ } break; @@ -3256,11 +3695,13 @@ check_goto_URL: */ if (showlist(&newdoc.address, TRUE) < 0) break; + StrAllocCopy(newdoc.title, LIST_PAGE_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; refresh_screen = TRUE; /* redisplay */ if (LYValidate || check_realm) { LYPermitURL = TRUE; @@ -3269,7 +3710,8 @@ check_goto_URL: break; case LYK_VLINKS: /* list links visited during the current session */ - if (!strcmp(curdoc.title, VISITED_LINKS_TITLE)) { + if (!strcmp((curdoc.title ? curdoc.title : ""), + VISITED_LINKS_TITLE)) { /* * Already viewing visited links page, so get out. */ @@ -3285,11 +3727,13 @@ check_goto_URL: sleep(MessageSecs); break; } + StrAllocCopy(newdoc.title, VISITED_LINKS_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; refresh_screen = TRUE; if (LYValidate || check_realm) { LYPermitURL = TRUE; @@ -3315,6 +3759,7 @@ check_goto_URL: *cp = '#'; StrAllocCopy(newdoc.address, toolbar); FREE(toolbar); + try_internal = TRUE; force_load = TRUE; /* force MainLoop to reload */ } break; @@ -3454,6 +3899,13 @@ check_goto_URL: #endif /* VMS */ #endif /* DIRED_SUPPORT || VMS*/ +#ifdef USE_EXTERNALS + case LYK_EXTERN: /* use external program on url */ + run_external(links[curdoc.link].lname); + refresh_screen = TRUE; + break; +#endif /* USE_EXTERNALS */ + case LYK_ADD_BOOKMARK: /* add link to bookmark file */ if (LYValidate) { if (old_c != real_c) { @@ -3574,6 +4026,7 @@ check_add_bookmark_to_self: FREE(curdoc.address); newdoc.line = curdoc.line; newdoc.link = curdoc.link; + newdoc.internal_link = FALSE; } FREE(temp); } else { @@ -3613,6 +4066,7 @@ check_add_bookmark_to_self: FREE(newdoc.post_content_type); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; } else { if (old_c != real_c) { old_c = real_c; @@ -3630,6 +4084,13 @@ check_add_bookmark_to_self: stop_curses(); printf(SPAWNING_MSG); fflush(stdout); + fflush(stderr); + if (LYTraceLogFP) + /* + * Set stderr back to its orginal value + * during the shell escape. - FM + */ + *stderr = LYOrigStderr; #ifdef DOSPATH system("cls"); system("echo Type EXIT to return to Lynx."); @@ -3641,8 +4102,14 @@ check_add_bookmark_to_self: system("exec $SHELL"); #endif /* VMS */ #endif /* DOSPATH */ + if (LYTraceLogFP) + /* + * Set stderr back to the log file on + * return from the shell escape. - FM + */ + *stderr = *LYTraceLogFP; start_curses(); - refresh_screen=TRUE; /* for a showpage */ + refresh_screen = TRUE; /* for a showpage */ } else { if (old_c != real_c) { old_c = real_c; @@ -3715,7 +4182,7 @@ check_add_bookmark_to_self: #ifdef DIRED_SUPPORT } else if (!strcmp((curdoc.title ? curdoc.title : ""), - UPLOAD_OPTIONS_TITLE)) { + UPLOAD_OPTIONS_TITLE)) { if (old_c != real_c) { old_c = real_c; _statusline(NO_DOWNLOAD_UPLOAD_OP); @@ -3739,6 +4206,8 @@ check_add_bookmark_to_self: if (LYdownload_options(&newdoc.address, links[curdoc.link].lname) < 0) StrAllocCopy(newdoc.address, temp); + else + newdoc.internal_link = FALSE; FREE(temp); #endif /* DIRED_SUPPORT */ @@ -3765,6 +4234,7 @@ check_add_bookmark_to_self: history[number].post_content_type); newdoc.isHEAD = history[number].isHEAD; newdoc.safe = history[number].safe; + newdoc.internal_link = FALSE; newdoc.link = 0; HTOutputFormat = HTAtom_for("www/download"); LYUserSpecifiedURL = TRUE; @@ -3788,6 +4258,7 @@ check_add_bookmark_to_self: */ StrAllocCopy(newdoc.address, links[curdoc.link].lname); StrAllocCopy(newdoc.title, links[curdoc.link].hightext); + newdoc.internal_link = FALSE; /* * Might be an anchor in the same doc from a POST * form. If so, don't free the content. -- FM @@ -3825,11 +4296,13 @@ check_add_bookmark_to_self: if (lynx_edit_mode && !no_dired_support) { LYUpload_options((char **)&newdoc.address, (char *)curdoc.address); + StrAllocCopy(newdoc.title, UPLOAD_OPTIONS_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; /* * Uncache the current listing so that it will * be updated to included the uploaded file if @@ -3840,14 +4313,119 @@ check_add_bookmark_to_self: break; #endif /* DIRED_SUPPORT */ - case LYK_TRACE_TOGGLE: + case LYK_TRACE_TOGGLE: /* Toggle TRACE mode. */ if (WWW_TraceFlag) - WWW_TraceFlag = FALSE; + WWW_TraceFlag = FALSE; else - WWW_TraceFlag = TRUE; + WWW_TraceFlag = TRUE; _statusline(WWW_TraceFlag ? TRACE_ON : TRACE_OFF); sleep(MessageSecs); + + if (TRACE && LYUseTraceLog && LYTraceLogFP == NULL) { + /* + * We haven't yet started a TRACE log for this + * session. If we can't open the file with write + * access, turn off TRACE and give up. Otherwise, + * on VMS we'll close it and delete it and any + * log file from a previous session, so they don't + * accumulate, and then open it again, including + * "shr=get" to overcome open file locking when + * attempting to read the log via the TRACE_LOG + * command. - FM + */ + if ((LYTraceLogFP = fopen(LYTraceLogPath, "w")) == NULL) { + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); + break; + } +#ifdef VMS + fclose(LYTraceLogFP); + while (remove(LYTraceLogPath) == 0) + ; + if ((LYTraceLogFP = fopen(LYTraceLogPath, "w", + "shr=get")) == NULL) { + WWW_TraceFlag == FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); + break; + } +#endif /* VMS */ + *stderr = *LYTraceLogFP; + fprintf(stderr, "\t\t%s\n\n", LYNX_TRACELOG_TITLE); + } + break; + + case LYK_TRACE_LOG: /* View TRACE log. */ + /* + * Check whether we've started a TRACE log + * in this session. - FM + */ + if (LYTraceLogFP == NULL) { + _statusline(NO_TRACELOG_STARTED); + sleep(MessageSecs); + break; + } + + /* + * Don't do if already viewing the TRACE log. - FM + */ + if (!strcmp((curdoc.title ? curdoc.title : ""), + LYNX_TRACELOG_TITLE)) + break; + + /* + * If TRACE mode is on, turn it off during this fetch of the + * TRACE log, so we don't enter stuff about this fetch, and + * set a flag for turning it back on when we return to this + * loop. Note that we'll miss any messages about memory + * exhaustion if it should occur. It seems unlikely that + * anything else bad might happen, but if it does, we'll + * miss messages about that too. We also fflush(), close, + * and open it again, to make sure all stderr messages thus + * far will be in the log. - FM + */ + if (TRACE) + fprintf(stderr, "\nTurning off TRACE for fetch of log.\n"); + fflush(stderr); + fclose(LYTraceLogFP); + *stderr = LYOrigStderr; +#ifdef VMS + if ((LYTraceLogFP = fopen(LYTraceLogPath, + "a+", "shr=get")) == NULL) +#else + if ((LYTraceLogFP = fopen(LYTraceLogPath, + "a+")) == NULL) +#endif /* VMS */ + { + WWW_TraceFlag = FALSE; + _statusline(TRACELOG_OPEN_FAILED); + sleep(MessageSecs); + break; + } + *stderr = *LYTraceLogFP; + if (TRACE) { + WWW_TraceFlag = FALSE; + trace_mode_flag = TRUE; + } + StrAllocCopy(newdoc.address, "file://localhost"); +#ifdef VMS + StrAllocCat(newdoc.address, HTVMS_wwwName(LYTraceLogPath)); +#else + StrAllocCat(newdoc.address, LYTraceLogPath); +#endif /* VMS */ + StrAllocCopy(newdoc.title, LYNX_TRACELOG_TITLE); + FREE(newdoc.post_data); + FREE(newdoc.post_content_type); + FREE(newdoc.bookmark); + newdoc.isHEAD = FALSE; + newdoc.safe = FALSE; + newdoc.internal_link = FALSE; + if (LYValidate || check_realm) { + LYPermitURL = TRUE; + } + LYforce_no_cache = TRUE; break; case LYK_IMAGE_TOGGLE: @@ -3923,7 +4501,10 @@ check_add_bookmark_to_self: break; } 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, "http", 4) && + (links[curdoc.link].type != WWW_INTERN_LINK_TYPE || + !curdoc.address || + strncmp(curdoc.address, "http", 4))) { _statusline(LINK_NOT_HTTP_URL); sleep(MessageSecs); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && @@ -3989,11 +4570,13 @@ check_add_bookmark_to_self: if (old_c != real_c) { old_c = real_c; StrAllocCopy(newdoc.address, "LYNXKEYMAP:"); + StrAllocCopy(newdoc.title, CURRENT_KEYMAP_TITLE); FREE(newdoc.post_data); FREE(newdoc.post_content_type); FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; /* * If vi_keys changed, the keymap did too, * so force no cache, and reset the flag. - FM @@ -4012,9 +4595,9 @@ check_add_bookmark_to_self: */ if (!no_dired_support) { prev_lynx_edit_mode = lynx_edit_mode; - LYforce_no_cache = TRUE; } #endif /* DIRED_SUPPORT && OK_OVERRIDE */ + LYforce_no_cache = TRUE; } break; @@ -4083,6 +4666,7 @@ check_add_bookmark_to_self: FREE(newdoc.bookmark); newdoc.isHEAD = FALSE; newdoc.safe = FALSE; + newdoc.internal_link = FALSE; FREE(ret); LYUserSpecifiedURL = TRUE; } else { @@ -4178,6 +4762,90 @@ PRIVATE int are_different ARGS2( return(FALSE); } +/* This determines whether two docs are _physically_ different, + * meaning they are "from different files". - kw + */ +PRIVATE int are_phys_different ARGS2( + document *, doc1, + document *, doc2) +{ + char *cp1, *cp2, *ap1 = doc1->address, *ap2 = doc2->address; + + /* + * Do we have two addresses? + */ + if (!doc1->address || !doc2->address) + return (TRUE); + + /* + * Do they differ in the type of request? + */ + if (doc1->isHEAD != doc2->isHEAD) + return (TRUE); + + /* + * Skip over possible LYNXIMGMAP parts. - kw + */ + if (0==strncmp(doc1->address, "LYNXIMGMAP:", 11)) + ap1 += 11; + if (0==strncmp(doc2->address, "LYNXIMGMAP:", 11)) + ap2 += 11; + /* + * If there isn't any real URL in doc2->address, but maybe just + * a fragment, doc2 is assumed to be an internal reference in + * the same physical document, so return FALSE. - kw + */ + if (*ap2 == '\0' || *ap2 == '#') + return(FALSE); + + /* + * See if the addresses are different, making sure + * we're not tripped up by multiple anchors in the + * the same document from a POST form. -- FM + */ + if ((cp1 = strchr(doc1->address, '#')) != NULL) + *cp1 = '\0'; + if ((cp2 = strchr(doc2->address, '#')) != NULL) + *cp2 = '\0'; + /* + * Are the base addresses different? + */ + if (strcmp(ap1, ap2)) + { + if (cp1) + *cp1 = '#'; + if (cp2) + *cp2 = '#'; + return(TRUE); + } + if (cp1) + *cp1 = '#'; + if (cp2) + *cp2 = '#'; + + /* + * Do the docs have different contents? + */ + if (doc1->post_data) + { + if (doc2->post_data) + { + if (strcmp(doc1->post_data, doc2->post_data)) + return(TRUE); + } + else + return(TRUE); + } + else + if (doc2->post_data) + return(TRUE); + + /* + * We'll assume the two documents in fact are the same. + */ + return(FALSE); +} + /* * Utility for freeing the list of goto URLs. - FM */ diff --git a/src/LYMap.c b/src/LYMap.c index 4aa0346a..e4141cf6 100644 --- a/src/LYMap.c +++ b/src/LYMap.c @@ -32,45 +32,47 @@ extern BOOL reloading; /* For Flushing Cache on Proxy Server */ -typedef struct _MapElement { +typedef struct _LYMapElement { char * address; char * title; -} MapElement; + BOOL intern_flag; +} LYMapElement; -typedef struct _ImageMap { +typedef struct _LYImageMap { char * address; char * title; HTList * elements; -} ImageMap; +} LYImageMap; struct _HTStream { HTStreamClass * isa; }; -PUBLIC HTList * LynxMaps = NULL; +PRIVATE HTList * LynxMaps = NULL; + PUBLIC BOOL LYMapsOnly = FALSE; /* - * Utility for freeing the list of MAPs. - FM + * Utility for freeing the list of MAPs. - FM */ PRIVATE void LYLynxMaps_free NOARGS { - ImageMap *map; - MapElement *element; + LYImageMap *map; + LYMapElement *element; HTList *cur = LynxMaps; HTList *current; if (!cur) return; - while (NULL != (map = (ImageMap *)HTList_nextObject(cur))) { + while (NULL != (map = (LYImageMap *)HTList_nextObject(cur))) { FREE(map->address); FREE(map->title); if (map->elements) { current = map->elements; while (NULL != - (element = (MapElement *)HTList_nextObject(current))) { + (element = (LYMapElement *)HTList_nextObject(current))) { FREE(element->address); FREE(element->title); FREE(element); @@ -86,14 +88,21 @@ PRIVATE void LYLynxMaps_free NOARGS } /* - * Utility for creating an ImageMap list (LynxMaps), if it doesn't - * exist already, and adding ImageMap entry structures. - FM + * Utility for creating an LYImageMap list (LynxMaps), if it doesn't + * exist already, adding LYImageMap entry structures if needed, and + * removing any LYMapElements in a pre-existing LYImageMap entry so that + * it will have only those from AREA tags for the current analysis of + * MAP element content. - FM */ -PUBLIC BOOL LYAddImageMap ARGS2(char *, address, char *, title) +PUBLIC BOOL LYAddImageMap ARGS2( + char *, address, + char *, title) { - ImageMap *new = NULL; - ImageMap *old; + LYImageMap *new = NULL; + LYImageMap *old = NULL; HTList *cur = NULL; + HTList *curele = NULL; + LYMapElement *ele = NULL; if (!(address && *address)) return FALSE; @@ -103,14 +112,28 @@ PUBLIC BOOL LYAddImageMap ARGS2(char *, address, char *, title) atexit(LYLynxMaps_free); } else { cur = LynxMaps; - while (NULL != (old = (ImageMap *)HTList_nextObject(cur))) { + while (NULL != (old = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(old->address, address)) { - return TRUE; + FREE(old->address); + FREE(old->title); + if (old->elements) { + curele = old->elements; + while (NULL != + (ele = (LYMapElement *)HTList_nextObject(curele))) { + FREE(ele->address); + FREE(ele->title); + FREE(ele); + } + HTList_delete(old->elements); + old->elements = NULL; + } + break; } } } - new = (ImageMap *)calloc(1, sizeof(ImageMap)); + new = (old != NULL) ? + old : (LYImageMap *)calloc(1, sizeof(LYImageMap)); if (new == NULL) { perror("Out of memory in LYAddImageMap"); return FALSE; @@ -118,18 +141,23 @@ PUBLIC BOOL LYAddImageMap ARGS2(char *, address, char *, title) StrAllocCopy(new->address, address); if (title && *title) StrAllocCopy(new->title, title); - HTList_addObject(LynxMaps, new); + if (new != old) + HTList_addObject(LynxMaps, new); return TRUE; } /* - * Utility for adding MapElements to ImageMaps + * Utility for adding LYMapElements to LYImageMaps * in the LynxMaps list. - FM */ -PUBLIC BOOL LYAddMapElement ARGS3(char *,map, char *,address, char *, title) +PUBLIC BOOL LYAddMapElement ARGS4( + char *, map, + char *, address, + char *, title, + BOOL, intern_flag) { - MapElement *new = NULL; - ImageMap *theMap = NULL; + LYMapElement *new = NULL; + LYImageMap *theMap = NULL; HTList *cur = NULL; if (!(map && *map && address && *address)) @@ -139,7 +167,7 @@ PUBLIC BOOL LYAddMapElement ARGS3(char *,map, char *,address, char *, title) LYAddImageMap(map, NULL); cur = LynxMaps; - while (NULL != (theMap = (ImageMap *)HTList_nextObject(cur))) { + while (NULL != (theMap = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(theMap->address, map)) { break; } @@ -149,7 +177,7 @@ PUBLIC BOOL LYAddMapElement ARGS3(char *,map, char *,address, char *, title) if (!theMap->elements) theMap->elements = HTList_new(); cur = theMap->elements; - while (NULL != (new = (MapElement *)HTList_nextObject(cur))) { + while (NULL != (new = (LYMapElement *)HTList_nextObject(cur))) { if (!strcmp(new->address, address)) { FREE(new->address); FREE(new->title); @@ -159,7 +187,7 @@ PUBLIC BOOL LYAddMapElement ARGS3(char *,map, char *,address, char *, title) } } - new = (MapElement *)calloc(1, sizeof(MapElement)); + new = (LYMapElement *)calloc(1, sizeof(LYMapElement)); if (new == NULL) { perror("Out of memory in LYAddMapElement"); return FALSE; @@ -169,10 +197,36 @@ PUBLIC BOOL LYAddMapElement ARGS3(char *,map, char *,address, char *, title) StrAllocCopy(new->title, title); else StrAllocCopy(new->title, address); + new->intern_flag = intern_flag; HTList_appendObject(theMap->elements, new); return TRUE; } +/* + * Utility for checking whether an LYImageMap entry + * with a given address already exists in the LynxMaps + * structure. - FM + */ +#if UNUSED +PUBLIC BOOL LYHaveImageMap ARGS1( + char *, address) +{ + LYImageMap *Map; + HTList *cur = LynxMaps; + + if (!(cur && address && *address != '\0')) + return FALSE; + + while (NULL != (Map = (LYImageMap *)HTList_nextObject(cur))) { + if (!strcmp(Map->address, address)) { + return TRUE; + } + } + + return FALSE; +} +#endif + /* LYLoadIMGmap - F.Macrides (macrides@sci.wfeb.edu) ** ------------ ** Create a text/html stream with a list of links @@ -188,8 +242,8 @@ PRIVATE int LYLoadIMGmap ARGS4 ( HTFormat format_in = WWW_HTML; HTStream *target = NULL; char buf[1024]; - MapElement *new = NULL; - ImageMap *theMap = NULL; + LYMapElement *new = NULL; + LYImageMap *theMap = NULL; char *MapTitle = NULL; char *MapAddress = NULL; HTList *cur = NULL; @@ -239,7 +293,7 @@ PRIVATE int LYLoadIMGmap ARGS4 ( } cur = LynxMaps; - while (NULL != (theMap = (ImageMap *)HTList_nextObject(cur))) { + while (NULL != (theMap = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(theMap->address, address)) { break; } @@ -268,7 +322,7 @@ PRIVATE int LYLoadIMGmap ARGS4 ( HTOutputFormat = old_format_out; LYMapsOnly = FALSE; cur = LynxMaps; - while (NULL != (theMap = (ImageMap *)HTList_nextObject(cur))) { + while (NULL != (theMap = (LYImageMap *)HTList_nextObject(cur))) { if (!strcmp(theMap->address, address)) { break; } @@ -279,6 +333,8 @@ PRIVATE int LYLoadIMGmap ARGS4 ( } } + anAnchor->no_cache = TRUE; + target = HTStreamStack(format_in, format_out, sink, anAnchor); @@ -321,15 +377,19 @@ PRIVATE int LYLoadIMGmap ARGS4 ( "ul" : "ol"); (*target->isa->put_block)(target, buf, strlen(buf)); cur = theMap->elements; - while (NULL != (new=(MapElement *)HTList_nextObject(cur))) { + while (NULL != (new=(LYMapElement *)HTList_nextObject(cur))) { StrAllocCopy(MapAddress, new->address); LYEntify(&MapAddress, FALSE); - sprintf(buf, "<li><a href=\"%s\"\n", MapAddress); - (*target->isa->put_block)(target, buf, strlen(buf)); + (*target->isa->put_block)(target, "<li><a href=\"", 13); + (*target->isa->put_block)(target, MapAddress, strlen(MapAddress)); + if (new->intern_flag) + (*target->isa->put_block)(target, "\" TYPE=\"internal link\"\n>",24); + else + (*target->isa->put_block)(target, "\"\n>", 3); StrAllocCopy(MapTitle, new->title); LYEntify(&MapTitle, TRUE); - sprintf(buf, ">%s</a>\n", MapTitle); - (*target->isa->put_block)(target, buf, strlen(buf)); + (*target->isa->put_block)(target, MapTitle, strlen(MapTitle)); + (*target->isa->put_block)(target, "</a>\n", 5); } sprintf(buf,"</%s>\n</body>\n", (keypad_mode == LINKS_ARE_NUMBERED) ? "ul" : "ol"); diff --git a/src/LYMap.h b/src/LYMap.h index 4620cfbe..48829eb7 100644 --- a/src/LYMap.h +++ b/src/LYMap.h @@ -5,6 +5,6 @@ extern BOOL LYMapsOnly; extern BOOL LYAddImageMap PARAMS((char *address, char *title)); -extern BOOL LYAddMapElement PARAMS((char *map, char *address, char *title)); +extern BOOL LYAddMapElement PARAMS((char *map, char *address, char *title, BOOL intern_flag)); #endif /* LYMAP_H */ diff --git a/src/LYOptions.c b/src/LYOptions.c index 236ba680..b26ee2ad 100644 --- a/src/LYOptions.c +++ b/src/LYOptions.c @@ -111,15 +111,14 @@ draw_options: response = 0; clear(); move(0, 5); - if (bold_H1 || bold_headers) - start_bold(); + + lynx_start_h1_color (); addstr(" Options Menu ("); addstr(LYNX_NAME); addstr(" Version "); addstr(LYNX_VERSION); addch(')'); - if (bold_H1 || bold_headers) - stop_bold(); + lynx_stop_h1_color (); move(L_EDITOR, 5); addstr("E)ditor : "); addstr((editor && *editor) ? editor : "NONE"); @@ -258,9 +257,9 @@ draw_options: response != 7 && response != 3) { move(LYlines-2, 0); - start_reverse(); + lynx_start_prompt_color (); addstr(COMMAND_PROMPT); - stop_reverse(); + lynx_stop_prompt_color (); refresh(); response = LYgetch(); @@ -965,18 +964,25 @@ PRIVATE int boolean_choice ARGS4( number--; - option_statusline(ACCEPT_DATA); + /* + * Update the statusline. + */ + option_statusline(ANY_KEY_CHANGE_RET_ACCEPT); + /* * Highlight the current selection. */ move(line, col); standout(); addstr(choices[status]); + refresh(); - standend(); - option_statusline(ANY_KEY_CHANGE_RET_ACCEPT); - standout(); - + /* + * Get the keyboard entry, and leave the + * cursor at the choice, to indicate that + * it can be changed, until the user accepts + * the current choice. + */ while (1) { move(line, col); response = LYgetch(); @@ -1038,7 +1044,7 @@ PRIVATE int boolean_choice ARGS4( addstr(choices[status]); option_statusline(VALUE_ACCEPTED); - return(status); + return(status); } } } @@ -1087,16 +1093,17 @@ draw_bookmark_list: */ clear(); move(0, 5); - if (bold_H1 || bold_headers) - start_bold(); + + lynx_start_h1_color (); + if (LYlines < (MBM_V_MAXFILES + MULTI_OFFSET)) { sprintf(ehead_buffer, MULTIBOOKMARKS_EHEAD_MASK, MBM_current); addstr(ehead_buffer); } else { addstr(MULTIBOOKMARKS_EHEAD); } - if (bold_H1 || bold_headers) - stop_bold(); + + lynx_stop_h1_color (); if (LYlines < (MBM_V_MAXFILES + MULTI_OFFSET)) { for (a = ((MBM_V_MAXFILES/2 + 1) * (MBM_current - 1)); @@ -1169,9 +1176,10 @@ draw_bookmark_list: response != '>') { move((LYlines - 2), 0); - start_reverse(); + + lynx_start_prompt_color (); addstr(MULTIBOOKMARKS_LETTER); - stop_reverse(); + lynx_stop_prompt_color (); refresh(); response = (def_response ? def_response : LYgetch()); diff --git a/src/LYPrint.c b/src/LYPrint.c index f7cf2e34..3bd365d7 100644 --- a/src/LYPrint.c +++ b/src/LYPrint.c @@ -22,6 +22,10 @@ #ifdef DOSPATH #include "HTDOS.h" #endif +#ifdef EXP_CHARTRANS +#include "LYCharSets.h" /* to get current charset for mail header */ +extern BOOLEAN LYHaveCJKCharacterSet; +#endif #include "LYLeaks.h" @@ -61,7 +65,7 @@ PUBLIC int printfile ARGS1(document *,newdoc) int pages = 0; int type = 0, c, len; FILE *outfile_fp; - char *cp; + char *cp = NULL; lynx_printer_item_type *cur_printer; char *sug_filename = NULL; char *link_info = NULL; @@ -74,6 +78,8 @@ PUBLIC int printfile ARGS1(document *,newdoc) char *content_base = NULL, *content_location = NULL; HTFormat format; HTAtom *encoding; + BOOL use_mime, use_cte, use_type; + char *disp_charset; #ifdef VMS extern BOOLEAN HadVMSInterrupt; #endif /* VMS */ @@ -134,6 +140,27 @@ PUBLIC int printfile ARGS1(document *,newdoc) StrAllocCopy(sug_filename, HText_getSugFname()); /* must be freed */ else StrAllocCopy(sug_filename, newdoc->address); /* must be freed */ + /* + * Strip any gzip or compress suffix, if present. - FM + */ + cp = NULL; + if (strlen(sug_filename) > 3) { + cp = (char *)&sug_filename[(strlen(sug_filename) - 3)]; + if ((*cp == '.' || *cp == '-' || *cp == '_') && + !strcasecomp((cp + 1), "gz")) { + *cp = '\0'; + } else { + cp = NULL; + } + } + if ((cp == NULL) && strlen(sug_filename) > 2) { + cp = (char *)&sug_filename[(strlen(sug_filename) - 2)]; + if ((*cp == '.' || *cp == '-' || *cp == '_') && + !strcasecomp((cp + 1), "Z")) { + *cp = '\0'; + } + } + cp = NULL; /* * Get the number of lines in the file. @@ -523,17 +550,47 @@ PUBLIC int printfile ARGS1(document *,newdoc) break; } #endif + + /* + * Determine which mail headers should be sent. + * Send Content-Transfer-Encoding only if the document + * has 8-bit characters. Send a charset parameter only + * if the document has 8-bit characters and we we seem + * to have a valid charset. Also use Content-Type + * and MIME-Version headers only if needed. - kw + */ + use_cte = HTLoadedDocumentEightbit(); +#ifdef EXP_CHARTRANS + disp_charset = LYCharSet_UC[current_char_set].MIMEname; + /* + * Don't send a charset if we have a CJK character set + * selected, since it may not be appropriate for mail... + * Also don't use an inofficial "x-" charset. - kw + */ + if (!use_cte || LYHaveCJKCharacterSet || + strncasecomp(disp_charset, "x-", 2) == 0) + disp_charset = NULL; +#else + disp_charset = HTLoadedDocumentCharset(); +#endif /* EXP_CHARTRANS */ + use_type = (disp_charset || HTisDocumentSource()); + use_mime = (use_cte || use_type); + + if (use_mime) { + fprintf(outfile_fp, "Mime-Version: 1.0\n"); + if (use_cte) + fprintf(outfile_fp, "Content-Transfer-Encoding: 8bit\n"); + } + if (HTisDocumentSource()) { /* * Add Content-Type, Content-Location, and * Content-Base headers for HTML source. - FM - * Also add Mime-Version header. - HM */ - fprintf(outfile_fp, "Mime-Version: 1.0\n"); fprintf(outfile_fp, "Content-Type: text/html"); - if (HTLoadedDocumentCharset() != NULL) { + if (disp_charset != NULL) { fprintf(outfile_fp, "; charset=%s\n", - HTLoadedDocumentCharset()); + disp_charset); } else { fprintf(outfile_fp, "\n"); } @@ -541,6 +598,17 @@ PUBLIC int printfile ARGS1(document *,newdoc) content_base); fprintf(outfile_fp, "Content-Location: %s\n", content_location); + } else { + /* + * Add Content-Type: text/plain if we have 8-bit + * characters and a valid charset for non-source + * documents. - kw + */ + if (disp_charset != NULL) { + fprintf(outfile_fp, + "Content-Type: text/plain; charset=%s\n", + disp_charset); + } } fprintf(outfile_fp, "X-URL: %s\n", newdoc->address); fprintf(outfile_fp, "To: %s\nSubject:%s\n\n", @@ -983,16 +1051,18 @@ PUBLIC int print_options ARGS2(char **,newfile, int,lines_in_file) lines_in_file, pages, (pages > 1 ? "s" : "")); fputs(buffer,fp0); - if (no_print || child_lynx || no_mail) + if (no_print || no_disk_save || child_lynx || no_mail) fputs("Some print functions have been disabled!!!<br>\n", fp0); fputs("You have the following print choices.<br>\n", fp0); fputs("Please select one:<br>\n<pre>\n", fp0); - if (child_lynx == FALSE && no_print == FALSE) + if (child_lynx == FALSE && no_disk_save == FALSE && no_print == FALSE) fprintf(fp0, " <a href=\"LYNXPRINT://LOCAL_FILE/lines=%d\">Save to a local file</a>\n", lines_in_file); + else + fprintf(fp0," Save to disk disabled.\n"); if (child_lynx == FALSE && no_mail == FALSE) fprintf(fp0, " <a href=\"LYNXPRINT://MAIL_FILE/lines=%d\">Mail the file</a>\n", diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c index 69c56c63..1ec86c3c 100644 --- a/src/LYReadCFG.c +++ b/src/LYReadCFG.c @@ -6,6 +6,9 @@ #include "LYStructs.h" #include "LYGlobalDefs.h" #include "LYCharSets.h" +#ifdef EXP_CHARTRANS +#include "UCMap.h" +#endif /* EXP_CHARTRANS */ #include "LYKeymap.h" #include "LYJump.h" #include "LYGetFile.h" @@ -102,6 +105,18 @@ PRIVATE void free_item_list NOARGS uploaders = NULL; #endif /* DIRED_SUPPORT */ +#ifdef USE_EXTERNALS + cur = externals; + while (cur) { + next = cur->next; + FREE(cur->name); + FREE(cur->command); + FREE(cur); + cur = next; + } + externals = NULL; +#endif /* USE_EXTERNALS */ + return; } @@ -273,7 +288,7 @@ PRIVATE void add_printer_to_list ARGS2( } } -#if defined(USE_SLANG) || defined(COLOR_CURSES) +#if USE_COLOR_TABLE #ifdef DOSPATH /* I.E. broken curses */ static char *Color_Strings[16] = { @@ -397,7 +412,7 @@ PRIVATE void parse_color ARGS1( exit_with_color_syntax(); #endif } -#endif /* defined(USE_SLANG) || defined(COLOR_CURSES) */ +#endif /* USE_COLOR_TABLE */ /* * Process the configuration file (lynx.cfg). @@ -475,6 +490,30 @@ PUBLIC void read_cfg ARGS1( } else if (!strncasecomp(buffer, "ALWAYS_TRUSTED_EXEC:", 20)) { add_trusted(&buffer[20], ALWAYS_EXEC_PATH); /* Add exec path */ #endif /* EXEC_LINKS */ + +#ifdef EXP_CHARTRANS + } else if (!strncasecomp(buffer, "ASSUME_CHARSET:", 15)) { + StrAllocCopy(UCAssume_MIMEcharset, buffer+15); + for (i = 0; UCAssume_MIMEcharset[i]; i++) + UCAssume_MIMEcharset[i] = TOLOWER(UCAssume_MIMEcharset[i]); + UCLYhndl_for_unspec = + UCGetLYhndl_byMIME(UCAssume_MIMEcharset); + + } else if (!strncasecomp(buffer, "ASSUME_LOCAL_CHARSET:", 21)) { + StrAllocCopy(UCAssume_localMIMEcharset, buffer+21); + for (i = 0; UCAssume_localMIMEcharset[i]; i++) + UCAssume_localMIMEcharset[i] = TOLOWER(UCAssume_localMIMEcharset[i]); + UCLYhndl_HTFile_for_unspec = + UCGetLYhndl_byMIME(UCAssume_localMIMEcharset); + + } else if (!strncasecomp(buffer, "ASSUME_UNREC_CHARSET:", 21)) { + StrAllocCopy(UCAssume_unrecMIMEcharset, buffer+21); + for (i = 0; UCAssume_unrecMIMEcharset[i]; i++) + UCAssume_unrecMIMEcharset[i] = TOLOWER(UCAssume_unrecMIMEcharset[i]); + UCLYhndl_for_unrec = + UCGetLYhndl_byMIME(UCAssume_unrecMIMEcharset); +#endif /* EXP_CHARTRANS */ + } break; @@ -513,10 +552,10 @@ PUBLIC void read_cfg ARGS1( } else if (!strncasecomp(buffer, "COLLAPSE_BR_TAGS:", 17)) { LYCollapseBRs = is_true(buffer+17); -#if defined(USE_SLANG) || defined(COLOR_CURSES) +#if USE_COLOR_TABLE } else if (!strncasecomp(buffer, "COLOR:", 6)) { parse_color(buffer + 6); -#endif /* defined(USE_SLANG) || defined(COLOR_CURSES) */ +#endif /* USE_COLOR_TABLE */ } else if (!strncasecomp(buffer, "cso_proxy:", 10)) { if (getenv("cso_proxy") == NULL) { @@ -593,6 +632,11 @@ PUBLIC void read_cfg ARGS1( } else if (!strncasecomp(buffer, "ENABLE_SCROLLBACK:", 18)) { enable_scrollback = is_true(buffer+18); } +#ifdef USE_EXTERNALS + else if(!strncasecomp(buffer,"EXTERNAL:",9)) { + add_item_to_list(&buffer[9],&externals); + } +#endif break; case 'F': @@ -820,11 +864,7 @@ PUBLIC void read_cfg ARGS1( break; case 'N': - if (!strncasecomp(buffer, "NEWS_POSTING:", 13)) { - LYNewsPosting = is_true(buffer+13); - no_newspost = (LYNewsPosting == FALSE); - - } else if (!strncasecomp(buffer, "NEWS_CHUNK_SIZE:", 16)) { + if (!strncasecomp(buffer, "NEWS_CHUNK_SIZE:", 16)) { HTNewsChunkSize = atoi(buffer+16); /* * If the new HTNewsChunkSize exceeds the maximum, @@ -844,6 +884,10 @@ PUBLIC void read_cfg ARGS1( HTNewsChunkSize = HTNewsMaxChunk; } + } else if (!strncasecomp(buffer, "NEWS_POSTING:", 13)) { + LYNewsPosting = is_true(buffer+13); + no_newspost = (LYNewsPosting == FALSE); + } else if (!strncasecomp(buffer, "news_proxy:", 11)) { if (getenv("news_proxy") == NULL) { #ifdef VMS @@ -918,6 +962,9 @@ PUBLIC void read_cfg ARGS1( } else if (!strncasecomp(buffer, "NO_FROM_HEADER:", 15)) { LYNoFromHeader = is_true(buffer+15); + } else if (!strncasecomp(buffer, "NO_ISMAP_IF_USEMAP:", 19)) { + LYNoISMAPifUSEMAP = is_true(buffer+19); + } else if (!strncasecomp(buffer, "no_proxy:", 9)) { if (getenv("no_proxy") == NULL) { #ifdef VMS @@ -1012,6 +1059,9 @@ PUBLIC void read_cfg ARGS1( } else if (!strncasecomp(buffer, "STARTFILE:", 10)) { StrAllocCopy(startfile, buffer+10); + } else if (!strncasecomp(buffer, "STRIP_DOTDOT_URLS:", 18)) { + LYStripDotDotURLs = is_true(buffer+18); + } else if (!strncasecomp(buffer, "SUBSTITUTE_UNDERSCORES:", 23)) { use_underscore = is_true(buffer+23); @@ -1082,7 +1132,7 @@ PUBLIC void read_cfg ARGS1( UseFixedRecords = is_true(buffer+18); #endif /* VMS */ -#ifdef NCURSES_MOUSE_VERSION +#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE) } else if(!strncasecomp(buffer, "USE_MOUSE:",10)) { LYUseMouse = is_true(buffer+10); #endif @@ -1161,7 +1211,7 @@ PUBLIC void read_cfg ARGS1( case 'X': if (!strncasecomp(buffer, "XLOADIMAGE_COMMAND:", 19)) { - StrAllocCat(XLoadImageCommand, (char *)&buffer[19]); + StrAllocCopy(XLoadImageCommand, (char *)&buffer[19]); } break; diff --git a/src/LYSearch.c b/src/LYSearch.c index 7dd6c26b..495e9e19 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -9,36 +9,151 @@ #include "LYLeaks.h" +#define FREE(x) if (x) {free(x); x = NULL;} + /* - * search for the target string inside of the links - * that are currently displayed on the screen beginning - * with the one after the currently selected one! - * if found set cur to the new value and return true - * in not found do not reset cur and return false. + * Search for the target string inside of the links + * that are currently displayed on the screen beginning + * with the one after the currently selected one. + * If found set cur to the new value and return TRUE. + * If not found do not reset cur and return FALSE. */ -PRIVATE int check_for_target_in_links ARGS2(int *,cur, char *,new_target) +PRIVATE int check_for_target_in_links ARGS2( + int *, cur, + char *, new_target) { - int i = *cur+1; + int i = *cur + 1; + OptionType *option; + char *stars = NULL, *cp; - if(nlinks==0) + if (nlinks == 0) return(FALSE); - for(; i < nlinks; i++) - if(case_sensitive) { - if(strstr(links[i].hightext,new_target) != NULL) - break; - } else { - if(LYstrstr(links[i].hightext,new_target) != NULL) - break; + for (; i < nlinks; i++) { + /* + * Search the hightext string, and hightext2 if present, + * taking the case_sensitive setting into account. - FM + */ + if (((links[i].hightext != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(links[i].hightext, new_target)) || + ((links[i].hightext != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(links[i].hightext, new_target))) { + break; + } + if (((links[i].hightext2 != NULL && case_sensitive == TRUE) && + LYno_attr_char_strstr(links[i].hightext2, new_target)) || + ((links[i].hightext2 != NULL && case_sensitive == FALSE) && + LYno_attr_char_case_strstr(links[i].hightext2, new_target))) { + break; + } + + /* + * Search the relevant form fields, taking the + * case_sensitive setting into account. - FM + */ + if ((links[i].form != NULL && links[i].type == WWW_FORM_LINK_TYPE && + links[i].form->value != NULL) && + links[i].form->type != F_HIDDEN_TYPE) { + if (links[i].form->type == F_PASSWORD_TYPE) { + /* + * Check the actual, hidden password, and then + * the displayed string. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(links[i].form->value, + new_target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(links[i].form->value, + new_target))) { + break; + } + StrAllocCopy(stars, links[i].form->value); + for (cp = stars; *cp != '\0'; cp++) + *cp = '*'; + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(stars, new_target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(stars, new_target))) { + FREE(stars); + break; + } + FREE(stars); + } else if (links[i].form->type == F_OPTION_LIST_TYPE) { + /* + * Search the option strings that are displayed + * when the popup is invoked. - FM + */ + option = links[i].form->select_list; + while (option != NULL) { + if (((option->name != NULL && + case_sensitive == TRUE) && + LYno_attr_char_strstr(option->name, new_target)) || + ((option->name != NULL && + case_sensitive == FALSE) && + LYno_attr_char_case_strstr(option->name, + new_target))) { + break; + } + option = option->next; + } + if (option != NULL) { + break; + } + } else if (links[i].form->type == F_RADIO_TYPE) { + /* + * Search for checked or unchecked parens. - FM + */ + if (links[i].form->num_value) { + cp = checked_radio; + } else { + cp = unchecked_radio; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, new_target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, new_target))) { + break; + } + } else if (links[i].form->type == F_CHECKBOX_TYPE) { + /* + * Search for checked or unchecked square brackets. - FM + */ + if (links[i].form->num_value) { + cp = checked_box; + } else { + cp = unchecked_box; + } + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(cp, new_target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(cp, new_target))) { + break; + } + } else { + /* + * Check the values intended for display. + * May have been found already via the + * hightext search, but make sure here + * that the entire value is searched. - FM + */ + if (((case_sensitive == TRUE) && + LYno_attr_char_strstr(links[i].form->value, + new_target)) || + ((case_sensitive == FALSE) && + LYno_attr_char_case_strstr(links[i].form->value, + new_target))) { + break; + } + } } + } if (i == nlinks) return(FALSE); - /* else */ - *cur = i; - return(TRUE); + *cur = i; + return(TRUE); } /* @@ -53,21 +168,22 @@ PRIVATE int check_for_target_in_links ARGS2(int *,cur, char *,new_target) * */ -PUBLIC void textsearch ARGS3(document *,cur_doc, - char *,prev_target, BOOL, next) +PUBLIC BOOL textsearch ARGS3(document *,cur_doc, + char *, prev_target, + BOOL, next) { int offset; int oldcur = cur_doc->link; static char prev_target_buffer[512]; /* Search string buffer */ static BOOL first = TRUE; char *cp; - int ch=0, recall; + int ch = 0, recall; int QueryTotal; int QueryNum; BOOLEAN FirstRecall = TRUE; /* - * Initialize the search string buffer. - FM + * Initialize the search string buffer. - FM */ if (first) { *prev_target_buffer = '\0'; @@ -80,30 +196,30 @@ PUBLIC void textsearch ARGS3(document *,cur_doc, if (next) /* - * LYK_NEXT was pressed, so copy the - * buffer into prev_target. - FM + * LYK_NEXT was pressed, so copy the + * buffer into prev_target. - FM */ strcpy(prev_target, prev_target_buffer); - if(strlen(prev_target) == 0 ) { + if (strlen(prev_target) == 0 ) { /* - * This is a new WHEREIS search ('/'), or - * LYK_NEXT was pressed but there was no - * previous search, so we need to get a - * search string from the user. - FM + * This is a new WHEREIS search ('/'), or + * LYK_NEXT was pressed but there was no + * previous search, so we need to get a + * search string from the user. - FM */ _statusline(ENTER_WHEREIS_QUERY); - if ((ch=LYgetstr(prev_target, VISIBLE, - sizeof(prev_target_buffer), recall)) < 0) { + if ((ch = LYgetstr(prev_target, VISIBLE, + sizeof(prev_target_buffer), recall)) < 0) { /* - * User cancelled the search via ^G. - * Restore prev_target and return. - FM + * User cancelled the search via ^G. + * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); _statusline(CANCELLED); sleep(InfoSecs); - return; + return(FALSE); } } @@ -111,26 +227,26 @@ check_recall: if (strlen(prev_target) == 0 && !(recall && (ch == UPARROW || ch == DNARROW))) { /* - * No entry. Simply return, retaining the current buffer. - * Because prev_target is now reset, highlighting of the - * previous search string will no longer occur, but it can - * be used again via LYK_NEXT. - FM + * No entry. Simply return, retaining the current buffer. + * Because prev_target is now reset, highlighting of the + * previous search string will no longer occur, but it can + * be used again via LYK_NEXT. - FM */ _statusline(CANCELLED); sleep(InfoSecs); - return; + return(FALSE); } if (recall && ch == UPARROW) { if (FirstRecall) { /* - * Use the current string or last query in the list. - FM + * Use the current string or last query in the list. - FM */ FirstRecall = FALSE; if (*prev_target_buffer) { for (QueryNum = (QueryTotal - 1); QueryNum > 0; QueryNum--) { - if ((cp=(char *)HTList_objectAt(search_queries, - QueryNum)) != NULL && + if ((cp = (char *)HTList_objectAt(search_queries, + QueryNum)) != NULL && !strcmp(prev_target_buffer, cp)) { break; } @@ -140,17 +256,17 @@ check_recall: } } else { /* - * Go back to the previous query in the list. - FM + * Go back to the previous query in the list. - FM */ QueryNum++; } if (QueryNum >= QueryTotal) /* - * Roll around to the last query in the list. - FM + * Roll around to the last query in the list. - FM */ QueryNum = 0; - if ((cp=(char *)HTList_objectAt(search_queries, - QueryNum)) != NULL) { + if ((cp = (char *)HTList_objectAt(search_queries, + QueryNum)) != NULL) { strcpy(prev_target, cp); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { @@ -161,29 +277,29 @@ check_recall: } else { _statusline(EDIT_A_PREV_QUERY); } - if ((ch=LYgetstr(prev_target, VISIBLE, - sizeof(prev_target_buffer), recall)) < 0) { + if ((ch = LYgetstr(prev_target, VISIBLE, + sizeof(prev_target_buffer), recall)) < 0) { /* - * User cancelled the search via ^G. - * Restore prev_target and return. - FM + * User cancelled the search via ^G. + * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); _statusline(CANCELLED); sleep(InfoSecs); - return; + return(FALSE); } goto check_recall; } } else if (recall && ch == DNARROW) { if (FirstRecall) { /* - * Use the current string or first query in the list. - FM + * Use the current string or first query in the list. - FM */ FirstRecall = FALSE; if (*prev_target_buffer) { for (QueryNum = 0; QueryNum < (QueryTotal - 1); QueryNum++) { - if ((cp=(char *)HTList_objectAt(search_queries, - QueryNum)) != NULL && + if ((cp = (char *)HTList_objectAt(search_queries, + QueryNum)) != NULL && !strcmp(prev_target_buffer, cp)) { break; } @@ -193,17 +309,17 @@ check_recall: } } else { /* - * Advance to the next query in the list. - FM + * Advance to the next query in the list. - FM */ QueryNum--; } if (QueryNum < 0) /* - * Roll around to the first query in the list. - FM + * Roll around to the first query in the list. - FM */ QueryNum = QueryTotal - 1; - if ((cp=(char *)HTList_objectAt(search_queries, - QueryNum)) != NULL) { + if ((cp = (char *)HTList_objectAt(search_queries, + QueryNum)) != NULL) { strcpy(prev_target, cp); if (*prev_target_buffer && !strcmp(prev_target_buffer, prev_target)) { @@ -214,51 +330,56 @@ check_recall: } else { _statusline(EDIT_A_PREV_QUERY); } - if ((ch=LYgetstr(prev_target, VISIBLE, - sizeof(prev_target_buffer), recall)) < 0) { + if ((ch = LYgetstr(prev_target, VISIBLE, + sizeof(prev_target_buffer), recall)) < 0) { /* - * User cancelled the search via ^G. - * Restore prev_target and return. - FM + * User cancelled the search via ^G. + * Restore prev_target and return. - FM */ strcpy(prev_target, prev_target_buffer); _statusline(CANCELLED); sleep(InfoSecs); - return; + return(FALSE); } goto check_recall; } } /* - * Replace the search string buffer with the new target. - FM + * Replace the search string buffer with the new target. - FM */ strcpy(prev_target_buffer, prev_target); HTAddSearchQuery(prev_target_buffer); /* - * Search only links for the string, - * starting from the current link + * Search the links on the currently displayed page for + * the string, starting after the current link. - FM */ if (check_for_target_in_links(&cur_doc->link, prev_target)) { /* - * Found in link, changed cur, we're done. + * Found in link, changed cur, we're done. */ highlight(OFF, oldcur); - return; + return(TRUE); } /* - * We'll search the text starting from the - * link we are on, or the next page. + * We'll search the text starting from the + * link we are on, or the next page. */ if (nlinks == 0) offset = (display_lines - 1); else - offset = links[cur_doc->link].ly; + offset = links[cur_doc->link].ly - 1; /* - * Resume search, this time for all text. - * Set www_search_result if string found, - * and position the hit at top of screen. + * Resume search, this time for all text. + * Set www_search_result if string found, + * and position the hit at top of screen. */ - www_user_search(cur_doc->line+offset, prev_target); + www_user_search(cur_doc->line+offset, cur_doc, prev_target); + if (cur_doc->link != oldcur) { + highlight(OFF, oldcur); + return(TRUE); + } + return(www_search_result > 0); } diff --git a/src/LYSearch.h b/src/LYSearch.h index 3e5faa0d..cff7b806 100644 --- a/src/LYSearch.h +++ b/src/LYSearch.h @@ -6,7 +6,7 @@ #include "LYStructs.h" #endif /* LYSTRUCT_H */ -extern void textsearch PARAMS((document *cur_doc, +extern BOOL textsearch PARAMS((document *cur_doc, char *prev_target, BOOL next)); #define IN_FILE 1 diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index dc314523..23c6b6de 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -92,7 +92,11 @@ PUBLIC int showinfo ARGS4( } } - fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n", + fprintf(fp0, "<head>\n"); +#ifdef EXP_CHARTRANS + add_META_charset_to_fd(fp0, -1); +#endif + fprintf(fp0, "<title>%s</title>\n</head>\n<body>\n", SHOWINFO_TITLE); fprintf(fp0,"<h1>You have reached the Information Page</h1>\n"); fprintf(fp0,"<h2>%s Version %s</h2>\n", LYNX_NAME, LYNX_VERSION); @@ -243,7 +247,7 @@ PUBLIC int showinfo ARGS4( fprintf(fp0,"<dt><em>Linkname:</em> %s\n", Title); StrAllocCopy(Address, doc->address); - LYEntify(&Address, FALSE); + LYEntify(&Address, TRUE); fprintf(fp0, "<dt> <em>URL:</em> %s\n", Address); @@ -283,7 +287,7 @@ PUBLIC int showinfo ARGS4( if (owner_address) { StrAllocCopy(Address, owner_address); - LYEntify(&Address, FALSE); + LYEntify(&Address, TRUE); } else { StrAllocCopy(Address, "None"); } @@ -292,8 +296,11 @@ PUBLIC int showinfo ARGS4( fprintf(fp0, "<dt> <em>size:</em> %d lines\n", size_of_file); - fprintf(fp0, "<dt> <em>mode:</em> %s\n", - (lynx_mode == FORMS_LYNX_MODE ? "forms mode" : "normal")); + fprintf(fp0, "<dt> <em>mode:</em> %s%s%s\n", + (lynx_mode == FORMS_LYNX_MODE ? "forms mode" : "normal"), + (doc->safe ? ", safe" : ""), + (doc->internal_link ? ", internal link" : "") + ); fprintf(fp0, "</dl>\n"); /* end of list */ @@ -320,7 +327,7 @@ PUBLIC int showinfo ARGS4( } if (links[doc->link].form->submit_action) { StrAllocCopy(Address, links[doc->link].form->submit_action); - LYEntify(&Address, FALSE); + LYEntify(&Address, TRUE); fprintf(fp0, "<dt> <em>Action:</em> %s\n", Address); } if (!(links[doc->link].form->submit_method && @@ -334,7 +341,7 @@ PUBLIC int showinfo ARGS4( } else { StrAllocCopy(Title, ""); } - fprintf(fp0, "<dt><em>Filename:</em> %s\n", Title); + fprintf(fp0, "<dt> <em>URL:</em> %s\n", Title); } fprintf(fp0, "</dl>\n"); /* end of list */ diff --git a/src/LYStrings.c b/src/LYStrings.c index 093ca774..f5c88ffd 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -189,6 +189,49 @@ PUBLIC void LYsubwindow ARGS1(WINDOW *, param) } #endif +#ifdef USE_SLANG_MOUSE +PRIVATE int sl_parse_mouse_event ARGS3(int *, x, int *, y, int *, button) +{ + /* "ESC [ M" has already been processed. There more characters are + * expected: BUTTON X Y + */ + *button = SLang_getkey (); + switch (*button) + { + case 040: /* left button */ + case 041: /* middle button */ + case 042: /* right button */ + *button -= 040; + break; + + default: /* Hmmm.... */ + SLang_flush_input (); + return -1; + } + + *x = SLang_getkey () - 33; + *y = SLang_getkey () - 33; + return 0; +} +#endif + +#ifdef USE_SLANG_MOUSE +PRIVATE int map_function_to_key ARGS1(char, keysym) +{ + int i; + + /* I would prefer to use sizeof keymap but its size is not available. + * A better method would be to declare it as some fixed size. + */ + for (i = 1; i < 256; i++) + { + if (keymap[i] == keysym) + return i - 1; + } + return -1; +} +#endif + /* * LYgetch() translates some escape sequences and may fake noecho */ @@ -233,7 +276,6 @@ re_read: case 440: c = 'Q'; break; /* alt x */ default: break; } -// if (c < 256) return(c); } #endif #ifdef USE_GETCHAR @@ -300,7 +342,32 @@ re_read: case 's': c = PGDOWN; break; /* keypad on pc ncsa telnet */ case 'w': c = HOME; break; /* keypad on pc ncsa telnet */ case 'q': c = END; break; /* keypad on pc ncsa telnet */ - case 'M': c = '\n'; break; /* kepad enter on pc ncsa telnet */ + case 'M': +#ifdef USE_SLANG_MOUSE + if ((c == 27) && (b == '[')) + { + int mouse_x, mouse_y, button; + + mouse_link = -1; + c = -1; + if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y, &button)) + { + if (button == 0) /* left */ + c = set_clicked_link (mouse_x, mouse_y); + else if (button == 2) /* right */ + { + /* Right button: go back to prev document. + * The problem is that we need to determine + * what to return to achieve this. + */ + c = map_function_to_key (LYK_PREV_DOC); + } + } + } + else +#endif + c = '\n'; /* kepad enter on pc ncsa telnet */ + break; case 'm': #ifdef VMS @@ -330,6 +397,12 @@ re_read: #endif /* VMS */ c = F1; /* macintosh help button */ break; + case 'p': +#ifdef VMS + if (b == 'O') +#endif /* VMS */ + c = '0'; /* keypad 0 */ + break; case '1': /** VT300 Find **/ if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = FIND_KEY; @@ -366,6 +439,12 @@ re_read: if ((b == '[' || c == 155) && (d=GetChar()) == '~') c = PGDOWN; break; + case '[': /** Linux F1-F5: ^[[[A etc. **/ + if (b == '[' || c == 155) { + if ((d=GetChar()) == 'A') + c = F1; + break; + } default: if (TRACE) { fprintf(stderr,"Unknown key sequence: %d:%d:%d\n",c,b,a); @@ -443,9 +522,11 @@ re_read: c=127; /* backspace key (delete, not Ctrl-H) */ break; #endif /* KEY_BACKSPACE */ + #ifdef NCURSES_MOUSE_VERSION case KEY_MOUSE: { +#ifndef DOSPATH MEVENT event; int err; @@ -455,6 +536,26 @@ re_read: if (event.bstate & BUTTON1_CLICKED) { c = set_clicked_link(event.x, event.y); } +#else /* pdcurses version */ + int left,right; + /* yes, I am assuming that my screen will be a certain width. */ + left = 6; + right = LYcols-6; + c = -1; + mouse_link = -1; + request_mouse_pos(); + if (Mouse_status.button[0] & BUTTON_CLICKED) { + if (Mouse_status.y == (LYlines-1)) + if (Mouse_status.x < left) c=LTARROW; + else if (Mouse_status.x > right) c='\b'; + else c=PGDOWN; + else if (Mouse_status.y == 0) + if (Mouse_status.x < left) c=LTARROW; + else if (Mouse_status.x > right) c='\b'; + else c=PGUP; + else c = set_clicked_link(Mouse_status.x, Mouse_status.y); + } +#endif /* _WINDOWS */ } break; #endif /* NCURSES_MOUSE_VERSION */ @@ -462,6 +563,13 @@ re_read: } #endif /* defined(HAVE_KEYPAD) */ + if (c > DO_NOTHING) + /* Don't return raw values for KEYPAD symbols which we may have missed + * in the switch above if they are obviously invalid when used as an + * index into (e.g.) keypad[]. - kw + */ + return (0); + else return(c); } diff --git a/src/LYStructs.h b/src/LYStructs.h index 12ad43be..2ea0de0d 100644 --- a/src/LYStructs.h +++ b/src/LYStructs.h @@ -35,6 +35,11 @@ typedef struct _document { char * bookmark; int link; int line; + BOOL internal_link; /* whether doc was reached via an internal + (fragment) link. - kw */ +#ifdef USEHASH + char * style; +#endif } document; #ifndef HTFORMS_H @@ -51,6 +56,11 @@ typedef struct _histstruct { BOOL isHEAD; int link; int page; + BOOL internal_link; /* whether doc was reached via an internal + (fragment) link. - kw */ + int intern_seq_start; /* indicates which element on the history + is the start of this sequence of + "internal links", otherwise -1 */ } histstruct; typedef struct _VisitedLink { @@ -92,4 +102,9 @@ extern lynx_html_item_type *downloaders; /* for upload commands */ extern lynx_html_item_type *uploaders; +#ifdef USE_EXTERNALS +/* for external commands */ +extern lynx_html_item_type *externals; +#endif + #endif /* LYSTRUCTS_H */ diff --git a/src/LYStyle.c b/src/LYStyle.c new file mode 100644 index 00000000..dd4d12fd --- /dev/null +++ b/src/LYStyle.c @@ -0,0 +1,396 @@ +/* character level styles for Lynx + * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) + * $Id: LYStyle.c,v 1.1 1997/05/25 00:14:19 tom Exp $ + */ +#include "HTUtils.h" +#include "HTML.h" +#include "tcp.h" +#include "LYSignal.h" +#include "LYGlobalDefs.h" + +#include "LYStructs.h" +#include "LYCurses.h" +#include "LYCharUtils.h" +#include "AttrList.h" +#include "SGML.h" +#include "HTMLDTD.h" + +/* Hash table definitions */ +#include "LYHash.h" +#include "LYStyle.h" + +#include "LYexit.h" + +#ifdef USE_COLOR_STYLE + +PUBLIC bucket hashStyles[HASHSIZE]; + +/* definitions for the mono attributes we can use */ +static int ncursesMono[7] = { + A_NORMAL, A_BOLD, A_REVERSE, A_UNDERLINE, A_STANDOUT, A_BLINK, A_DIM +}; + +/* + * If these strings don't match the meanings of the above attributes, + * you'll confuse the hell out of people, so make them the same. - RP + */ +static char *Mono_Strings[7] = +{ + "normal", "bold", "reverse", "underline", "standout", "blink", "dim" +}; + +/* definitions for the colour attributes we can use */ +static int ncursesColors[8] = { + COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, + COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE +}; + +/* + * Ditto for these strings - RP + */ +static char *Color_Strings[16] = +{ + "black", "red", "green", "brown", "blue", "magenta", "cyan", "lightgray", + "gray", "brightred", "brightgreen", "yellow", "brightblue", "brightmagenta", + "brightcyan", "white" +}; + +/* Remember the hash codes for common elements */ +PUBLIC int s_alink=NOSTYLE, s_a=NOSTYLE, s_status=NOSTYLE, + s_label=NOSTYLE, s_value=NOSTYLE, s_high=NOSTYLE, + s_normal=NOSTYLE, s_alert=NOSTYLE, s_title=NOSTYLE; + +/* start somewhere safe */ +PRIVATE int colorPairs=0; + +#define FREE(x) if (x) {free(x); x = NULL;} + +/* icky parsing of the style options */ +PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char*,element) +{ + int i; + int mA=0, fA=COLOR_WHITE, bA=COLOR_BLACK, cA=0; + int newstyle=hash_code(element); + if (TRACE) + fprintf(stderr, "CSS(PA):style d=%d / h=%d, e=%s\n", style, newstyle,element); + + for (i=0; i<7; i++) + { + if (!strcasecmp(Mono_Strings[i], mono)) + { + mA = ncursesMono[i]; + } + } + if (TRACE) + fprintf(stderr, "CSS(CP):%d\n", colorPairs); + /* + * `nocolor' means don't even try to do colour for this - RP + */ + if (!strcasecmp("nocolor", fg)) + { + fA=-1; + bA=-1; + cA=-1; + } + else + { + for (i=0; i<16; i++) + { + if (!strcasecmp(Color_Strings[i], fg)) + { + fA = ncursesColors[i%8]; + /* + * if the string was in the upper 8, then it's + * a bright version, so set the BOLD attribute + */ + cA = (i>=8 ? A_BOLD : 0); + } + } + /* + * Backgrounds are horribly broken under ncurses - RP + */ + for (i=0; i<16; i++) + { + if (!strcasecmp(Color_Strings[i], bg)) + { + bA = ncursesColors[i%8]; + cA |=(i>=8 ? A_BOLD : 0); + } + } + } + + /* + * If we have colour, and space to create a new colour attribute, + * and we have a valid colour description, then add this style + */ + if (has_color && colorPairs < COLOR_PAIRS-1 && fA!=-1) + { + colorPairs++; + init_pair(colorPairs, fA, bA); + setStyle(style, COLOR_PAIR(colorPairs)|cA, cA, mA); + setHashStyle(newstyle, COLOR_PAIR(colorPairs)|cA, cA, mA, element); + } + else + { + /* only mono is set */ + setStyle(style, -1, -1, mA); + setHashStyle(newstyle, -1, -1, mA, element); + } +} + +/* parse a style option of the format + * STYLE:<OBJECT>:FG:BG + */ +PRIVATE void parse_style ARGS1(char*,buffer) +{ + char *tmp = strchr(buffer, ':'); + char *element, *mono, *fg, *bg; + + if(!tmp) + { + fprintf (stderr, "\ +Syntax Error parsing style in lss file:\n\ +[%s]\n\ +The line must be of the form:\n\ +OBJECT:MONO:COLOR (ie em:bold:brightblue:white)\n\ +where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); + if (!dump_output_immediately) { +#ifndef NOSIGHUP + (void) signal(SIGHUP, SIG_DFL); +#endif /* NOSIGHUP */ + (void) signal(SIGTERM, SIG_DFL); +#ifndef VMS + (void) signal(SIGINT, SIG_DFL); +#endif /* !VMS */ +#ifdef SIGTSTP + if (no_suspend) + (void) signal(SIGTSTP,SIG_DFL); +#endif /* SIGTSTP */ + exit(-1); + } + exit(1); + } + { + char *i; + for (i=buffer; *i; *i++=tolower(*i)); + } + *tmp='\0'; + element=buffer; + + mono=tmp+1; + tmp=strchr(mono, ':'); + + if (!tmp) { fg="nocolor"; bg="nocolor"; } + else + { + *tmp='\0'; + fg=tmp+1; + tmp=strchr(fg, ':'); + if (!tmp) bg="black"; + else {*tmp='\0'; bg=tmp+1;} + } + + if (TRACE) + { + int bucket = hash_code(element); + fprintf(stderr, "CSSPARSE:%s => %d %s\n", + element, bucket, + (hashStyles[bucket].name ? "used" : "")); + } + + strtolower(element); + + /* + * We use some pseudo-elements, so catch these first + */ + if (!strncasecmp(element, "alink", 5)) /* active link */ + { + parse_attributes(mono,fg,bg,DSTYLE_ALINK,"alink"); + } + else if (!strcasecmp(element, "a")) /* normal link */ + { + parse_attributes(mono,fg,bg, DSTYLE_LINK,"a"); + parse_attributes(mono,fg,bg, HTML_A,"a"); + } + else if (!strncasecmp(element, "status", 4)) /* status bar */ + { + parse_attributes(mono,fg,bg, DSTYLE_STATUS,"status"); + } + else if (!strncasecmp(element, "label", 6)) /* [INLINE]'s */ + { + parse_attributes(mono,fg,bg,DSTYLE_OPTION,"label"); + } + else if (!strncasecmp(element, "value", 5)) /* [INLINE]'s */ + { + parse_attributes(mono,fg,bg,DSTYLE_VALUE,"value"); + } + else if (!strncasecmp(element, "high", 4)) /* [INLINE]'s */ + { + parse_attributes(mono,fg,bg,DSTYLE_HIGH,"high"); + } + /* this may vanish */ + else if (!strncasecmp(element, "candy", 5)) /* [INLINE]'s */ + { + parse_attributes(mono,fg,bg,DSTYLE_CANDY,"candy"); + } + /* Ok, it must be a HTML element, so look through the list until we + * find it + */ + else + { +#if !defined(USEHASH) + int i; + for (i=0; i<HTML_ELEMENTS; i++) + { + if (!strcasecmp (HTML_dtd.tags[i].name, element)) + { + if (TRACE) + fprintf(stderr, "PARSECSS:applying style <%s,%s,%s> for HTML_%s\n",mono,fg,bg,HTML_dtd.tags[i].name); + parse_attributes(mono,fg,bg,i+STARTAT,element); + break; + } + } +#else + parse_attributes(mono,fg,bg,hash_code(element),element); +#endif + } +} + +/* + * initialise the default style sheet + * This should be able to be read from a file in CSS format :-) + */ +PRIVATE void initialise_default_stylesheet NOARGS +{ +} + +/* Set all the buckets in the hash table to be empty */ +PUBLIC void style_initialiseHashTable NOARGS +{ + int i; + + for (i=0; i<HASHSIZE; i++) + { + hashStyles[i].name=NULL; + hashStyles[i].color=-1; + hashStyles[i].cattr=-1; + hashStyles[i].mono=-1; + } + s_high=hash_code("high"); + s_alink=hash_code("alink"); + s_value=hash_code("value"); + s_label=hash_code("label"); + s_a=hash_code("a"); + s_status=hash_code("status"); + s_alert=hash_code("alert"); + s_title=hash_code("title"); +} + +/* because curses isn't started when we parse the config file, we + * need to remember the STYLE: lines we encounter and parse them + * after curses has started + */ +HTList *lss_styles = NULL; + +PUBLIC void parse_userstyles NOARGS +{ + char *name; + HTList *cur = lss_styles; + colorPairs=0; + style_initialiseHashTable(); + + /* set our styles to be the same as vanilla-curses-lynx */ + initialise_default_stylesheet(); + + while ((name=HTList_nextObject(cur)) != NULL) + { + if (TRACE) + fprintf(stderr, "LSS:%s\n", name ? name : "!?! empty !?!"); + if (name != NULL) + parse_style(name); + } +} + + +/* Add a STYLE: option line to our list */ +PUBLIC void HStyle_addStyle ARGS1(char*,buffer) +{ + char *name=NULL; + StrAllocCopy(name, buffer); + if (lss_styles==NULL) + lss_styles=HTList_new(); + strtolower(name); + if (TRACE) + fprintf(stderr, "READCSS:%s\n", name ? name : "!?! empty !?!"); + HTList_addObject (lss_styles, name); +} + +PUBLIC void style_deleteStyleList NOARGS +{ + char *name; + while ((name = HTList_removeLastObject(lss_styles)) != NULL) + FREE(name); + HTList_delete (lss_styles); + lss_styles=NULL; +} + +char* default_stylesheet[]={ + "a:bold", "em:bold", "strong:bold", "b:bold", "i:bold", + "alink:reverse", "status:reverse", NULL +}; + +PUBLIC void style_defaultStyleSheet NOARGS +{ + int i; + for (i=0; default_stylesheet[i]; i++) + HStyle_addStyle(default_stylesheet[i]); +} + +PUBLIC int style_readFromFile ARGS1(char*, file) +{ + FILE *fh; + char buffer[1024]; + int len; + + if (TRACE) + fprintf(stderr, "CSS:Reading styles from file: %s\n", file ? file : "?!? empty ?!?"); + if (file == NULL || *file == '\0') + return -1; + fh=fopen(file, "r"); + if (!fh) + { +/* this should probably be an alert or something */ + if (TRACE) + fprintf(stderr, "CSS:Can't open style file %s, using defaults\n", file); + return -1; + } + + style_initialiseHashTable(); + style_deleteStyleList(); + + while (!feof(fh) + && fgets(buffer, sizeof(buffer)-1, fh) != NULL) + { + len = strlen(buffer); + if (len > 0) { + if (buffer[len-1] == '\n' || buffer[len-1] == '\r') + buffer[len-1]='\0'; /* hack */ + else + buffer[1023]='\0'; /* hack */ + } + LYTrimTail(buffer); + LYTrimHead(buffer); + if (buffer[0] != '#' && (len = strlen(buffer)) > 0) + HStyle_addStyle(buffer); + } + /* the default styles are added after the user styles in order + ** that they come before them <grin> RP + */ +/* style_defaultStyleSheet(); */ + + fclose (fh); + if (LYCursesON) + parse_userstyles(); + return 0; +} +#endif /* USE_COLOR_STYLE */ diff --git a/src/LYStyle.h b/src/LYStyle.h new file mode 100644 index 00000000..cfc4ae69 --- /dev/null +++ b/src/LYStyle.h @@ -0,0 +1,32 @@ +#ifndef LYSTYLE_H +#define LYSTYLE_H + +#ifdef USE_COLOR_STYLE + +#include "AttrList.h" + +/* list of elements */ +extern CONST SGML_dtd HTML_dtd; + +/* array of currently set styles */ +extern HTCharStyle displayStyles[DSTYLE_ELEMENTS]; + +/* Can we do colour? - RP */ +extern int has_color; + +/* Set all the buckets in the hash table to be empty */ +extern void style_initialiseHashTable NOPARAMS; + +extern void parse_userstyles NOPARAMS; + +extern void HStyle_addStyle PARAMS((char* buffer)); + +extern void style_deleteStyleList NOPARAMS; + +extern void style_defaultStyleSheet NOPARAMS; + +extern int style_readFromFile PARAMS((char* file)); + +#endif /* USE_COLOR_STYLE */ + +#endif /* LYSTYLE_H */ diff --git a/src/LYUtils.c b/src/LYUtils.c index 4543edca..37ad23f2 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -48,6 +48,12 @@ #include "LYLeaks.h" +#ifdef USE_COLOR_STYLE +#include "AttrList.h" +#include "LYHash.h" +#include "LYStyle.h" +#endif + #ifdef SVR4_BSDSELECT extern int BSDselect PARAMS((int nfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval * timeout)); @@ -105,20 +111,28 @@ PUBLIC void highlight ARGS2( cur = 0; if (nlinks > 0) { +#ifdef USE_COLOR_STYLE +#define LXP (links[cur].lx) +#define LYP (links[cur].ly) +#endif move(links[cur].ly, links[cur].lx); +#ifndef USE_COLOR_STYLE + lynx_start_link_color (flag == ON); +#else if (flag == ON) { - /* makes some terminals work wrong because - * they can't handle two attributes at the - * same time - */ - /* start_bold(); */ - start_reverse(); -#if defined(USE_SLANG) || defined(FANCY_CURSES) - start_underline (); -#endif /* USE_SLANG */ + LynxChangeStyle(s_alink, ABS_ON, 0); } else { - start_bold(); + /* the logic is flawed here - no provision is made for links that + ** aren't coloured as [s_a] by default - rjp + */ + if (cached_styles[LYP][LXP]) { + LynxChangeStyle(cached_styles[LYP][LXP], ABS_ON, 0); + } + else { + LynxChangeStyle(s_a, ABS_ON, 0); + } } +#endif if (links[cur].type == WWW_FORM_LINK_TYPE) { int len; @@ -156,55 +170,37 @@ PUBLIC void highlight ARGS2( /* display a second line as well */ if (links[cur].hightext2 && links[cur].ly < display_lines) { - if (flag == ON) { - stop_reverse(); -#if defined(USE_SLANG) || defined(FANCY_CURSES) - stop_underline (); -#endif /* USE_SLANG */ - } else { - stop_bold(); - } + lynx_stop_link_color (flag == ON); addch('\n'); for (i=0; i < links[cur].hightext2_offset; i++) - addch(' '); + addch(' '); - if (flag == ON) { - start_reverse(); -#if defined(USE_SLANG) || defined(FANCY_CURSES) - start_underline (); -#endif /* USE_SLANG */ - } else { - start_bold(); - } +#ifndef USE_COLOR_STYLE + lynx_start_link_color (flag == ON); +#else + LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_ON, 0); +#endif for (i = 0; (tmp[0] = links[cur].hightext2[i]) != '\0' && - i+links[cur].hightext2_offset < LYcols; i++) { + i+links[cur].hightext2_offset < LYcols; i++) { if (!IsSpecialAttrChar(links[cur].hightext2[i])) { /* For CJK strings, by Masanobu Kimura */ if (HTCJK != NOCJK && !isascii(tmp[0])) { - tmp[1] = links[cur].hightext2[++i]; + tmp[1] = links[cur].hightext2[++i]; addstr(tmp); tmp[1] = '\0'; } else { - addstr(tmp); + addstr(tmp); } } } } - - if (flag == ON) { - stop_reverse(); -#if defined(USE_SLANG) || defined(FANCY_CURSES) - stop_underline (); -#endif /* USE_SLANG */ - } else { - stop_bold(); - } + lynx_stop_link_color (flag == ON); #if defined(FANCY_CURSES) || defined(USE_SLANG) if (!LYShowCursor) - move(LYlines-1, LYcols-1); /* get cursor out of the way */ + move(LYlines-1, LYcols-1); /* get cursor out of the way */ else #endif /* FANCY CURSES || USE_SLANG */ /* never hide the cursor if there's no FANCY CURSES or SLANG */ @@ -349,7 +345,7 @@ PUBLIC void statusline ARGS1( * make sure text is not longer than the statusline window. - FM */ max_length = ((LYcols - 2) < 256) ? (LYcols - 2) : 255; - if ((buffer[0] != '\0') && + if ((text[0] != '\0') && (LYHaveCJKCharacterSet)) { /* * Translate or filter any escape sequences. - FM @@ -427,14 +423,21 @@ PUBLIC void statusline ARGS1( } clrtoeol(); if (text != NULL) { -#ifdef COLOR_CURSES - lynx_set_color(2); - addstr(buffer); - lynx_set_color(0); +#ifndef USE_COLOR_STYLE + lynx_start_status_color (); + addstr (buffer); + lynx_stop_status_color (); #else - start_reverse(); - addstr(buffer); - stop_reverse(); + /* draw the status bar in the STATUS style */ + { + int a=(strncmp(buffer, "Alert", 5) || !hashStyles[s_alert].name ? s_status : s_alert); + LynxChangeStyle (a, ABS_ON, 1); + addstr(buffer); + wbkgdset(stdscr, hashStyles[a].color); + clrtoeol(); + wbkgdset(stdscr, hashStyles[s_normal].color); + LynxChangeStyle (a, ABS_OFF, 0); + } #endif } refresh(); @@ -471,7 +474,7 @@ PUBLIC void noviceline ARGS1( return; move(LYlines-2,0); - stop_reverse(); + /* stop_reverse(); */ clrtoeol(); addstr(NOVICE_LINE_ONE); clrtoeol(); @@ -555,7 +558,11 @@ PUBLIC int HTCheckForInterrupt NOARGS ret = select(FD_SETSIZE, (void *)&readfds, NULL, NULL, &socket_timeout); - /** No keystroke was entered **/ + /** Suspended? **/ + if ((ret == -1) && (errno == EINTR)) + return((int)FALSE); + + /** No keystroke was entered? **/ if (!FD_ISSET(0,&readfds)) return((int)FALSE); #endif /* USE_SLANG */ @@ -1201,7 +1208,7 @@ PUBLIC void remove_backslashes ARGS1( PUBLIC char * quote_pathname ARGS1( char *, pathname) { - int i, n = 0; + size_t i, n = 0; char * result; for (i=0; i < strlen(pathname); ++i) @@ -1422,7 +1429,7 @@ PUBLIC void change_sug_filename ARGS1( char *, fname) { char *temp, *cp, *cp1, *end; - int len; + size_t len; #ifdef VMS char *dot; int j,k; @@ -1636,25 +1643,100 @@ PUBLIC void tempname ARGS2( char *, namebuffer, int, action) { - static int counter = 0; - - if (action == REMOVE_FILES) { /* REMOVE ALL FILES */ - for (; counter > 0; counter--) { - sprintf(namebuffer, "%sL%d%uTMP.txt", lynx_temp_space, - (int)getpid(), counter-1); - remove(namebuffer); - sprintf(namebuffer, "%sL%d%uTMP.html", lynx_temp_space, - (int)getpid(), counter-1); - remove(namebuffer); + static int counter = 0; + FILE *fp = NULL; + int LYMaxTempCount = 10000; /* Arbitrary limit. Make it configurable? */ + + if (action == REMOVE_FILES) { + /* + * Remove all temporary files with .txt or .html suffixes. - FM + */ + for (; counter > 0; counter--) { + sprintf(namebuffer, + "%sL%d%uTMP.txt", + lynx_temp_space, (int)getpid(), counter-1); + remove(namebuffer); + sprintf(namebuffer, + "%sL%d%uTMP.html", + lynx_temp_space, (int)getpid(), counter-1); + remove(namebuffer); + } + } else { + /* + * Load a tentative temporary file name into namebuffer. - FM + */ + while (counter < LYMaxTempCount) { + /* + * Create names with .txt, then .bin, then + * .html suffixes, and check for their prior + * existence. If any already exist, someone + * might be trying to spoof us, so increment + * the count and try again. Otherwise, return + * with the name which has the .html suffix + * loaded in namebuffer. - FM + */ + sprintf(namebuffer, + "%sL%d%uTMP.txt", + lynx_temp_space, (int)getpid(), counter); + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exits!\n", + namebuffer); + counter++; + continue; + } + sprintf(namebuffer, + "%sL%d%uTMP.bin", + lynx_temp_space, (int)getpid(), counter); + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exits!\n", + namebuffer); + counter++; + continue; + } + sprintf(namebuffer, + "%sL%d%uTMP.html", + lynx_temp_space, (int)getpid(), counter++); + if ((fp = fopen(namebuffer, "r")) != NULL) { + fclose(fp); + if (TRACE) + fprintf(stderr, + "tempname: file '%s' already exits!\n", + namebuffer); + continue; } - } else /* add a file */ { + /* + * Return to the calling function, with the tentative + * temporary file name loaded in namebuffer. Note that + * if the calling function will use a suffix other than + * .txt, .bin, or .html, it similarly should do tests for + * a spoof. The file name can be reused if it is written + * to on receipt of this name, and thereafter accessed + * for reading. Note that if writing to a file is to + * be followed by reading it, as it the usual case for + * Lynx, the spoof attempt will be apparent, and the user + * can take appropriate action. - FM + */ + return; + } /* - * Create name + * The tempfile maximum count has been reached. + * Issue a message and exit. - FM */ - sprintf(namebuffer, "%sL%d%uTMP.html", lynx_temp_space, - (int)getpid(), counter++); - } - return; + _statusline(MAX_TEMPCOUNT_REACHED); + sleep(AlertSecs); + exit(-1); + } + + /* + * We were called for a clean up, and have done it. - FM + */ + return; } /* @@ -1736,6 +1818,9 @@ PRIVATE char *restrict_name[] = { "change_exec_perms", #endif /* OK_PERMIT */ #endif /* DIRED_SUPPORT */ +#ifdef USE_EXTERNALS + "externals" , +#endif (char *) 0 }; /* restrict_name and restrict_flag structure order @@ -1778,6 +1863,9 @@ PRIVATE BOOLEAN *restrict_flag[] = { &no_change_exec_perms, #endif /* OK_PERMIT */ #endif /* DIRED_SUPPORT */ +#ifdef USE_EXTERNALS + &no_externals , +#endif (BOOLEAN *) 0 }; PUBLIC void parse_restrictions ARGS1( @@ -2049,7 +2137,7 @@ PUBLIC void LYConvertToURL ARGS1( return; #ifdef DOSPATH -{ + { char *cp_url = *AllocatedString; for(; *cp_url != '\0'; cp_url++) if(*cp_url == '\\') *cp_url = '/'; @@ -2060,7 +2148,7 @@ PUBLIC void LYConvertToURL ARGS1( if(strlen(old_string) > 3 && *cp_url == '/') *cp_url = '\0'; #endif -} + } #endif *AllocatedString = NULL; /* so StrAllocCopy doesn't free it */ @@ -2310,7 +2398,9 @@ have_VMS_URL: /* * It is a subdirectory or file on the local system. */ - StrAllocCat(*AllocatedString, temp); + cp = HTEscape(temp, URL_PATH); + StrAllocCat(*AllocatedString, cp); + FREE(cp); if (TRACE) { fprintf(stderr, "Converted '%s' to '%s'\n", old_string, *AllocatedString); @@ -2377,6 +2467,8 @@ have_VMS_URL: } #endif /* VMS */ } else { + struct stat st; + FILE *fptemp = NULL; /* * Path begins with a slash. Simplify and use it. */ @@ -2391,6 +2483,27 @@ have_VMS_URL: #else StrAllocCat(*AllocatedString, "/"); #endif /* VMS */ + } else if ((stat(old_string, &st) > -1) || + (fptemp = fopen(old_string, "r")) != NULL) { + /* + * It is an absolute directory or file + * on the local system. - kw + */ + StrAllocCopy(temp, old_string); + LYTrimRelFromAbsPath(temp); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", old_string, temp); + } + cp = HTEscape(temp, URL_PATH); + StrAllocCat(*AllocatedString, cp); + FREE(cp); + FREE(temp); + if (fptemp) + fclose(fptemp); + if (TRACE) { + fprintf(stderr, "Converted '%s' to '%s'\n", + old_string, *AllocatedString); + } } else if (old_string[1] == '~') { /* * Has a Home_Dir() reference. Handle it @@ -3500,7 +3613,7 @@ PUBLIC time_t LYmktime ARGS1( clock2 = (time_t)0; if (TRACE && clock2 > 0) fprintf(stderr, - "LYmktime: clock=%i, ctime=%s", clock2, ctime(&clock2)); + "LYmktime: clock=%ld, ctime=%s", (long) clock2, ctime(&clock2)); return(clock2); } diff --git a/src/LYexit.c b/src/LYexit.c index 7d737606..7b3035d5 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -53,7 +53,7 @@ PUBLIC void LYexit ARGS1( * Ignore further interrupts. - FM */ #ifndef NOSIGHUP - (void) signal(SIGHUP, SIG_DFL); + (void) signal(SIGHUP, SIG_IGN); #endif /* NOSIGHUP */ (void) signal (SIGTERM, SIG_IGN); (void) signal (SIGINT, SIG_IGN); diff --git a/src/Makefile b/src/Makefile index e11132e1..112f0521 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,8 +8,8 @@ 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 \ - $(CHARTRANS_OBJS) +LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o\ +LYStyle.o LYHash.o $(CHARTRANS_OBJS) CFLAGS= $(MCFLAGS) -I.. $(SLANGINC) diff --git a/src/UCAuto.c b/src/UCAuto.c index ec267f26..cd786b76 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -64,6 +64,12 @@ PRIVATE void call_setfont ARGS3(char *,font, char *,fnsuffix, char *,umap) } if (*T_setfont_cmd) { + + if (TRACE) { + fprintf(stderr, "Executing setfont: '%s'\n", + T_setfont_cmd); + } + system(T_setfont_cmd); } } diff --git a/src/chrtrans/MAKEW32.BAT b/src/chrtrans/MAKEW32.BAT index 1259b344..3655ba0f 100644 --- a/src/chrtrans/MAKEW32.BAT +++ b/src/chrtrans/MAKEW32.BAT @@ -22,4 +22,3 @@ makeuctb rfc_suni.tbl > rfc_suni.h makeuctb def7_uni.tbl > def7_uni.h makeuctb koi8r_uni.tbl > koi8r_uni.h - diff --git a/src/chrtrans/Makefile b/src/chrtrans/Makefile index 055dbad2..02f36f4f 100644 --- a/src/chrtrans/Makefile +++ b/src/chrtrans/Makefile @@ -54,12 +54,14 @@ makeuctb: makeuctb.c UCkd.h iso01_uni.h: iso01_uni.tbl makeuctb iso02_uni.h: iso02_uni.tbl makeuctb +def7_uni.h: def7_uni.tbl makeuctb iso03_uni.h: iso03_uni.tbl makeuctb iso04_uni.h: iso04_uni.tbl makeuctb iso05_uni.h: iso05_uni.tbl makeuctb iso07_uni.h: iso07_uni.tbl makeuctb iso09_uni.h: iso09_uni.tbl makeuctb iso10_uni.h: iso10_uni.tbl makeuctb +koi8r_uni.h: koi8r_uni.tbl makeuctb cp437_uni.h: cp437_uni.tbl makeuctb cp850_uni.h: cp850_uni.tbl makeuctb cp852_uni.h: cp852_uni.tbl makeuctb diff --git a/src/chrtrans/README.tables b/src/chrtrans/README.tables index 94622a99..c9a86605 100644 --- a/src/chrtrans/README.tables +++ b/src/chrtrans/README.tables @@ -45,8 +45,10 @@ if in doubt, check the last lines of the corresponding ...uni.h file.] c) To let make automatically notice when you have changed one of the table files, and automatically regenerate the *uni.h file(s), you also have to add any new tables to both src/Makefile *and* -src/chrtrans/Makefile. (That may be inconvenient, but I didn't want to -depend on features than not all makes may have.) Note that for recompiling -Lynx, a `make clean' should not be necessary if you have *only* made +src/chrtrans/Makefile. Or, for auto-config, the equivalent files +named makefile.in before running ./configure, or makefile after running +./configure. (That may be inconvenient, but I didn't want to depend +on features than not all makes may have.) Note that for recompiling +Lynx, a `make clean' should not be necessary if you have *only* made changes to the files in src/chrtrans. diff --git a/src/chrtrans/def7_uni.tbl b/src/chrtrans/def7_uni.tbl index ab7fd4de..7978e73a 100644 --- a/src/chrtrans/def7_uni.tbl +++ b/src/chrtrans/def7_uni.tbl @@ -1230,7 +1230,7 @@ U+2020:/- U+2021:/= U+2022: o U+2025:.. -U+2025:... +U+2026:... # Dont wanna see these: # POP DIRECTIONAL FORMATTING 202C diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in index 8d5da41f..246e94ba 100644 --- a/src/chrtrans/makefile.in +++ b/src/chrtrans/makefile.in @@ -76,12 +76,14 @@ makeuctb: makeuctb.c UCkd.h iso01_uni.h: iso01_uni.tbl makeuctb iso02_uni.h: iso02_uni.tbl makeuctb +def7_uni.h: def7_uni.tbl makeuctb iso03_uni.h: iso03_uni.tbl makeuctb iso04_uni.h: iso04_uni.tbl makeuctb iso05_uni.h: iso05_uni.tbl makeuctb iso07_uni.h: iso07_uni.tbl makeuctb iso09_uni.h: iso09_uni.tbl makeuctb iso10_uni.h: iso10_uni.tbl makeuctb +koi8r_uni.h: koi8r_uni.tbl makeuctb cp437_uni.h: cp437_uni.tbl makeuctb cp850_uni.h: cp850_uni.tbl makeuctb cp852_uni.h: cp852_uni.tbl makeuctb diff --git a/src/chrtrans/makeuctb.c b/src/chrtrans/makeuctb.c index aeb1a0e9..f5f73066 100644 --- a/src/chrtrans/makeuctb.c +++ b/src/chrtrans/makeuctb.c @@ -503,6 +503,11 @@ static u8 dfont_unicount%s[%d] = \n\ printf(", "); } + /* If lowest_eightbit is anything else but 999, this can't be 7-bit + * only. */ + if (lowest_eight != 999 && !RawUni) + RawUni = UCT_ENC_8BIT; + if (nuni) printf("\nstatic u16 dfont_unitable%s[%d] = \n{\n\t", id_append, nuni); else diff --git a/src/makefile.dos b/src/makefile.dos index 8a820ab8..367d2e62 100644 --- a/src/makefile.dos +++ b/src/makefile.dos @@ -5,14 +5,13 @@ 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 HTML.o \ -UCAUTO.o UCAUX.o UCDOMAP.o +LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.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 = -DEXP_CHARTRANS -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 +MCFLAGS = -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 diff --git a/src/makefile.in b/src/makefile.in index 92977d01..847a724e 100644 --- a/src/makefile.in +++ b/src/makefile.in @@ -24,8 +24,8 @@ 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 \ - $(CHARTRANS_OBJS) +LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \ +LYStyle.o LYHash.o $(CHARTRANS_OBJS) all: lynx |