diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GridText.c | 780 | ||||
-rw-r--r-- | src/GridText.h | 6 | ||||
-rw-r--r-- | src/HTAlert.c | 18 | ||||
-rw-r--r-- | src/HTForms.h | 12 | ||||
-rw-r--r-- | src/LYClean.c | 13 | ||||
-rw-r--r-- | src/LYCookie.c | 1358 | ||||
-rw-r--r-- | src/LYCookie.h | 37 | ||||
-rw-r--r-- | src/LYCurses.c | 24 | ||||
-rw-r--r-- | src/LYExtern.c | 33 | ||||
-rw-r--r-- | src/LYForms.c | 94 | ||||
-rw-r--r-- | src/LYGetFile.c | 16 | ||||
-rw-r--r-- | src/LYHistory.c | 2 | ||||
-rw-r--r-- | src/LYLocal.c | 4 | ||||
-rw-r--r-- | src/LYMail.c | 28 | ||||
-rw-r--r-- | src/LYMain.c | 18 | ||||
-rw-r--r-- | src/LYMainLoop.c | 352 | ||||
-rw-r--r-- | src/LYSearch.c | 45 | ||||
-rw-r--r-- | src/LYShowInfo.c | 16 | ||||
-rw-r--r-- | src/LYStrings.c | 37 | ||||
-rw-r--r-- | src/LYStrings.h | 2 | ||||
-rw-r--r-- | src/LYStructs.h | 34 | ||||
-rw-r--r-- | src/LYStyle.c | 4 | ||||
-rw-r--r-- | src/LYUtils.c | 1669 | ||||
-rw-r--r-- | src/LYUtils.h | 4 | ||||
-rw-r--r-- | src/LYexit.c | 1 | ||||
-rw-r--r-- | src/structdump.h | 6 |
26 files changed, 2015 insertions, 2598 deletions
diff --git a/src/GridText.c b/src/GridText.c index 26cb0656..69c73f37 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -155,7 +155,7 @@ PUBLIC int LYsb_end = -1; #define MAX_STYLES_ON_LINE 64 /*try to fit in 2 shorts*/ -typedef struct _stylechange { +typedef struct { unsigned int direction:2; /* on or off */ unsigned int horizpos: (sizeof(short)*CHAR_BIT-2); /* horizontal position of this change */ @@ -187,7 +187,7 @@ HTStyleChange stylechanges_buffers[2][MAX_STYLES_ON_LINE]; int stylechanges_buffers_free;/*this is an index of the free buffer. Can be 0 or 1*/ -/* These are generic macors for any pools (provided those structures have the +/* These are generic macros for any pools (provided those structures have the same members as HTStyleChangePool). Pools are used for allocation of groups of objects of the same type T. Pools are represented as a list of structures of type P (called pool chunks here). Structure P has an array of N objects of @@ -303,9 +303,7 @@ typedef struct _TextAnchor { int line_pos; /* Bytes/chars - extent too */ int extent; /* (see HText_trimHightext) */ int line_num; /* Place in document */ - char * hightext; /* The link text */ - char * hightext2; /* A second line*/ - int hightext2offset;/* offset from left */ + HiliteList lites; int link_type; /* Normal, internal, or form? */ FormInfo * input_field; /* Info for form links */ BOOL show_anchor; /* Show the anchor? */ @@ -314,7 +312,7 @@ typedef struct _TextAnchor { HTChildAnchor * anchor; } TextAnchor; -typedef struct _HTTabID { +typedef struct { char * name; /* ID value of TAB */ int column; /* Zero-based column value */ } HTTabID; @@ -427,7 +425,7 @@ PUBLIC BOOL can_justify_stack_depth;/* can be 0 or 1 if all code is correct*/ #endif -typedef struct ht_run_info_ { +typedef struct { int byte_len; /*length in bytes*/ int cell_len; /*length in cells*/ } ht_run_info; @@ -522,6 +520,114 @@ PRIVATE int HText_TrueLineSize PARAMS(( #define CHECK_FREE_MEM #endif +/* + * Set the initial highlight information for a given anchor. + */ +PRIVATE void LYSetHiText ARGS3( + TextAnchor *, a, + char *, text, + int, len) +{ + unsigned have = a->lites.hl_len; + + if (a->lites.hl_info != NULL) { + while (have-- != 0) { + if ((int) (have + 1) < a->lites.hl_len) { + FREE(a->lites.hl_info[have].hl_text); + } + } + FREE(a->lites.hl_info); + } + FREE(a->lites.hl_base.hl_text); + a->lites.hl_len = 0; + + if (text != NULL) { + StrnAllocCopy(a->lites.hl_base.hl_text, text, len); + a->lites.hl_len = 1; + } +} + +/* + * Add highlight information for the next line of a anchor. + */ +PRIVATE void LYAddHiText ARGS3( + TextAnchor *, a, + char *, text, + int, x) +{ + HiliteInfo *have = a->lites.hl_info; + unsigned need = (a->lites.hl_len - 1); + unsigned want = ++(a->lites.hl_len) * sizeof(HiliteInfo); + + if (have != NULL) { + have = realloc(have, want); + } else { + have = malloc(want); + } + a->lites.hl_info = have; + + have[need].hl_text = NULL; + StrAllocCopy(have[need].hl_text, text); + have[need].hl_x = x; +} + +/* + * Get the highlight text, counting from zero. + */ +PRIVATE char *LYGetHiTextStr ARGS2( + TextAnchor *, a, + int, count) +{ + char *result; + + if (count >= a->lites.hl_len) + result = NULL; + else if (count > 0) + result = a->lites.hl_info[count - 1].hl_text; + else + result = a->lites.hl_base.hl_text; + return result; +} + +/* + * Get the X-ordinate at which to draw the corresponding highlight-text + */ +PRIVATE int LYGetHiTextPos ARGS2( + TextAnchor *, a, + int, count) +{ + int result; + + if (count >= a->lites.hl_len) + result = -1; + else if (count > 0) + result = a->lites.hl_info[count - 1].hl_x; + else + result = a->line_pos; + return result; +} + +/* + * Copy highlighting information from anchor 'a' to 'b'. + */ +PRIVATE void LYCopyHiText ARGS2( + TextAnchor *, a, + TextAnchor *, b) +{ + int count; + char *s; + + LYSetHiText(a, NULL, 0); + for (count = 0; ; ++count) { + if ((s = LYGetHiTextStr(b, count)) == NULL) + break; + if (count == 0) { + LYSetHiText(a, s, strlen(s)); + } else { + LYAddHiText(a, s, LYGetHiTextPos(b, count)); + } + } +} #ifdef CHECK_FREE_MEM @@ -843,7 +949,7 @@ PUBLIC HText * HText_new ARGS1( &LYCharSet_UC[current_char_set]); /* - * Check the kcode setting if the anchor has a charset element. - FM + * Check the kcode setting if the anchor has a charset element. -FM */ HText_setKcode(self, anchor->charset, HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT)); @@ -856,13 +962,13 @@ PUBLIC HText * HText_new ARGS1( */ if (underscore_string[0] != '.') { /* - * Create an array of dots for the UNDERSCORES macro. - FM + * Create an array of dots for the UNDERSCORES macro. -FM */ memset(underscore_string, '.', (MAX_LINE-1)); underscore_string[(MAX_LINE-1)] = '\0'; underscore_string[MAX_LINE] = '\0'; /* - * Create an array of underscores for the STARS macro. - FM + * Create an array of underscores for the STARS macro. -FM */ memset(star_string, '_', (MAX_LINE-1)); star_string[(MAX_LINE-1)] = '\0'; @@ -1000,15 +1106,14 @@ PUBLIC void HText_free ARGS1( FREE(l->input_field); } - FREE(l->hightext); - FREE(l->hightext2); + LYSetHiText(l, NULL, 0); FREE(l); } FormList_delete(self->forms); /* - * Free the tabs list. - FM + * Free the tabs list. -FM */ if (self->tabs) { HTTabID * Tab = NULL; @@ -1023,7 +1128,7 @@ PUBLIC void HText_free ARGS1( } /* - * Free the hidden links list. - FM + * Free the hidden links list. -FM */ if (self->hidden_links) { char * href = NULL; @@ -1037,7 +1142,7 @@ PUBLIC void HText_free ARGS1( /* * Invoke HTAnchor_delete() to free the node_anchor - * if it is not a destination of other links. - FM + * if it is not a destination of other links. -FM */ if (self->node_anchor) { HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_STRUCTURED, @@ -1276,12 +1381,12 @@ PRIVATE int display_line ARGS4( * into LastDisplayChar if it was a multibyte * character) or hyphen, though it should have * been excluded by HText_appendCharacter() or by - * split_line() in those cases. - FM + * split_line() in those cases. -FM */ break; } else { /* - * Make it a hard hyphen and fall through. - FM + * Make it a hard hyphen and fall through. -FM */ buffer[0] = '-'; } @@ -1339,7 +1444,7 @@ PRIVATE int display_line ARGS4( * spacing characters in this code set, * but this will become an issue when * the development code set's multibyte - * character handling is used. - FM + * character handling is used. -FM */ LastDisplayChar = 'M'; } else { @@ -1395,7 +1500,7 @@ PRIVATE void display_title ARGS1( int limit; /* - * Make sure we have a text structure. - FM + * Make sure we have a text structure. -FM */ if (!text) return; @@ -1411,7 +1516,7 @@ PRIVATE void display_title ARGS1( #endif /* USE_COLOR_STYLE */ /* - * Load the title field. - FM + * Load the title field. -FM */ StrAllocCopy(title, (HTAnchor_title(text->node_anchor) ? @@ -1420,7 +1525,7 @@ PRIVATE void display_title ARGS1( /* * There shouldn't be any \n in the title field, * but if there is, lets kill it now. Also trim - * any trailing spaces. - FM + * any trailing spaces. -FM */ if ((cp = strchr(title,'\n')) != NULL) *cp = '\0'; @@ -1465,7 +1570,7 @@ PRIVATE void display_title ARGS1( /* * Generate and display the title string, with page indicator * if appropriate, preceded by the toolbar token if appropriate, - * and truncated if necessary. - FM & KW + * and truncated if necessary. -FM & KW */ if (HTCJK != NOCJK) { if (*title && @@ -1518,7 +1623,7 @@ PRIVATE void display_title ARGS1( /* * Note that this truncation is not taking into * account the possibility that multibyte - * characters might be present. - FM + * characters might be present. -FM */ #ifdef SH_EX /* 1999/06/15 (Tue) 10:17:28 */ int last; @@ -1880,11 +1985,11 @@ PRIVATE void display_page ARGS3( #ifdef USE_COLOR_STYLE /* otherwise done in display_line - kw */ /* * If the target is on this line, recursively - * seek and emphasize it. - FM + * seek and emphasize it. -FM */ data = (char *)line->data; offset = (int)line->offset; - while ((target && *target) && + while (non_empty(target) && (cp = LYno_attr_mb_strstr(data, target, text->T.output_utf8, YES, @@ -1954,7 +2059,7 @@ PRIVATE void display_page ARGS3( /* * Stop the emphasis, and reset the offset and * data pointer for our current position in the - * line. - FM + * line. -FM */ LYstopTargetEmphasis(); LYGetYX(y, offset); @@ -1963,7 +2068,7 @@ PRIVATE void display_page ARGS3( /* * Adjust the cursor position, should we be at * the end of the line, or not have another hit - * in it. - FM + * in it. -FM */ LYmove((i + 2), 0); } /* end while */ @@ -1972,7 +2077,7 @@ PRIVATE void display_page ARGS3( /* * Stop if this is the last line. Otherwise, make sure - * display_flag is set and process the next line. - FM + * display_flag is set and process the next line. -FM */ if (line == text->last_line) { /* @@ -2009,18 +2114,29 @@ PRIVATE void display_page ARGS3( Anchor_ptr->line_num <= stop_before_for_anchors; Anchor_ptr = Anchor_ptr->next) { - if (Anchor_ptr->line_num >= line_number && - Anchor_ptr->line_num < stop_before_for_anchors) { + if (Anchor_ptr->line_num >= line_number + && Anchor_ptr->line_num < stop_before_for_anchors) { + char *hi_string = LYGetHiTextStr(Anchor_ptr, 0); + /* * Load normal hypertext anchors. */ - if (Anchor_ptr->show_anchor && Anchor_ptr->hightext && - strlen(Anchor_ptr->hightext) > 0 && - (Anchor_ptr->link_type & HYPERTEXT_ANCHOR)) { + if (Anchor_ptr->show_anchor + && non_empty(hi_string) + && (Anchor_ptr->link_type & HYPERTEXT_ANCHOR)) { + int count; + char *s; + + for (count = 0; ; ++count) { + s = LYGetHiTextStr(Anchor_ptr, count); + if (count == 0) + LYSetHilite(nlinks, s); + if (s == NULL) + break; + if (count != 0) + LYAddHilite(nlinks, s, LYGetHiTextPos(Anchor_ptr, count)); + } - links[nlinks].hightext = Anchor_ptr->hightext; - links[nlinks].hightext2 = Anchor_ptr->hightext2; - links[nlinks].hightext2_offset = Anchor_ptr->hightext2offset; links[nlinks].inUnderline = Anchor_ptr->inUnderline; links[nlinks].anchor_number = Anchor_ptr->number; @@ -2072,13 +2188,13 @@ PRIVATE void display_page ARGS3( else links[nlinks].type = WWW_LINK_TYPE; links[nlinks].target = empty_string; - links[nlinks].form = NULL; + links[nlinks].l_form = NULL; nlinks++; display_flag = TRUE; } else if (Anchor_ptr->link_type == INPUT_ANCHOR - && Anchor_ptr->input_field->type != F_HIDDEN_TYPE) { + && Anchor_ptr->input_field->type != F_HIDDEN_TYPE) { /* * Handle form fields. */ @@ -2089,7 +2205,7 @@ PRIVATE void display_page ARGS3( links[nlinks].anchor_number = Anchor_ptr->number; links[nlinks].anchor_line_num = Anchor_ptr->line_num; - links[nlinks].form = FormInfo_ptr; + links[nlinks].l_form = FormInfo_ptr; links[nlinks].lx = Anchor_ptr->line_pos; links[nlinks].ly = ((Anchor_ptr->line_num + 1) - line_number); links[nlinks].type = WWW_FORM_LINK_TYPE; @@ -2098,30 +2214,23 @@ PRIVATE void display_page ARGS3( StrAllocCopy(links[nlinks].lname, empty_string); if (FormInfo_ptr->type == F_RADIO_TYPE) { - if (FormInfo_ptr->num_value) - links[nlinks].hightext = checked_radio; - else - links[nlinks].hightext = unchecked_radio; - + LYSetHilite(nlinks, + FormInfo_ptr->num_value + ? checked_radio + : unchecked_radio); } else if (FormInfo_ptr->type == F_CHECKBOX_TYPE) { - if (FormInfo_ptr->num_value) - links[nlinks].hightext = checked_box; - else - links[nlinks].hightext = unchecked_box; - + LYSetHilite(nlinks, + FormInfo_ptr->num_value + ? checked_box + : unchecked_box); } else if (FormInfo_ptr->type == F_PASSWORD_TYPE) { - links[nlinks].hightext = STARS(strlen(FormInfo_ptr->value)); - + LYSetHilite(nlinks, + STARS(strlen(FormInfo_ptr->value))); } else { /* TEXT type */ - links[nlinks].hightext = FormInfo_ptr->value; + LYSetHilite(nlinks, + FormInfo_ptr->value); } - /* - * Never a second line on form types. - */ - links[nlinks].hightext2 = NULL; - links[nlinks].hightext2_offset = 0; - nlinks++; /* * Bold the link after incrementing nlinks. @@ -2134,23 +2243,23 @@ PRIVATE void display_page ARGS3( /* * Not showing anchor. */ - if (Anchor_ptr->hightext && *Anchor_ptr->hightext) + if (non_empty(hi_string)) CTRACE((tfp, "\nGridText: Not showing link, hightext=%s\n", - Anchor_ptr->hightext)); + hi_string)); } } if (Anchor_ptr == text->last_anchor) /* - * No more links in document. - FM + * No more links in document. -FM */ break; if (nlinks == MAXLINKS) { /* * Links array is full. If interactive, tell user - * to use half-page or two-line scrolling. - FM + * to use half-page or two-line scrolling. -FM */ if (LYCursesON) { HTAlert(MAXLINKS_REACHED); @@ -2162,10 +2271,12 @@ PRIVATE void display_page ARGS3( /* * Free any un-reallocated links[] entries - * from the previous page draw. - FM + * from the previous page draw. -FM */ - for (i = nlinks; i < last_nlinks; i++) + for (i = nlinks; i < last_nlinks; i++) { + LYSetHilite(i, NULL); FREE(links[i].lname); + } last_nlinks = nlinks; /* @@ -2633,13 +2744,13 @@ PRIVATE void split_line ARGS2( unsigned plen; int i; - /* Split the line. - FM */ + /* Split the line. -FM */ prevdata[previous->size] = '\0'; previous->size = split; /* * Trim any spaces or soft hyphens from the beginning - * of our new line. - FM + * of our new line. -FM */ p = prevdata + split; while (( @@ -2679,7 +2790,7 @@ PRIVATE void split_line ARGS2( } ctrl_chars_on_this_line += utfxtra_on_this_line; - /* Add the data to the new line. - FM */ + /* Add the data to the new line. -FM */ strcat(linedata, p); line->size += plen; } @@ -2965,7 +3076,7 @@ PRIVATE void split_line ARGS2( /* * If we split the line, adjust the anchor - * structure values for the new line. - FM + * structure values for the new line. -FM */ if (s > 0) { /* if not completely empty */ @@ -3503,7 +3614,7 @@ PUBLIC void HText_appendCharacter ARGS2( if (ch == CH_ESC) { /* S/390 -- gil -- 1536 */ /* ** Setting up for CJK escape sequence handling (based on - ** Takuya ASADA's (asada@three-a.co.jp) CJK Lynx). - FM + ** Takuya ASADA's (asada@three-a.co.jp) CJK Lynx). -FM */ text->state = S_esc; text->kanji_buf = '\0'; @@ -3561,7 +3672,7 @@ PUBLIC void HText_appendCharacter ARGS2( */ if (ch == 'B' || ch == 'J' || ch == 'T') { /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; text->state = S_text; @@ -3569,7 +3680,7 @@ PUBLIC void HText_appendCharacter ARGS2( } else if (ch == 'I') { text->state = S_jisx0201_text; /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; text->kcode = JIS; @@ -3655,7 +3766,7 @@ PUBLIC void HText_appendCharacter ARGS2( } else { text->kanji_buf = ch; /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; return; @@ -3717,7 +3828,7 @@ PUBLIC void HText_appendCharacter ARGS2( /* * Ignore the soft hyphen if it is the first character * on the line, or if it is preceded by a space or - * hyphen. - FM + * hyphen. -FM */ if (line->size < 1 || text->permissible_split >= line->size) { return; @@ -3870,7 +3981,7 @@ PUBLIC void HText_appendCharacter ARGS2( if (line->size > 0 && line->data[line->size-1] == LY_SOFT_HYPHEN) { /* * A tab shouldn't follow a soft hyphen, so - * if one does, we'll dump the soft hyphen. - FM + * if one does, we'll dump the soft hyphen. -FM */ line->data[--line->size] = '\0'; ctrl_chars_on_this_line--; @@ -3915,7 +4026,7 @@ PUBLIC void HText_appendCharacter ARGS2( new_line(text); } else { /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = line->size; if (target_cu > (WRAP_COLS(text)-1)) @@ -3963,7 +4074,7 @@ check_WrapSource: if (ch == ' ') { /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; /* @@ -4202,7 +4313,7 @@ check_WrapSource: if (ch == LY_SOFT_HYPHEN) { ctrl_chars_on_this_line++; /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; } @@ -4792,8 +4903,6 @@ PUBLIC int HText_beginAnchor ARGS3( if (a == NULL) outofmem(__FILE__, "HText_beginAnchor"); - a->hightext = NULL; - a->hightext2 = NULL; a->inUnderline = underline; a->line_num = text->Lines; @@ -4842,7 +4951,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * a particular anchor. This allows us to set links * for positions indicated by NAME or ID attributes, * without needing to close any anchor with an HREF - * within which that link might be embedded. - FM + * within which that link might be embedded. -FM */ if (number <= 0 || number == text->last_anchor->number) { a = text->last_anchor; @@ -4856,7 +4965,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * There's no anchor with that number, * so we'll default to the last anchor, - * and cross our fingers. - FM + * and cross our fingers. -FM */ a = text->last_anchor; } @@ -4907,19 +5016,19 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * Check if the anchor content has only * white and special characters, starting - * with the content on the last line. - FM + * with the content on the last line. -FM */ a->extent += extent_adjust; if (a->extent > (int)last->size) { /* * The anchor extends over more than one line, - * so set up to check the entire last line. - FM + * so set up to check the entire last line. -FM */ i = last->size; } else { /* * The anchor is restricted to the last line, - * so check from the start of the anchor. - FM + * so check from the start of the anchor. -FM */ i = a->extent; } @@ -4939,14 +5048,14 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * The anchor starts on a preceding line, and * the last line has only white and special * characters, so declare the entire extent - * of the last line as blank. - FM + * of the last line as blank. -FM */ CurBlankExtent = BlankExtent = last->size; } else { /* * The anchor starts on the last line, and * has only white or special characters, so - * declare the anchor's extent as blank. - FM + * declare the anchor's extent as blank. -FM */ CurBlankExtent = BlankExtent = a->extent; } @@ -4957,7 +5066,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * checked has only white and special characters, * check whether the anchor's content on the * immediately preceding line also has only - * white and special characters. - FM + * white and special characters. -FM */ while (i == 0 && (a->extent > CurBlankExtent || @@ -4971,13 +5080,13 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( if (j < 0) { /* * The anchor starts on a preceding line, - * so check all of this line. - FM + * so check all of this line. -FM */ j = 0; i = prev->size; } else { /* - * The anchor starts on this line. - FM + * The anchor starts on this line. -FM */ i = a->extent - CurBlankExtent; } @@ -5001,7 +5110,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * This line has only white and special * characters, so treat its entire extent * as blank, and decrement the pointer for - * the line to be analyzed. - FM + * the line to be analyzed. -FM */ CurBlankExtent += prev->size; BlankExtent = CurBlankExtent; @@ -5010,7 +5119,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * The anchor starts on this line, and it * has only white or special characters, so - * declare the anchor's extent as blank. - FM + * declare the anchor's extent as blank. -FM */ BlankExtent = a->extent; break; @@ -5025,7 +5134,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * It's an invisible anchor probably from an ALT="" * or an ignored ISMAP attribute due to a companion - * USEMAP. - FM + * USEMAP. -FM */ a->show_anchor = NO; @@ -5036,7 +5145,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * If links are numbered, then try to get rid of the - * numbered bracket and adjust the anchor count. - FM + * 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 @@ -5053,16 +5162,16 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * Set start->data[j] to the close-square-bracket, * or to the beginning of the line on which the - * anchor start. - FM + * anchor start. -FM */ if (start == last) { /* - * The anchor starts on the last line. - FM + * The anchor starts on the last line. -FM */ j = (last->size - a->extent - 1); } else { /* - * The anchor starts on a previous line. - FM + * The anchor starts on a previous line. -FM */ prev = start->prev; j = (start->size - a->extent + CurBlankExtent - 1); @@ -5078,7 +5187,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * a close-square-bracket, check whether we had a wrap * and the close-square-bracket is at the end of the * previous line. If so, strip the numbered bracket - * from that line. - FM + * from that line. -FM */ if (start->data[j] == ']') { j--; @@ -5094,7 +5203,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( if (start->data[j] == '[') { /* * The numbered bracket is entirely - * on this line. - FM + * on this line. -FM */ NumSize++; if (start==last && (int)text->permissible_split > j) { @@ -5135,7 +5244,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * The numbered bracket started on the * previous line, and part of it was - * wrapped to this line. - FM + * wrapped to this line. -FM */ NumSize++; l = (i - j); @@ -5168,14 +5277,14 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( } else { /* * Shucks! We didn't find the - * numbered bracket. - FM + * numbered bracket. -FM */ a->show_anchor = YES; } } else { /* * Shucks! We didn't find the - * numbered bracket. - FM + * numbered bracket. -FM */ a->show_anchor = YES; } @@ -5205,7 +5314,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * The numbered bracket is all on the * previous line, and the anchor content - * was wrapped to the last line. - FM + * was wrapped to the last line. -FM */ NumSize++; k = j + NumSize; @@ -5218,21 +5327,21 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( } else { /* * Shucks! We didn't find the - * numbered bracket. - FM + * numbered bracket. -FM */ a->show_anchor = YES; } } else { /* * Shucks! We didn't find the - * numbered bracket. - FM + * numbered bracket. -FM */ a->show_anchor = YES; } } else { /* * Shucks! We didn't find the - * numbered bracket. - FM + * numbered bracket. -FM */ a->show_anchor = YES; } @@ -5243,7 +5352,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * The anchor's content is not restricted to only * white and special characters, so we'll show it - * as a link. - FM + * as a link. -FM */ a->show_anchor = YES; if (BlankExtent) { @@ -5259,7 +5368,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * and special characters, so set its number * and extent to zero, decrement the visible * anchor number counter, and add this anchor - * to the hidden links list. - FM + * to the hidden links list. -FM */ a->extent = 0; if (text->hiddenlinkflag != HIDDENLINKS_MERGE) { @@ -5272,7 +5381,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( * The anchor's content is not restricted to white * and special characters, so we'll display the * content, but shorten its extent by any trailing - * blank lines we've detected. - FM + * blank lines we've detected. -FM */ a->extent -= ((BlankExtent < a->extent) ? BlankExtent : 0); @@ -5290,7 +5399,7 @@ PRIVATE BOOL HText_endAnchor0 ARGS3( /* * It's a named anchor without an HREF, so it * should be registered but not shown as a - * link. - FM + * link. -FM */ a->show_anchor = NO; a->extent = 0; @@ -5349,8 +5458,7 @@ PRIVATE int remove_special_attr_chars ARGS1( */ soft_newline_count += (*cp == LY_SOFT_NEWLINE); if (!IsSpecialAttrChar(*cp)) { - *buf = *cp, - buf++; + *buf++ = *cp; } } *buf = '\0'; @@ -5424,7 +5532,7 @@ PUBLIC void HText_endAppend ARGS1( /* * Fix up the anchor structure values and - * create the hightext strings. - FM + * create the hightext strings. -FM */ HText_trimHightext(text, TRUE, -1); } @@ -5445,12 +5553,13 @@ PUBLIC void HText_endAppend ARGS1( ** extent fields are counting bytes in the HTLine data, including ** invisible special attribute chars and counting UTF-8 multibyte ** characters as multiple bytes. -** AFTER the adjustment, the anchor line_pos (and hightext2offset -** if applicable) fields indicate x positions in terms of displayed -** character cells, and the extent field apparently is unimportant; -** the anchor text has been copied to the hightext (and possibly -** hightext2) fields (which should have been NULL up to that point), -** with special attribute chars removed. +** +** AFTER the adjustment, the anchor line_pos (and hightext offset if +** applicable) fields indicate x positions in terms of displayed character +** cells, and the extent field apparently is unimportant; the anchor text has +** been copied to the hightext fields (which should have been NULL up to that +** point), with special attribute chars removed. +** ** This needs to be done so that display_page finds the anchors in the ** form it expects when it sets the links[] elements. */ @@ -5463,7 +5572,12 @@ PRIVATE void HText_trimHightext ARGS3( TextAnchor *anchor_ptr; TextAnchor *prev_a = NULL; HTLine *line_ptr; + HTLine *line_ptr2; unsigned char ch; + char *hilite_str; + int hilite_len; + int actual_len; + int count_line; if (!text) return; @@ -5486,7 +5600,7 @@ PRIVATE void HText_trimHightext ARGS3( /* * Fix up the anchor structure values and - * create the hightext strings. - FM + * create the hightext strings. -FM */ for (anchor_ptr = text->first_anchor; anchor_ptr; @@ -5528,7 +5642,7 @@ re_parse: * done the trimming & adjusting for this anchor, so avoid * doing it a second time. - kw */ - if (anchor_ptr->hightext) + if ((hilite_str = LYGetHiTextStr(anchor_ptr, 0)) != NULL) continue; if (anchor_ptr->line_pos > (int) line_ptr->size) { @@ -5564,11 +5678,12 @@ re_parse: CTRACE((tfp, "anchor text: '%s'\n", line_ptr->data)); /* - * If the link begins with an end of line and we have more - * lines, then start the highlighting on the next line. - FM - * But if an empty anchor is at the end of line and empty, - * keep it where it is, unless the previous anchor in the list - * (if any) already starts later. - kw + * If the link begins with an end of line and we have more lines, then + * start the highlighting on the next line. -FM. + * + * But if an empty anchor is at the end of line and empty, keep it + * where it is, unless the previous anchor in the list (if any) already + * starts later. - kw */ if ((unsigned)anchor_ptr->line_pos >= strlen(line_ptr->data)) { if (cur_line < text->Lines && @@ -5586,61 +5701,76 @@ re_parse: } /* - * Copy the link name into the data structure. + * Copy the link name into the data structure. */ - if (line_ptr->data && - anchor_ptr->extent > 0 && anchor_ptr->line_pos >= 0) { - StrnAllocCopy(anchor_ptr->hightext, - &line_ptr->data[anchor_ptr->line_pos], - anchor_ptr->extent); + if (line_ptr->data + && anchor_ptr->extent > 0 + && anchor_ptr->line_pos >= 0) { + LYSetHiText(anchor_ptr, + &line_ptr->data[anchor_ptr->line_pos], + anchor_ptr->extent); } else { - StrAllocCopy(anchor_ptr->hightext, ""); + LYSetHiText(anchor_ptr, "", 0); } /* - * If true the anchor extends over two lines, - * copy that into the data structure. + * If the anchor extends over more than one line, copy that into the + * data structure. */ - if ((unsigned)anchor_ptr->extent > strlen(anchor_ptr->hightext)) { - HTLine *line_ptr2 = line_ptr->next; - - if (!final) { - if (cur_line + 1 >= stop_before) { - FREE(anchor_ptr->hightext); /* bail out */ - break; - } + hilite_str = LYGetHiTextStr(anchor_ptr, 0); + hilite_len = strlen(hilite_str); + actual_len = anchor_ptr->extent; + + line_ptr2 = line_ptr; + count_line = cur_line; + while (actual_len > hilite_len) { + count_line++; + line_ptr2 = line_ptr2->next; + + if (!final + && count_line >= stop_before) { + LYSetHiText(anchor_ptr, NULL, 0); + break; } + /* - * Double check that we have a line pointer, - * and if so, copy into hightext2. + * Double check that we have a line pointer, and if so, copy into + * highlight text. */ if (line_ptr2) { - StrnAllocCopy(anchor_ptr->hightext2, + char *hi_string = NULL; + int hi_offset = line_ptr2->offset; + + StrnAllocCopy(hi_string, line_ptr2->data, - (anchor_ptr->extent - - strlen(anchor_ptr->hightext))); - anchor_ptr->hightext2offset = line_ptr2->offset; + (actual_len - hilite_len)); + actual_len -= strlen(hi_string); /*handle LY_SOFT_NEWLINEs -VH */ - anchor_ptr->hightext2offset += - remove_special_attr_chars(anchor_ptr->hightext2); + hi_offset += remove_special_attr_chars(hi_string); if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { - LYTrimTrailing(anchor_ptr->hightext2); - if (anchor_ptr->hightext2[0] == '\0') { - FREE(anchor_ptr->hightext2); - anchor_ptr->hightext2offset = 0; - } + LYTrimTrailing(hi_string); + } + if (non_empty(hi_string)) { + LYAddHiText(anchor_ptr, hi_string, hi_offset); } + FREE(hi_string); } } - remove_special_attr_chars(anchor_ptr->hightext); + + if (!final + && count_line >= stop_before) { + break; + } + + hilite_str = LYGetHiTextStr(anchor_ptr, 0); + remove_special_attr_chars(hilite_str); if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) { - LYTrimTrailing(anchor_ptr->hightext); + LYTrimTrailing(hilite_str); } /* - * Subtract any formatting characters from the x position - * of the link. + * Subtract any formatting characters from the x position of the link. */ if (anchor_ptr->line_pos > 0) { register int offset = 0, i = 0; @@ -5709,7 +5839,7 @@ PUBLIC HTChildAnchor * HText_childNumber ARGS1( /* * HText_FormDescNumber() returns a description of the form field * with index N. The index corresponds to the [number] we print - * for the field. - FM & LE + * for the field. -FM & LE */ PUBLIC void HText_FormDescNumber ARGS2( int, number, @@ -5982,7 +6112,7 @@ PUBLIC int HTGetLinkInfo ARGS6( } return(LINK_LINE_FOUND); } else { - *hightext= a->hightext; + *hightext = LYGetHiTextStr(a, 0); link_dest = HTAnchor_followMainLink((HTAnchor *)a->anchor); { char *cp_freeme = NULL; @@ -6057,7 +6187,7 @@ PRIVATE BOOLEAN same_anchor_or_field ARGS5( #define same_anchor_as_link(i,a,ta_same) (i >= 0 && a &&\ same_anchor_or_field(links[i].anchor_number,\ - (links[i].type == WWW_FORM_LINK_TYPE) ? links[i].form : NULL,\ + (links[i].type == WWW_FORM_LINK_TYPE) ? links[i].l_form : NULL,\ a->number,\ (a->link_type == INPUT_ANCHOR) ? a->input_field : NULL,\ ta_same)) @@ -6085,7 +6215,7 @@ PUBLIC BOOL HText_TAHasMoreLines ARGS2( if (direction < 0) { for (a = HTMainText->first_anchor; a; prev_a = a, a = a->next) { if (a->link_type == INPUT_ANCHOR && - links[curlink].form == a->input_field) { + links[curlink].l_form == a->input_field) { return same_anchors(a, prev_a, TRUE); } if (links[curlink].anchor_number && @@ -6098,7 +6228,7 @@ PUBLIC BOOL HText_TAHasMoreLines ARGS2( if (a == HTMainText->last_anchor) break; if (a->link_type == INPUT_ANCHOR && - links[curlink].form == a->input_field) { + links[curlink].l_form == a->input_field) { return same_anchors(a, a->next, TRUE); } if (links[curlink].anchor_number && @@ -6321,7 +6451,7 @@ PUBLIC int HTGetLinkOrFieldStart ARGS5( * *data with all IsSpecial characters stripped, its offset and * the printable target length (without IsSpecial, or extra CJK * or utf8 characters) are loaded into *offset and *tLen, and - * TRUE is returned. - FM + * TRUE is returned. -FM */ PUBLIC BOOL HText_getFirstTargetInLine ARGS7( HText *, text, @@ -6339,14 +6469,16 @@ PUBLIC BOOL HText_getFirstTargetInLine ARGS7( /* * Make sure we have an HText structure, that line_num is - * in its range, and that we have a target string. - FM + * in its range, and that we have a target string. -FM */ - if (!(text && line_num >= 0 && line_num <= text->Lines && - target && *target)) + if (!(text + && line_num >= 0 + && line_num <= text->Lines + && non_empty(target))) return(FALSE); /* - * Find the line and set up its data and offset - FM + * Find the line and set up its data and offset -FM */ for (i = 0, line = FirstHTLine(text); i < line_num && (line != text->last_line); @@ -6364,7 +6496,7 @@ PUBLIC BOOL HText_getFirstTargetInLine ARGS7( * If the target is on the line, load the offset of * its first character and the subsequent line data, * strip any special characters from the loaded line - * data, and return TRUE. - FM + * data, and return TRUE. -FM */ if (((cp = LYno_attr_mb_strstr(LineData, target, @@ -6376,7 +6508,7 @@ PUBLIC BOOL HText_getFirstTargetInLine ARGS7( * We had a hit so load the results, * remove IsSpecial characters from * the allocated data string, and - * return TRUE. - FM + * return TRUE. -FM */ *offset = (LineOffset + HitOffset); *tLen = (LenNeeded - HitOffset); @@ -6386,7 +6518,7 @@ PUBLIC BOOL HText_getFirstTargetInLine ARGS7( } /* - * The line does not contain the target. - FM + * The line does not contain the target. -FM */ return(FALSE); } @@ -6421,7 +6553,7 @@ PUBLIC CONST char *HText_getStyle NOARGS /* * HText_getSugFname returns the suggested filename of the current * document (normally derived from a Content-Disposition header with - * attachment; filename=name.suffix). - FM + * attachment; filename=name.suffix). -FM */ PUBLIC CONST char * HText_getSugFname NOARGS { @@ -6435,7 +6567,7 @@ PUBLIC CONST char * HText_getSugFname NOARGS * or truncates the string's suffix if appropriate, based on whether * the anchor indicates that the file is compressed. We assume * that the file was not uncompressed (as when downloading), and - * believe the headers about whether it's compressed or not. - FM + * believe the headers about whether it's compressed or not. -FM * * Added third arg - if strip_ok is FALSE, we don't trust the anchor * info enough to remove a compression suffix if the anchor object @@ -6455,7 +6587,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( CompressFileType second; /* - * Make sure we have a string and anchor. - FM + * Make sure we have a string and anchor. -FM */ if (!(fn && anchor)) return; @@ -6468,14 +6600,14 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * Check the anchor's content_type and content_encoding - * elements for a gzip or Unix compressed file. - FM + * elements for a gzip or Unix compressed file. -FM */ ct = HTAnchor_content_type(anchor); ce = HTAnchor_content_encoding(anchor); if (ce == NULL && ct != 0) { /* * No Content-Encoding, so check - * the Content-Type. - FM + * the Content-Type. -FM */ if (!strncasecomp(ct, "application/gzip", 16) || !strncasecomp(ct, "application/x-gzip", 18)) { @@ -6521,7 +6653,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * Seek the last dot, and check whether - * we have a gzip or compress suffix. - FM + * we have a gzip or compress suffix. -FM */ if ((dot = strrchr(fn, '.')) != NULL) { if (HTCompressFileType(fn, ".", &cp) != cftNone) { @@ -6529,7 +6661,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * It has a suffix which signifies a gzipped * or compressed file for us, but the anchor - * claims otherwise, so tweak the suffix. - FM + * claims otherwise, so tweak the suffix. -FM */ *dot = '\0'; } @@ -6540,7 +6672,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * It has a tail which signifies a gzipped * file for us, but the anchor claims otherwise, - * so tweak the suffix. - FM + * so tweak the suffix. -FM */ if (cp == dot+1) cp--; @@ -6549,7 +6681,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * The anchor claims it's gzipped, and we * believe it, so force this tail to the - * conventional suffix. - FM + * conventional suffix. -FM */ #ifdef VMS *cp = '-'; @@ -6581,7 +6713,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( } /* - * Add the appropriate suffix. - FM + * Add the appropriate suffix. -FM */ if (*suffix) { if (!dot) { @@ -6599,7 +6731,7 @@ PUBLIC void HTCheckFnameForCompression ARGS3( /* * HText_getLastModified returns the Last-Modified header - * if available, for the current document. - FM + * if available, for the current document. -FM */ PUBLIC CONST char * HText_getLastModified NOARGS { @@ -6609,7 +6741,7 @@ PUBLIC CONST char * HText_getLastModified NOARGS /* * HText_getDate returns the Date header - * if available, for the current document. - FM + * if available, for the current document. -FM */ PUBLIC CONST char * HText_getDate NOARGS { @@ -6619,7 +6751,7 @@ PUBLIC CONST char * HText_getDate NOARGS /* * HText_getServer returns the Server header - * if available, for the current document. - FM + * if available, for the current document. -FM */ PUBLIC CONST char * HText_getServer NOARGS { @@ -6688,7 +6820,7 @@ PUBLIC BOOL HText_pageHasPrevTarget NOARGS /* * HText_LinksInLines returns the number of links in the - * 'Lines' number of lines beginning with 'line_num'-1. - FM + * 'Lines' number of lines beginning with 'line_num'-1. -FM */ PUBLIC int HText_LinksInLines ARGS3( HText *, text, @@ -6828,7 +6960,7 @@ PUBLIC BOOL HText_select ARGS1( HTMainAnchor = text->node_anchor; /* - * Make this text the most current in the loaded texts list. - FM + * Make this text the most current in the loaded texts list. -FM */ if (loaded_texts && HTList_removeObject(loaded_texts, text)) HTList_addObject(loaded_texts, text); @@ -6841,7 +6973,7 @@ PUBLIC BOOL HText_select ARGS1( /* * This function returns TRUE if doc's post_data, address * and isHEAD elements are identical to those of a loaded - * (memory cached) text. - FM + * (memory cached) text. -FM */ PUBLIC BOOL HText_POSTReplyLoaded ARGS1( document *, doc) @@ -6852,13 +6984,13 @@ PUBLIC BOOL HText_POSTReplyLoaded ARGS1( BOOL is_head; /* - * Make sure we have the structures. - FM + * Make sure we have the structures. -FM */ if (!cur || !doc) return(FALSE); /* - * Make sure doc is for a POST reply. - FM + * Make sure doc is for a POST reply. -FM */ if ((post_data = doc->post_data) == NULL || (address = doc->address) == NULL) @@ -6867,7 +6999,7 @@ PUBLIC BOOL HText_POSTReplyLoaded ARGS1( /* * Loop through the loaded texts looking for a - * POST reply match. - FM + * POST reply match. -FM */ while (NULL != (text = (HText *)HTList_nextObject(cur))) { if (text->node_anchor && @@ -7059,7 +7191,7 @@ PUBLIC HTAnchor * HText_linkSelTo ARGS2( } /* - * Utility for freeing the list of previous isindex and whereis queries. - FM + * Utility for freeing the list of previous isindex and whereis queries. -FM */ PUBLIC void HTSearchQueries_free NOARGS { @@ -7079,7 +7211,7 @@ PUBLIC void HTSearchQueries_free NOARGS /* * Utility for listing isindex and whereis queries, making - * any repeated queries the most current in the list. - FM + * any repeated queries the most current in the list. -FM */ PUBLIC void HTAddSearchQuery ARGS1( char *, query) @@ -7088,7 +7220,7 @@ PUBLIC void HTAddSearchQuery ARGS1( char *old; HTList *cur; - if (!(query && *query)) + if (!non_empty(query)) return; StrAllocCopy(new_query, query); @@ -7140,7 +7272,7 @@ PUBLIC int do_www_search ARGS1( HTUnEscape(searchstring); strcpy(temp, searchstring); /* - * Make sure it's treated as the most recent query. - FM + * Make sure it's treated as the most recent query. -FM */ HTAddSearchQuery(searchstring); } else { @@ -7172,19 +7304,19 @@ get_query: if (recall && ch == UPARROW) { if (PreviousSearch) { /* - * Use the second to last query in the list. - FM + * Use the second to last query in the list. -FM */ QueryNum = 1; PreviousSearch = FALSE; } 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, @@ -7203,19 +7335,19 @@ get_query: } else if (recall && ch == DNARROW) { if (PreviousSearch) { /* - * Use the first query in the list. - FM + * Use the first query in the list. -FM */ QueryNum = QueryTotal - 1; PreviousSearch = FALSE; } 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, @@ -7241,7 +7373,7 @@ get_query: } /* - * Strip leaders and trailers. - FM + * Strip leaders and trailers. -FM */ LYTrimLeading(searchstring); if (!(*searchstring)) { @@ -7260,7 +7392,7 @@ get_query: /* * Add searchstring to the query list, - * or make it the most current. - FM + * or make it the most current. -FM */ HTAddSearchQuery(searchstring); @@ -7309,7 +7441,7 @@ get_query: * If it's redirection, use_this_url_instead is set, and * mainloop() will deal with it such that security features * and restrictions are checked before acting on the URL, or - * rejecting it. - FM + * rejecting it. -FM */ return(NOT_FOUND); } @@ -7373,7 +7505,7 @@ PUBLIC void print_wwwfile_to_fd ARGS2( if (!first && line->data[0] != LY_SOFT_NEWLINE) { fputc('\n',fp); /* - * Add news-style quotation if requested. - FM + * Add news-style quotation if requested. -FM */ if (is_reply) { fputc('>',fp); @@ -7586,26 +7718,29 @@ PRIVATE BOOL anchor_has_target ARGS2( { OptionType * option; char *stars = NULL, *cp; + int count; /* - * Search the hightext string, and hightext2 if present, - * taking the case_sensitive setting into account. - FM + * Search the hightext strings, taking the case_sensitive setting into + * account. -FM */ - if (LYno_attr_strstr(a->hightext, target) - || LYno_attr_strstr(a->hightext2, target)) { - return TRUE; + for (count = 0; ; ++count) { + if ((cp = LYGetHiTextStr(a, count)) == NULL) + break; + if (LYno_attr_strstr(cp, target)) + return TRUE; } /* * Search the relevant form fields, taking the - * case_sensitive setting into account. - FM + * 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 + * the displayed string. -FM */ if (LYno_attr_strstr(a->input_field->value, target)) { return TRUE; @@ -7621,7 +7756,7 @@ PRIVATE BOOL anchor_has_target ARGS2( } else if (a->input_field->type == F_OPTION_LIST_TYPE) { /* * Search the option strings that are displayed - * when the popup is invoked. - FM + * when the popup is invoked. -FM */ option = a->input_field->select_list; while (option != NULL) { @@ -7632,7 +7767,7 @@ PRIVATE BOOL anchor_has_target ARGS2( } } else if (a->input_field->type == F_RADIO_TYPE) { /* - * Search for checked or unchecked parens. - FM + * Search for checked or unchecked parens. -FM */ if (a->input_field->num_value) { cp = checked_radio; @@ -7644,7 +7779,7 @@ PRIVATE BOOL anchor_has_target ARGS2( } } else if (a->input_field->type == F_CHECKBOX_TYPE) { /* - * Search for checked or unchecked square brackets. - FM + * Search for checked or unchecked square brackets. -FM */ if (a->input_field->num_value) { cp = checked_box; @@ -7656,10 +7791,9 @@ PRIVATE BOOL anchor_has_target ARGS2( } } 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 + * 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 (LYno_attr_strstr(a->input_field->value, target)) { return TRUE; @@ -8368,7 +8502,7 @@ PUBLIC BOOL HText_inLineOne ARGS1( * the removed line (i.e., control characters, or it * wouldn't have tested blank) should have been * reiterated by split_line() in the retained blank - * line. - FM + * line. -FM */ PUBLIC void HText_RemovePreviousLine ARGS1( HText *, text) @@ -8393,7 +8527,7 @@ PUBLIC void HText_RemovePreviousLine ARGS1( * alignment is HT_LEFT. The offset is still zero, * because that's not determined for HT_CENTER or * HT_RIGHT until subsequent characters are received - * and split_line() is called. - FM + * and split_line() is called. -FM */ PUBLIC int HText_getCurrentColumn ARGS1( HText *, text) @@ -8424,7 +8558,7 @@ PUBLIC int HText_getMaximumColumn ARGS1( /* * NOTE: This function uses HText_getCurrentColumn() which * presently is correct only if the alignment is - * HT_LEFT. - FM + * HT_LEFT. -FM */ PUBLIC void HText_setTabID ARGS2( HText *, text, @@ -8467,7 +8601,7 @@ PUBLIC int HText_getTabIDColumn ARGS2( HTTabID * Tab; HTList * cur = text->tabs; - if (text && name && *name && cur) { + if (text && non_empty(name) && cur) { while (NULL != (Tab = (HTTabID *)HTList_nextObject(cur))) { if (Tab->name && !strcmp(Tab->name, name)) break; @@ -8487,7 +8621,7 @@ PUBLIC int HText_getTabIDColumn ARGS2( * 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 + * count. -FM */ PRIVATE void HText_AddHiddenLink ARGS2( HText *, text, @@ -8496,14 +8630,14 @@ PRIVATE void HText_AddHiddenLink ARGS2( HTAnchor *dest; /* - * Make sure we have an HText structure and anchor. - FM + * 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 it hasn't been already. -FM */ if (text->hidden_links == NULL) text->hidden_links = HTList_new(); @@ -8511,7 +8645,7 @@ PRIVATE void HText_AddHiddenLink ARGS2( /* * Store the address, in reverse list order * so that first in will be first out on - * retrievals. - FM + * retrievals. -FM */ if ((dest = HTAnchor_followMainLink((HTAnchor *)textanchor->anchor)) && (text->hiddenlinkflag != HIDDENLINKS_IGNORE || @@ -8523,7 +8657,7 @@ PRIVATE void HText_AddHiddenLink ARGS2( /* * This function returns the number of addresses - * that are loaded in text->hidden_links. - FM + * that are loaded in text->hidden_links. -FM */ PUBLIC int HText_HiddenLinkCount ARGS1( HText *, text) @@ -8539,7 +8673,7 @@ PUBLIC int HText_HiddenLinkCount ARGS1( /* * 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 + * text->hidden_links list of the number argument. -FM */ PUBLIC char * HText_HiddenLinkAt ARGS2( HText *, text, @@ -8581,7 +8715,7 @@ PUBLIC void HText_beginForm ARGS5( HTFormDisabled = FALSE; /* - * Check the ACTION. - FM + * Check the ACTION. -FM */ if (action != NULL) { if (!strncmp(action, "mailto:", 7)) { @@ -8593,16 +8727,16 @@ PUBLIC void HText_beginForm ARGS5( StrAllocCopy(HTFormAction, HTLoadedDocumentURL()); /* - * Check the METHOD. - FM + * Check the METHOD. -FM */ if (method != NULL && HTFormMethod != URL_MAIL_METHOD) if (!strcasecomp(method,"post") || !strcasecomp(method,"pget")) HTFormMethod = URL_POST_METHOD; /* - * Check the ENCTYPE. - FM + * Check the ENCTYPE. -FM */ - if ((enctype != NULL) && *enctype) { + if (non_empty(enctype)) { StrAllocCopy(HTFormEnctype, enctype); if (HTFormMethod != URL_MAIL_METHOD && !strncasecomp(enctype, "multipart/form-data", 19)) @@ -8612,9 +8746,9 @@ PUBLIC void HText_beginForm ARGS5( } /* - * Check the TITLE. - FM + * Check the TITLE. -FM */ - if ((title != NULL) && *title) + if (non_empty(title)) StrAllocCopy(HTFormTitle, title); else FREE(HTFormTitle); @@ -8662,18 +8796,18 @@ PUBLIC void HText_endForm ARGS1( if (HTFormFields == 1 && text && text->first_anchor) { /* * Support submission of a single text input field in - * the form via <return> instead of a submit button. - FM + * the form via <return> instead of a submit button. -FM */ TextAnchor * a = text->first_anchor; /* - * Go through list of anchors and get our input field. - FM + * Go through list of anchors and get our input field. -FM */ while (a) { if (a->link_type == INPUT_ANCHOR && a->input_field->number == HTFormNumber && a->input_field->type == F_TEXT_TYPE) { /* - * Got it. Make it submitting. - FM + * Got it. Make it submitting. -FM */ a->input_field->submit_action = NULL; StrAllocCopy(a->input_field->submit_action, HTFormAction); @@ -8815,7 +8949,7 @@ PRIVATE char * HText_skipOptionNumPrefix ARGS1( */ char *cp = opname; - if ((cp && *cp && *cp++ == '(') && + if ((non_empty(cp) && *cp++ == '(') && *cp && isdigit(UCH(*cp++))) { while (*cp && isdigit(UCH(*cp))) ++cp; @@ -8897,7 +9031,7 @@ PUBLIC char * HText_setLastOptionValue ARGS7( fields_are_numbered()) { /* * Collapse any space between the popup option - * prefix and actual value. - FM + * prefix and actual value. -FM */ if ((cp1 = HText_skipOptionNumPrefix(cp)) > cp) { i = 0, j = (cp1 - cp); @@ -9152,7 +9286,7 @@ PUBLIC int HText_beginInput ARGS3( * to a radio button, and it's the first with this name, make * sure it's checked by default. Otherwise, if it's checked, * uncheck the default or any preceding radio button with this - * name that was checked. - FM + * name that was checked. -FM */ if (I->type != NULL && !strcmp(I->type,"OPTION") && HTCurSelectGroupType == F_RADIO_TYPE && LYSelectPopups == FALSE) { @@ -9194,7 +9328,7 @@ PUBLIC int HText_beginInput ARGS3( a->link_type = INPUT_ANCHOR; a->show_anchor = YES; - a->hightext = NULL; + LYSetHiText(a, NULL, 0); a->extent = 2; a->input_field = f; @@ -9207,7 +9341,7 @@ PUBLIC int HText_beginInput ARGS3( HTFormFields++; /* - * Set the no_cache flag if the METHOD is POST. - FM + * Set the no_cache flag if the METHOD is POST. -FM */ if (HTFormMethod == URL_POST_METHOD) f->no_cache = TRUE; @@ -9329,7 +9463,7 @@ PUBLIC int HText_beginInput ARGS3( f->type = F_KEYGEN_TYPE; } else { /* - * Note that TYPE="scribble" defaults to TYPE="text". - FM + * Note that TYPE="scribble" defaults to TYPE="text". -FM */ f->type = F_TEXT_TYPE; /* default */ } @@ -9375,7 +9509,7 @@ PUBLIC int HText_beginInput ARGS3( /* * Set VALUE, if it exists. Otherwise, if it's not - * an option list make it a zero-length string. - FM + * an option list make it a zero-length string. -FM */ if (IValue != NULL) { /* @@ -9407,7 +9541,7 @@ PUBLIC int HText_beginInput ARGS3( * Run checks and fill in necessary values. */ if (f->type == F_RESET_TYPE) { - if (f->value && *f->value != '\0') { + if (non_empty(f->value)) { f->size = strlen(f->value); } else { StrAllocCopy(f->value, "Reset"); @@ -9415,7 +9549,7 @@ PUBLIC int HText_beginInput ARGS3( } } else if (f->type == F_IMAGE_SUBMIT_TYPE || f->type == F_SUBMIT_TYPE) { - if (f->value && *f->value != '\0') { + if (non_empty(f->value)) { f->size = strlen(f->value); } else if (f->type == F_IMAGE_SUBMIT_TYPE) { StrAllocCopy(f->value, "[IMAGE]-Submit"); @@ -9523,7 +9657,7 @@ PUBLIC int HText_beginInput ARGS3( * the most we could highlight on overwrites, and/or * handle in the line editor. The actual values for * text entry lines can be long, and will be scrolled - * horizontally within the editing window. - FM + * horizontally within the editing window. -FM */ MaximumSize -= (1 + (int)text->style->leftIndent + @@ -9551,7 +9685,7 @@ PUBLIC int HText_beginInput ARGS3( * For all other fields we limit the size element to * 10 less than the screen width, because either they * are types with small placeholders, and/or are a - * type which is handled via a popup window. - FM + * type which is handled via a popup window. -FM */ MaximumSize -= 10; break; @@ -9660,7 +9794,7 @@ PRIVATE double get_trans_q ARGS2( UCGetLYhndl_byMIME(givenmime)); if (!tq) return 0.0; - if (p && *p) { + if (non_empty(p)) { char *pair, *field = p, *pval, *ptok; /* Get all the parameters to the Charset */ while ((pair = HTNextTok(&field, ";", "\"", NULL)) != NULL) { @@ -9905,7 +10039,7 @@ PUBLIC int HText_SubmitForm ARGS4( if (submit_item->submit_action) { /* - * If we're mailing, make sure it's a mailto ACTION. - FM + * If we're mailing, make sure it's a mailto ACTION. -FM */ if ((submit_item->submit_method == URL_MAIL_METHOD) && strncmp(submit_item->submit_action, "mailto:", 7)) { @@ -9917,13 +10051,13 @@ PUBLIC int HText_SubmitForm ARGS4( } /* - * Check the ENCTYPE and set up the appropriate variables. - FM + * Check the ENCTYPE and set up the appropriate variables. -FM */ if (submit_item->submit_enctype && !strncasecomp(submit_item->submit_enctype, "text/plain", 10)) { /* * Do not hex escape, and use physical newlines - * to separate name=value pairs. - FM + * to separate name=value pairs. -FM */ PlainText = TRUE; } else if (submit_item->submit_enctype && @@ -9931,7 +10065,7 @@ PUBLIC int HText_SubmitForm ARGS4( "application/sgml-form-urlencoded", 32)) { /* * Use semicolons instead of ampersands as the - * separators for name=value pairs. - FM + * separators for name=value pairs. -FM */ SemiColon = TRUE; } else if (submit_item->submit_enctype && @@ -9941,7 +10075,7 @@ PUBLIC int HText_SubmitForm ARGS4( * Use the multipart MIME format. We should generate * a boundary string which we are sure doesn't occur * in the content, but for now we'll just assume that - * this string doesn't. - FM + * this string doesn't. -FM */ Boundary = "xnyLAaB03X"; } @@ -10012,7 +10146,7 @@ PUBLIC int HText_SubmitForm ARGS4( field_has_special = NO; for (p = val; - p && *p && !(field_has_8bit && field_has_special); + non_empty(p) && !(field_has_8bit && field_has_special); p++) if ((*p == HT_NON_BREAK_SPACE) || (*p == HT_EN_SPACE) || @@ -10022,7 +10156,7 @@ PUBLIC int HText_SubmitForm ARGS4( field_has_8bit = YES; } for (p = form_ptr->name; - p && *p && !(name_has_8bit && name_has_special); + non_empty(p) && !(name_has_8bit && name_has_special); p++) if ((*p == HT_NON_BREAK_SPACE) || (*p == HT_EN_SPACE) || @@ -10115,7 +10249,7 @@ PUBLIC int HText_SubmitForm ARGS4( /* * We are submitting POST content to a server, * so load content_type_out. This will be put in - * the post_content_type element if all goes well. - FM, kw + * the post_content_type element if all goes well. -FM, kw */ if (SemiColon == TRUE) { StrAllocCopy(content_type_out, @@ -10207,19 +10341,19 @@ PUBLIC int HText_SubmitForm ARGS4( case F_SUBMIT_TYPE: case F_TEXT_SUBMIT_TYPE: case F_IMAGE_SUBMIT_TYPE: - if (!(form_ptr->name && *form_ptr->name != '\0' && + if (!(non_empty(form_ptr->name) && !strcmp(form_ptr->name, link_name))) { CTRACE((tfp, "SubmitForm: skipping submit field with ")); CTRACE((tfp, "name \"%s\" for link_name \"%s\", %s.\n", form_ptr->name ? form_ptr->name : "???", link_name ? link_name : "???", - (form_ptr->name && *form_ptr->name) ? + non_empty(form_ptr->name) ? "not current link" : "no field name")); break; } if (!(form_ptr->type == F_TEXT_SUBMIT_TYPE || - (form_ptr->value && *form_ptr->value != '\0' && + (non_empty(form_ptr->value) && !strcmp(form_ptr->value, link_value)))) { CTRACE((tfp, "SubmitForm: skipping submit field with ")); @@ -10255,7 +10389,7 @@ PUBLIC int HText_SubmitForm ARGS4( field_has_8bit = NO; field_has_special = NO; for (p = val_used; - p && *p && !(field_has_8bit && field_has_special); + non_empty(p) && !(field_has_8bit && field_has_special); p++) { if ((*p == HT_NON_BREAK_SPACE) || (*p == HT_EN_SPACE) || @@ -10341,7 +10475,7 @@ PUBLIC int HText_SubmitForm ARGS4( name_has_8bit = NO; name_has_special = NO; for (p = name_used; - p && *p && !(name_has_8bit && name_has_special); + non_empty(p) && !(name_has_8bit && name_has_special); p++) { if ((*p == HT_NON_BREAK_SPACE) || (*p == HT_EN_SPACE) || @@ -10454,12 +10588,12 @@ PUBLIC int HText_SubmitForm ARGS4( * multiple submit buttons, or a single type="text" * that's been converted to a TEXT_SUBMIT_TYPE), * include the name=value pair, or fake name.x=0 and - * name.y=0 pairs for IMAGE_SUBMIT_TYPE. - FM + * name.y=0 pairs for IMAGE_SUBMIT_TYPE. -FM */ - if ((form_ptr->name && *form_ptr->name != '\0' && + if ((non_empty(form_ptr->name) && !strcmp(form_ptr->name, link_name)) && (form_ptr->type == F_TEXT_SUBMIT_TYPE || - (form_ptr->value && *form_ptr->value != '\0' && + (non_empty(form_ptr->value) && !strcmp(form_ptr->value, link_value)))) { int cdisp_name_startpos = 0; @@ -10495,7 +10629,7 @@ PUBLIC int HText_SubmitForm ARGS4( /* * It's a clickable image submit button. * Fake a 0,0 coordinate pair, which - * typically returns the image's default. - FM + * typically returns the image's default. -FM */ if (Boundary) { escaped1[cdisp_name_startpos] = '\0'; @@ -11054,7 +11188,7 @@ PUBLIC BOOL HText_hasUTF8OutputSet ARGS1( } /* -** Check charset and set the kcode element. - FM +** Check charset and set the kcode element. -FM ** Info on the input charset may be passed in in two forms, ** as a string (if given explicitly) and as a pointer to ** a LYUCcharset (from chartrans mechanism); either can be NULL. @@ -11087,7 +11221,7 @@ PUBLIC void HText_setKcode ARGS3( charset = p_in->MIMEname; } /* - ** Check whether we have a specified charset. - FM + ** Check whether we have a specified charset. -FM */ if (!charset || *charset == '\0') { return; @@ -11097,7 +11231,7 @@ PUBLIC void HText_setKcode ARGS3( ** We've included the charset, and not forced a download offer, ** only if the currently selected character set can handle it, ** so check the charset value and set the text->kcode element - ** appropriately. - FM + ** appropriately. -FM */ /* If charset isn't specified explicitely nor assumed, * p_in->MIMEname would be set as display charset. @@ -11126,7 +11260,7 @@ PUBLIC void HText_setKcode ARGS3( } else { /* ** If we get to here, it's not CJK, so disable that if - ** it is enabled. But only if we are quite sure. - FM & kw + ** it is enabled. But only if we are quite sure. -FM & kw */ text->kcode = NOKANJI; if (HTCJK != NOCJK) { @@ -11149,7 +11283,7 @@ PUBLIC void HText_setKcode ARGS3( } /* -** Set a permissible split at the current end of the last line. - FM +** Set a permissible split at the current end of the last line. -FM */ PUBLIC void HText_setBreakPoint ARGS1( HText *, text) @@ -11158,7 +11292,7 @@ PUBLIC void HText_setBreakPoint ARGS1( return; /* - * Can split here. - FM + * Can split here. -FM */ text->permissible_split = text->last_line->size; @@ -11176,7 +11310,7 @@ PUBLIC void HText_setBreakPoint ARGS1( ** 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 +** claimed or suggested this. -FM */ PUBLIC BOOL HText_AreDifferent ARGS2( HTParentAnchor *, anchor, @@ -11273,7 +11407,7 @@ PUBLIC BOOL HText_AreDifferent ARGS2( /* * We'll assume the target is a position in the currently * displayed document, and thus can ignore any header, META, - * or other directives not to use a cached rendition. - FM + * or other directives not to use a cached rendition. -FM */ return(FALSE); } @@ -11693,9 +11827,7 @@ PRIVATE void insert_new_textarea_anchor ARGS2( a->line_pos = anchor->line_pos; a->extent = anchor->extent; a->line_num = anchor->line_num + 1; - StrAllocCopy (a->hightext, anchor->hightext); - StrAllocCopy (a->hightext2, anchor->hightext2); - a->hightext2offset = anchor->hightext2offset; + LYCopyHiText(a, anchor); a->link_type = anchor->link_type; a->input_field = f; a->show_anchor = anchor->show_anchor; @@ -11918,7 +12050,7 @@ hang_detected: /* ugliness has happened; inform user and do the best we can */ * --KED 02/01/99 */ PUBLIC int HText_ExtEditForm ARGS1( - struct link *, form_link) + LinkInfo *, form_link) { struct stat stat_info; size_t size; @@ -11939,7 +12071,7 @@ PUBLIC int HText_ExtEditForm ARGS1( int orig_cnt = 0; int line_cnt = 1; - FormInfo *form = form_link->form; + FormInfo *form = form_link->l_form; char *areaname = form->name; int form_num = form->number; @@ -12256,14 +12388,14 @@ PUBLIC int HText_ExtEditForm ARGS1( * --KED 02/14/99 */ PUBLIC void HText_ExpandTextarea ARGS2( - struct link *, form_link, - int, newlines) + LinkInfo *, form_link, + int, newlines) { TextAnchor *anchor_ptr; TextAnchor *end_anchor = NULL; BOOLEAN firstanchor = TRUE; - FormInfo *form = form_link->form; + FormInfo *form = form_link->l_form; char *areaname = form->name; int form_num = form->number; @@ -12356,7 +12488,7 @@ PUBLIC void HText_ExpandTextarea ARGS2( * --KED 02/21/99 */ PUBLIC int HText_InsertFile ARGS1( - struct link *, form_link) + LinkInfo *, form_link) { struct stat stat_info; size_t size; @@ -12370,7 +12502,7 @@ PUBLIC int HText_InsertFile ARGS1( BOOLEAN firstanchor = TRUE; BOOLEAN truncalert = FALSE; - FormInfo *form = form_link->form; + FormInfo *form = form_link->l_form; char *areaname = form->name; int form_num = form->number; @@ -12518,9 +12650,7 @@ PUBLIC int HText_InsertFile ARGS1( a->line_pos = anchor_ptr->line_pos; a->extent = anchor_ptr->extent; a->line_num = anchor_ptr->line_num; - StrAllocCopy (a->hightext, anchor_ptr->hightext); - StrAllocCopy (a->hightext2, anchor_ptr->hightext2); - a->hightext2offset = anchor_ptr->hightext2offset; + LYCopyHiText(a, anchor_ptr); a->link_type = anchor_ptr->link_type; a->input_field = f; a->show_anchor = anchor_ptr->show_anchor; @@ -12675,14 +12805,12 @@ PUBLIC int HText_InsertFile ARGS1( * characters) of it. It doesn't check whether the 'len' bytes crosses a * character boundary (if multibyte chars are in string). Assumes that the * cursor is positioned in the place where the 1st char of string should be - * drawn. Currently used only in redraw_lines_of_link when - * defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) + * drawn. + * * This code is based on display_line. This code was tested with ncurses only - * (since no support for lss is availble for Slang) and with - * defined(USE_COLOR_STYLE). - * -HV. + * (since no support for lss is availble for Slang) -HV. */ -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) +#ifdef USE_COLOR_STYLE PRIVATE void redraw_part_of_line ARGS4( HTLine *, line, char*, str, @@ -12772,12 +12900,12 @@ PRIVATE void redraw_part_of_line ARGS4( * into LastDisplayChar if it was a multibyte * character) or hyphen, though it should have * been excluded by HText_appendCharacter() or by - * split_line() in those cases. - FM + * split_line() in those cases. -FM */ break; } else { /* - * Make it a hard hyphen and fall through. - FM + * Make it a hard hyphen and fall through. -FM */ buffer[0] = '-'; i++; @@ -12814,7 +12942,7 @@ PRIVATE void redraw_part_of_line ARGS4( * spacing characters in this code set, * but this will become an issue when * the development code set's multibyte - * character handling is used. - FM + * character handling is used. -FM */ LastDisplayChar = 'M'; } else { @@ -12839,7 +12967,7 @@ PRIVATE void redraw_part_of_line ARGS4( #endif return; } -#endif /* defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) */ +#endif /* USE_COLOR_STYLE */ #ifndef USE_COLOR_STYLE /* @@ -13153,12 +13281,12 @@ PRIVATE void move_to_glyph ARGS10( * into LastDisplayChar if it was a multibyte * character) or hyphen, though it should have * been excluded by HText_appendCharacter() or by - * split_line() in those cases. - FM + * split_line() in those cases. -FM */ break; } else { /* - * Make it a hard hyphen and fall through. - FM + * Make it a hard hyphen and fall through. -FM */ buffer[0] = '-'; } @@ -13273,15 +13401,13 @@ PRIVATE void move_to_glyph ARGS10( i++; sdata++; data++; /* - * For now, load 'M' into LastDisplayChar, - * but we should check whether it's white - * and if so, use ' '. I don't know if - * there actually are white CJK characters, - * and we're loading ' ' for multibyte - * spacing characters in this code set, - * but this will become an issue when - * the development code set's multibyte - * character handling is used. - FM + * For now, load 'M' into LastDisplayChar, but we should + * check whether it's white and if so, use ' '. I don't + * know if there actually are white CJK characters, and + * we're loading ' ' for multibyte spacing characters in + * this code set, but this will become an issue when the + * development code set's multibyte character handling is + * used. -FM */ LastDisplayChar = 'M'; } else { @@ -13350,7 +13476,7 @@ PUBLIC void LYMoveToLink ARGS6( if (links[i].ly < links[cur].ly) break; if (links[i].type == WWW_FORM_LINK_TYPE) { - XP_draw_min = links[i].ly + links[i].form->size; + XP_draw_min = links[i].ly + links[i].l_form->size; break; } } @@ -13384,41 +13510,37 @@ PUBLIC void LYMoveToLink ARGS6( #endif /* !USE_COLOR_STYLE */ /* - This is used only if compiled with lss support. It's called to draw - regular link (1st two lines of link) when it's being unhighlighted in - highlight:LYUtils. -*/ - + * This is used only if compiled with lss support. It's called to draw regular + * link (1st two lines of link) when it's being unhighlighted in LYhighlight(). + */ PUBLIC void redraw_lines_of_link ARGS1( int, cur GCC_UNUSED) { -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) +#ifdef USE_COLOR_STYLE #define pvtTITLE_HEIGHT 1 - HTLine* todr1, *todr2; + HTLine* todr1; int lines_back; + int row, col, count; + char *text; if (HTMainText->next_line == HTMainText->last_line) { /* we are at the last page - that is partially filled */ - lines_back = HTMainText->Lines - ( links[cur].ly-pvtTITLE_HEIGHT+ + lines_back = HTMainText->Lines - ( links[cur].ly - pvtTITLE_HEIGHT+ HTMainText->top_of_screen); } else { - lines_back = display_lines - (links[cur].ly-pvtTITLE_HEIGHT); + lines_back = display_lines - (links[cur].ly - pvtTITLE_HEIGHT); } todr1 = HTMainText->next_line; while (lines_back-- > 0) todr1 = todr1->prev; - todr2 = (links[cur].hightext2 && links[cur].ly < display_lines) ? - todr1->next : 0; - LYmove(links[cur].ly, links[cur].lx); - redraw_part_of_line (todr1, links[cur].hightext, - strlen(links[cur].hightext), HTMainText); - if (todr2) { - LYmove(links[cur].ly+1,links[cur].hightext2_offset); - redraw_part_of_line (todr2, links[cur].hightext2, - strlen(links[cur].hightext2), HTMainText); + row = links[cur].ly; + for (count = 0; row < display_lines && (text = LYGetHiliteStr(cur, count)) != NULL; ++count) { + col = LYGetHilitePos(cur, count); + LYmove(row++, col); + redraw_part_of_line (todr1, text, strlen(text), HTMainText); + todr1 = todr1->next; } - #undef pvtTITLE_HEIGHT #else /* no dead code !*/ diff --git a/src/GridText.h b/src/GridText.h index 0e2956a7..e2887925 100644 --- a/src/GridText.h +++ b/src/GridText.h @@ -260,12 +260,12 @@ extern BOOL HText_AreDifferent PARAMS(( CONST char * full_address)); extern int HText_ExtEditForm PARAMS(( - struct link * form_link)); + LinkInfo * form_link)); extern void HText_ExpandTextarea PARAMS(( - struct link * form_link, + LinkInfo * form_link, int newlines)); extern int HText_InsertFile PARAMS(( - struct link * form_link)); + LinkInfo * form_link)); extern void redraw_lines_of_link PARAMS((int cur)); extern void LYMoveToLink PARAMS(( diff --git a/src/HTAlert.c b/src/HTAlert.c index 2fb89f9f..d70423aa 100644 --- a/src/HTAlert.c +++ b/src/HTAlert.c @@ -774,7 +774,7 @@ PUBLIC BOOL HTConfirmCookie ARGS4( _statusline(message); FREE(message); } - while (1) { + for (;;) { if(LYAcceptAllCookies) { ch = 'A'; } else { @@ -806,15 +806,17 @@ PUBLIC BOOL HTConfirmCookie ARGS4( && isalpha(ch) && (p = strrchr(prompt, L_PAREN)) != 0) { + CTRACE((tfp, "Looking for %c in %s\n", ch, p)); while (*p != R_PAREN && *p != 0 && isalpha(UCH(*s))) { - if (*p == ch) { - ch = *s; - break; - } else { - if (isalpha(UCH(*p)) && (*p == TOUPPER(*p))) - s++; - p++; + if (isalpha(UCH(*p)) && (*p == TOUPPER(*p))) { + CTRACE((tfp, "...testing %c/%c\n", *p, *s)); + if (*p == ch) { + ch = *s; + break; + } + ++s; } + ++p; } } } diff --git a/src/HTForms.h b/src/HTForms.h index 5962f594..c9c82dcc 100644 --- a/src/HTForms.h +++ b/src/HTForms.h @@ -9,15 +9,15 @@ /* change_form_link calls change_form_link_ex with all its args and FALSE as last arg */ -extern int change_form_link PARAMS((struct link *form_link, - document *newdoc, BOOLEAN *refresh_screen, - char *link_name, char *link_value, +extern int change_form_link PARAMS((int cur, + document *newdoc, + BOOLEAN *refresh_screen, BOOLEAN use_last_tfpos, BOOLEAN immediate_submit)); -extern int change_form_link_ex PARAMS((struct link *form_link, - document *newdoc, BOOLEAN *refresh_screen, - char *link_name, char *link_value, +extern int change_form_link_ex PARAMS((int cur, + document *newdoc, + BOOLEAN *refresh_screen, BOOLEAN use_last_tfpos, BOOLEAN immediate_submit, BOOLEAN draw_only)); diff --git a/src/LYClean.c b/src/LYClean.c index 22bb32cb..1082ca88 100644 --- a/src/LYClean.c +++ b/src/LYClean.c @@ -13,6 +13,10 @@ #include <LYexit.h> #include <LYLeaks.h> +#ifdef WATT32 +extern void sig_handler_watt(int); +#endif /* WATT32 */ + #ifdef VMS BOOLEAN HadVMSInterrupt = FALSE; #endif /* VMS */ @@ -29,8 +33,17 @@ PUBLIC void cleanup_sig ARGS1( /* * Need to rearm the signal. */ +#ifdef WATT32 + if (wathndlcbrk) { + sig_handler_watt(sig); /* Use WATT-32 signal handler */ + } /* Requires patch to WATT-32 */ +#endif /* WATT32 */ signal(SIGINT, cleanup_sig); sigint = TRUE; +#ifdef WATT32 + _eth_release(); + _eth_init(); +#endif /* WATT32 */ return; } #endif /* IGNORE_CTRL_C */ diff --git a/src/LYCookie.c b/src/LYCookie.c index 8efc4e6c..fdf37227 100644 --- a/src/LYCookie.c +++ b/src/LYCookie.c @@ -296,6 +296,30 @@ PRIVATE BOOL is_prefix ARGS2(CONST char *, a, CONST char *, b) } /* + * Find the domain-entry for the given name. + */ +PRIVATE domain_entry * find_domain_entry ARGS1( + CONST char *, name) +{ + HTList *hl; + domain_entry *de = NULL; + + if (name != 0 + && *name != '\0') { + for (hl = domain_list; hl != NULL; hl = hl->next) { + de = (domain_entry *)hl->object; + if (de != NULL + && de->domain != NULL + && !strcasecomp(name, de->domain)) { + break; + } + de = NULL; + } + } + return de; +} + +/* ** Store a cookie somewhere in the domain list. - AK & FM */ PRIVATE void store_cookie ARGS3( @@ -333,19 +357,8 @@ PRIVATE void store_cookie ARGS3( * is already listed. */ cookie_list = NULL; - for (hl = domain_list; hl != NULL; hl = hl->next) { - de = (domain_entry *)hl->object; - if ((de != NULL && de->domain != NULL) && - !strcasecomp(co->domain, de->domain)) { - cookie_list = de->cookie_list; - break; - } - } - - if(hl == NULL) { - de = NULL; - cookie_list = NULL; - } + if ((de = find_domain_entry(co->domain)) != NULL) + cookie_list = de->cookie_list; /* * Apply sanity checks. @@ -375,6 +388,7 @@ PRIVATE void store_cookie ARGS3( return; } } + /* * The next 4 conditions do NOT apply if the domain is still * the default of request-host. (domains - case insensitive). @@ -398,15 +412,13 @@ PRIVATE void store_cookie ARGS3( * value otherwise qualified. - FM */ if (co->domain[0] != '.' || co->domain[1] == '\0') { - CTRACE((tfp, "store_cookie: Rejecting domain '%s'.\n", - co->domain)); + CTRACE((tfp, "store_cookie: Rejecting domain '%s'.\n", co->domain)); freeCookie(co); return; } ptr = strchr((co->domain + 1), '.'); if (ptr == NULL || ptr[1] == '\0') { - CTRACE((tfp, "store_cookie: Rejecting domain '%s'.\n", - co->domain)); + CTRACE((tfp, "store_cookie: Rejecting domain '%s'.\n", co->domain)); freeCookie(co); return; } @@ -468,8 +480,8 @@ PRIVATE void store_cookie ARGS3( hostname); if (!HTConfirmDefault(msg, NO)) { CTRACE((tfp, "store_cookie: Rejecting domain '%s' for host '%s'.\n", - co->domain, - hostname)); + co->domain, + hostname)); freeCookie(co); FREE(msg); return; @@ -490,28 +502,14 @@ PRIVATE void store_cookie ARGS3( FREE(msg); } - if (hl == NULL) { + if (de == NULL) { /* - * Domain not found; add a new entry for this domain. + * Domain not found; add a new entry for this domain. */ de = typecalloc(domain_entry); if (de == NULL) outofmem(__FILE__, "store_cookie"); -#if 0 /* was: ifdef EXP_PERSISTENT_COOKIES */ - /* - * The default behavior for this new domain could be set - * differently if the cookie comes from a file, as the - * code had it originally, but there doesn't seem to be - * a good reason for it any more; setting more permissive - * behavior for individual domains is now possible via - * configuration options. - kw - */ - if (persistent_cookies - && (co->flags & COOKIE_FLAG_FROM_FILE)) - de->bv = ACCEPT_ALWAYS; /* ?? */ - else -#endif - de->bv = QUERY_USER; + de->bv = QUERY_USER; de->invcheck_bv = DEFAULT_INVCHECK_BV; /* should this go here? */ cookie_list = de->cookie_list = HTList_new(); StrAllocCopy(de->domain, co->domain); @@ -823,6 +821,260 @@ PRIVATE char * scan_cookie_sublist ARGS6( } /* + * Presence of value is needed (indicated normally by '=') to start a cookie, + * but it can be an empty string. - kw 1999-06-24 + */ +PRIVATE char *alloc_attr_value ARGS2( + CONST char *, value_start, + CONST char *, value_end) +{ + char *value = NULL; + + if (value_start && value_end >= value_start) { + int value_len = (value_end - value_start); + + if (value_len > max_cookies_buffer) { + value_len = max_cookies_buffer; + } + value = typecallocn(char, value_len + 1); + if (value == NULL) + outofmem(__FILE__, "LYProcessSetCookies"); + LYstrncpy(value, value_start, value_len); + } + return value; +} + +#define FLAGS_INVALID_PORT 1 +#define FLAGS_KNOWN_ATTR 2 +#define FLAGS_MAXAGE_ATTR 4 + +PRIVATE unsigned parse_attribute ARGS9( + unsigned, flags, + cookie *, cur_cookie, + int *, cookie_len, + CONST char *, attr_start, + int, attr_len, + char *, value, + CONST char *, address, + char *, hostname, + int, port) +{ + BOOLEAN known_attr = NO; + int url_type; + + flags &= ~FLAGS_KNOWN_ATTR; + if (attr_len == 6 && !strncasecomp(attr_start, "secure", 6)) { + if (value == NULL) { + known_attr = YES; + if (cur_cookie != NULL) { + cur_cookie->flags |= COOKIE_FLAG_SECURE; + } + } else { + /* + * If secure has a value, assume someone + * misused it as cookie name. - FM + */ + known_attr = NO; + } + } else if (attr_len == 7 && !strncasecomp(attr_start, "discard", 7)) { + if (value == NULL) { + known_attr = YES; + if (cur_cookie != NULL) { + cur_cookie->flags |= COOKIE_FLAG_DISCARD; + } + } else { + /* + * If discard has a value, assume someone + * used it as a cookie name. - FM + */ + known_attr = NO; + } + } else if (attr_len == 7 && !strncasecomp(attr_start, "comment", 7)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat comment. - FM + */ + cur_cookie->comment == NULL) { + StrAllocCopy(cur_cookie->comment, value); + *cookie_len += strlen(cur_cookie->comment); + } + } else if (attr_len == 10 && !strncasecomp(attr_start, + "commentURL", 10)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat commentURL. - FM + */ + cur_cookie->commentURL == NULL) { + /* + * We should get only absolute URLs as + * values, but will resolve versus the + * request's URL just in case. - FM + */ + cur_cookie->commentURL = HTParse(value, + address, + PARSE_ALL); + /* + * Accept only URLs for http or https servers. - FM + */ + if ((url_type = is_url(cur_cookie->commentURL)) && + (url_type == HTTP_URL_TYPE || + url_type == HTTPS_URL_TYPE)) { + *cookie_len += strlen(cur_cookie->commentURL); + } else { + CTRACE((tfp, "LYProcessSetCookies: Rejecting commentURL value '%s'\n", + cur_cookie->commentURL)); + FREE(cur_cookie->commentURL); + } + } + } else if (attr_len == 6 && !strncasecomp(attr_start, "domain", 6)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat domain. - FM + */ + !(cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) { + *cookie_len -= strlen(cur_cookie->domain); + /* + * If the value does not have a lead dot, + * but does have an embedded dot, and is + * not an exact match to the hostname, nor + * is a numeric IP address, add a lead dot. + * Otherwise, use the value as is. - FM + * (domains - case insensitive). + */ + if (value[0] != '.' && value[0] != '\0' && + value[1] != '\0' && strcasecomp(value, hostname)) { + char *ptr = strchr(value, '.'); + if (ptr != NULL && ptr[1] != '\0') { + ptr = value; + while (*ptr == '.' || + isdigit(UCH(*ptr))) + ptr++; + if (*ptr != '\0') { + CTRACE((tfp, + "LYProcessSetCookies: Adding lead dot for domain value '%s'\n", + value)); + StrAllocCopy(cur_cookie->domain, "."); + StrAllocCat(cur_cookie->domain, value); + } else { + StrAllocCopy(cur_cookie->domain, value); + } + } else { + StrAllocCopy(cur_cookie->domain, value); + } + } else { + StrAllocCopy(cur_cookie->domain, value); + } + *cookie_len += strlen(cur_cookie->domain); + cur_cookie->flags |= COOKIE_FLAG_DOMAIN_SET; + } + } else if (attr_len == 4 && !strncasecomp(attr_start, "path", 4)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat path. - FM + */ + !(cur_cookie->flags & COOKIE_FLAG_PATH_SET)) { + *cookie_len -= strlen(cur_cookie->path); + StrAllocCopy(cur_cookie->path, value); + *cookie_len += (cur_cookie->pathlen = strlen(cur_cookie->path)); + cur_cookie->flags |= COOKIE_FLAG_PATH_SET; + } + } else if (attr_len == 4 && !strncasecomp(attr_start, "port", 4)) { + if (cur_cookie != NULL && value && + /* + * Don't process a repeat port. - FM + */ + cur_cookie->PortList == NULL) { + char *cp = value; + while ((*cp != '\0') && + (isdigit(UCH(*cp)) || + *cp == ',' || *cp == ' ')) { + cp++; + } + if (*cp == '\0') { + if (!port_matches(port, value)) { + flags |= FLAGS_INVALID_PORT; + } else { + StrAllocCopy(cur_cookie->PortList, value); + *cookie_len += strlen(cur_cookie->PortList); + } + known_attr = YES; + } else { + known_attr = NO; + } + } else if (cur_cookie != NULL) { + /* + * Don't process a repeat port. - FM + */ + if (cur_cookie->PortList == NULL) { + HTSprintf0(&(cur_cookie->PortList), "%d", port); + *cookie_len += strlen(cur_cookie->PortList); + } + known_attr = YES; + } + } else if (attr_len == 7 && !strncasecomp(attr_start, "version", 7)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat version. - FM + */ + cur_cookie->version < 1) { + int temp = strtol(value, NULL, 10); + if (errno != -ERANGE) { + cur_cookie->version = temp; + } + } + } else if (attr_len == 7 && !strncasecomp(attr_start, "max-age", 7)) { + known_attr = YES; + if (cur_cookie != NULL && value && + /* + * Don't process a repeat max-age. - FM + */ + !(flags & FLAGS_MAXAGE_ATTR)) { + int temp = strtol(value, NULL, 10); + cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; + if (errno == -ERANGE) { + cur_cookie->expires = (time_t)0; + } else { + cur_cookie->expires = (time(NULL) + temp); + CTRACE((tfp, "LYSetCookie: expires %ld, %s", + (long) cur_cookie->expires, + ctime(&cur_cookie->expires))); + } + flags |= FLAGS_MAXAGE_ATTR; + } + } else if (attr_len == 7 && !strncasecomp(attr_start, "expires", 7)) { + /* + * Convert an 'expires' attribute value if we haven't + * received a 'max-age'. Note that 'expires' should not + * be used in Version 1 cookies, but it might be used for + * "backward compatibility", and, in turn, ill-informed + * people surely would start using it instead of, rather + * than in addition to, 'max-age'. - FM + */ + known_attr = YES; + if ((cur_cookie != NULL && !(flags & FLAGS_MAXAGE_ATTR)) && + !(cur_cookie->flags & COOKIE_FLAG_EXPIRES_SET)) { + if (value) { + cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; + cur_cookie->expires = LYmktime(value, FALSE); + if (cur_cookie->expires > 0) { + CTRACE((tfp, "LYSetCookie: expires %ld, %s", + (long) cur_cookie->expires, + ctime(&cur_cookie->expires))); + } + } + } + } + if (known_attr) + flags |= FLAGS_KNOWN_ATTR; + return flags; +} + +/* ** Process potentially concatenated Set-Cookie2 and/or Set-Cookie ** headers. - FM */ @@ -837,11 +1089,10 @@ PRIVATE void LYProcessSetCookies ARGS6( CONST char *p, *attr_start, *attr_end, *value_start, *value_end; HTList *CombinedCookies = NULL, *cl = NULL; cookie *cur_cookie = NULL, *co = NULL; - int length = 0, url_type = 0; + int cookie_len = 0; int NumCookies = 0; - BOOL MaxAgeAttrSet = FALSE; BOOL Quoted = FALSE; - BOOLEAN invalidport = FALSE; + unsigned parse_flags = 0; if (!(SetCookie && *SetCookie) && !(SetCookie2 && *SetCookie2)) { @@ -1052,257 +1303,32 @@ PRIVATE void LYProcessSetCookies ARGS6( * Now, we can handle this attribute/value pair. */ if (attr_end > attr_start) { - int len = (attr_end - attr_start); - BOOLEAN known_attr = NO; - char *value = NULL; - - if (value_start && value_end >= value_start) { - /* - * Presence of value is now needed (indicated normally by '=') - * to start a cookie, but it can now be an empty string. - * - kw 1999-06-24 - */ - int value_len = (value_end - value_start); - - if (value_len > max_cookies_buffer) { - value_len = max_cookies_buffer; - } - value = typecallocn(char, value_len + 1); - if (value == NULL) - outofmem(__FILE__, "LYProcessSetCookies"); - LYstrncpy(value, value_start, value_len); - } - if (len == 6 && !strncasecomp(attr_start, "secure", 6)) { - if (value == NULL) { - known_attr = YES; - if (cur_cookie != NULL) { - cur_cookie->flags |= COOKIE_FLAG_SECURE; - } - } else { - /* - * If secure has a value, assume someone - * misused it as cookie name. - FM - */ - known_attr = NO; - } - } else if (len == 7 && !strncasecomp(attr_start, "discard", 7)) { - if (value == NULL) { - known_attr = YES; - if (cur_cookie != NULL) { - cur_cookie->flags |= COOKIE_FLAG_DISCARD; - } - } else { - /* - * If discard has a value, assume someone - * used it as a cookie name. - FM - */ - known_attr = NO; - } - } else if (len == 7 && !strncasecomp(attr_start, "comment", 7)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat comment. - FM - */ - cur_cookie->comment == NULL) { - StrAllocCopy(cur_cookie->comment, value); - length += strlen(cur_cookie->comment); - } - } else if (len == 10 && !strncasecomp(attr_start, - "commentURL", 10)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat commentURL. - FM - */ - cur_cookie->commentURL == NULL) { - /* - * We should get only absolute URLs as - * values, but will resolve versus the - * request's URL just in case. - FM - */ - cur_cookie->commentURL = HTParse(value, - address, - PARSE_ALL); - /* - * Accept only URLs for http or https servers. - FM - */ - if ((url_type = is_url(cur_cookie->commentURL)) && - (url_type == HTTP_URL_TYPE || - url_type == HTTPS_URL_TYPE)) { - length += strlen(cur_cookie->commentURL); - } else { - CTRACE((tfp, "LYProcessSetCookies: Rejecting commentURL value '%s'\n", - cur_cookie->commentURL)); - FREE(cur_cookie->commentURL); - } - } - } else if (len == 6 && !strncasecomp(attr_start, "domain", 6)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat domain. - FM - */ - !(cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) { - length -= strlen(cur_cookie->domain); - /* - * If the value does not have a lead dot, - * but does have an embedded dot, and is - * not an exact match to the hostname, nor - * is a numeric IP address, add a lead dot. - * Otherwise, use the value as is. - FM - * (domains - case insensitive). - */ - if (value[0] != '.' && value[0] != '\0' && - value[1] != '\0' && strcasecomp(value, hostname)) { - char *ptr = strchr(value, '.'); - if (ptr != NULL && ptr[1] != '\0') { - ptr = value; - while (*ptr == '.' || - isdigit(UCH(*ptr))) - ptr++; - if (*ptr != '\0') { - CTRACE((tfp, - "LYProcessSetCookies: Adding lead dot for domain value '%s'\n", - value)); - StrAllocCopy(cur_cookie->domain, "."); - StrAllocCat(cur_cookie->domain, value); - } else { - StrAllocCopy(cur_cookie->domain, value); - } - } else { - StrAllocCopy(cur_cookie->domain, value); - } - } else { - StrAllocCopy(cur_cookie->domain, value); - } - length += strlen(cur_cookie->domain); - cur_cookie->flags |= COOKIE_FLAG_DOMAIN_SET; - } - } else if (len == 4 && !strncasecomp(attr_start, "path", 4)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat path. - FM - */ - !(cur_cookie->flags & COOKIE_FLAG_PATH_SET)) { - length -= strlen(cur_cookie->path); - StrAllocCopy(cur_cookie->path, value); - length += (cur_cookie->pathlen = strlen(cur_cookie->path)); - cur_cookie->flags |= COOKIE_FLAG_PATH_SET; - } - } else if (len == 4 && !strncasecomp(attr_start, "port", 4)) { - if (cur_cookie != NULL && value && - /* - * Don't process a repeat port. - FM - */ - cur_cookie->PortList == NULL) { - char *cp = value; - while ((*cp != '\0') && - (isdigit(UCH(*cp)) || - *cp == ',' || *cp == ' ')) { - cp++; - } - if (*cp == '\0' && !port_matches(port, value)) { - invalidport = TRUE; - known_attr = YES; - } else if (*cp == '\0') { - StrAllocCopy(cur_cookie->PortList, value); - length += strlen(cur_cookie->PortList); - known_attr = YES; - } else { - known_attr = NO; - } - } else if (cur_cookie != NULL) { - /* - * Don't process a repeat port. - FM - */ - if (cur_cookie->PortList == NULL) { - HTSprintf0(&(cur_cookie->PortList), "%d", port); - length += strlen(cur_cookie->PortList); - } - known_attr = YES; - } - } else if (len == 7 && !strncasecomp(attr_start, "version", 7)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat version. - FM - */ - cur_cookie->version < 1) { - int temp = strtol(value, NULL, 10); - if (errno != -ERANGE) { - cur_cookie->version = temp; - } - } - } else if (len == 7 && !strncasecomp(attr_start, "max-age", 7)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat max-age. - FM - */ - !MaxAgeAttrSet) { - int temp = strtol(value, NULL, 10); - cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; - if (errno == -ERANGE) { - cur_cookie->expires = (time_t)0; - } else { - cur_cookie->expires = (time(NULL) + temp); - CTRACE((tfp, "LYSetCookie: expires %ld, %s", - (long) cur_cookie->expires, - ctime(&cur_cookie->expires))); - } - MaxAgeAttrSet = TRUE; - } - } else if (len == 7 && !strncasecomp(attr_start, "expires", 7)) { - /* - * Convert an 'expires' attribute value if we haven't - * received a 'max-age'. Note that 'expires' should not - * be used in Version 1 cookies, but it might be used for - * "backward compatibility", and, in turn, ill-informed - * people surely would start using it instead of, rather - * than in addition to, 'max-age'. - FM - */ - known_attr = YES; - if ((cur_cookie != NULL && !MaxAgeAttrSet) && - !(cur_cookie->flags & COOKIE_FLAG_EXPIRES_SET)) { - if (value) { - cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; - cur_cookie->expires = LYmktime(value, FALSE); - if (cur_cookie->expires > 0) { - CTRACE((tfp, "LYSetCookie: expires %ld, %s", - (long) cur_cookie->expires, - ctime(&cur_cookie->expires))); - } - } - } - } + char *value = alloc_attr_value(value_start, value_end); + + parse_flags = parse_attribute (parse_flags, + cur_cookie, + &cookie_len, + attr_start, + (attr_end - attr_start), + value, + address, + hostname, + port); /* - * If none of the above comparisons succeeded, and we have - * a value, then we have an unknown pair of the form 'foo=bar', - * which means it's time to create a new cookie. If we don't - * have a non-zero-length value, assume it's an error or a - * new, unknown attribute which doesn't take a value, and - * ignore it. - FM - */ - /* if (!known_attr && value_end > value_start) */ - - /* Is there any reason we don't want to accept cookies with - * no value? This seems to be needed for sites that reset a - * cookie by nulling out the value. If this causes problems, - * we can go back to the original behavior above. - BJP - * - * Presence of value is now needed (indicated normally by '='), - * but it can now be an empty string. - kw 1999-06-24 + * Presence of value is needed (indicated normally by '='), + * but it can be an empty string. - kw 1999-06-24 */ - if (!known_attr && value && value_end >= value_start) { + if (!(parse_flags & FLAGS_KNOWN_ATTR) + && value + && value_end >= value_start) { /* * If we've started a cookie, and it's not too big, * save it in the CombinedCookies list. - FM */ - if (length <= max_cookies_buffer && cur_cookie != NULL && - !invalidport) { + if (cookie_len <= max_cookies_buffer + && cur_cookie != NULL + && !(parse_flags & FLAGS_INVALID_PORT)) { /* * Assume version 1 if not set to that or higher. - FM */ @@ -1318,10 +1344,10 @@ PRIVATE void LYProcessSetCookies ARGS6( (cur_cookie->value ? cur_cookie->value : "[no value]"))); CTRACE((tfp, - invalidport ? + (parse_flags & FLAGS_INVALID_PORT) ? " due to excessive length!\n" : " due to invalid port!\n")); - if (invalidport) { + if (parse_flags & FLAGS_INVALID_PORT) { NumCookies --; } freeCookie(cur_cookie); @@ -1331,19 +1357,18 @@ PRIVATE void LYProcessSetCookies ARGS6( * Start a new cookie. - FM */ cur_cookie = newCookie(); - invalidport = FALSE; - length = 0; + cookie_len = 0; NumCookies++; MemAllocCopy(&(cur_cookie->name), attr_start, attr_end); - length += strlen(cur_cookie->name); + cookie_len += strlen(cur_cookie->name); MemAllocCopy(&(cur_cookie->value), value_start, value_end); - length += strlen(cur_cookie->value); + cookie_len += strlen(cur_cookie->value); StrAllocCopy(cur_cookie->domain, hostname); - length += strlen(cur_cookie->domain); + cookie_len += strlen(cur_cookie->domain); StrAllocCopy(cur_cookie->path, path); - length += (cur_cookie->pathlen = strlen(cur_cookie->path)); + cookie_len += (cur_cookie->pathlen = strlen(cur_cookie->path)); cur_cookie->port = port; - MaxAgeAttrSet = FALSE; + parse_flags = 0; cur_cookie->quoted = TRUE; } FREE(value); @@ -1355,19 +1380,19 @@ PRIVATE void LYProcessSetCookies ARGS6( * if we are within the length limit. - FM */ if (NumCookies <= max_cookies_domain - && length <= max_cookies_buffer - && cur_cookie != NULL && !invalidport) { + && cookie_len <= max_cookies_buffer + && cur_cookie != NULL && !(parse_flags & FLAGS_INVALID_PORT)) { if (cur_cookie->version < 1) { cur_cookie->version = 1; } HTList_appendObject(CombinedCookies, cur_cookie); - } else if (cur_cookie != NULL && !invalidport) { + } else if (cur_cookie != NULL && !(parse_flags & FLAGS_INVALID_PORT)) { CTRACE((tfp, "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n", (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]"))); CTRACE((tfp, " due to excessive %s%s%s\n", - (length > max_cookies_buffer ? "length" : ""), - (length > max_cookies_buffer && + (cookie_len > max_cookies_buffer ? "length" : ""), + (cookie_len > max_cookies_buffer && NumCookies > max_cookies_domain ? " and " : ""), @@ -1388,7 +1413,7 @@ PRIVATE void LYProcessSetCookies ARGS6( * Process the Set-Cookie header, if no non-zero-length Set-Cookie2 * header was present. - FM */ - length = 0; + cookie_len = 0; NumCookies = 0; cur_cookie = NULL; p = ((SetCookie && !(SetCookie2 && *SetCookie2)) ? SetCookie : ""); @@ -1572,241 +1597,31 @@ PRIVATE void LYProcessSetCookies ARGS6( * Now, we can handle this attribute/value pair. */ if (attr_end > attr_start) { - int len = (attr_end - attr_start); - BOOLEAN known_attr = NO; - char *value = NULL; - - if (value_start && value_end >= value_start) { - /* - * Presence of value is now needed (indicated normally by '=') - * to start a cookie, but it can now be an empty string. - * - kw 1999-06-24 - */ - int value_len = (value_end - value_start); - - if (value_len > max_cookies_buffer) { - value_len = max_cookies_buffer; - } - value = typecallocn(char, value_len + 1); - if (value == NULL) - outofmem(__FILE__, "LYProcessSetCookies"); - LYstrncpy(value, value_start, value_len); - } - if (len == 6 && !strncasecomp(attr_start, "secure", 6)) { - if (value == NULL) { - known_attr = YES; - if (cur_cookie != NULL) { - cur_cookie->flags |= COOKIE_FLAG_SECURE; - } - } else { - /* - * If secure has a value, assume someone - * misused it as cookie name. - FM - */ - known_attr = NO; - } - } else if (len == 7 && !strncasecomp(attr_start, "discard", 7)) { - if (value == NULL) { - known_attr = YES; - if (cur_cookie != NULL) { - cur_cookie->flags |= COOKIE_FLAG_DISCARD; - } - } else { - /* - * If discard has a value, assume someone - * used it as a cookie name. - FM - */ - known_attr = NO; - } - } else if (len == 7 && !strncasecomp(attr_start, "comment", 7)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat comment. - FM - */ - cur_cookie->comment == NULL) { - StrAllocCopy(cur_cookie->comment, value); - length += strlen(cur_cookie->comment); - } - } else if (len == 10 && !strncasecomp(attr_start, - "commentURL", 10)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat commentURL. - FM - */ - cur_cookie->commentURL == NULL) { - /* - * We should get only absolute URLs as - * values, but will resolve versus the - * request's URL just in case. - FM - */ - cur_cookie->commentURL = HTParse(value, - address, - PARSE_ALL); - /* - * Accept only URLs for http or https servers. - FM - */ - if ((url_type = is_url(cur_cookie->commentURL)) && - (url_type == HTTP_URL_TYPE || - url_type == HTTPS_URL_TYPE)) { - length += strlen(cur_cookie->commentURL); - } else { - CTRACE((tfp, "LYProcessSetCookies: Rejecting commentURL value '%s'\n", - cur_cookie->commentURL)); - FREE(cur_cookie->commentURL); - } - } - } else if (len == 6 && !strncasecomp(attr_start, "domain", 6)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat domain. - FM - */ - !(cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) { - length -= strlen(cur_cookie->domain); - /* - * If the value does not have a lead dot, - * but does have an embedded dot, and is - * not an exact match to the hostname, nor - * is a numeric IP address, add a lead dot. - * Otherwise, use the value as is. - FM - * (domains - case insensitive). - */ - if (value[0] != '.' && value[0] != '\0' && - value[1] != '\0' && strcasecomp(value, hostname)) { - char *ptr = strchr(value, '.'); - if (ptr != NULL && ptr[1] != '\0') { - ptr = value; - while (*ptr == '.' || - isdigit(UCH(*ptr))) - ptr++; - if (*ptr != '\0') { - CTRACE((tfp, - "LYProcessSetCookies: Adding lead dot for domain value '%s'\n", - value)); - StrAllocCopy(cur_cookie->domain, "."); - StrAllocCat(cur_cookie->domain, value); - } else { - StrAllocCopy(cur_cookie->domain, value); - } - } else { - StrAllocCopy(cur_cookie->domain, value); - } - } else { - StrAllocCopy(cur_cookie->domain, value); - } - length += strlen(cur_cookie->domain); - cur_cookie->flags |= COOKIE_FLAG_DOMAIN_SET; - } - } else if (len == 4 && !strncasecomp(attr_start, "path", 4)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat path. - FM - */ - !(cur_cookie->flags & COOKIE_FLAG_PATH_SET)) { - length -= strlen(cur_cookie->path); - StrAllocCopy(cur_cookie->path, value); - length += (cur_cookie->pathlen = strlen(cur_cookie->path)); - cur_cookie->flags |= COOKIE_FLAG_PATH_SET; - } - } else if (len == 4 && !strncasecomp(attr_start, "port", 4)) { - if (cur_cookie != NULL && value && - /* - * Don't process a repeat port. - FM - */ - cur_cookie->PortList == NULL) { - char *cp = value; - while ((*cp != '\0') && - (isdigit(UCH(*cp)) || - *cp == ',' || *cp == ' ')) { - cp++; - } - if (*cp == '\0' && port_matches(port, value)) { - StrAllocCopy(cur_cookie->PortList, value); - length += strlen(cur_cookie->PortList); - known_attr = YES; - } else { - known_attr = NO; - } - } else if (cur_cookie != NULL) { - /* - * Don't process a repeat port. - FM - */ - if (cur_cookie->PortList == NULL) { - HTSprintf0(&(cur_cookie->PortList), "%d", port); - length += strlen(cur_cookie->PortList); - } - known_attr = YES; - } - } else if (len == 7 && !strncasecomp(attr_start, "version", 7)) { - known_attr = YES; - if (cur_cookie != NULL && value && - /* - * Don't process a repeat version. - FM - */ - cur_cookie->version < 1) { - int temp = strtol(value, NULL, 10); - if (errno != -ERANGE) { - cur_cookie->version = temp; - } - } - } else if (len == 7 && !strncasecomp(attr_start, "max-age", 7)) { - known_attr = YES; - if ((cur_cookie != NULL) && !MaxAgeAttrSet && value) { - int temp = strtol(value, NULL, 10); - cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; - if (errno == -ERANGE) { - cur_cookie->expires = (time_t)0; - } else { - cur_cookie->expires = (time(NULL) + temp); - } - MaxAgeAttrSet = TRUE; - } - } else if (len == 7 && !strncasecomp(attr_start, "expires", 7)) { - /* - * Convert an 'expires' attribute value if we haven't - * received a 'max-age'. Note that 'expires' should not - * be used in Version 1 cookies, but it might be used for - * "backward compatibility", and, in turn, ill-informed - * people surely would start using it instead of, rather - * than in addition to, 'max-age'. - FM - */ - known_attr = YES; - if ((cur_cookie != NULL) && !(MaxAgeAttrSet) && - !(cur_cookie->flags & COOKIE_FLAG_EXPIRES_SET)) { - if (value) { - cur_cookie->flags |= COOKIE_FLAG_EXPIRES_SET; - cur_cookie->expires = LYmktime(value, FALSE); - } - } - } + char *value = alloc_attr_value(value_start, value_end); + + parse_flags = parse_attribute (parse_flags, + cur_cookie, + &cookie_len, + attr_start, + (attr_end - attr_start), + value, + address, + hostname, + port); /* - * If none of the above comparisons succeeded, and we have - * a value, then we have an unknown pair of the form 'foo=bar', - * which means it's time to create a new cookie. If we don't - * have a non-zero-length value, assume it's an error or a - * new, unknown attribute which doesn't take a value, and - * ignore it. - FM - */ - /* if (!known_attr && value_end > value_start) */ - - /* Is there any reason we don't want to accept cookies with - * no value? This seems to be needed for sites that reset a - * cookie by nulling out the value. If this causes problems, - * we can go back to the original behavior above. - BJP - * - * Presence of value is now needed (indicated normally by '='), - * but it can now be an empty string. - kw 1999-06-24 + * Presence of value is needed (indicated normally by '='), + * but it can be an empty string. - kw 1999-06-24 */ - if (!known_attr && value && value_end >= value_start) { + if (!(parse_flags & FLAGS_KNOWN_ATTR) + && value + && value_end >= value_start) { /* * If we've started a cookie, and it's not too big, * save it in the CombinedCookies list. - FM */ - if (length <= max_cookies_buffer && cur_cookie != NULL) { + if (cookie_len <= max_cookies_buffer + && cur_cookie != NULL) { /* * If we had a Set-Cookie2 header, make sure * the version is at least 1, and mark it for @@ -1833,17 +1648,18 @@ PRIVATE void LYProcessSetCookies ARGS6( * Start a new cookie. - FM */ cur_cookie = newCookie(); - length = 0; + NumCookies++; + cookie_len = 0; MemAllocCopy(&(cur_cookie->name), attr_start, attr_end); - length += strlen(cur_cookie->name); + cookie_len += strlen(cur_cookie->name); MemAllocCopy(&(cur_cookie->value), value_start, value_end); - length += strlen(cur_cookie->value); + cookie_len += strlen(cur_cookie->value); StrAllocCopy(cur_cookie->domain, hostname); - length += strlen(cur_cookie->domain); + cookie_len += strlen(cur_cookie->domain); StrAllocCopy(cur_cookie->path, path); - length += (cur_cookie->pathlen = strlen(cur_cookie->path)); + cookie_len += (cur_cookie->pathlen = strlen(cur_cookie->path)); cur_cookie->port = port; - MaxAgeAttrSet = FALSE; + parse_flags = 0; cur_cookie->quoted = Quoted; Quoted = FALSE; } @@ -1854,7 +1670,7 @@ PRIVATE void LYProcessSetCookies ARGS6( /* * Handle the final Set-Cookie cookie if within length limit. - FM */ - if (NumCookies <= max_cookies_domain && length <= max_cookies_buffer && cur_cookie != NULL) { + if (NumCookies <= max_cookies_domain && cookie_len <= max_cookies_buffer && cur_cookie != NULL) { if (SetCookie2 != NULL) { if (cur_cookie->version < 1) { cur_cookie->version = 1; @@ -1867,8 +1683,8 @@ PRIVATE void LYProcessSetCookies ARGS6( (cur_cookie->name ? cur_cookie->name : "[no name]"), (cur_cookie->value ? cur_cookie->value : "[no value]"))); CTRACE((tfp, " due to excessive %s%s%s\n", - (length > max_cookies_buffer ? "length" : ""), - (length > max_cookies_buffer && NumCookies > max_cookies_domain ? " and " : ""), + (cookie_len > max_cookies_buffer ? "length" : ""), + (cookie_len > max_cookies_buffer && NumCookies > max_cookies_domain ? " and " : ""), (NumCookies > max_cookies_domain ? "number!\n" : "!\n"))); freeCookie(cur_cookie); cur_cookie = NULL; @@ -1987,7 +1803,7 @@ PUBLIC void LYSetCookie ARGS3( ** Entry function from creating a Cookie: request header ** if needed. - AK & FM */ -PUBLIC char * LYCookie ARGS4( +PUBLIC char * LYAddCookieHeader ARGS4( char *, hostname, char *, path, int, port, @@ -2013,17 +1829,15 @@ PUBLIC char * LYCookie ARGS4( if (de != NULL) { if (!HTList_isEmpty(de->cookie_list)) { /* - * Scan the domain's cookie_list for - * any cookies we should include in - * our request header. + * Scan the domain's cookie_list for any cookies we should + * include in our request header. */ header = scan_cookie_sublist(hostname, path, port, de->cookie_list, header, secure); } else if (de->bv == QUERY_USER && de->invcheck_bv == DEFAULT_INVCHECK_BV) { /* - * No cookies in this domain, and no default - * accept/reject choice was set by the user, - * so delete the domain. - FM + * No cookies in this domain, and no default accept/reject + * choice was set by the user, so delete the domain. - FM */ FREE(de->domain); HTList_delete(de->cookie_list); @@ -2345,203 +2159,185 @@ PRIVATE int LYHandleCookies ARGS4 ( /* * Seek the domain in the domain_list structure. - FM */ - for (dl = domain_list; dl != NULL; dl = dl->next) { - de = dl->object; - if (!(de && de->domain)) - /* - * First object in the list always is empty. - FM - */ - continue; - if (!strcasecomp(domain, de->domain)) { - FREE(domain); + if ((de = find_domain_entry(domain)) != NULL) { + FREE(domain); + /* + * We found the domain. Check + * whether a lynxID is present. - FM + */ + if (lynxID) { /* - * We found the domain. Check - * whether a lynxID is present. - FM + * Seek and delete the cookie with this lynxID + * in the domain's cookie list. - FM */ - if (lynxID) { - /* - * Seek and delete the cookie with this lynxID - * in the domain's cookie list. - FM - */ - for (cl = de->cookie_list; cl != NULL; cl = cl->next) { - if ((co = (cookie *)cl->object) == NULL) - /* - * First object is always empty. - FM - */ - continue; - if (!strcmp(lynxID, co->lynxID)) { + for (cl = de->cookie_list; cl != NULL; cl = cl->next) { + if ((co = (cookie *)cl->object) == NULL) + /* + * First object is always empty. - FM + */ + continue; + if (!strcmp(lynxID, co->lynxID)) { + /* + * We found the cookie. + * Delete it if confirmed. - FM + */ + if (HTConfirm(DELETE_COOKIE_CONFIRMATION) == FALSE) + { + FREE(lynxID); + HTNoDataOK = 1; + return(HT_NO_DATA); + } + HTList_removeObject(de->cookie_list, co); + freeCookie(co); + co = NULL; + total_cookies--; + if ((de->bv == QUERY_USER && + HTList_isEmpty(de->cookie_list)) && + HTConfirm(DELETE_EMPTY_DOMAIN_CONFIRMATION)) { /* - * We found the cookie. - * Delete it if confirmed. - FM + * No more cookies in this domain, no + * default accept/reject choice was set + * by the user, and got confirmation on + * deleting the domain, so do it. - FM */ - if (HTConfirm(DELETE_COOKIE_CONFIRMATION) == FALSE) - { - FREE(lynxID); - HTNoDataOK = 1; - return(HT_NO_DATA); - } - HTList_removeObject(de->cookie_list, co); - freeCookie(co); - co = NULL; - total_cookies--; - if ((de->bv == QUERY_USER && - HTList_isEmpty(de->cookie_list)) && - HTConfirm(DELETE_EMPTY_DOMAIN_CONFIRMATION)) { - /* - * No more cookies in this domain, no - * default accept/reject choice was set - * by the user, and got confirmation on - * deleting the domain, so do it. - FM - */ - FREE(de->domain); - HTList_delete(de->cookie_list); - de->cookie_list = NULL; - HTList_removeObject(domain_list, de); - FREE(de); - HTProgress(DOMAIN_EATEN); - } else { - HTProgress(COOKIE_EATEN); - } - LYSleepMsg(); - HTNoDataOK = 1; - break; + FREE(de->domain); + HTList_delete(de->cookie_list); + de->cookie_list = NULL; + HTList_removeObject(domain_list, de); + FREE(de); + HTProgress(DOMAIN_EATEN); + } else { + HTProgress(COOKIE_EATEN); } + LYSleepMsg(); + HTNoDataOK = 1; + break; } + } + } else { + /* + * Prompt whether to delete all of the cookies in this domain, + * or the domain if no cookies in it, or to change its 'allow' + * setting, or to cancel, and then act on the user's response. + * - FM + */ + if (HTList_isEmpty(de->cookie_list)) { + _statusline(DELETE_DOMAIN_SET_ALLOW_OR_CANCEL); } else { - /* - * Prompt whether to delete all of the cookies in - * this domain, or the domain if no cookies in it, - * or to change its 'allow' setting, or to cancel, - * and then act on the user's response. - FM - */ - if (HTList_isEmpty(de->cookie_list)) { - _statusline(DELETE_DOMAIN_SET_ALLOW_OR_CANCEL); - } else { - _statusline(DELETE_COOKIES_SET_ALLOW_OR_CANCEL); - } - HTNoDataOK = 1; - while (1) { - ch = LYgetch_single(); + _statusline(DELETE_COOKIES_SET_ALLOW_OR_CANCEL); + } + HTNoDataOK = 1; + while (1) { + ch = LYgetch_single(); #ifdef VMS - if (HadVMSInterrupt) { - HadVMSInterrupt = FALSE; - ch = 'C'; - } + if (HadVMSInterrupt) { + HadVMSInterrupt = FALSE; + ch = 'C'; + } #endif /* VMS */ - switch(ch) { - case 'A': - /* - * Set to accept all cookies - * from this domain. - FM - */ - de->bv = ACCEPT_ALWAYS; - HTUserMsg2(ALWAYS_ALLOWING_COOKIES, - de->domain); - return(HT_NO_DATA); - - case 'C': - /* - * Cancelled. - FM - */ - reject: - HTUserMsg(CANCELLED); - return(HT_NO_DATA); - - case 'D': - if (HTList_isEmpty(de->cookie_list)) { - /* - * We had an empty domain, so we - * were asked to delete it. - FM - */ - FREE(de->domain); - HTList_delete(de->cookie_list); - de->cookie_list = NULL; - HTList_removeObject(domain_list, de); - FREE(de); - HTProgress(DOMAIN_EATEN); - LYSleepMsg(); - break; - } + switch(ch) { + case 'A': + /* + * Set to accept all cookies from this domain. - FM + */ + de->bv = ACCEPT_ALWAYS; + HTUserMsg2(ALWAYS_ALLOWING_COOKIES, de->domain); + return(HT_NO_DATA); + + case 'C': + /* + * Cancelled. - FM + */ + reject: + HTUserMsg(CANCELLED); + return(HT_NO_DATA); + + case 'D': + if (HTList_isEmpty(de->cookie_list)) { + /* + * We had an empty domain, so we were asked to + * delete it. - FM + */ + FREE(de->domain); + HTList_delete(de->cookie_list); + de->cookie_list = NULL; + HTList_removeObject(domain_list, de); + FREE(de); + HTProgress(DOMAIN_EATEN); + LYSleepMsg(); + break; + } Delete_all_cookies_in_domain: - /* - * Delete all cookies in this domain. - FM - */ - cl = de->cookie_list; - while (cl) { - next = cl->next; - co = cl->object; - if (co) { - HTList_removeObject(de->cookie_list, - co); - freeCookie(co); - co = NULL; - total_cookies--; - } - cl = next; - } - HTProgress(DOMAIN_COOKIES_EATEN); - LYSleepMsg(); - /* - * If a default accept/reject - * choice is set, we're done. - FM - */ - if (de->bv != QUERY_USER) - return(HT_NO_DATA); - /* - * Check whether to delete - * the empty domain. - FM - */ - if(HTConfirm( - DELETE_EMPTY_DOMAIN_CONFIRMATION)) { - FREE(de->domain); - HTList_delete(de->cookie_list); - de->cookie_list = NULL; - HTList_removeObject(domain_list, de); - FREE(de); - HTProgress(DOMAIN_EATEN); - LYSleepMsg(); - } - break; - - case 'P': - /* - * Set to prompt for cookie acceptance - * from this domain. - FM - */ - de->bv = QUERY_USER; - HTUserMsg2(PROMPTING_TO_ALLOW_COOKIES, - de->domain); - return(HT_NO_DATA); - - case 'V': - /* - * Set to reject all cookies - * from this domain. - FM - */ - de->bv = REJECT_ALWAYS; - HTUserMsg2(NEVER_ALLOWING_COOKIES, - de->domain); - if ((!HTList_isEmpty(de->cookie_list)) && - HTConfirm(DELETE_ALL_COOKIES_IN_DOMAIN)) - goto Delete_all_cookies_in_domain; - return(HT_NO_DATA); - - default: - if (LYCharIsINTERRUPT(ch)) - goto reject; - continue; + /* + * Delete all cookies in this domain. - FM + */ + cl = de->cookie_list; + while (cl) { + next = cl->next; + co = cl->object; + if (co) { + HTList_removeObject(de->cookie_list, co); + freeCookie(co); + co = NULL; + total_cookies--; + } + cl = next; + } + HTProgress(DOMAIN_COOKIES_EATEN); + LYSleepMsg(); + /* + * If a default accept/reject choice is set, we're + * done. - FM + */ + if (de->bv != QUERY_USER) + return(HT_NO_DATA); + /* + * Check whether to delete the empty domain. - FM + */ + if (HTConfirm(DELETE_EMPTY_DOMAIN_CONFIRMATION)) { + FREE(de->domain); + HTList_delete(de->cookie_list); + de->cookie_list = NULL; + HTList_removeObject(domain_list, de); + FREE(de); + HTProgress(DOMAIN_EATEN); + LYSleepMsg(); } break; + + case 'P': + /* + * Set to prompt for cookie acceptance from this + * domain. - FM + */ + de->bv = QUERY_USER; + HTUserMsg2(PROMPTING_TO_ALLOW_COOKIES, de->domain); + return(HT_NO_DATA); + + case 'V': + /* + * Set to reject all cookies from this domain. - FM + */ + de->bv = REJECT_ALWAYS; + HTUserMsg2(NEVER_ALLOWING_COOKIES, de->domain); + if ((!HTList_isEmpty(de->cookie_list)) && + HTConfirm(DELETE_ALL_COOKIES_IN_DOMAIN)) + goto Delete_all_cookies_in_domain; + return(HT_NO_DATA); + + default: + if (LYCharIsINTERRUPT(ch)) + goto reject; + continue; } + break; } - break; } } if (HTList_isEmpty(domain_list)) { /* - * There are no more domains left. - * Don't delete the domain_list, otherwise - * atexit may be called multiple times. - kw + * There are no more domains left. Don't delete the domain_list, + * otherwise atexit may be called multiple times. - kw */ HTProgress(ALL_COOKIES_EATEN); LYSleepMsg(); @@ -2552,11 +2348,10 @@ Delete_all_cookies_in_domain: } /* - * If we get to here, it was a LYNXCOOKIE:/ URL - * for creating and displaying the Cookie Jar Page, - * or we didn't find the domain or cookie in a - * deletion request. Set up an HTML stream and - * return an updated Cookie Jar Page. - FM + * If we get to here, it was a LYNXCOOKIE:/ URL for creating and displaying + * the Cookie Jar Page, or we didn't find the domain or cookie in a + * deletion request. Set up an HTML stream and return an updated Cookie + * Jar Page. - FM */ target = HTStreamStack(format_in, format_out, @@ -2570,8 +2365,8 @@ Delete_all_cookies_in_domain: } /* - * Load HTML strings into buf and pass buf - * to the target for parsing and rendering. - FM + * Load HTML strings into buf and pass buf to the target for parsing and + * rendering. - FM */ #define PUTS(buf) (*target->isa->put_block)(target, buf, strlen(buf)) @@ -2607,15 +2402,15 @@ Delete_all_cookies_in_domain: de->domain, de->domain, de->domain); PUTS(buf); switch (de->bv) { - case (ACCEPT_ALWAYS): - HTSprintf0(&buf, COOKIES_ALWAYS_ALLOWED); - break; - case (REJECT_ALWAYS): - HTSprintf0(&buf, COOKIES_NEVER_ALLOWED); - break; - case (QUERY_USER): - HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT); - break; + case (ACCEPT_ALWAYS): + HTSprintf0(&buf, COOKIES_ALWAYS_ALLOWED); + break; + case (REJECT_ALWAYS): + HTSprintf0(&buf, COOKIES_NEVER_ALLOWED); + break; + case (QUERY_USER): + HTSprintf0(&buf, COOKIES_ALLOWED_VIA_PROMPT); + break; } PUTS(buf); HTSprintf0(&buf, "\n"); @@ -2745,17 +2540,14 @@ Delete_all_cookies_in_domain: ** invcheck behavior, as well as accept/reject behavior. - BJP */ -PUBLIC void cookie_domain_flag_set ARGS2( +PRIVATE void cookie_domain_flag_set ARGS2( char *, domainstr, int, flag) { domain_entry *de = NULL; - domain_entry *de2 = NULL; - HTList *hl = NULL; char **str = typecalloc(char *); char *dstr = NULL; char *strsmall = NULL; - int isexisting = FALSE; if (str == NULL) { HTAlwaysAlert(gettext("Internal"), @@ -2764,10 +2556,8 @@ PUBLIC void cookie_domain_flag_set ARGS2( } /* - * Is this the first domain we're handling? If so, initialize - * domain_list. + * Is this the first domain we're handling? If so, initialize domain_list. */ - if (domain_list == NULL) { #ifdef LY_FIND_LEAKS atexit(LYCookieJar_free); @@ -2789,67 +2579,53 @@ PUBLIC void cookie_domain_flag_set ARGS2( /* * Check the list of existing domains to see if this is a - * re-setting of an already existing domains -- if so, just + * re-setting of an already existing domain -- if so, just * change the behavior, if not, create a new domain entry. */ - for (hl = domain_list; hl != NULL; hl = hl->next) { - de2 = (domain_entry *)hl->object; - if ((de2 != NULL && de2->domain != NULL) && - !strcasecomp(strsmall, de2->domain)) { - isexisting = TRUE; - break; - } else { - isexisting = FALSE; - } - } - - if(!isexisting) { + if ((de = find_domain_entry(strsmall)) == NULL) { de = typecalloc(domain_entry); - if (de == NULL) outofmem(__FILE__, "cookie_domain_flag_set"); + de->bv = ACCEPT_ALWAYS; + de->invcheck_bv = INVCHECK_QUERY; + switch(flag) { - case (FLAG_ACCEPT_ALWAYS): de->bv = ACCEPT_ALWAYS; - de->invcheck_bv = DEFAULT_INVCHECK_BV; - break; - case (FLAG_REJECT_ALWAYS): de->bv = REJECT_ALWAYS; - de->invcheck_bv = DEFAULT_INVCHECK_BV; - break; - case (FLAG_QUERY_USER): de->bv = QUERY_USER; - de->invcheck_bv = DEFAULT_INVCHECK_BV; - break; - case (FLAG_INVCHECK_QUERY): de->invcheck_bv = INVCHECK_QUERY; - de->bv = QUERY_USER; - break; - case (FLAG_INVCHECK_STRICT): de->invcheck_bv = INVCHECK_STRICT; - de->bv = QUERY_USER; - break; - case (FLAG_INVCHECK_LOOSE): de->invcheck_bv = INVCHECK_LOOSE; - de->bv = QUERY_USER; - break; + case (FLAG_ACCEPT_ALWAYS): de->invcheck_bv = DEFAULT_INVCHECK_BV; + break; + case (FLAG_REJECT_ALWAYS): de->invcheck_bv = DEFAULT_INVCHECK_BV; + break; + case (FLAG_QUERY_USER): de->invcheck_bv = DEFAULT_INVCHECK_BV; + break; + case (FLAG_INVCHECK_QUERY): de->bv = QUERY_USER; + break; + case (FLAG_INVCHECK_STRICT): de->bv = QUERY_USER; + break; + case (FLAG_INVCHECK_LOOSE): de->bv = QUERY_USER; + break; } StrAllocCopy(de->domain, strsmall); de->cookie_list = HTList_new(); HTList_appendObject(domain_list, de); - } else { - switch(flag) { - case (FLAG_ACCEPT_ALWAYS): de2->bv = ACCEPT_ALWAYS; - break; - case (FLAG_REJECT_ALWAYS): de2->bv = REJECT_ALWAYS; - break; - case (FLAG_QUERY_USER): de2->bv = QUERY_USER; - break; - case (FLAG_INVCHECK_QUERY): de2->invcheck_bv = INVCHECK_QUERY; - break; - case (FLAG_INVCHECK_STRICT): de2->invcheck_bv = INVCHECK_STRICT; - break; - case (FLAG_INVCHECK_LOOSE): de2->invcheck_bv = INVCHECK_LOOSE; - break; - } } + switch(flag) { + case (FLAG_ACCEPT_ALWAYS): de->bv = ACCEPT_ALWAYS; + break; + case (FLAG_REJECT_ALWAYS): de->bv = REJECT_ALWAYS; + break; + case (FLAG_QUERY_USER): de->bv = QUERY_USER; + break; + case (FLAG_INVCHECK_QUERY): de->invcheck_bv = INVCHECK_QUERY; + break; + case (FLAG_INVCHECK_STRICT): de->invcheck_bv = INVCHECK_STRICT; + break; + case (FLAG_INVCHECK_LOOSE): de->invcheck_bv = INVCHECK_LOOSE; + break; + } + CTRACE((tfp, "cookie_domain_flag_set (%s, bv=%d, invcheck_bv=%d)\n", + strsmall, de->bv, de->invcheck_bv)); } FREE(strsmall); diff --git a/src/LYCookie.h b/src/LYCookie.h index f038ed2d..59e7ab79 100644 --- a/src/LYCookie.h +++ b/src/LYCookie.h @@ -7,17 +7,27 @@ #include <HTList.h> -typedef enum {ACCEPT_ALWAYS, REJECT_ALWAYS, QUERY_USER} behaviour_t; -typedef enum {INVCHECK_QUERY, - INVCHECK_STRICT, - INVCHECK_LOOSE} invcheck_behaviour_t; -typedef enum {FLAG_ACCEPT_ALWAYS, - FLAG_REJECT_ALWAYS, - FLAG_QUERY_USER, - FLAG_FROM_FILE, - FLAG_INVCHECK_QUERY, - FLAG_INVCHECK_STRICT, - FLAG_INVCHECK_LOOSE} cookie_domain_flags; +typedef enum { + ACCEPT_ALWAYS = 0 + , REJECT_ALWAYS + , QUERY_USER +} behaviour_t; + +typedef enum { + INVCHECK_QUERY = 0 + , INVCHECK_STRICT + , INVCHECK_LOOSE +} invcheck_behaviour_t; + +typedef enum { + FLAG_ACCEPT_ALWAYS = 0 + , FLAG_REJECT_ALWAYS + , FLAG_QUERY_USER + , FLAG_FROM_FILE + , FLAG_INVCHECK_QUERY + , FLAG_INVCHECK_STRICT + , FLAG_INVCHECK_LOOSE +} cookie_domain_flags; struct _domain_entry { char * domain; /* Domain for which these cookies are valid */ @@ -31,7 +41,7 @@ extern void LYSetCookie PARAMS(( CONST char * SetCookie, CONST char * SetCookie2, CONST char * address)); -extern char *LYCookie PARAMS(( +extern char *LYAddCookieHeader PARAMS(( char * hostname, char * partialpath, int port, @@ -40,9 +50,6 @@ extern void LYStoreCookies PARAMS(( char * cookie_file)); extern void LYLoadCookies PARAMS(( char * cookie_file)); -extern void cookie_domain_flag_set PARAMS(( - char * domainstr, - int flag)); extern void LYConfigCookies NOPARAMS; #endif /* LYCOOKIES_H */ diff --git a/src/LYCurses.c b/src/LYCurses.c index 9e040ee0..aca351b3 100644 --- a/src/LYCurses.c +++ b/src/LYCurses.c @@ -1,8 +1,17 @@ #include <HTUtils.h> #include <HTAlert.h> + #ifdef __DJGPP__ #include <conio.h> +/* The conio.h distributed with GNU gettext package may redefine gettext() to + * _conio_gettext(). Restore our definition. + */ +#ifndef HAVE_GETTEXT +#undef gettext +#define gettext(s) s +#endif /* HAVE_GETTEXT */ #endif /* __DJGPP__ */ + #include <LYCurses.h> #include <LYStyle.h> #include <LYUtils.h> @@ -757,6 +766,7 @@ PUBLIC void LYnoVideo ARGS1( #endif } +#define NEWTERM_NAME "newterm" #if !defined(VMS) && !defined(USE_SLANG) /* * If newterm is not defined, assume a curses subset which @@ -766,6 +776,7 @@ PUBLIC void LYnoVideo ARGS1( static SCREEN *LYscreen = NULL; #define LYDELSCR() { \ if (recent_sizechange) { \ + CTRACE((tfp, "Screen size: delscreen()\n")); \ delscreen(LYscreen); \ LYscreen = NULL; } } /* @@ -773,6 +784,8 @@ if (recent_sizechange) { \ */ #else /* HAVE_NEWTERM */ static WINDOW *LYscreen = NULL; +#undef NEWTERM_NAME +#define NEWTERM_NAME "initscr" #undef newterm #define newterm(type, out, in) (initscr()) #define LYDELSCR() /* nothing */ @@ -907,6 +920,7 @@ PUBLIC void start_curses NOARGS * If we are VMS then do initscr() everytime start_curses() * is called! */ + CTRACE((tfp, "Screen size: initscr()\n")); initscr(); /* start curses */ #else /* Unix: */ @@ -942,12 +956,14 @@ PUBLIC void start_curses NOARGS } #endif /* defined(__MVS__) */ #endif /* !(defined(NCURSES) && defined(HAVE_RESIZETERM)) */ + CTRACE((tfp, "Screen size: %s()\n", NEWTERM_NAME)); if (!(LYscreen = newterm(NULL,stdout,stdin))) { /* start curses */ fprintf(tfp, "%s\n", gettext("Terminal initialisation failed - unknown terminal type?")); exit_immediately (EXIT_FAILURE); } #else + CTRACE((tfp, "Screen size: initscr()\n")); initscr(); #endif /* HAVE_NEWTERM */ lynx_called_initscr = TRUE; @@ -956,6 +972,7 @@ PUBLIC void start_curses NOARGS size_change(0); recent_sizechange = FALSE; /* prevent mainloop drawing 1st doc twice */ #endif /* SIGWINCH */ + CTRACE((tfp, "Screen size is now %d x %d\n", LYlines, LYcols )); #ifdef USE_CURSES_PADS if (LYuseCursesPads) { @@ -1417,13 +1434,6 @@ PUBLIC BOOLEAN setup ARGS1( #if HAVE_TTYTYPE /* - * Get terminal type (strip 'dec-' from vms style types). - */ - if (strncmp((CONST char*)ttytype, "dec-vt", 6) == 0) { - (void) setterm(ttytype + 4); - } - - /* * Account for lossage on the 'sun' terminal type (80x24) Sun text * console driver. It only supports reverse video, but all SGR * sequences produce that same reverse video, and the terminfo diff --git a/src/LYExtern.c b/src/LYExtern.c index 01939689..3bf057fb 100644 --- a/src/LYExtern.c +++ b/src/LYExtern.c @@ -68,10 +68,6 @@ static char *decode_string(char *s) #ifdef WIN_EX /* * Quote the path to make it safe for shell command processing. - * - * We use a simple technique which involves quoting the entire - * string using single quotes, escaping the real single quotes - * with double quotes. This may be gross but it seems to work. */ PUBLIC char * quote_pathname ARGS1( char *, pathname) @@ -110,20 +106,16 @@ PRIVATE char *format_command ARGS2( char *, command, char *, param) { -#ifdef WIN_EX - char pram_string[LY_MAXPATH]; -#endif char *cmdbuf = NULL; -#if (defined(VMS) || defined(DOSPATH) || defined(__EMX__)) && !defined(WIN_EX) - format(&cmdbuf, command, param); -#else /* Unix or DOS/Win: */ #if defined(WIN_EX) if (*param != '\"' && strchr(param, ' ') != NULL) { char *cp = quote_pathname(param); format(&cmdbuf, command, cp); FREE(cp); } else { + char pram_string[LY_MAXPATH]; + LYstrncpy(pram_string, param, sizeof(pram_string)-1); decode_string(pram_string); param = pram_string; @@ -156,31 +148,28 @@ PRIVATE char *format_command ARGS2( *p = '\0'; } } - if (*e_buff != '\"' && strchr(e_buff, ' ') != NULL) { - p = quote_pathname(e_buff); - LYstrncpy(e_buff, p, sizeof(e_buff)-1); - FREE(p); - } - /* Less ==> short filename, - * less ==> long filename + /* Less ==> short filename with backslashes, + * less ==> long filename with forward slashes, may be quoted */ if (isupper(command[0])) { format(&cmdbuf, command, HTDOS_short_name(e_buff)); } else { + if (*e_buff != '\"' && strchr(e_buff, ' ') != NULL) { + p = quote_pathname(e_buff); + LYstrncpy(e_buff, p, sizeof(e_buff)-1); + FREE(p); + } format(&cmdbuf, command, e_buff); } } else { format(&cmdbuf, command, param); } } -#else /* Unix */ - { - format(&cmdbuf, command, param); - } +#else + format(&cmdbuf, command, param); #endif -#endif /* VMS */ return cmdbuf; } diff --git a/src/LYForms.c b/src/LYForms.c index 928b1663..f7b9e99b 100644 --- a/src/LYForms.c +++ b/src/LYForms.c @@ -26,7 +26,7 @@ #endif /* VMS && !USE_SLANG */ PRIVATE int form_getstr PARAMS(( - struct link * form_link, + int cur, BOOLEAN use_last_tfpos, BOOLEAN redraw_only)); @@ -58,17 +58,17 @@ PRIVATE char ** options_list ARGS1( return result; } -PUBLIC int change_form_link_ex ARGS8( - struct link *, form_link, +PUBLIC int change_form_link_ex ARGS6( + int, cur, document *, newdoc, BOOLEAN *, refresh_screen, - char *, link_name, - char *, link_value, BOOLEAN, use_last_tfpos, BOOLEAN, immediate_submit, BOOLEAN, redraw_only) { - FormInfo *form = form_link->form; + FormInfo *form = links[cur].l_form; + char *link_name = form->name; + char *link_value = form->value; int newdoc_changed = 0; int c = DO_NOTHING; int OrigNumValue; @@ -85,19 +85,14 @@ PUBLIC int change_form_link_ex ARGS8( /* * Move to the link position. */ - LYmove(form_link->ly, form_link->lx); + LYmove(links[cur].ly, links[cur].lx); switch(form->type) { case F_CHECKBOX_TYPE: if (form->disabled == YES) break; - if (form->num_value) { - form_link->hightext = unchecked_box; - form->num_value = 0; - } else { - form_link->hightext = checked_box; - form->num_value = 1; - } + LYSetHilite(cur, form->num_value ? unchecked_box : checked_box); + form->num_value = ! form->num_value; break; case F_OPTION_LIST_TYPE: @@ -110,8 +105,8 @@ PUBLIC int change_form_link_ex ARGS8( if (form->disabled == YES) { int dummy; dummy = LYhandlePopupList(form->num_value, - form_link->ly, - form_link->lx, + links[cur].ly, + links[cur].lx, (CONST char **)my_data, form->size, form->size_l, @@ -128,8 +123,8 @@ PUBLIC int change_form_link_ex ARGS8( } OrigNumValue = form->num_value; form->num_value = LYhandlePopupList(form->num_value, - form_link->ly, - form_link->lx, + links[cur].ly, + links[cur].lx, (CONST char **)my_data, form->size, form->size_l, @@ -179,17 +174,17 @@ PUBLIC int change_form_link_ex ARGS8( */ 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 && - links[i].form->number == form->number && + if (links[i].type == WWW_FORM_LINK_TYPE + && links[i].l_form->type == F_RADIO_TYPE + && links[i].l_form->number == form->number /* * If it has the same name and its on... */ - !strcmp(links[i].form->name, form->name) && - links[i].form->num_value) { + && !strcmp(links[i].l_form->name, form->name) + && links[i].l_form->num_value) { LYmove(links[i].ly, links[i].lx); LYaddstr(unchecked_radio); - links[i].hightext = unchecked_radio; + LYSetHilite(i, unchecked_radio); } } lynx_stop_radio_color (); @@ -200,7 +195,7 @@ PUBLIC int change_form_link_ex ARGS8( /* * Now highlight this one. */ - form_link->hightext = checked_radio; + LYSetHilite(cur, checked_radio); } break; @@ -208,11 +203,10 @@ PUBLIC int change_form_link_ex ARGS8( case F_TEXT_TYPE: case F_TEXTAREA_TYPE: case F_PASSWORD_TYPE: - c = form_getstr(form_link, use_last_tfpos, redraw_only); - if (form->type == F_PASSWORD_TYPE) - form_link->hightext = STARS(strlen(form->value)); - else - form_link->hightext = form->value; + c = form_getstr(cur, use_last_tfpos, redraw_only); + LYSetHilite(cur, (form->type == F_PASSWORD_TYPE) + ? STARS(strlen(form->value)) + : form->value); break; case F_RESET_TYPE: @@ -224,11 +218,11 @@ PUBLIC int change_form_link_ex ARGS8( case F_TEXT_SUBMIT_TYPE: if (redraw_only) { - c = form_getstr(form_link, use_last_tfpos, TRUE); + c = form_getstr(cur, use_last_tfpos, TRUE); break; } if (!immediate_submit) - c = form_getstr(form_link, use_last_tfpos, FALSE); + c = form_getstr(cur, use_last_tfpos, FALSE); if (form->disabled == YES && (c == '\r' || c == '\n' || immediate_submit)) { if (peek_mouse_link() >= 0) @@ -257,7 +251,7 @@ PUBLIC int change_form_link_ex ARGS8( if (immediate_submit || ((c == '\r' || c == '\n' || c == LAC_TO_LKC0(LYK_SUBMIT)) && peek_mouse_link() == -1)) { - form_link->hightext = form->value; + LYSetHilite(cur, form->value); #ifdef TEXT_SUBMIT_CONFIRM_WANTED if (!immediate_submit && (c == '\r' || c == '\n') && !HTConfirmDefault(NO_SUBMIT_BUTTON_QUERY), YES) { @@ -307,7 +301,7 @@ PUBLIC int change_form_link_ex ARGS8( c = DO_NOTHING; break; } else { - form_link->hightext = form->value; + LYSetHilite(cur, form->value); } break; @@ -348,18 +342,20 @@ PUBLIC int change_form_link_ex ARGS8( return(c); } -PUBLIC int change_form_link ARGS7( - struct link *, form_link, +PUBLIC int change_form_link ARGS5( + int, cur, document *, newdoc, BOOLEAN *, refresh_screen, - char *, link_name, - char *, link_value, BOOLEAN, use_last_tfpos, BOOLEAN, immediate_submit) { /*pass all our args and FALSE as last arg*/ - return change_form_link_ex(form_link,newdoc,refresh_screen,link_name, - link_value,use_last_tfpos,immediate_submit, FALSE /*redraw_only*/ ); + return change_form_link_ex(cur, + newdoc, + refresh_screen, + use_last_tfpos, + immediate_submit, + FALSE /*redraw_only*/ ); } PRIVATE int LastTFPos = -1; /* remember last text field position */ @@ -371,11 +367,11 @@ PRIVATE void LYSetLastTFPos ARGS1( } PRIVATE int form_getstr ARGS3( - struct link *, form_link, + int, cur, BOOLEAN, use_last_tfpos, BOOLEAN, redraw_only) { - FormInfo *form = form_link->form; + FormInfo *form = links[cur].l_form; char *value = form->value; int ch; int far_col; @@ -760,13 +756,15 @@ again: to do it inside LYLineEdit(). This should work for prompts too. */ if ( (action != LYE_BACK_LL && action != LYE_FORW_RL) - || ((form_link - links) >= 0 - && (form_link - links) < nlinks + || (cur >= 0 + && cur < nlinks && (action==LYE_FORW_RL - ? (form_link - links) < nlinks - 1 - : (form_link - links) > 0) - && form_link[action==LYE_FORW_RL ? 1 : -1].ly - == form_link->ly)) + ? cur < nlinks - 1 + : cur > 0) + && links[cur + ((action==LYE_FORW_RL) + ? 1 + : -1)].ly + == links[cur].ly)) goto breakfor; } #ifdef SUPPORT_MULTIBYTE_EDIT diff --git a/src/LYGetFile.c b/src/LYGetFile.c index 1c4097ea..ce0bb79b 100644 --- a/src/LYGetFile.c +++ b/src/LYGetFile.c @@ -1250,6 +1250,8 @@ PUBLIC int follow_link_number ARGS4( */ if (*num > 0) { int info; + char *text; + /* * Get the lname, and hightext, directly from www * structures and add it to the cur link so that @@ -1260,12 +1262,14 @@ PUBLIC int follow_link_number ARGS4( * in the current document, whether it is displayed * on the screen or not! */ - if ((info = HTGetLinkInfo(*num, - want_go, - &new_top, - &new_link, - &links[cur].hightext, - &links[cur].lname)) == WWW_INTERN_LINK_TYPE) { + info = HTGetLinkInfo(*num, + want_go, + &new_top, + &new_link, + &text, + &links[cur].lname); + LYSetHilite(cur, text); + if (info == WWW_INTERN_LINK_TYPE) { links[cur].type = WWW_INTERN_LINK_TYPE; return(DO_LINK_STUFF); } else if (info == LINK_LINE_FOUND) { diff --git a/src/LYHistory.c b/src/LYHistory.c index b012e230..554cc786 100644 --- a/src/LYHistory.c +++ b/src/LYHistory.c @@ -292,7 +292,7 @@ PRIVATE void clean_extra NOARGS /* What is the relationship to are_different() from the mainloop?! */ PRIVATE int are_identical ARGS2( - histstruct *, doc, + HistInfo *, doc, document *, doc1) { return ( STREQ(doc1->address, doc->address) diff --git a/src/LYLocal.c b/src/LYLocal.c index 42b96763..1183b30e 100644 --- a/src/LYLocal.c +++ b/src/LYLocal.c @@ -434,8 +434,12 @@ PRIVATE int make_directory ARGS1(char *, path) code = (LYExecv(MKDIR_PATH, args, msg) <= 0) ? -1 : 1; FREE(msg); #else +#ifdef _WINDOWS + code = mkdir(path) ? -1 : 1; +#else code = mkdir(path, 0777) ? -1 : 1; #endif +#endif return (code); } diff --git a/src/LYMail.c b/src/LYMail.c index d5432c7f..4fbf79a4 100644 --- a/src/LYMail.c +++ b/src/LYMail.c @@ -476,6 +476,9 @@ PUBLIC int LYSendMailFile ARGS5( char *, message) { char *cmd = NULL; +#ifdef __DJGPP__ + char *shell; +#endif /* __DJGPP__ */ int code; #if USE_BLAT_MAILER @@ -492,10 +495,33 @@ PUBLIC int LYSendMailFile ARGS5( ); else #endif +#ifdef __DJGPP__ + if ((shell = getenv("SHELL")) != NULL) { + if (strstr(shell, "sh") != NULL) { + HTSprintf0(&cmd, "%s -c %s -t \"%s\" -F %s", + shell, + system_mail, + the_address, + the_filename); + } else { + HTSprintf0(&cmd, "%s /c %s -t \"%s\" -F %s", + shell, + system_mail, + the_address, + the_filename); + } + } else { + HTSprintf0(&cmd, "%s -t \"%s\" -F %s", + system_mail, + the_address, + the_filename); + } +#else HTSprintf0(&cmd, "%s -t \"%s\" -F %s", system_mail, the_address, the_filename); +#endif /* __DJGPP__ */ stop_curses(); SetOutputMode(O_TEXT); @@ -988,7 +1014,7 @@ PUBLIC void mailmsg ARGS4( fprintf(fd, gettext("The link %s :?: %s \n"), links[cur].lname, links[cur].target); - fprintf(fd, gettext("called \"%s\"\n"), links[cur].hightext); + fprintf(fd, gettext("called \"%s\"\n"), LYGetHiliteStr(cur, 0)); fprintf(fd, gettext("in the file \"%s\" called \"%s\"\n"), filename, linkname); fprintf(fd, "%s\n\n", gettext("was requested but was not available.")); fprintf(fd, "%s\n\n", gettext("Thought you might want to know.")); diff --git a/src/LYMain.c b/src/LYMain.c index 6524f09a..e8905b90 100644 --- a/src/LYMain.c +++ b/src/LYMain.c @@ -40,6 +40,7 @@ #include <dpmi.h> #include <io.h> #include <sys/stat.h> +#include <sys/exceptn.h> #endif /* __DJGPP__ */ #ifdef __EMX__ @@ -420,7 +421,7 @@ PUBLIC char *startrealm = NULL; /* the startfile realm */ PUBLIC char *system_mail = NULL; /* The path for sending mail */ PUBLIC char *system_mail_flags = NULL; /* Flags for sending mail */ PUBLIC char *x_display = NULL; /* display environment variable */ -PUBLIC histstruct history[MAXHIST]; +PUBLIC HistInfo history[MAXHIST]; PUBLIC int AlertSecs; /* time-delay for HTAlert() messages */ PUBLIC int InfoSecs; /* time-delay for Information messages */ PUBLIC int LYMultiBookmarks = MULTI_BOOKMARK_SUPPORT; @@ -434,7 +435,7 @@ PUBLIC int lynx_temp_subspace = 0; /* > 0 if we made temp-directory */ PUBLIC int nhist = 0; /* number of history entries */ PUBLIC int nlinks = 0; /* number of links in memory */ PUBLIC int outgoing_mail_charset = -1; /* translate mail to this charset */ -PUBLIC linkstruct links[MAXLINKS]; +PUBLIC LinkInfo links[MAXLINKS]; #ifndef DISABLE_BIBP PUBLIC BOOLEAN BibP_bibhost_available = FALSE; /* until check succeeds */ @@ -948,6 +949,8 @@ PUBLIC int main ARGS2( } else { init_ctrl_break[0] = 1; } + __djgpp_set_sigquit_key(0x082D); /* Bind ALT-X to SIGQUIT */ + signal(SIGQUIT, cleanup_sig); atexit(reset_break); #endif /* __DJGPP__ */ @@ -1034,8 +1037,8 @@ PUBLIC int main ARGS2( /* * Zero the links and history struct arrays. */ - memset((void *)links, 0, sizeof(linkstruct)*MAXLINKS); - memset((void *)history, 0, sizeof(histstruct)*MAXHIST); + memset((void *)links, 0, sizeof(LinkInfo)*MAXLINKS); + memset((void *)history, 0, sizeof(HistInfo)*MAXHIST); /* * Zero the MultiBookmark arrays. */ @@ -1101,15 +1104,15 @@ PUBLIC int main ARGS2( if ((cp = getenv("LYNX_TEMP_SPACE")) != NULL) StrAllocCopy(lynx_temp_space, cp); -#if defined (UNIX) +#if defined (UNIX) || defined (__DJGPP__) else if ((cp = getenv("TMPDIR")) != NULL) StrAllocCopy(lynx_temp_space, cp); #endif #if defined (DOSPATH) || defined (__EMX__) else if ((cp = getenv("TEMP")) != NULL) - StrAllocCopy(lynx_temp_space, HTSYS_name(cp)); + StrAllocCopy(lynx_temp_space, cp); else if ((cp = getenv("TMP")) != NULL) - StrAllocCopy(lynx_temp_space, HTSYS_name(cp)); + StrAllocCopy(lynx_temp_space, cp); #endif else #ifdef TEMP_SPACE @@ -1159,6 +1162,7 @@ PUBLIC int main ARGS2( } #else LYAddPathSep(&lynx_temp_space); + StrAllocCopy(lynx_temp_space, HTSYS_name(lynx_temp_space)); #endif /* VMS */ if ((HTStat(lynx_temp_space, &dir_info) < 0 diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c index e19a908c..545f0bb7 100644 --- a/src/LYMainLoop.c +++ b/src/LYMainLoop.c @@ -171,7 +171,7 @@ PRIVATE int str_n_cmp(const char *p, const char *q, int n) PRIVATE void exit_immediately_with_error_message PARAMS((int state, BOOLEAN first_file)); PRIVATE void status_link PARAMS((char *curlink_name, BOOLEAN show_more, BOOLEAN show_indx)); -PRIVATE void show_main_statusline PARAMS((CONST linkstruct curlink, int for_what)); +PRIVATE void show_main_statusline PARAMS((CONST LinkInfo curlink, int for_what)); PRIVATE void form_noviceline PARAMS((int)); PRIVATE int are_different PARAMS((document *doc1, document *doc2)); @@ -826,9 +826,10 @@ PRIVATE int find_link_near_col ARGS2( while ((delta > 0 ? (i < nlinks) : (i >= 0)) && cy == links[i].ly) { int cx = links[i].lx; + char *text = LYGetHiliteStr(i, 0); - if (links[i].hightext) - cx += strlen(links[i].hightext)/2; + if (text != NULL) + cx += strlen(text) / 2; cx -= col; if (cx < 0) cx = -cx; @@ -986,7 +987,7 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION if (real_cmd == LYK_ACTIVATE && textfields_need_activation && - F_TEXTLIKE(links[curdoc.link].form->type)) { + F_TEXTLIKE(links[curdoc.link].l_form->type)) { textinput_activated = TRUE; show_main_statusline(links[curdoc.link], FOR_INPUT); @@ -998,14 +999,14 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( /* * Don't try to submit forms with bad actions. - FM */ - if (links[curdoc.link].form->type == F_SUBMIT_TYPE || - links[curdoc.link].form->type == F_IMAGE_SUBMIT_TYPE || - links[curdoc.link].form->type == + if (links[curdoc.link].l_form->type == F_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_IMAGE_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE) { /* * Do nothing if it's disabled. - FM */ - if (links[curdoc.link].form->disabled == YES) { + if (links[curdoc.link].l_form->disabled == YES) { HTOutputFormat = WWW_PRESENT; LYforce_no_cache = FALSE; reloading = FALSE; @@ -1014,8 +1015,8 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( /* * Make sure we have an action. - FM */ - if (!links[curdoc.link].form->submit_action || - *links[curdoc.link].form->submit_action + if (!links[curdoc.link].l_form->submit_action || + *links[curdoc.link].l_form->submit_action == '\0') { HTUserMsg(NO_FORM_ACTION); HTOutputFormat = WWW_PRESENT; @@ -1027,7 +1028,7 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( * Check for no_mail if the form action * is a mailto URL. - FM */ - if (links[curdoc.link].form->submit_method + if (links[curdoc.link].l_form->submit_method == URL_MAIL_METHOD && no_mail) { HTAlert(FORM_MAILTO_DISALLOWED); HTOutputFormat = WWW_PRESENT; @@ -1041,7 +1042,7 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( */ if (no_file_url && !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "file:", 5)) { HTAlert(FILE_ACTIONS_DISALLOWED); HTOutputFormat = WWW_PRESENT; @@ -1054,48 +1055,48 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( * via an internal URL. - FM */ if (!strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXCOOKIE:", 11) || #ifdef DIRED_SUPPORT #ifdef OK_PERMIT (!(strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXDIRED:", 10)) && (no_dired_support || strncasecomp( - (links[curdoc.link].form->submit_action + 10), + (links[curdoc.link].l_form->submit_action + 10), "//PERMIT_LOCATION", 17) || !LYIsUIPage(curdoc.address, UIP_PERMIT_OPTIONS))) || #else !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXDIRED:", 10) || #endif /* OK_PERMIT */ #endif /* DIRED_SUPPORT */ !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXDOWNLOAD:", 13) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXHIST:", 9) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXKEYMAP:", 11) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXIMGMAP:", 11) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "LYNXPRINT:", 10) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "lynxexec:", 9) || !strncasecomp( - links[curdoc.link].form->submit_action, + links[curdoc.link].l_form->submit_action, "lynxprog:", 9)) { HTAlert(SPECIAL_ACTION_DISALLOWED); CTRACE((tfp, "LYMainLoop: Rejected '%s'\n", - links[curdoc.link].form->submit_action)); + links[curdoc.link].l_form->submit_action)); HTOutputFormat = WWW_PRESENT; LYforce_no_cache = FALSE; reloading = FALSE; @@ -1106,9 +1107,9 @@ PRIVATE int handle_LYK_ACTIVATE ARGS6( * Check for enctype and let user know we * don't yet support multipart/form-data - FM */ - if (links[curdoc.link].form->submit_enctype) { + if (links[curdoc.link].l_form->submit_enctype) { if (!strcmp( - links[curdoc.link].form->submit_enctype, + links[curdoc.link].l_form->submit_enctype, "multipart/form-data")) { HTAlert( gettext("Enctype multipart/form-data not yet supported! Cannot submit.")); @@ -1126,52 +1127,49 @@ gettext("Enctype multipart/form-data not yet supported! Cannot submit.")); !strncmp(curdoc.address, "file:", 5)) { LYNoRefererForThis = TRUE; } - if (links[curdoc.link].form->submit_method - != URL_MAIL_METHOD) { + if (links[curdoc.link].l_form->submit_method != URL_MAIL_METHOD) { StrAllocCopy(newdoc.title, - links[curdoc.link].hightext); + LYGetHiliteStr(curdoc.link, 0)); } } + /* * Normally we don't get here for text input fields, * but it can happen as a result of mouse positioning. * In that case the statusline will not have updated * info, so update it now. - kw */ - - if (F_TEXTLIKE(links[curdoc.link].form->type)) { - show_formlink_statusline(links[curdoc.link].form, - (real_cmd==LYK_NOCACHE || - real_cmd==LYK_DOWNLOAD || - real_cmd==LYK_HEAD || - (real_cmd==LYK_SUBMIT && + if (F_TEXTLIKE(links[curdoc.link].l_form->type)) { + show_formlink_statusline(links[curdoc.link].l_form, + (real_cmd == LYK_NOCACHE || + real_cmd == LYK_DOWNLOAD || + real_cmd == LYK_HEAD || + (real_cmd == LYK_SUBMIT && !textinput_activated)) ? FOR_PANEL : FOR_INPUT); - if (user_mode==NOVICE_MODE && + if (user_mode == NOVICE_MODE && textinput_activated && - (real_cmd==LYK_ACTIVATE || real_cmd==LYK_SUBMIT)) { - form_noviceline(links[curdoc.link].form->disabled); + (real_cmd == LYK_ACTIVATE || real_cmd == LYK_SUBMIT)) { + form_noviceline(links[curdoc.link].l_form->disabled); } } - *c = change_form_link(&links[curdoc.link], + *c = change_form_link(curdoc.link, &newdoc, refresh_screen, - links[curdoc.link].form->name, - links[curdoc.link].form->value, FALSE, - (BOOLEAN)(real_cmd==LYK_SUBMIT || - real_cmd==LYK_NOCACHE || - real_cmd==LYK_DOWNLOAD || - real_cmd==LYK_HEAD)); + (BOOLEAN)(real_cmd == LYK_SUBMIT || + real_cmd == LYK_NOCACHE || + real_cmd == LYK_DOWNLOAD || + real_cmd == LYK_HEAD)); if (*c != LKC_DONE || *refresh_screen) { /* * Cannot have been a submit field for which * newdoc was filled in. - kw */ - if ((links[curdoc.link].form->type == F_SUBMIT_TYPE || - links[curdoc.link].form->type == F_IMAGE_SUBMIT_TYPE || - links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE) && - links[curdoc.link].form->submit_method + if ((links[curdoc.link].l_form->type == F_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_IMAGE_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE) && + links[curdoc.link].l_form->submit_method != URL_MAIL_METHOD) { /* * Try to undo change of newdoc.title done above. @@ -1233,7 +1231,7 @@ gettext("Enctype multipart/form-data not yet supported! Cannot submit.")); case '\r': default: if ((real_cmd == LYK_ACTIVATE || real_cmd == LYK_SUBMIT) && - F_TEXTLIKE(links[curdoc.link].form->type) && + F_TEXTLIKE(links[curdoc.link].l_form->type) && textinput_activated) return 3; break; @@ -1314,7 +1312,7 @@ gettext("Enctype multipart/form-data not yet supported! Cannot submit.")); * Follow a normal link or anchor. */ StrAllocCopy(newdoc.address, links[curdoc.link].lname); - StrAllocCopy(newdoc.title, links[curdoc.link].hightext); + StrAllocCopy(newdoc.title, LYGetHiliteStr(curdoc.link, 0)); #ifndef DONT_TRACK_INTERNAL_LINKS /* * For internal links, retain POST content if present. @@ -1591,7 +1589,7 @@ PRIVATE void handle_LYK_ADD_BOOKMARK ARGS3( */ if (links[curdoc.link].type != WWW_FORM_LINK_TYPE) { save_bookmark_link(links[curdoc.link].lname, - links[curdoc.link].hightext); + LYGetHiliteStr(curdoc.link, 0)); *refresh_screen = TRUE; /* MultiBookmark support */ } else { HTUserMsg(NOBOOK_FORM_FIELD); @@ -2020,10 +2018,10 @@ PRIVATE int handle_LYK_DOWNLOAD ARGS3( return 1; /* mouse stuff was confused, ignore - kw */ if (nlinks > 0) { if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { - if (links[curdoc.link].form->type == F_SUBMIT_TYPE || - links[curdoc.link].form->type == F_IMAGE_SUBMIT_TYPE || - links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE) { - if (links[curdoc.link].form->submit_method == + if (links[curdoc.link].l_form->type == F_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_IMAGE_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE) { + if (links[curdoc.link].l_form->submit_method == URL_MAIL_METHOD) { if (*old_c != real_c) { *old_c = real_c; @@ -2031,7 +2029,7 @@ PRIVATE int handle_LYK_DOWNLOAD ARGS3( } return 0; } - if (!strncmp(links[curdoc.link].form->submit_action, + if (!strncmp(links[curdoc.link].l_form->submit_action, "LYNXOPTIONS:", 12)) { if (*old_c != real_c) { *old_c = real_c; @@ -2107,7 +2105,7 @@ PRIVATE int handle_LYK_DOWNLOAD ARGS3( * OK, we download from history page, restore URL from stack. */ StrAllocCopy(newdoc.address, history[number].address); - StrAllocCopy(newdoc.title, links[curdoc.link].hightext); + StrAllocCopy(newdoc.title, LYGetHiliteStr(curdoc.link, 0)); StrAllocCopy(newdoc.bookmark, history[number].bookmark); FREE(newdoc.post_data); FREE(newdoc.post_content_type); @@ -2181,7 +2179,7 @@ PRIVATE int handle_LYK_DOWNLOAD ARGS3( * entire document will be downloaded. */ StrAllocCopy(newdoc.address, links[curdoc.link].lname); - StrAllocCopy(newdoc.title, links[curdoc.link].hightext); + StrAllocCopy(newdoc.title, LYGetHiliteStr(curdoc.link, 0)); #ifndef DONT_TRACK_INTERNAL_LINKS /* * Might be an internal link in the same doc from a @@ -2246,10 +2244,11 @@ PRIVATE void handle_LYK_DOWN_LINK ARGS3( int newlink; if (*follow_col == -1) { + char *text = LYGetHiliteStr(curdoc.link, 0); *follow_col = links[curdoc.link].lx; - if (links[curdoc.link].hightext) - *follow_col += strlen(links[curdoc.link].hightext)/2; + if (text != NULL) + *follow_col += strlen(text) / 2; } newlink = find_link_near_col(*follow_col, 1); @@ -2303,8 +2302,8 @@ PRIVATE int handle_LYK_DWIMEDIT ARGS3( * document. KED */ if (nlinks > 0 && - links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { *cmd = LYK_EDIT_TEXTAREA; return 2; } @@ -2321,8 +2320,8 @@ PRIVATE int handle_LYK_DWIMEDIT ARGS3( * via the above if() statement.] */ if (nlinks > 0 && - links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXT_TYPE) { + links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXT_TYPE) { HTUserMsg (CANNOT_EDIT_FIELD); return 1; } @@ -2515,11 +2514,11 @@ PRIVATE void handle_LYK_DWIMHELP ARGS1( */ if (curdoc.link >= 0 && curdoc.link < nlinks && links[curdoc.link].type == WWW_FORM_LINK_TYPE && - !links[curdoc.link].form->disabled && - (links[curdoc.link].form->type == F_TEXT_TYPE || - links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE || - links[curdoc.link].form->type == F_PASSWORD_TYPE || - links[curdoc.link].form->type == F_TEXTAREA_TYPE)) { + !links[curdoc.link].l_form->disabled && + (links[curdoc.link].l_form->type == F_TEXT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_PASSWORD_TYPE || + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE)) { *cshelpfile = LYLineeditHelpURL(); } } @@ -2545,8 +2544,8 @@ PRIVATE void handle_LYK_EDIT_TEXTAREA ARGS3( /* * See if the current link is in a form TEXTAREA. */ - else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { /* stop screen */ stop_curses(); @@ -2594,9 +2593,9 @@ PRIVATE int handle_LYK_ELGOTO ARGS5( } if (!(nlinks > 0 && curdoc.link > -1) || (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type != F_SUBMIT_TYPE && - links[curdoc.link].form->type != F_IMAGE_SUBMIT_TYPE && - links[curdoc.link].form->type != F_TEXT_SUBMIT_TYPE)) { + links[curdoc.link].l_form->type != F_SUBMIT_TYPE && + links[curdoc.link].l_form->type != F_IMAGE_SUBMIT_TYPE && + links[curdoc.link].l_form->type != F_TEXT_SUBMIT_TYPE)) { /* * No links on page, or not a normal link * or form submit button. - FM @@ -2608,8 +2607,8 @@ PRIVATE int handle_LYK_ELGOTO ARGS5( return 0; } if ((links[curdoc.link].type == WWW_FORM_LINK_TYPE) && - (!links[curdoc.link].form->submit_action || - *links[curdoc.link].form->submit_action == '\0')) { + (!links[curdoc.link].l_form->submit_action || + *links[curdoc.link].l_form->submit_action == '\0')) { /* * Form submit button with no ACTION defined. - FM */ @@ -2643,7 +2642,7 @@ PRIVATE int handle_LYK_ELGOTO ARGS5( LYstrncpy(user_input_buffer, ((links[curdoc.link].type == WWW_FORM_LINK_TYPE) ? - links[curdoc.link].form->submit_action : links[curdoc.link].lname), + links[curdoc.link].l_form->submit_action : links[curdoc.link].lname), (MAX_LINE - 1)); /* @@ -2655,7 +2654,7 @@ PRIVATE int handle_LYK_ELGOTO ARGS5( user_input_buffer[0] != '\0' && strcmp(user_input_buffer, ((links[curdoc.link].type == WWW_FORM_LINK_TYPE) - ? links[curdoc.link].form->submit_action + ? links[curdoc.link].l_form->submit_action : links[curdoc.link].lname))) { if (!LYTrimStartfile(user_input_buffer)) { LYRemoveBlanks(user_input_buffer); @@ -2711,32 +2710,32 @@ PRIVATE BOOLEAN handle_LYK_FASTBACKW_LINK ARGS3( * before it if there is one on this screen. - kw */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { - int thisgroup = links[curdoc.link].form->number; - char *thisname = links[curdoc.link].form->name; + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { + int thisgroup = links[curdoc.link].l_form->number; + char *thisname = links[curdoc.link].l_form->name; if (curdoc.link > 0 && !(links[0].type == WWW_FORM_LINK_TYPE && - links[0].form->type == F_TEXTAREA_TYPE && - links[0].form->number == thisgroup && - sametext(links[0].form->name, thisname))) { + links[0].l_form->type == F_TEXTAREA_TYPE && + links[0].l_form->number == thisgroup && + sametext(links[0].l_form->name, thisname))) { do nextlink--; while (links[nextlink].type == WWW_FORM_LINK_TYPE && - links[nextlink].form->type == F_TEXTAREA_TYPE && - links[nextlink].form->number == thisgroup && - sametext(links[nextlink].form->name, thisname)); + links[nextlink].l_form->type == F_TEXTAREA_TYPE && + links[nextlink].l_form->number == thisgroup && + sametext(links[nextlink].l_form->name, thisname)); samepage = 1; } else if (!more && Newline == 1 && (links[0].type == WWW_FORM_LINK_TYPE && - links[0].form->type == F_TEXTAREA_TYPE && - links[0].form->number == thisgroup && - sametext(links[0].form->name, thisname)) && + links[0].l_form->type == F_TEXTAREA_TYPE && + links[0].l_form->number == thisgroup && + sametext(links[0].l_form->name, thisname)) && !(links[nlinks-1].type == WWW_FORM_LINK_TYPE && - links[nlinks-1].form->type == F_TEXTAREA_TYPE && - links[nlinks-1].form->number == thisgroup && - sametext(links[nlinks-1].form->name, thisname))) { + links[nlinks-1].l_form->type == F_TEXTAREA_TYPE && + links[nlinks-1].l_form->number == thisgroup && + sametext(links[nlinks-1].l_form->name, thisname))) { nextlink = nlinks - 1; samepage = 1; @@ -2760,21 +2759,21 @@ PRIVATE BOOLEAN handle_LYK_FASTBACKW_LINK ARGS3( */ if (nextlink > 0 && links[nextlink].type == WWW_FORM_LINK_TYPE && - links[nextlink].form->type == F_TEXTAREA_TYPE) { - int thisgroup = links[nextlink].form->number; - char *thisname = links[nextlink].form->name; + links[nextlink].l_form->type == F_TEXTAREA_TYPE) { + int thisgroup = links[nextlink].l_form->number; + char *thisname = links[nextlink].l_form->name; if (links[0].type == WWW_FORM_LINK_TYPE && - links[0].form->type == F_TEXTAREA_TYPE && - links[0].form->number == thisgroup && - sametext(links[0].form->name, thisname)) { + links[0].l_form->type == F_TEXTAREA_TYPE && + links[0].l_form->number == thisgroup && + sametext(links[0].l_form->name, thisname)) { nextlink = 0; } else while (nextlink > 1 && links[nextlink-1].type == WWW_FORM_LINK_TYPE && - links[nextlink-1].form->type == F_TEXTAREA_TYPE && - links[nextlink-1].form->number == thisgroup && - sametext(links[nextlink-1].form->name, thisname)) { + links[nextlink-1].l_form->type == F_TEXTAREA_TYPE && + links[nextlink-1].l_form->number == thisgroup && + sametext(links[nextlink-1].l_form->name, thisname)) { nextlink--; } } @@ -2818,21 +2817,21 @@ PRIVATE void handle_LYK_FASTFORW_LINK ARGS2( * after it if there is one on this screen. - kw */ if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { - int thisgroup = links[curdoc.link].form->number; - char *thisname = links[curdoc.link].form->name; + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { + int thisgroup = links[curdoc.link].l_form->number; + char *thisname = links[curdoc.link].l_form->name; if (curdoc.link < nlinks-1 && !(links[nlinks-1].type == WWW_FORM_LINK_TYPE && - links[nlinks-1].form->type == F_TEXTAREA_TYPE && - links[nlinks-1].form->number == thisgroup && - sametext(links[nlinks-1].form->name, thisname))) { + links[nlinks-1].l_form->type == F_TEXTAREA_TYPE && + links[nlinks-1].l_form->number == thisgroup && + sametext(links[nlinks-1].l_form->name, thisname))) { do nextlink++; while (links[nextlink].type == WWW_FORM_LINK_TYPE && - links[nextlink].form->type == F_TEXTAREA_TYPE && - links[nextlink].form->number == thisgroup && - sametext(links[nextlink].form->name, thisname)); + links[nextlink].l_form->type == F_TEXTAREA_TYPE && + links[nextlink].l_form->number == thisgroup && + sametext(links[nextlink].l_form->name, thisname)); samepage = 1; } else if (!more && Newline == 1 && curdoc.link > 0) { nextlink = 0; @@ -2943,8 +2942,8 @@ PRIVATE void handle_LYK_GROW_TEXTAREA ARGS1( /* * See if the current link is in a form TEXTAREA. */ - if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { HText_ExpandTextarea (&links[curdoc.link], TEXTAREA_EXPAND_SIZE); @@ -2962,10 +2961,10 @@ PRIVATE BOOLEAN handle_LYK_HEAD ARGS1( int c; if (nlinks > 0 && - (links[curdoc.link].type != WWW_FORM_LINK_TYPE || - links[curdoc.link].form->type == F_SUBMIT_TYPE || - links[curdoc.link].form->type == F_IMAGE_SUBMIT_TYPE || - links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE)) { + (links[curdoc.link].type != WWW_FORM_LINK_TYPE || + links[curdoc.link].l_form->type == F_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_IMAGE_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE)) { /* * We have links, and the current link is a normal link or a form's * submit button. - FM @@ -3009,16 +3008,16 @@ PRIVATE BOOLEAN handle_LYK_HEAD ARGS1( strncmp(curdoc.address, "http", 4))) { HTUserMsg(LINK_NOT_HTTP_URL); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->disabled) { + links[curdoc.link].l_form->disabled) { HTUserMsg(FORM_ACTION_DISABLED); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - strncmp(links[curdoc.link].form->submit_action, + strncmp(links[curdoc.link].l_form->submit_action, "lynxcgi:", 8) && - strncmp(links[curdoc.link].form->submit_action, + strncmp(links[curdoc.link].l_form->submit_action, "http", 4)) { HTUserMsg(FORM_ACTION_NOT_HTTP_URL); } else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->submit_method == + links[curdoc.link].l_form->submit_method == URL_POST_METHOD && HTConfirm(CONFIRM_POST_LINK_HEAD) == FALSE) { HTInfoMsg(CANCELLED); @@ -3374,8 +3373,8 @@ PRIVATE void handle_LYK_INSERT_FILE ARGS3( /* * See if the current link is in a form TEXTAREA. */ - if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) { + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) { /* * Reject attempts to use this for gaining access to @@ -3908,18 +3907,18 @@ PRIVATE void handle_LYK_NEXT_LINK ARGS3( /* * Move to different textarea if TAB in textarea. */ - if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE && + if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE && c=='\t') { - int thisgroup = links[curdoc.link].form->number; - char *thisname = links[curdoc.link].form->name; + int thisgroup = links[curdoc.link].l_form->number; + char *thisname = links[curdoc.link].l_form->name; do curdoc.link++; while ((curdoc.link < nlinks-1) && links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE && - links[curdoc.link].form->number == thisgroup && - sametext(links[curdoc.link].form->name, thisname)); + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE && + links[curdoc.link].l_form->number == thisgroup && + sametext(links[curdoc.link].l_form->name, thisname)); } else { curdoc.link++; } @@ -3962,9 +3961,9 @@ PRIVATE BOOLEAN handle_LYK_NOCACHE ARGS2( { if (nlinks > 0) { if (links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type != F_SUBMIT_TYPE && - links[curdoc.link].form->type != F_IMAGE_SUBMIT_TYPE && - links[curdoc.link].form->type != F_TEXT_SUBMIT_TYPE) { + links[curdoc.link].l_form->type != F_SUBMIT_TYPE && + links[curdoc.link].l_form->type != F_IMAGE_SUBMIT_TYPE && + links[curdoc.link].l_form->type != F_TEXT_SUBMIT_TYPE) { if (*old_c != real_c) { *old_c = real_c; HTUserMsg(NOT_ON_SUBMIT_OR_LINK); @@ -4481,12 +4480,12 @@ PRIVATE void handle_LYK_SWITCH_DTD NOARGS PRIVATE void handle_LYK_TAG_LINK NOARGS { if (lynx_edit_mode && nlinks > 0 && !no_dired_support) { - if (!strcmp(links[curdoc.link].hightext, "..")) + if (!strcmp(LYGetHiliteStr(curdoc.link, 0), "..")) return; /* Never tag the parent directory */ if (dir_list_style == MIXED_STYLE) { - if (!strcmp(links[curdoc.link].hightext, "../")) + if (!strcmp(LYGetHiliteStr(curdoc.link, 0), "../")) return; - } else if (!strncmp(links[curdoc.link].hightext, "Up to ", 6)) + } else if (!strncmp(LYGetHiliteStr(curdoc.link, 0), "Up to ", 6)) return; { /* @@ -4682,10 +4681,11 @@ PRIVATE void handle_LYK_UP_LINK ARGS4( int newlink; if (*follow_col == -1) { + char *text = LYGetHiliteStr(curdoc.link, 0); *follow_col = links[curdoc.link].lx; - if (links[curdoc.link].hightext) - *follow_col += strlen(links[curdoc.link].hightext)/2; + if (text != NULL) + *follow_col += strlen(text) / 2; } newlink = find_link_near_col(*follow_col, -1); @@ -4916,7 +4916,7 @@ PRIVATE void handle_LYK_digit ARGS6( * Follow a normal link. */ StrAllocCopy(newdoc.address, links[lindx].lname); - StrAllocCopy(newdoc.title, links[lindx].hightext); + StrAllocCopy(newdoc.title, LYGetHiliteStr(lindx, 0)); #ifndef DONT_TRACK_INTERNAL_LINKS /* * For internal links, retain POST content if present. @@ -6441,10 +6441,10 @@ try_again: curlink_is_editable = (nlinks > 0 && links[curdoc.link].type == WWW_FORM_LINK_TYPE && - (links[curdoc.link].form->type == F_TEXT_TYPE || - links[curdoc.link].form->type == F_TEXT_SUBMIT_TYPE || - links[curdoc.link].form->type == F_PASSWORD_TYPE || - links[curdoc.link].form->type == F_TEXTAREA_TYPE)); + (links[curdoc.link].l_form->type == F_TEXT_TYPE || + links[curdoc.link].l_form->type == F_TEXT_SUBMIT_TYPE || + links[curdoc.link].l_form->type == F_PASSWORD_TYPE || + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE)); use_last_tfpos = (curlink_is_editable && (real_cmd == LYK_LPOS_PREV_LINK || @@ -6464,7 +6464,7 @@ try_again: if (links[curdoc.link].type == WWW_FORM_LINK_TYPE) { - switch(links[curdoc.link].form->type) { + switch(links[curdoc.link].l_form->type) { case F_TEXT_SUBMIT_TYPE: case F_SUBMIT_TYPE: case F_IMAGE_SUBMIT_TYPE: @@ -6605,13 +6605,11 @@ try_again: * Replace novice lines if in NOVICE_MODE. */ if (user_mode==NOVICE_MODE) { - form_noviceline(links[curdoc.link].form->disabled); + form_noviceline(links[curdoc.link].l_form->disabled); } - real_c = change_form_link(&links[curdoc.link], + real_c = change_form_link(curdoc.link, &newdoc, &refresh_screen, - links[curdoc.link].form->name, - links[curdoc.link].form->value, - use_last_tfpos, FALSE); + use_last_tfpos, FALSE); } #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION if (textfields_need_activation) @@ -6630,15 +6628,15 @@ try_again: do_change_link(); if ((c == '\n' || c == '\r') && links[curdoc.link].type == WWW_FORM_LINK_TYPE && - F_TEXTLIKE(links[curdoc.link].form->type) && + F_TEXTLIKE(links[curdoc.link].l_form->type) && !textfields_need_activation) { c = DO_NOTHING; } #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION } else if ((links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) && textfields_need_activation - && !links[curdoc.link].form->disabled + && !links[curdoc.link].l_form->disabled && peek_mouse_link() < 0 && (((LKC_TO_LAC(keymap,real_c) == LYK_NEXT_LINK || #ifdef TEXTAREA_AUTOGROW @@ -6648,11 +6646,11 @@ try_again: LKC_TO_LAC(keymap,real_c) == LYK_DOWN_LINK) && ((curdoc.link < nlinks-1 && links[curdoc.link+1].type == WWW_FORM_LINK_TYPE && - links[curdoc.link+1].form->type == F_TEXTAREA_TYPE - && (links[curdoc.link].form->number == - links[curdoc.link+1].form->number) && - strcmp(links[curdoc.link].form->name, - links[curdoc.link+1].form->name) == 0) || + links[curdoc.link+1].l_form->type == F_TEXTAREA_TYPE + && (links[curdoc.link].l_form->number == + links[curdoc.link+1].l_form->number) && + strcmp(links[curdoc.link].l_form->name, + links[curdoc.link+1].l_form->name) == 0) || (curdoc.link == nlinks-1 && more && HText_TAHasMoreLines(curdoc.link, 1)))) || ((LKC_TO_LAC(keymap,real_c) == LYK_PREV_LINK || @@ -6660,11 +6658,11 @@ try_again: LKC_TO_LAC(keymap,real_c) == LYK_UP_LINK) && ((curdoc.link > 0 && links[curdoc.link-1].type == WWW_FORM_LINK_TYPE && - links[curdoc.link-1].form->type == F_TEXTAREA_TYPE - && (links[curdoc.link].form->number == - links[curdoc.link-1].form->number) && - strcmp(links[curdoc.link].form->name, - links[curdoc.link-1].form->name) == 0) || + links[curdoc.link-1].l_form->type == F_TEXTAREA_TYPE + && (links[curdoc.link].l_form->number == + links[curdoc.link-1].l_form->number) && + strcmp(links[curdoc.link].l_form->name, + links[curdoc.link-1].l_form->name) == 0) || (curdoc.link == 0 && curdoc.line > 1 && HText_TAHasMoreLines(curdoc.link, -1)))))) { textinput_activated = TRUE; @@ -6693,23 +6691,23 @@ try_again: * try and improve the "readability" (such as it is). * Caveat emptor to anyone trying to change it.] */ - if ((links[curdoc.link].type == WWW_FORM_LINK_TYPE && - links[curdoc.link].form->type == F_TEXTAREA_TYPE) && + if ((links[curdoc.link].type == WWW_FORM_LINK_TYPE && + links[curdoc.link].l_form->type == F_TEXTAREA_TYPE) && ((curdoc.link == nlinks-1 && !(more && HText_TAHasMoreLines(curdoc.link, 1))) || ((curdoc.link < nlinks-1) && !(links[curdoc.link+1].type == WWW_FORM_LINK_TYPE && - links[curdoc.link+1].form->type == F_TEXTAREA_TYPE)) + links[curdoc.link+1].l_form->type == F_TEXTAREA_TYPE)) || ((curdoc.link < nlinks-1) && ((links[curdoc.link+1].type == WWW_FORM_LINK_TYPE && - links[curdoc.link+1].form->type == F_TEXTAREA_TYPE) + links[curdoc.link+1].l_form->type == F_TEXTAREA_TYPE) && - ((links[curdoc.link].form->number != - links[curdoc.link+1].form->number) || - (strcmp (links[curdoc.link].form->name, - links[curdoc.link+1].form->name) != 0)))))) { + ((links[curdoc.link].l_form->number != + links[curdoc.link+1].l_form->number) || + (strcmp (links[curdoc.link].l_form->name, + links[curdoc.link+1].l_form->name) != 0)))))) { HText_ExpandTextarea (&links[curdoc.link], 1); @@ -6758,10 +6756,8 @@ try_again: if (curlink_is_editable && !textinput_redrawn) { /*draw the text entry, but don't activate it*/ textinput_redrawn = TRUE; - change_form_link_ex(&links[curdoc.link], + change_form_link_ex(curdoc.link, &newdoc, &refresh_screen, - links[curdoc.link].form->name, - links[curdoc.link].form->value, use_last_tfpos, FALSE, TRUE); if (LYShowCursor) { LYmove(links[curdoc.link].ly, @@ -6869,7 +6865,7 @@ new_cmd: /* default: if (curdoc.link >= 0 && curdoc.link < nlinks && links[curdoc.link].type == WWW_FORM_LINK_TYPE && - F_TEXTLIKE(links[curdoc.link].form->type)) { + F_TEXTLIKE(links[curdoc.link].l_form->type)) { #ifdef TEXTFIELDS_MAY_NEED_ACTIVATION if (textfields_need_activation) { @@ -7677,7 +7673,7 @@ PUBLIC void HTAddGotoURL ARGS1( * to tell the user other misc info. */ PRIVATE void show_main_statusline ARGS2( - CONST linkstruct, curlink, + CONST LinkInfo, curlink, int, for_what) { /* @@ -7710,7 +7706,7 @@ PRIVATE void show_main_statusline ARGS2( #endif /* NORMAL_NON_FORM_LINK_STATUSLINES_FOR_ALL_USER_MODES */ #endif /* INDICATE_FORMS_MODE_FOR_ALL_LINKS_ON_PAGE */ if (curlink.type == WWW_FORM_LINK_TYPE) { - show_formlink_statusline(curlink.form, for_what); + show_formlink_statusline(curlink.l_form, for_what); } else { statusline(NORMAL_LINK_MESSAGE); } diff --git a/src/LYSearch.c b/src/LYSearch.c index 1afa5eb2..9e4f5b25 100644 --- a/src/LYSearch.c +++ b/src/LYSearch.c @@ -9,36 +9,41 @@ #include <LYLeaks.h> PRIVATE BOOL link_has_target ARGS2( - linkstruct *, a, + int, cur, char *, target) { + LinkInfo *a = &links[cur]; OptionType *option; char *stars = NULL, *cp; + int count; /* - * Search the hightext string, and hightext2 if present, - * taking the case_sensitive setting into account. - FM + * Search the hightext strings, if present, taking the case_sensitive + * setting into account. */ - if (LYno_attr_strstr(a->hightext, target) - || LYno_attr_strstr(a->hightext2, target)) { - return TRUE; + for (count = 0; ; ++count) { + char *text = LYGetHiliteStr(cur, count); + if (text == NULL) + break; + if (LYno_attr_strstr(text, target)) + return TRUE; } /* * Search the relevant form fields, taking the * case_sensitive setting into account. - FM */ - if ((a->form != NULL && a->form->value != NULL) && - a->form->type != F_HIDDEN_TYPE) { - if (a->form->type == F_PASSWORD_TYPE) { + if ((a->l_form != NULL && a->l_form->value != NULL) && + a->l_form->type != F_HIDDEN_TYPE) { + if (a->l_form->type == F_PASSWORD_TYPE) { /* * Check the actual, hidden password, and then * the displayed string. - FM */ - if (LYno_attr_strstr(a->form->value, target)) { + if (LYno_attr_strstr(a->l_form->value, target)) { return TRUE; } - StrAllocCopy(stars, a->form->value); + StrAllocCopy(stars, a->l_form->value); for (cp = stars; *cp != '\0'; cp++) *cp = '*'; if (LYno_attr_strstr(stars, target)) { @@ -46,23 +51,23 @@ PRIVATE BOOL link_has_target ARGS2( return TRUE; } FREE(stars); - } else if (a->form->type == F_OPTION_LIST_TYPE) { + } else if (a->l_form->type == F_OPTION_LIST_TYPE) { /* * Search the option strings that are displayed * when the popup is invoked. - FM */ - option = a->form->select_list; + option = a->l_form->select_list; while (option != NULL) { if (LYno_attr_strstr(option->name, target)) { return TRUE; } option = option->next; } - } else if (a->form->type == F_RADIO_TYPE) { + } else if (a->l_form->type == F_RADIO_TYPE) { /* * Search for checked or unchecked parens. - FM */ - if (a->form->num_value) { + if (a->l_form->num_value) { cp = checked_radio; } else { cp = unchecked_radio; @@ -70,11 +75,11 @@ PRIVATE BOOL link_has_target ARGS2( if (LYno_attr_strstr(cp, target)) { return TRUE; } - } else if (a->form->type == F_CHECKBOX_TYPE) { + } else if (a->l_form->type == F_CHECKBOX_TYPE) { /* * Search for checked or unchecked square brackets. - FM */ - if (a->form->num_value) { + if (a->l_form->num_value) { cp = checked_box; } else { cp = unchecked_box; @@ -89,7 +94,7 @@ PRIVATE BOOL link_has_target ARGS2( * hightext search, but make sure here * that the entire value is searched. - FM */ - if (LYno_attr_strstr(a->form->value, target)) { + if (LYno_attr_strstr(a->l_form->value, target)) { return TRUE; } } @@ -113,7 +118,7 @@ PRIVATE int check_next_target_in_links ARGS2( if (nlinks != 0) { for (i = *cur + 1; i < nlinks; ++i) { - if (link_has_target(&links[i], target)) { + if (link_has_target(i, target)) { *cur = i; return TRUE; } @@ -130,7 +135,7 @@ PRIVATE int check_prev_target_in_links ARGS2( if (nlinks != 0) { for (i = *cur - 1; i >= 0; --i) { - if (link_has_target(&links[i], target)) { + if (link_has_target(i, target)) { *cur = i; return TRUE; } diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index 9fe2b751..8b2337c6 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -369,16 +369,16 @@ PUBLIC int LYShowInfo ARGS4( if (nlinks > 0) { fprintf(fp0, "<h2>%s</h2>\n<dl compact>", gettext("Link that you currently have selected")); - StrAllocCopy(Title, links[doc->link].hightext); + StrAllocCopy(Title, LYGetHiliteStr(doc->link, 0)); LYEntify(&Title, TRUE); fprintf(fp0, "<dt><em>%s</em> %s\n", gettext("Linkname:"), Title); if (lynx_mode == FORMS_LYNX_MODE && links[doc->link].type == WWW_FORM_LINK_TYPE) { - if (links[doc->link].form->submit_method) { - int method = links[doc->link].form->submit_method; - char *enctype = links[doc->link].form->submit_enctype; + if (links[doc->link].l_form->submit_method) { + int method = links[doc->link].l_form->submit_method; + char *enctype = links[doc->link].l_form->submit_enctype; fprintf(fp0, "<dt> <em>%s</em> %s\n", gettext("Method:"), @@ -391,13 +391,13 @@ PUBLIC int LYShowInfo ARGS4( *enctype ? enctype : "application/x-www-form-urlencoded")); } - if (links[doc->link].form->submit_action) { - StrAllocCopy(Address, links[doc->link].form->submit_action); + if (links[doc->link].l_form->submit_action) { + StrAllocCopy(Address, links[doc->link].l_form->submit_action); LYEntify(&Address, TRUE); fprintf(fp0, "<dt> <em>Action:</em> %s\n", Address); } - if (!(links[doc->link].form->submit_method && - links[doc->link].form->submit_action)) { + if (!(links[doc->link].l_form->submit_method && + links[doc->link].l_form->submit_action)) { fprintf(fp0, "<dt> %s\n", gettext("(Form field)")); } } else { diff --git a/src/LYStrings.c b/src/LYStrings.c index dc9862d4..730d7e38 100644 --- a/src/LYStrings.c +++ b/src/LYStrings.c @@ -452,26 +452,28 @@ PRIVATE int set_clicked_link ARGS4( /* Loop over the links and see if we can get a match */ for (i = 0; i < nlinks; i++) { int len, lx = links[i].lx, is_text = 0; + int count = 0; + char *text = LYGetHiliteStr(i, count); if (links[i].type == WWW_FORM_LINK_TYPE - && F_TEXTLIKE(links[i].form->type)) + && F_TEXTLIKE(links[i].l_form->type)) is_text = 1; - if (is_text) - len = links[i].form->size; - else - len = strlen(links[i].hightext ); - /* Check the first line of the link */ - if ( links[i].hightext != NULL) { + if (text != NULL) { + if (is_text) + len = links[i].l_form->size; + else + len = strlen(text); cur_err = XYdist(x, y, links[i].lx, links[i].ly, len); /* Check the second line */ - if (cur_err > 0 && links[i].hightext2 != NULL) { - /* Note that there is never hightext2 if is_text */ + while (cur_err > 0 + && (text = LYGetHiliteStr(i, ++count)) != NULL) { + /* Note that there is at most one hightext if is_text */ int cur_err_2 = XYdist(x, y, - links[i].hightext2_offset, - links[i].ly+1, - strlen(links[i].hightext2)); + LYGetHilitePos(i, count), + links[i].ly + count, + strlen(text)); cur_err = HTMIN(cur_err, cur_err_2); } if (cur_err > 0 && is_text) @@ -484,7 +486,7 @@ PRIVATE int set_clicked_link ARGS4( /* double-click, if we care: submit text submit fields. - kw */ if (clicks > 1 && is_text && - links[i].form->type == F_TEXT_SUBMIT_TYPE) { + links[i].l_form->type == F_TEXT_SUBMIT_TYPE) { if (code != FOR_INPUT /* submit current input field directly */ || !(cury == y && (curx >= lx) && ((curx - lx) <= len))) { @@ -649,7 +651,7 @@ PUBLIC int LYmbcsstrlen ARGS3( { int i, j, len = 0; - if (!str && *str) + if (!non_empty(str)) return(len); for (i = 0; str[i] != '\0'; i++) { @@ -2103,7 +2105,7 @@ re_read: else if (mouse_link >= 0 && textfields_need_activation && links[mouse_link].type == WWW_FORM_LINK_TYPE && - F_TEXTLIKE(links[mouse_link].form->type)) + F_TEXTLIKE(links[mouse_link].l_form->type)) lac = LYK_ACTIVATE; #endif } @@ -4393,7 +4395,7 @@ redraw: */ if ((cp = (char *)HTList_objectAt(search_queries, 0)) != NULL) { - LYstrncpy(prev_target_buffer, cp, sizeof(prev_target_buffer)); + LYstrncpy(prev_target_buffer, cp, sizeof(prev_target_buffer) - 1); QueryNum = 0; FirstRecall = FALSE; } @@ -4938,6 +4940,7 @@ PUBLIC CONST char * LYLineeditHelpURL NOARGS } return NULL; } + /* * A replacement for 'strsep()' */ @@ -5420,7 +5423,7 @@ PUBLIC char * SNACat ARGS3( CONST char *, src, int, n) { - if (src && *src) { + if (non_empty(src)) { if (*dest) { int length = strlen(*dest); *dest = (char *)realloc(*dest, length + n + 1); diff --git a/src/LYStrings.h b/src/LYStrings.h index 0fcebc98..5a4e95b0 100644 --- a/src/LYStrings.h +++ b/src/LYStrings.h @@ -78,6 +78,8 @@ extern char * LYno_attr_mbcs_case_strstr PARAMS(( int * nstartp, int * nendp)); +#define non_empty(s) ((s) != NULL && *(s) != '\0') + #define LYno_attr_mb_strstr(chptr, tarptr, utf_flag, count_gcells, nstartp, nendp) \ (case_sensitive \ ? LYno_attr_mbcs_strstr(chptr, tarptr, utf_flag, count_gcells, nstartp, nendp) \ diff --git a/src/LYStructs.h b/src/LYStructs.h index fd95aee5..180a5ab1 100644 --- a/src/LYStructs.h +++ b/src/LYStructs.h @@ -5,24 +5,36 @@ #include <HTAnchor.h> #endif /* HTANCHOR_H */ -typedef struct link { +typedef struct { + int hl_x; + char *hl_text; +} HiliteInfo; + +typedef struct { + int hl_len; /* number of strings in this struct */ + HiliteInfo hl_base; + HiliteInfo *hl_info; +} HiliteList; + +typedef struct { char *lname; char *target; - char *hightext; - char *hightext2; - int hightext2_offset; + char *l_hightext; + char *l_hightext2; + int l_hightext2_offset; BOOL inUnderline; /* TRUE when this link is in underlined context. */ int lx; int ly; int type; /* Type of link, Forms, WWW, etc. */ int anchor_number; /* The anchor number within the HText structure. */ int anchor_line_num;/* The anchor line number in the HText structure. */ - struct _FormInfo *form; /* Pointer to form info. */ -} linkstruct; -extern linkstruct links[MAXLINKS]; + HiliteList list; + struct _FormInfo *l_form; /* Pointer to form info. */ +} LinkInfo; +extern LinkInfo links[MAXLINKS]; extern int nlinks; -typedef struct _document { +typedef struct { char * title; char * address; char * post_data; @@ -43,7 +55,7 @@ typedef struct _document { #include <HTForms.h> #endif /* HTFORMS_H */ -typedef struct _histstruct { +typedef struct { char * title; char * address; char * post_data; @@ -58,7 +70,7 @@ typedef struct _histstruct { int intern_seq_start; /* indicates which element on the history is the start of this sequence of "internal links", otherwise -1 */ -} histstruct; +} HistInfo; extern int Visited_Links_As; @@ -77,7 +89,7 @@ typedef struct _VisitedLink { struct _VisitedLink *prev_first; } VisitedLink; -extern histstruct history[MAXHIST]; +extern HistInfo history[MAXHIST]; extern int nhist; /******************************************************************************/ diff --git a/src/LYStyle.c b/src/LYStyle.c index 0d2caeea..496bf802 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,6 +1,6 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * @Id: LYStyle.c 1.48 Wed, 15 Aug 2001 15:09:52 -0700 dickey @ + * @Id: LYStyle.c 1.49 Tue, 01 Jan 2002 17:30:08 -0800 dickey @ */ #include <HTUtils.h> #include <HTML.h> @@ -604,7 +604,7 @@ PUBLIC void cache_tag_styles NOARGS for (i = 0; i < HTML_ELEMENTS; ++i) { - strcpy(buf, HTML_dtd.tags[i].name); + LYstrncpy(buf, HTML_dtd.tags[i].name, sizeof(buf)-1); LYLowerCase(buf); cached_tag_styles[i] = hash_code(buf); } diff --git a/src/LYUtils.c b/src/LYUtils.c index 3f94afad..6baa52cd 100644 --- a/src/LYUtils.c +++ b/src/LYUtils.c @@ -188,7 +188,7 @@ PRIVATE LY_TEMP *FindTempfileByFP ARGS1(FILE *, fp) PRIVATE char *getenv_text ARGS1(char *, name) { char *result = getenv(name); - return (result != 0 && *result != 0) ? result : 0; + return non_empty(result) ? result : 0; } /* @@ -229,261 +229,158 @@ PUBLIC size_t utf8_length ARGS2( } /* - * Highlight (or unhighlight) a given link. + * Set the initial highlight information for a given link. */ -PUBLIC void LYhighlight ARGS3( - int, flag, +PUBLIC void LYSetHilite ARGS2( int, cur, - char *, target) + char *, text) { - char buffer[200]; - int i; - char tmp[7]; -#ifdef SHOW_WHEREIS_TARGETS - char *cp; - char *theData = NULL; - char *Data = NULL; - int Offset, HitOffset, tLen; - int LenNeeded; - BOOL TargetEmphasisON = FALSE; - BOOL target1_drawn = NO; -#endif - BOOL utf_flag = (BOOL)(LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8); - BOOL hl1_drawn = NO; -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) - BOOL hl2_drawn = FALSE; /* whether links[cur].hightext2 is already drawn - properly */ -#endif - tmp[0] = tmp[1] = tmp[2] = '\0'; + links[cur].list.hl_base.hl_text = text; + links[cur].list.hl_len = (text != NULL) ? 1 : 0; + FREE(links[cur].list.hl_info); +} - /* - * Bugs in the history code might cause -1 to be sent for cur, which - * yields a crash when LYstrncpy() is called with a nonsense pointer. - * As far as I know, such bugs have been squashed, but if they should - * reappear, this works around them. - FM - */ - if (cur < 0) - cur = 0; -#if defined(TEXTFIELDS_MAY_NEED_ACTIVATION) && defined(INACTIVE_INPUT_STYLE_VH) - if (flag == OFF) - textinput_redrawn = FALSE; -#endif +/* + * Add highlight information for the next line of a link. + */ +PUBLIC void LYAddHilite ARGS3( + int, cur, + char *, text, + int, x) +{ + HiliteList *list = &(links[cur].list); + HiliteInfo *have = list->hl_info; + unsigned need = (list->hl_len - 1); + unsigned want = ++(list->hl_len) * sizeof(HiliteInfo); - if (nlinks > 0) { -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) - if (flag == ON || links[cur].type == WWW_FORM_LINK_TYPE) -#endif - { -#ifndef USE_COLOR_STYLE - if (links[cur].type == WWW_FORM_LINK_TYPE || - !links[cur].hightext) { - LYMoveToLink(cur, target, NULL, - flag, links[cur].inUnderline, utf_flag); - lynx_start_link_color (flag == ON, links[cur].inUnderline); - } else { - LYMoveToLink(cur, target, links[cur].hightext, - flag, links[cur].inUnderline, utf_flag); - hl1_drawn = YES; -#ifdef SHOW_WHEREIS_TARGETS - target1_drawn = YES; -#endif - } -#else /* here USE_COLOR_STYLE defined */ - int s = s_alink; + if (have != NULL) { + have = realloc(have, want); + } else { + have = malloc(want); + } + list->hl_info = have; + have[need].hl_text = text; + have[need].hl_x = x; +} -#ifdef TEXTFIELDS_MAY_NEED_ACTIVATION - if ( textfields_need_activation && - links[cur].type == WWW_FORM_LINK_TYPE && - F_TEXTLIKE(links[cur].form->type) ) - s = s_curedit; -#endif +/* + * Get the highlight text, counting from zero. + */ +PUBLIC char *LYGetHiliteStr ARGS2( + int, cur, + int, count) +{ + char *result; + if (count >= links[cur].list.hl_len) + result = NULL; + else if (count > 0) + result = links[cur].list.hl_info[count - 1].hl_text; + else + result = links[cur].list.hl_base.hl_text; + return result; +} -# define LXP (links[cur].lx) -# define LYP (links[cur].ly) - if (flag != ON) { - int x; - /* - * This is where we try to restore the original style when - * a link is unhighlighted. The purpose of cached_styles[][] - * is to save the original style just for this case. - * If it doesn't have a color change saved at just the right - * position, we look at preceding positions in the same line - * until we find one. - */ - if (LYP >= 0 && LYP < CACHEH && LXP >= 0 && LXP < CACHEW) { - CTRACE2(TRACE_STYLE, - (tfp, "STYLE.highlight.off: cached style @(%d,%d): ", - LYP, LXP)); - s = cached_styles[LYP][LXP]; - if (s == 0) { - for (x = LXP-1; x >= 0; x--) { - if (cached_styles[LYP][x]) { - if (cached_styles[LYP][x] > 0) { - s = cached_styles[LYP][x]; - cached_styles[LYP][LXP] = s; - } - CTRACE((tfp, "found %d, x_offset=%d.\n", - cached_styles[LYP][x], (int)x-LXP)); - break; - } - } - if (s == 0) { - CTRACE((tfp, "not found, assume <a>.\n")); - s = s_a; - } - } else { - CTRACE((tfp, "found %d.\n", s)); - } - } else { - CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.off: can't use cache.\n")); - s = s_a; - } - } else { - CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.on: @(%d,%d).\n", LYP, LXP)); - } - LYmove(LYP, LXP); - LynxChangeStyle(s, STACK_ON); -#endif - } +/* + * Get the X-ordinate at which to draw the corresponding highlight-text + */ +PUBLIC int LYGetHilitePos ARGS2( + int, cur, + int, count) +{ + int result; + if (count >= links[cur].list.hl_len) + result = -1; + else if (count > 0) + result = links[cur].list.hl_info[count - 1].hl_x; + else + result = links[cur].lx; + return result; +} - if (links[cur].type == WWW_FORM_LINK_TYPE) { - int len; - int avail_space = (LYcols - links[cur].lx) - 1; +#define LXP (links[cur].lx) +#define LYP (links[cur].ly) - LYstrncpy(buffer, - (links[cur].hightext ? - links[cur].hightext : ""), - (avail_space > links[cur].form->size ? - links[cur].form->size : avail_space)); - LYaddstr(buffer); +#ifdef SHOW_WHEREIS_TARGETS - len = strlen(buffer); - for (; len < links[cur].form->size && len < avail_space; len++) - LYaddch('_'); +#define SKIP_GLYPHS(theFlag, theData, theOffset) \ + (theFlag \ + ? LYmbcs_skip_glyphs(theData, (theOffset), theFlag) \ + : (theData + (theOffset))) - } else { -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) - if (flag == OFF) { - hl2_drawn = TRUE; - redraw_lines_of_link(cur); - CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.off: NOFIX branch @(%d,%d).\n", LYP, LXP)); - } else -#endif - if (!hl1_drawn) { - /* - * Copy into the buffer only what will fit - * within the width of the screen. - */ - LYmbcsstrncpy(buffer, - (links[cur].hightext ? - links[cur].hightext : ""), - (sizeof(buffer) - 1), - ((LYcols - 1) - links[cur].lx), - utf_flag); - LYaddstr(buffer); - } - } +/* + * If we have an emphasized WHEREIS hit in the highlighted text, restore the + * emphasis. Note that we never emphasize the first and last characters of the + * highlighted text when we are making the link current, so the link attributes + * for the current link will persist at the beginning and end, providing an + * indication to the user that it has been made current. Also note that we use + * HText_getFirstTargetInLine() to determine if there's a hit in the HText + * structure line containing the link, and if so, get back a copy of the line + * starting at that first hit (which might be before or after our link), and + * with all IsSpecial characters stripped, so we don't need to deal with them + * here. -FM + */ +PRIVATE BOOL show_whereis_targets ARGS6( + int, flag, + int, cur, + int, count, + char *, target, + BOOL, TargetEmphasisON, + BOOL, utf_flag) +{ + char *Data = NULL; + char *cp; + char *theData = NULL; + char buffer[MAX_LINE]; + char tmp[7]; + int HitOffset; + int LenNeeded; + int Offset; + int tLen; - /* - * Display a second line as well. - */ - if ( links[cur].hightext2 && links[cur].ly < display_lines -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) - && hl2_drawn == FALSE -#endif - ) { - lynx_stop_link_color (flag == ON, links[cur].inUnderline); - LYmove((links[cur].ly + 1), links[cur].hightext2_offset); -#ifndef USE_COLOR_STYLE - lynx_start_link_color (flag == ON, links[cur].inUnderline); -#else - CTRACE2(TRACE_STYLE, - (tfp, "STYLE.highlight.line2: @(%d,%d), style=%d.\n", - links[cur].ly + 1, links[cur].hightext2_offset, - flag == ON ? s_alink : s_a)); - LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_ON); -#endif + tmp[0] = tmp[1] = tmp[2] = '\0'; - for (i = 0; (tmp[0] = links[cur].hightext2[i]) != '\0' && - i+links[cur].hightext2_offset < LYcols; i++) { - if (!IsSpecialAttrChar(links[cur].hightext2[i])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - if (HTCJK != NOCJK && is8bits(tmp[0])) { - tmp[1] = links[cur].hightext2[++i]; - LYaddstr(tmp); - tmp[1] = '\0'; - } else { - LYaddstr(tmp); - } - } - } - } -#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) - if ( hl2_drawn == FALSE ) -#endif - lynx_stop_link_color (flag == ON, links[cur].inUnderline); + if (non_empty(target) + && (links[cur].type & WWW_LINK_TYPE) + && non_empty(LYGetHiliteStr(cur, count)) + && links[cur].ly + count < display_lines + && HText_getFirstTargetInLine(HTMainText, + links[cur].anchor_line_num + count, + utf_flag, + &Offset, + &tLen, + &theData, + target)) { + int itmp, written, len, y, offset; + char *data; + int tlen = strlen(target); + int hlen, hLen; + int hLine = links[cur].ly + count; + int hoffset = LYGetHilitePos(cur, count); + size_t utf_extra = 0; -#ifdef SHOW_WHEREIS_TARGETS - if (!target1_drawn) /* - * If we have an emphasized WHEREIS hit in the highlighted - * text, restore the emphasis. Note that we never emphasize - * the first and last characters of the highlighted text when - * we are making the link current, so the link attributes for - * the current link will persist at the beginning and end, - * providing an indication to the user that it has been made - * current. Also note that we use HText_getFirstTargetInLine() - * to determine if there's a hit in the HText structure line - * containing the link, and if so, get back a copy of the line - * starting at that first hit (which might be before or after - * our link), and with all IsSpecial characters stripped, so we - * don't need to deal with them here. - FM + * Copy into the buffer only what will fit up to the right border of + * the screen. -FM */ - if (target && *target && (links[cur].type & WWW_LINK_TYPE) && - links[cur].hightext && *links[cur].hightext && - HText_getFirstTargetInLine(HTMainText, - links[cur].anchor_line_num, - utf_flag, - (int *)&Offset, - (int *)&tLen, - (char **)&theData, - target)) { - int itmp, written, len, y, offset; - char *data; - int tlen = strlen(target); - int hlen, hLen; - int hLine = links[cur].ly, hoffset = links[cur].lx; - size_t utf_extra = 0; - - /* - * Copy into the buffer only what will fit - * up to the right border of the screen. - FM - */ - LYmbcsstrncpy(buffer, - (links[cur].hightext ? - links[cur].hightext : ""), - (sizeof(buffer) - 1), - ((LYcols - 1) - links[cur].lx), - utf_flag); - hlen = strlen(buffer); - hLen = ((HTCJK != NOCJK || utf_flag) ? - LYmbcsstrlen(buffer, utf_flag, YES) : hlen); - - /* - * Break out if the first hit in the line - * starts after this link. - FM - */ - if (Offset >= (hoffset + hLen)) { - goto highlight_search_hightext2; - } + LYmbcsstrncpy(buffer, + (LYGetHiliteStr(cur, count) ? + LYGetHiliteStr(cur, count) : ""), + (sizeof(buffer) - 1), + ((LYcols - 1) - LYGetHilitePos(cur, count)), + utf_flag); + hlen = strlen(buffer); + hLen = ((HTCJK != NOCJK || utf_flag) ? + LYmbcsstrlen(buffer, utf_flag, YES) : hlen); + /* + * Break out if the first hit in the line starts after this link. -FM + */ + if (Offset < (hoffset + hLen)) { /* - * Recursively skip hits that end before this link, and - * break out if there is no hit beyond those. - FM + * Recursively skip hits that end before this link, and break out + * if there is no hit beyond those. -FM */ Data = theData; while ((Offset < hoffset) && @@ -494,22 +391,22 @@ PUBLIC void LYhighlight ARGS3( target, utf_flag, YES, &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { + &LenNeeded)) != NULL) + && (offset + LenNeeded) < LYcols) { Data = cp; Offset = (offset + HitOffset); } else { - goto highlight_search_hightext2; + goto highlight_search_done; } } data = buffer; offset = hoffset; /* - * If the hit starts before the hightext, and ends - * in or beyond the hightext, restore the emphasis, - * skipping the first and last characters of the - * hightext if we're making the link current. - FM + * If the hit starts before the hightext, and ends in or beyond the + * hightext, restore the emphasis, skipping the first and last + * characters of the hightext if we're making the link current. + * -FM */ if ((Offset < offset) && ((Offset + tLen) > offset)) { @@ -518,8 +415,8 @@ PUBLIC void LYhighlight ARGS3( len = (tlen - (offset - Offset)); /* - * Go to the start of the hightext and - * handle its first character. - FM + * Go to the start of the hightext and handle its first + * character. -FM */ LYmove(hLine, offset); tmp[0] = data[itmp]; @@ -528,8 +425,8 @@ PUBLIC void LYhighlight ARGS3( LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); itmp += utf_extra; /* - * Start emphasis immediately if we are - * making the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current. -FM */ if (flag != ON) { LYstartTargetEmphasis(); @@ -543,12 +440,12 @@ PUBLIC void LYhighlight ARGS3( utf_extra = 0; } else if (HTCJK != NOCJK && is8bits(tmp[0])) { /* - * For CJK strings, by Masanobu Kimura. + * For CJK strings, by Masanobu Kimura. */ tmp[1] = data[++itmp]; /* - * Start emphasis immediately if we are - * making the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current. -FM */ if (flag != ON) { LYstartTargetEmphasis(); @@ -561,8 +458,8 @@ PUBLIC void LYhighlight ARGS3( written += 2; } else { /* - * Start emphasis immediately if we are making - * the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current. -FM */ if (flag != ON) { LYstartTargetEmphasis(); @@ -575,9 +472,8 @@ PUBLIC void LYhighlight ARGS3( } itmp++; /* - * Start emphasis after the first character - * if we are making the link current and this - * is not the last character. - FM + * Start emphasis after the first character if we are making + * the link current and this is not the last character. -FM */ if (!TargetEmphasisON && data[itmp] != '\0') { @@ -586,25 +482,24 @@ PUBLIC void LYhighlight ARGS3( } /* - * Handle the remaining characters. - FM + * Handle the remaining characters. -FM */ for (; written < len && (tmp[0] = data[itmp]) != '\0'; itmp++) { /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext and we are making - * the link current. - FM + * Print all the other target chars, except the last + * character if it is also the last character of hightext + * and we are making the link current. -FM */ utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); itmp += utf_extra; /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -619,13 +514,13 @@ PUBLIC void LYhighlight ARGS3( utf_extra = 0; } else if (HTCJK != NOCJK && is8bits(tmp[0])) { /* - * For CJK strings, by Masanobu Kimura. + * For CJK strings, by Masanobu Kimura. */ tmp[1] = data[++itmp]; /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -639,9 +534,9 @@ PUBLIC void LYhighlight ARGS3( written += 2; } else { /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -656,56 +551,38 @@ PUBLIC void LYhighlight ARGS3( } /* - * Stop the emphasis if we haven't already, then - * reset the offset to our current position in - * the line, and if that is beyond the link, or - * or we are making the link current and it is - * the last character of the hightext, we are - * done. - FM + * Stop the emphasis if we haven't already, then reset the + * offset to our current position in the line, and if that is + * beyond the link, or or we are making the link current and it + * is the last character of the hightext, we are done. -FM */ if (TargetEmphasisON) { LYstopTargetEmphasis(); TargetEmphasisON = FALSE; } LYGetYX(y, offset); - if (offset >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_hightext2; - } - - /* - * See if we have another hit that starts - * within the hightext. - FM - */ - data = (Data + (offset - Offset)); - if (!utf_flag) { - data = Data + (offset - Offset); - } else { - data = LYmbcs_skip_glyphs(Data, - (offset - Offset), - utf_flag); - } - if (((cp = LYno_attr_mb_strstr(data, + if (offset < (hoffset + (flag == ON ? (hLen - 1) : hLen)) + /* + * See if we have another hit that starts within the + * hightext. -FM + */ + && ((cp = LYno_attr_mb_strstr(data = SKIP_GLYPHS(utf_flag, Data, offset - Offset), target, utf_flag, YES, &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { + &LenNeeded)) != NULL) + && (offset + LenNeeded) < LYcols /* - * If the hit starts after the end of the hightext, - * or we are making the link current and the hit - * starts at its last character, we are done. - FM + * If the hit starts after the end of the hightext, or we + * are making the link current and the hit starts at its + * last character, we are done. -FM */ - if ((HitOffset + offset) >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_hightext2; - } - + && (HitOffset + offset) < + (hoffset + + (flag == ON ? (hLen - 1) : hLen))) { /* - * Set up the data and offset for the hit, and let - * the code for within hightext hits handle it. - FM + * Set up the data and offset for the hit, and let the code + * for within hightext hits handle it. -FM */ Data = cp; Offset = (offset + HitOffset); @@ -713,410 +590,29 @@ PUBLIC void LYhighlight ARGS3( offset = hoffset; goto highlight_hit_within_hightext; } - goto highlight_search_hightext2; - } - -highlight_hit_within_hightext: - /* - * If we get to here, the hit starts within the - * hightext. If we are making the link current - * and it's the last character in the hightext, - * we are done. Otherwise, move there and start - * restoring the emphasis. - FM - */ - if ((Offset - offset) > - (flag == ON ? (hLen - 1) : hLen)) { - goto highlight_search_hightext2; - } - if (!utf_flag) { - data += (Offset - offset); - } else { - LYrefresh(); - data = LYmbcs_skip_glyphs(data, - (Offset - offset), - utf_flag); - } - offset = Offset; - itmp = 0; - written = 0; - len = tlen; - - /* - * Go to the start of the hit and - * handle its first character. - FM - */ - LYmove(hLine, offset); - tmp[0] = data[itmp]; - utf_extra = utf8_length(utf_flag, data + itmp); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); - } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); - } - tmp[1] = '\0'; - written += 2; - } else { - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); - } - written++; - } - itmp++; - /* - * Start emphasis after the first character - * if we are making the link current and this - * is not the last character. - FM - */ - if (!TargetEmphasisON && - data[itmp] != '\0') { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - } - - for (; - written < len && (tmp[0] = data[itmp]) != '\0'; - itmp++) { - /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext and we are making - * the link current. - FM - */ - utf_extra = utf8_length(utf_flag, data + itmp); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += 2; - } else { - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - written++; - } - } - - /* - * Stop the emphasis if we haven't already, then reset - * the offset to our current position in the line, and - * if that is beyond the link, or we are making the link - * current and it is the last character in the hightext, - * we are done. - FM - */ - if (TargetEmphasisON) { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } - LYGetYX(y, offset); - if (offset >= - (hoffset + (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_hightext2; - } - - /* - * See if we have another hit that starts - * within the hightext. - FM - */ - if (!utf_flag) { - data = Data + (offset - Offset); - } else { - data = LYmbcs_skip_glyphs(Data, - (offset - Offset), - utf_flag); - } - if (((cp = LYno_attr_mb_strstr(data, - target, - utf_flag, YES, - &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { - /* - * If the hit starts after the end of the hightext, - * or we are making the link current and the hit - * starts at its last character, we are done. - FM - */ - if ((HitOffset + offset) >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_hightext2; - } - - /* - * If the target extends beyond our buffer, emphasize - * everything in the hightext starting at this hit. - * Otherwise, set up the data and offsets, and loop - * back. - FM - */ - if ((HitOffset + (offset + tLen)) >= - (hoffset + hLen)) { - offset = (HitOffset + offset); - if (!utf_flag) { - data = buffer + (offset - hoffset); - } else { - LYrefresh(); - data = LYmbcs_skip_glyphs(buffer, - (offset - hoffset), - utf_flag); - } - LYmove(hLine, offset); - itmp = 0; - written = 0; - len = strlen(data); - - /* - * Turn the emphasis back on. - FM - */ - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - for (; - written < len && (tmp[0] = data[itmp]) != '\0'; - itmp++) { - /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext and we are making - * the link current. - FM - */ - utf_extra = utf8_length(utf_flag, data); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += 2; - } else { - /* - * Make sure we don't restore emphasis to - * the last character of hightext if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } else { - LYaddstr(tmp); - } - written++; - } - } - /* - * Turn off the emphasis if we haven't already, - * and then we're done. - FM - */ - if (TargetEmphasisON) { - LYstopTargetEmphasis(); - } - goto highlight_search_hightext2; - } else { - Data = cp; - Offset = (offset + HitOffset); - data = buffer; - offset = hoffset; - goto highlight_hit_within_hightext; - } - } - goto highlight_search_hightext2; - } -highlight_search_hightext2: - if (target && *target && (links[cur].type & WWW_LINK_TYPE) && - links[cur].hightext2 && *links[cur].hightext2 && - links[cur].ly < display_lines && - HText_getFirstTargetInLine(HTMainText, - (links[cur].anchor_line_num + 1), - utf_flag, - (int *)&Offset, - (int *)&tLen, - (char **)&theData, - target)) { - int itmp, written, len, y, offset; - char *data; - int tlen = strlen(target); - int hlen, hLen; - int hLine = (links[cur].ly + 1); - int hoffset = links[cur].hightext2_offset; - size_t utf_extra = 0; - - /* - * Copy into the buffer only what will fit - * up to the right border of the screen. - FM - */ - LYmbcsstrncpy(buffer, - (links[cur].hightext2 ? - links[cur].hightext2 : ""), - (sizeof(buffer) - 1), - ((LYcols - 1) - links[cur].hightext2_offset), - utf_flag); - hlen = strlen(buffer); - hLen = ((HTCJK != NOCJK || utf_flag) ? - LYmbcsstrlen(buffer, utf_flag, YES) : hlen); - - /* - * Break out if the first hit in the line - * starts after this link. - FM - */ - if (Offset >= (hoffset + hLen)) { goto highlight_search_done; } +highlight_hit_within_hightext: /* - * Recursively skip hits that end before this link, and - * break out if there is no hit beyond those. - FM + * If we get to here, the hit starts within the hightext. If we + * are making the link current and it's the last character in the + * hightext, we are done. Otherwise, move there and start + * restoring the emphasis. -FM */ - Data = theData; - while ((Offset < hoffset) && - ((Offset + tLen) <= hoffset)) { - data = (Data + tlen); - offset = (Offset + tLen); - if (((cp = LYno_attr_mb_strstr(data, - target, - utf_flag, YES, - &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { - Data = cp; - Offset = (offset + HitOffset); - } else { - goto highlight_search_done; + if ((Offset - offset) <= (flag == ON ? (hLen - 1) : hLen)) { + data = SKIP_GLYPHS(utf_flag, data, Offset - offset); + if (utf_flag) { + LYrefresh(); } - } - data = buffer; - offset = hoffset; - - /* - * If the hit starts before the hightext2, and ends - * in or beyond the hightext2, restore the emphasis, - * skipping the first and last characters of the - * hightext2 if we're making the link current. - FM - */ - if ((Offset < offset) && - ((Offset + tLen) > offset)) { + offset = Offset; itmp = 0; written = 0; - len = (tlen - (offset - Offset)); + len = tlen; /* - * Go to the start of the hightext2 and - * handle its first character. - FM + * Go to the start of the hit and handle its first character. + * -FM */ LYmove(hLine, offset); tmp[0] = data[itmp]; @@ -1125,10 +621,12 @@ highlight_search_hightext2: LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); itmp += utf_extra; /* - * Start emphasis immediately if we are - * making the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current, or we are making it current but this is not + * the first or last character of the hightext. -FM */ - if (flag != ON) { + if (flag != ON || + (offset > hoffset && data[itmp+1] != '\0')) { LYstartTargetEmphasis(); TargetEmphasisON = TRUE; LYaddstr(tmp); @@ -1140,14 +638,16 @@ highlight_search_hightext2: utf_extra = 0; } else if (HTCJK != NOCJK && is8bits(tmp[0])) { /* - * For CJK strings, by Masanobu Kimura. + * For CJK strings, by Masanobu Kimura. */ tmp[1] = data[++itmp]; /* - * Start emphasis immediately if we are - * making the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current, or we are making it current but this is not + * the first or last character of the hightext. -FM */ - if (flag != ON) { + if (flag != ON || + (offset > hoffset && data[itmp+1] != '\0')) { LYstartTargetEmphasis(); TargetEmphasisON = TRUE; LYaddstr(tmp); @@ -1158,10 +658,12 @@ highlight_search_hightext2: written += 2; } else { /* - * Start emphasis immediately if we are making - * the link non-current. - FM + * Start emphasis immediately if we are making the link + * non-current, or we are making it current but this is not + * the first or last character of the hightext. -FM */ - if (flag != ON) { + if (flag != ON || + (offset > hoffset && data[itmp+1] != '\0')) { LYstartTargetEmphasis(); TargetEmphasisON = TRUE; LYaddstr(tmp); @@ -1172,9 +674,8 @@ highlight_search_hightext2: } itmp++; /* - * Start emphasis after the first character - * if we are making the link current and this - * is not the last character. - FM + * Start emphasis after the first character if we are making + * the link current and this is not the last character. -FM */ if (!TargetEmphasisON && data[itmp] != '\0') { @@ -1182,26 +683,22 @@ highlight_search_hightext2: TargetEmphasisON = TRUE; } - /* - * Handle the remaining characters. - FM - */ for (; written < len && (tmp[0] = data[itmp]) != '\0'; itmp++) { /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext2 and we are making - * the link current. - FM + * Print all the other target chars, except the last + * character if it is also the last character of hightext + * and we are making the link current. -FM */ utf_extra = utf8_length(utf_flag, data + itmp); if (utf_extra) { LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); itmp += utf_extra; /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -1216,13 +713,13 @@ highlight_search_hightext2: utf_extra = 0; } else if (HTCJK != NOCJK && is8bits(tmp[0])) { /* - * For CJK strings, by Masanobu Kimura. + * For CJK strings, by Masanobu Kimura. */ tmp[1] = data[++itmp]; /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -1236,9 +733,9 @@ highlight_search_hightext2: written += 2; } else { /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM + * Make sure we don't restore emphasis to the last + * character of hightext if we are making the link + * current. -FM */ if (flag == ON && data[(itmp + 1)] == '\0') { LYstopTargetEmphasis(); @@ -1253,388 +750,353 @@ highlight_search_hightext2: } /* - * Stop the emphasis if we haven't already, then - * reset the offset to our current position in - * the line, and if that is beyond the link, or - * or we are making the link current and it is - * the last character of the hightext2, we are - * done. - FM + * Stop the emphasis if we haven't already, then reset the + * offset to our current position in the line, and if that is + * beyond the link, or we are making the link current and it is + * the last character in the hightext, we are done. -FM */ if (TargetEmphasisON) { LYstopTargetEmphasis(); TargetEmphasisON = FALSE; } LYGetYX(y, offset); - if (offset >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_done; - } - - /* - * See if we have another hit that starts - * within the hightext2. - FM - */ - if (!utf_flag) { - data = Data + (offset - Offset); - } else { - data = LYmbcs_skip_glyphs(Data, - (offset - Offset), - utf_flag); - } - if (((cp = LYno_attr_mb_strstr(data, + if (offset < (hoffset + (flag == ON ? (hLen - 1) : hLen)) + /* + * See if we have another hit that starts within the + * hightext. -FM + */ + && ((cp = LYno_attr_mb_strstr(data = SKIP_GLYPHS(utf_flag, Data, offset - Offset), target, utf_flag, YES, &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { + &LenNeeded)) != NULL) + && (offset + LenNeeded) < LYcols /* - * If the hit starts after the end of the hightext2, - * or we are making the link current and the hit - * starts at its last character, we are done. - FM + * If the hit starts after the end of the hightext, or we + * are making the link current and the hit starts at its + * last character, we are done. -FM */ - if ((HitOffset + offset) >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_done; - } - + && (HitOffset + offset) < (hoffset + (flag == ON ? (hLen - 1) : hLen))) { /* - * Set up the data and offset for the hit, and let - * the code for within hightext2 hits handle it. - FM + * If the target extends beyond our buffer, emphasize + * everything in the hightext starting at this hit. + * Otherwise, set up the data and offsets, and loop back. + * -FM */ - Data = cp; - Offset = (offset + HitOffset); - data = buffer; - offset = hoffset; - goto highlight_hit_within_hightext2; + if ((HitOffset + (offset + tLen)) >= (hoffset + hLen)) { + offset = (HitOffset + offset); + data = SKIP_GLYPHS(utf_flag, Data, offset - hoffset); + if (utf_flag) { + LYrefresh(); + } + LYmove(hLine, offset); + itmp = 0; + written = 0; + len = strlen(data); + + /* + * Turn the emphasis back on. -FM + */ + LYstartTargetEmphasis(); + TargetEmphasisON = TRUE; + for (; + written < len && (tmp[0] = data[itmp]) != '\0'; + itmp++) { + /* + * Print all the other target chars, except the + * last character if it is also the last character + * of hightext and we are making the link current. + * -FM + */ + utf_extra = utf8_length(utf_flag, data + itmp); + if (utf_extra) { + LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); + itmp += utf_extra; + /* + * Make sure we don't restore emphasis to the + * last character of hightext if we are making + * the link current. -FM + */ + if (flag == ON && data[(itmp + 1)] == '\0') { + LYstopTargetEmphasis(); + TargetEmphasisON = FALSE; + LYGetYX(y, offset); + LYmove(hLine, (offset + 1)); + } else { + LYaddstr(tmp); + } + tmp[1] = '\0'; + written += (utf_extra + 1); + utf_extra = 0; + } else if (HTCJK != NOCJK && is8bits(tmp[0])) { + /* + * For CJK strings, by Masanobu Kimura. + */ + tmp[1] = data[++itmp]; + /* + * Make sure we don't restore emphasis to the + * last character of hightext if we are making + * the link current. -FM + */ + if (flag == ON && data[(itmp + 1)] == '\0') { + LYstopTargetEmphasis(); + TargetEmphasisON = FALSE; + } else { + LYaddstr(tmp); + } + tmp[1] = '\0'; + written += 2; + } else { + /* + * Make sure we don't restore emphasis to the + * last character of hightext if we are making + * the link current. -FM + */ + if (flag == ON && data[(itmp + 1)] == '\0') { + LYstopTargetEmphasis(); + TargetEmphasisON = FALSE; + } else { + LYaddstr(tmp); + } + written++; + } + } + /* + * Turn off the emphasis if we haven't already, and + * then we're done. -FM + */ + if (TargetEmphasisON) { + LYstopTargetEmphasis(); + } + } else { + Data = cp; + Offset = (offset + HitOffset); + data = buffer; + offset = hoffset; + goto highlight_hit_within_hightext; + } } - goto highlight_search_done; } + } + } +highlight_search_done: + FREE(theData); + return TargetEmphasisON; +} +#endif /* SHOW_WHEREIS_TARGETS */ -highlight_hit_within_hightext2: - /* - * If we get to here, the hit starts within the - * hightext2. If we are making the link current - * and it's the last character in the hightext2, - * we are done. Otherwise, move there and start - * restoring the emphasis. - FM - */ - if ((Offset - offset) > - (flag == ON ? (hLen - 1) : hLen)) { - goto highlight_search_done; - } - if (!utf_flag) { - data += (Offset - offset); - } else { - LYrefresh(); - data = LYmbcs_skip_glyphs(data, - (Offset - offset), - utf_flag); - } - offset = Offset; - itmp = 0; - written = 0; - len = tlen; +#ifdef USE_COLOR_STYLE +PRIVATE int find_cached_style ARGS2( + int, cur, + int, flag) +{ + int s = s_alink; - /* - * Go to the start of the hit and - * handle its first character. - FM - */ - LYmove(hLine, offset); - tmp[0] = data[itmp]; - utf_extra = utf8_length(utf_flag, data + itmp); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext2. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); +#ifdef TEXTFIELDS_MAY_NEED_ACTIVATION + if ( textfields_need_activation + && links[cur].type == WWW_FORM_LINK_TYPE + && F_TEXTLIKE(links[cur].l_form->type) ) + s = s_curedit; +#endif + + if (flag != ON) { + int x; + /* + * This is where we try to restore the original style when a link is + * unhighlighted. The purpose of cached_styles[][] is to save the + * original style just for this case. If it doesn't have a color + * change saved at just the right position, we look at preceding + * positions in the same line until we find one. + */ + if (LYP >= 0 && LYP < CACHEH && LXP >= 0 && LXP < CACHEW) { + CTRACE2(TRACE_STYLE, + (tfp, "STYLE.highlight.off: cached style @(%d,%d): ", + LYP, LXP)); + s = cached_styles[LYP][LXP]; + if (s == 0) { + for (x = LXP-1; x >= 0; x--) { + if (cached_styles[LYP][x]) { + if (cached_styles[LYP][x] > 0) { + s = cached_styles[LYP][x]; + cached_styles[LYP][LXP] = s; + } + CTRACE((tfp, "found %d, x_offset=%d.\n", + cached_styles[LYP][x], (int)x-LXP)); + break; + } } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext2. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); + if (s == 0) { + CTRACE((tfp, "not found, assume <a>.\n")); + s = s_a; } - tmp[1] = '\0'; - written += 2; } else { - /* - * Start emphasis immediately if we are making - * the link non-current, or we are making it - * current but this is not the first or last - * character of the hightext2. - FM - */ - if (flag != ON || - (offset > hoffset && data[itmp+1] != '\0')) { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - LYaddstr(tmp); - } else { - LYmove(hLine, (offset + 1)); - } - written++; - } - itmp++; - /* - * Start emphasis after the first character - * if we are making the link current and this - * is not the last character. - FM - */ - if (!TargetEmphasisON && - data[itmp] != '\0') { - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; + CTRACE((tfp, "found %d.\n", s)); } + } else { + CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.off: can't use cache.\n")); + s = s_a; + } + } else { + CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.on: @(%d,%d).\n", LYP, LXP)); + } + return s; +} +#endif /* USE_COLOR_STYLE */ - for (; - written < len && (tmp[0] = data[itmp]) != '\0'; - itmp++) { - /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext2 and we are making - * the link current. - FM - */ - utf_extra = utf8_length(utf_flag, data + itmp); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += 2; - } else { - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - written++; - } - } +/* + * Highlight (or unhighlight) a given link. + */ +PUBLIC void LYhighlight ARGS3( + int, flag, + int, cur, + char *, target) +{ + char buffer[MAX_LINE]; + int i; + int hi_count; + int hi_offset; + char tmp[7]; + char *hi_string; +#ifdef SHOW_WHEREIS_TARGETS + BOOL TargetEmphasisON = FALSE; + BOOL target1_drawn = NO; +#endif + BOOL utf_flag = (BOOL)(LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8); + BOOL hl1_drawn = NO; +#ifdef USE_COLOR_STYLE + BOOL hl2_drawn = FALSE; /* whether links[cur].l_hightext2 is already drawn + properly */ +#endif + tmp[0] = tmp[1] = tmp[2] = '\0'; - /* - * Stop the emphasis if we haven't already, then reset - * the offset to our current position in the line, and - * if that is beyond the link, or we are making the link - * current and it is the last character in the hightext2, - * we are done. - FM - */ - if (TargetEmphasisON) { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } - LYGetYX(y, offset); - if (offset >= - (hoffset + (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_done; - } + /* + * Bugs in the history code might cause -1 to be sent for cur, which yields + * a crash when LYstrncpy() is called with a nonsense pointer. As far as I + * know, such bugs have been squashed, but if they should reappear, this + * works around them. -FM + */ + if (cur < 0) + cur = 0; +#if defined(TEXTFIELDS_MAY_NEED_ACTIVATION) && defined(INACTIVE_INPUT_STYLE_VH) + if (flag == OFF) + textinput_redrawn = FALSE; +#endif + + if (nlinks > 0) { +#ifdef USE_COLOR_STYLE + if (flag == ON || links[cur].type == WWW_FORM_LINK_TYPE) { + LYmove(LYP, LXP); + LynxChangeStyle(find_cached_style(cur, flag), STACK_ON); + } +#else + if (links[cur].type == WWW_FORM_LINK_TYPE + || LYGetHiliteStr(cur, 0) == NULL) { + LYMoveToLink(cur, target, NULL, + flag, links[cur].inUnderline, utf_flag); + lynx_start_link_color (flag == ON, links[cur].inUnderline); + } else { + LYMoveToLink(cur, target, LYGetHiliteStr(cur, 0), + flag, links[cur].inUnderline, utf_flag); + hl1_drawn = YES; +#ifdef SHOW_WHEREIS_TARGETS + target1_drawn = YES; +#endif + } +#endif + + if (links[cur].type == WWW_FORM_LINK_TYPE) { + int len; + int avail_space = (LYcols - links[cur].lx) - 1; + char *text = LYGetHiliteStr(cur, 0); + + if (avail_space > links[cur].l_form->size) + avail_space = links[cur].l_form->size; + if (avail_space > (int) sizeof(buffer) - 1) + avail_space = (int) sizeof(buffer) - 1; + + LYstrncpy(buffer, (text != NULL ? text : ""), avail_space); + LYaddstr(buffer); + len = strlen(buffer); + for (; len < links[cur].l_form->size && len < avail_space; len++) + LYaddch('_'); + +#ifdef USE_COLOR_STYLE + } else if (flag == OFF) { + hl2_drawn = TRUE; + redraw_lines_of_link(cur); + CTRACE2(TRACE_STYLE, (tfp, "STYLE.highlight.off: NOFIX branch @(%d,%d).\n", LYP, LXP)); +#endif + } else if (!hl1_drawn) { /* - * See if we have another hit that starts - * within the hightext2. - FM + * Copy into the buffer only what will fit within the width of the + * screen. */ - if (!utf_flag) { - data = (Data + (offset - Offset)); - } else { - data = LYmbcs_skip_glyphs(Data, - (offset - Offset), - utf_flag); - } - if (((cp = LYno_attr_mb_strstr(data, - target, - utf_flag, YES, - &HitOffset, - &LenNeeded)) != NULL) && - (offset + LenNeeded) < LYcols) { - /* - * If the hit starts after the end of the hightext2, - * or we are making the link current and the hit - * starts at its last character, we are done. - FM - */ - if ((HitOffset + offset) >= - (hoffset + - (flag == ON ? (hLen - 1) : hLen))) { - goto highlight_search_done; - } + LYmbcsstrncpy(buffer, + (LYGetHiliteStr(cur, 0) ? + LYGetHiliteStr(cur, 0) : ""), + (sizeof(buffer) - 1), + ((LYcols - 1) - links[cur].lx), + utf_flag); + LYaddstr(buffer); + } - /* - * If the target extends beyond our buffer, emphasize - * everything in the hightext2 starting at this hit. - * Otherwise, set up the data and offsets, and loop - * back. - FM - */ - if ((HitOffset + (offset + tLen)) >= - (hoffset + hLen)) { - offset = (HitOffset + offset); - if (!utf_flag) { - data = buffer + (offset - hoffset); - } else { - LYrefresh(); - data = LYmbcs_skip_glyphs(buffer, - (offset - hoffset), - utf_flag); - } - LYmove(hLine, offset); - itmp = 0; - written = 0; - len = strlen(data); + /* + * Display a second line as well. + */ +#ifdef USE_COLOR_STYLE + if (hl2_drawn == FALSE) +#endif + { + for (hi_count = 1; + (hi_string = LYGetHiliteStr(cur, hi_count)) != NULL + && links[cur].ly + hi_count <= display_lines; + ++hi_count) { - /* - * Turn the emphasis back on. - FM - */ - LYstartTargetEmphasis(); - TargetEmphasisON = TRUE; - for (; - written < len && (tmp[0] = data[itmp]) != '\0'; - itmp++) { + hi_offset = LYGetHilitePos(cur, hi_count); + lynx_stop_link_color (flag == ON, links[cur].inUnderline); + LYmove(links[cur].ly + hi_count, hi_offset); + +#ifdef USE_COLOR_STYLE + CTRACE2(TRACE_STYLE, + (tfp, "STYLE.highlight.line2: @(%d,%d), style=%d.\n", + links[cur].ly + hi_count, hi_offset, + flag == ON ? s_alink : s_a)); + LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_ON); +#else + lynx_start_link_color (flag == ON, links[cur].inUnderline); +#endif + + for (i = 0; (tmp[0] = hi_string[i]) != '\0' + && (i + hi_offset) < LYcols; i++) { + if (!IsSpecialAttrChar(hi_string[i])) { /* - * Print all the other target chars, except - * the last character if it is also the last - * character of hightext2 and we are making - * the link current. - FM + * For CJK strings, by Masanobu Kimura. */ - utf_extra = utf8_length(utf_flag, data + itmp); - if (utf_extra) { - LYstrncpy(&tmp[1], &data[itmp+1], utf_extra); - itmp += utf_extra; - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - LYGetYX(y, offset); - LYmove(hLine, (offset + 1)); - } else { - LYaddstr(tmp); - } - tmp[1] = '\0'; - written += (utf_extra + 1); - utf_extra = 0; - } else if (HTCJK != NOCJK && is8bits(tmp[0])) { - /* - * For CJK strings, by Masanobu Kimura. - */ - tmp[1] = data[++itmp]; - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } else { - LYaddstr(tmp); - } + if (HTCJK != NOCJK && is8bits(tmp[0])) { + tmp[1] = LYGetHiliteStr(cur, 1)[++i]; + LYaddstr(tmp); tmp[1] = '\0'; - written += 2; } else { - /* - * Make sure we don't restore emphasis to - * the last character of hightext2 if we - * are making the link current. - FM - */ - if (flag == ON && data[(itmp + 1)] == '\0') { - LYstopTargetEmphasis(); - TargetEmphasisON = FALSE; - } else { - LYaddstr(tmp); - } - written++; + LYaddstr(tmp); } - } - /* - * Turn off the emphasis if we haven't already, - * and then we're done. - FM - */ - if (TargetEmphasisON) { - LYstopTargetEmphasis(); - } - goto highlight_search_done; - } else { - Data = cp; - Offset = (offset + HitOffset); - data = buffer; - offset = hoffset; - goto highlight_hit_within_hightext2; + } } } - goto highlight_search_done; + lynx_stop_link_color (flag == ON, links[cur].inUnderline); + } + +#ifdef SHOW_WHEREIS_TARGETS + for (hi_count = target1_drawn ? 1 : 0; + LYGetHiliteStr(cur, hi_count) != NULL; + hi_count++) { + TargetEmphasisON = show_whereis_targets(flag, + cur, + hi_count, + target, + TargetEmphasisON, + utf_flag); } -highlight_search_done: - FREE(theData); if (!LYShowCursor) /* @@ -2432,7 +1894,7 @@ PUBLIC void LYAddLocalhostAlias ARGS1( { char *LocalAlias = NULL; - if (!(alias && *alias)) + if (!non_empty(alias)) return; if (!localhost_aliases) { @@ -2910,12 +2372,11 @@ PUBLIC BOOLEAN LYFixCursesOnForAccess ARGS2( * Determine whether we allow HEAD and related flags for a URL. - kw */ PUBLIC BOOLEAN LYCanDoHEAD ARGS1( - CONST char *, address - ) + CONST char *, address) { char *temp0 = NULL; int isurl; - if (!(address && *address)) + if (!non_empty(address)) return FALSE; if (!strncmp(address, "http", 4)) return TRUE; @@ -2963,7 +2424,7 @@ PUBLIC BOOLEAN LYCanDoHEAD ARGS1( #ifdef ALLOW_PROXY_HEAD if (isurl != FILE_URL_TYPE) { char *acc_method = HTParse(temp0, "", PARSE_ACCESS); - if (acc_method && *acc_method) { + if (non_empty(acc_method)) { char *proxy; StrAllocCat(acc_method, "_proxy"); proxy = getenv(acc_method); @@ -3341,7 +2802,7 @@ PUBLIC void HTAddSugFilename ARGS1( char *old; HTList *cur; - if (!(fname && *fname)) + if (!non_empty(fname)) return; StrAllocCopy(new, fname); @@ -4237,7 +3698,7 @@ PUBLIC void LYEnsureAbsoluteURL ARGS3( { char *temp = NULL; - if (!(*href && *(*href))) + if (!non_empty(*href)) return; /* @@ -4254,7 +3715,7 @@ PUBLIC void LYEnsureAbsoluteURL ARGS3( (name ? name : ""), (name ? " " : ""), *href)); LYConvertToURL(href, fixit); } - if ((temp = HTParse(*href, "", PARSE_ALL)) != NULL && *temp != '\0') + if (non_empty(temp = HTParse(*href, "", PARSE_ALL))) StrAllocCopy(*href, temp); FREE(temp); } @@ -5213,7 +4674,7 @@ PUBLIC BOOLEAN LYAddSchemeForURL ARGS2( FREE(Str); return GotScheme; - } else if (default_scheme != NULL && *default_scheme != '\0') { + } else if (non_empty(default_scheme)) { StrAllocCopy(Str, default_scheme); GotScheme = TRUE; StrAllocCat(Str, *AllocatedString); @@ -5424,7 +4885,7 @@ PUBLIC CONST char * Home_Dir NOARGS StrAllocCopy(HomeDir, "/tmp"); } #ifdef UNIX - if (cp && *cp) + if (non_empty(cp)) HTAlwaysAlert(NULL, gettext("Ignoring invalid HOME")); #endif #endif /* VMS */ @@ -5701,7 +5162,7 @@ PUBLIC void LYAddPathToHome ARGS3( #else #define NO_HOMEPATH "/error" #endif /* VMS */ - if (!(home && *home)) + if (!non_empty(home)) /* * Home_Dir() has a bug if this ever happens. - FM */ @@ -5789,7 +5250,7 @@ PUBLIC time_t LYmktime ARGS2( /* * Make sure we have a string to parse. - FM */ - if (!(string && *string)) + if (!non_empty(string)) return(0); s = string; CTRACE((tfp, "LYmktime: Parsing '%s'\n", s)); @@ -6707,7 +6168,7 @@ PUBLIC int LYRemoveTemp ARGS1( LY_TEMP *p, *q; int code = -1; - if (name != 0 && *name != 0) { + if (non_empty(name)) { CTRACE((tfp, "LYRemoveTemp(%s)\n", name)); for (p = ly_temp, q = 0; p != 0; q = p, p = p->next) { if (!strcmp(name, p->name)) { @@ -7196,7 +6657,7 @@ PUBLIC void LYTrimPathSep ARGS1( #endif /* - * Add a trailing path-separator to avoid confusing other programs when we concateate + * Add a trailing path-separator to avoid confusing other programs when we concatenate * to it. This only applies to local filesystems. */ PUBLIC void LYAddPathSep ARGS1( @@ -7750,8 +7211,6 @@ PUBLIC void get_clip_release NOARGS #if defined(WIN_EX) /* 1997/10/16 (Thu) 20:13:28 */ -#define MAX_DOS_PATH 128 /* exactly 80 */ - PUBLIC int put_clip(char *szBuffer) { HANDLE hWnd; @@ -7838,28 +7297,6 @@ PUBLIC void get_clip_release() CloseClipboard(); m_locked = 0; } - - -PUBLIC char *HTDOS_short_name(char *path) -{ - static char sbuf[MAX_DOS_PATH]; - char *ret; - DWORD r; - - r = GetShortPathName(path, sbuf, sizeof sbuf); - if (r >= sizeof sbuf) { -#if 0 /* DEBUG */ - fprintf(stderr, "bug: recompile with MAX_DOS_PATH > %d\n", r); -#endif - ret = path; - } - if (r == 0) { - ret = path; - } else { - ret = sbuf; - } - return ret; -} #endif #if defined(WIN_EX) diff --git a/src/LYUtils.h b/src/LYUtils.h index 575f872c..f009994f 100644 --- a/src/LYUtils.h +++ b/src/LYUtils.h @@ -91,6 +91,7 @@ extern FILE *LYOpenTemp PARAMS((char *result, CONST char *suffix, CONST char *mo extern FILE *LYOpenTempRewrite PARAMS((char *result, CONST char *suffix, CONST char *mode)); extern FILE *LYReopenTemp PARAMS((char *name)); extern char *Current_Dir PARAMS((char * pathname)); +extern char *LYGetHiliteStr PARAMS(( int cur, int count)); extern char *LYLastPathSep PARAMS((CONST char *path)); extern char *LYPathLeaf PARAMS((char * pathname)); extern char *LYSysShell NOPARAMS; @@ -101,6 +102,7 @@ extern int HTCheckForInterrupt NOPARAMS; extern int LYCheckForProxyURL PARAMS((char *filename)); extern int LYConsoleInputFD PARAMS((BOOLEAN need_selectable)); extern int LYCopyFile PARAMS((char *src, char *dst)); +extern int LYGetHilitePos PARAMS(( int cur, int count)); extern int LYRemoveTemp PARAMS((char *name)); extern int LYSystem PARAMS((char *command)); extern int LYValidateOutput PARAMS((char * filename)); @@ -113,6 +115,7 @@ extern void BeginInternalPage PARAMS((FILE *fp0, char *Title, char *HelpURL)); extern void EndInternalPage PARAMS((FILE *fp0)); extern void HTAddSugFilename PARAMS((char *fname)); extern void HTSugFilenames_free NOPARAMS; +extern void LYAddHilite PARAMS((int cur, char *text, int x)); extern void LYAddHtmlSep PARAMS((char **path)); extern void LYAddHtmlSep0 PARAMS((char *path)); extern void LYAddLocalhostAlias PARAMS((char *alias)); @@ -132,6 +135,7 @@ extern void LYFixCursesOn PARAMS((CONST char* reason)); extern void LYLocalFileToURL PARAMS((char **target, CONST char *source)); extern void LYLocalhostAliases_free NOPARAMS; extern void LYRenamedTemp PARAMS((char * oldname, char * newname)); +extern void LYSetHilite PARAMS((int cur, char *text)); extern void LYTrimHtmlSep PARAMS((char *path)); extern void LYTrimPathSep PARAMS((char *path)); extern void LYTrimRelFromAbsPath PARAMS((char *path)); diff --git a/src/LYexit.c b/src/LYexit.c index fbc13160..8341180f 100644 --- a/src/LYexit.c +++ b/src/LYexit.c @@ -166,6 +166,7 @@ PUBLIC void LYexit ARGS1( } LYCloseTracelog(); #endif /* !VMS */ + show_alloc(); exit(status); } diff --git a/src/structdump.h b/src/structdump.h index 03f6e49a..cd64e71a 100644 --- a/src/structdump.h +++ b/src/structdump.h @@ -31,8 +31,10 @@ CTRACE((tfp, "\n" \ "}\n", \ (L), sizeof(*((L))), \ (L)->lname, (L)->lname, (L)->target, (L)->target, \ - (L)->hightext, (L)->hightext, (L)->hightext2, (L)->hightext2, \ - (L)->hightext2_offset, (L)->inUnderline, (L)->lx, (L)->ly, \ + (L)->l_hightext, (L)->l_hightext, \ + (L)->l_hightext2, (L)->l_hightext2, \ + (L)->l_hightext2_offset, \ + (L)->inUnderline, (L)->lx, (L)->ly, \ (L)->type, (L)->anchor_number, (L)->anchor_line_num, (L)->form)); \ }else{ \ CTRACE((tfp, "\n" \ |