about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2013-10-03 12:27:55 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2013-10-03 12:27:55 -0400
commit1e048f0f991949075238d94f8748aa1c84598571 (patch)
tree95f0e4d5b419a8c43afbab19aba822158d08380a
parent6d47b44511310c62f3a8897b0b6e2c8c3e08cd7e (diff)
downloadlynx-snapshots-1e048f0f991949075238d94f8748aa1c84598571.tar.gz
snapshot of project "lynx", label v2-8-8dev_16l
-rw-r--r--CHANGES5
-rw-r--r--src/GridText.c98
-rw-r--r--src/LYSearch.c138
-rw-r--r--src/LYSearch.h8
-rw-r--r--src/LYStructs.h4
-rw-r--r--src/LYUtils.c73
6 files changed, 133 insertions, 193 deletions
diff --git a/CHANGES b/CHANGES
index 21e9861a..05be3da1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,9 +1,12 @@
--- $LynxId: CHANGES,v 1.669 2013/10/03 08:21:55 tom Exp $
+-- $LynxId: CHANGES,v 1.670 2013/10/03 09:27:24 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
 2013-10-02 (2.8.8dev.17)
+* correct search logic to match links which are wrapped on the right margin.
+  Previous fixes to highlight arbitrarily long links overlooked this case
+  (Debian #546264) -TD
 * modify the INFO page, normally bound to "=", to show decoded strings for
   URLs, e.g., which use %xy hexadecimal encoding.  The decoded strings are
   shown on the line following the encoded URLs if the strings are different.
diff --git a/src/GridText.c b/src/GridText.c
index 01a3edee..b15d2d19 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.267 2013/10/02 20:09:49 tom Exp $
+ * $LynxId: GridText.c,v 1.269 2013/10/03 12:13:18 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -36,6 +36,7 @@
 #include <LYEdit.h>
 #include <LYPrint.h>
 #include <LYPrettySrc.h>
+#include <LYSearch.h>
 #include <TRSTable.h>
 #include <LYHistory.h>
 #ifdef EXP_CHARTRANS_AUTOSWITCH
@@ -8410,94 +8411,33 @@ static void adjust_search_result(DocInfo *doc, int tentative_result,
     }
 }
 
+/*
+ * see also link_has_target
+ */
 static BOOL anchor_has_target(TextAnchor *a, char *target)
 {
-    OptionType *option;
-    char *stars = NULL, *sp;
-    const char *cp;
+    char *text = NULL;
+    const char *last = "?";
     int count;
 
     /*
-     * Search the hightext strings, taking the LYcase_sensitive setting into
-     * account.  -FM
+     * Combine the parts of the link's text using the highlighting information,
+     * and compare the target against that.
      */
-    for (count = 0;; ++count) {
-	if ((cp = LYGetHiTextStr(a, count)) == NULL)
-	    break;
-	if (LYno_attr_strstr(cp, target))
-	    return TRUE;
-    }
+    for (count = 0; count < 10; ++count) {
+	const char *part = LYGetHiTextStr(a, count);
 
-    /*
-     * Search the relevant form fields, taking the
-     * LYcase_sensitive setting into account.  -FM
-     */
-    if ((a->input_field != NULL && a->input_field->value != NULL) &&
-	a->input_field->type != F_HIDDEN_TYPE) {
-	if (a->input_field->type == F_PASSWORD_TYPE) {
-	    /*
-	     * Check the actual, hidden password, and then
-	     * the displayed string.  -FM
-	     */
-	    if (LYno_attr_strstr(a->input_field->value, target)) {
-		return TRUE;
-	    }
-	    StrAllocCopy(stars, a->input_field->value);
-	    for (sp = stars; *sp != '\0'; sp++)
-		*sp = '*';
-	    if (LYno_attr_strstr(stars, target)) {
-		FREE(stars);
-		return TRUE;
-	    }
-	    FREE(stars);
-	} else if (a->input_field->type == F_OPTION_LIST_TYPE) {
-	    /*
-	     * Search the option strings that are displayed
-	     * when the popup is invoked.  -FM
-	     */
-	    option = a->input_field->select_list;
-	    while (option != NULL) {
-		if (LYno_attr_strstr(option->name, target)) {
-		    return TRUE;
-		}
-		option = option->next;
-	    }
-	} else if (a->input_field->type == F_RADIO_TYPE) {
-	    /*
-	     * Search for checked or unchecked parens.  -FM
-	     */
-	    if (a->input_field->num_value) {
-		cp = checked_radio;
-	    } else {
-		cp = unchecked_radio;
-	    }
-	    if (LYno_attr_strstr(cp, target)) {
-		return TRUE;
-	    }
-	} else if (a->input_field->type == F_CHECKBOX_TYPE) {
-	    /*
-	     * Search for checked or unchecked square brackets.  -FM
-	     */
-	    if (a->input_field->num_value) {
-		cp = checked_box;
-	    } else {
-		cp = unchecked_box;
-	    }
-	    if (LYno_attr_strstr(cp, target)) {
-		return TRUE;
-	    }
-	} else {
-	    /*
-	     * Check the values intended for display.  May have been found
-	     * already via the hightext search, but make sure here that the
-	     * entire value is searched.  -FM
-	     */
-	    if (LYno_attr_strstr(a->input_field->value, target)) {
+	if (part == NULL || part == last) {
+	    if (text != NULL && LYno_attr_strstr(text, target)) {
 		return TRUE;
 	    }
+	    break;
 	}
+	StrAllocCat(text, part);
+	last = part;
     }
-    return FALSE;
+
+    return field_has_target(a->input_field, target);
 }
 
 static TextAnchor *line_num_to_anchor(int line_num)
@@ -8577,6 +8517,7 @@ static int www_search_forward(int start_line,
 	} else if (line == HTMainText->last_line) {
 	    count = 0;
 	    wrapped++;
+	    a = HTMainText->first_anchor;
 	}
 	line = line->next;
 	count++;
@@ -8619,6 +8560,7 @@ static int www_search_backward(int start_line,
 	} else if (line == FirstHTLine(HTMainText)) {
 	    count = line_num_in_text(HTMainText, LastHTLine(HTMainText)) + 1;
 	    wrapped++;
+	    a = HTMainText->last_anchor;
 	}
 	line = line->prev;
 	count--;
diff --git a/src/LYSearch.c b/src/LYSearch.c
index 7c6d1d28..f989bf31 100644
--- a/src/LYSearch.c
+++ b/src/LYSearch.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYSearch.c,v 1.31 2012/02/09 19:02:53 tom Exp $
+ * $LynxId: LYSearch.c,v 1.37 2013/10/03 12:27:55 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTAlert.h>
@@ -11,97 +11,97 @@
 
 #include <LYLeaks.h>
 
-static BOOL link_has_target(int cur,
-			    char *target)
+#define MATCH(a,b) (BOOL)(LYno_attr_strstr(a, b) != 0)
+
+/*
+ * Handle special field-related comparisons for anchor_has_target() and
+ * link_has_target().
+ */
+BOOL field_has_target(FormInfo * field, const char *target)
 {
-    LinkInfo *a = &links[cur];
+    BOOL result = FALSE;
     OptionType *option;
     char *stars = NULL;
     const char *cp;
-    int count;
-
-    /*
-     * Search the hightext strings, if present, taking the LYcase_sensitive
-     * setting into account.
-     */
-    for (count = 0;; ++count) {
-	const char *text = LYGetHiliteStr(cur, count);
-
-	if (text == NULL)
-	    break;
-	if (LYno_attr_strstr(text, target))
-	    return TRUE;
-    }
 
-    /*
-     * Search the relevant form fields, taking the LYcase_sensitive setting into
-     * account.  - FM
-     */
-    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) {
+    if ((field != NULL && field->value != NULL) &&
+	field->type != F_HIDDEN_TYPE) {
+	if (field->type == F_PASSWORD_TYPE) {
 	    /*
-	     * Check the actual, hidden password, and then the displayed
-	     * string.  - FM
+	     * Check the actual (hidden password), and then the displayed
+	     * string - FM
 	     */
-	    if (LYno_attr_strstr(a->l_form->value, target)) {
-		return TRUE;
-	    }
-	    StrAllocCopy(stars, a->l_form->value);
-	    memset(stars, '*', strlen(stars));
-	    if (LYno_attr_strstr(stars, target)) {
+	    if (MATCH(field->value, target)) {
+		result = TRUE;
+	    } else {
+		StrAllocCopy(stars, field->value);
+		memset(stars, '*', strlen(stars));
+		result = MATCH(stars, target);
 		FREE(stars);
-		return TRUE;
 	    }
-	    FREE(stars);
-	} else if (a->l_form->type == F_OPTION_LIST_TYPE) {
+	} else if (field->type == F_OPTION_LIST_TYPE) {
 	    /*
 	     * Search the option strings that are displayed when the popup is
-	     * invoked.  - FM
+	     * invoked - FM
 	     */
-	    option = a->l_form->select_list;
-	    while (option != NULL) {
-		if (LYno_attr_strstr(option->name, target)) {
-		    return TRUE;
+	    for (option = field->select_list; option != NULL; option = option->next) {
+		if (MATCH(option->name, target)) {
+		    result = TRUE;
+		    break;
 		}
-		option = option->next;
 	    }
-	} else if (a->l_form->type == F_RADIO_TYPE) {
+	} else if (field->type == F_RADIO_TYPE) {
 	    /*
-	     * Search for checked or unchecked parens.  - FM
+	     * Search for checked or unchecked parens - FM
 	     */
-	    if (a->l_form->num_value) {
-		cp = checked_radio;
-	    } else {
-		cp = unchecked_radio;
-	    }
-	    if (LYno_attr_strstr(cp, target)) {
-		return TRUE;
-	    }
-	} else if (a->l_form->type == F_CHECKBOX_TYPE) {
+	    cp = ((field->num_value)
+		  ? checked_radio
+		  : unchecked_radio);
+	    result = MATCH(cp, target);
+	} else if (field->type == F_CHECKBOX_TYPE) {
 	    /*
-	     * Search for checked or unchecked square brackets.  - FM
+	     * Search for checked or unchecked square brackets - FM
 	     */
-	    if (a->l_form->num_value) {
-		cp = checked_box;
-	    } else {
-		cp = unchecked_box;
-	    }
-	    if (LYno_attr_strstr(cp, target)) {
-		return TRUE;
-	    }
+	    cp = ((field->num_value)
+		  ? checked_box
+		  : unchecked_box);
+	    result = MATCH(cp, target);
 	} else {
-	    /*
-	     * Check the values intended for display.  May have been found
-	     * already via the hightext search, but make sure here that the
-	     * entire value is searched.  - FM
-	     */
-	    if (LYno_attr_strstr(a->l_form->value, target)) {
+	    result = MATCH(field->value, target);
+	}
+    }
+    return result;
+}
+
+/*
+ * see also anchor_has_target
+ */
+static BOOL link_has_target(int cur,
+			    char *target)
+{
+    LinkInfo *a = &links[cur];
+    char *text = NULL;
+    const char *last = "?";
+    int count;
+
+    /*
+     * Combine the parts of the link's text using the highlighting information,
+     * and compare the target against that.
+     */
+    for (count = 0; count < 10; ++count) {
+	const char *part = LYGetHiliteStr(cur, count);
+
+	if (part == NULL || part == last) {
+	    if (MATCH(text, target)) {
 		return TRUE;
 	    }
+	    break;
 	}
+	StrAllocCat(text, part);
+	last = part;
     }
-    return FALSE;
+
+    return field_has_target(a->l_form, target);
 }
 
 /*
diff --git a/src/LYSearch.h b/src/LYSearch.h
index c95d59cd..17fd5dda 100644
--- a/src/LYSearch.h
+++ b/src/LYSearch.h
@@ -1,6 +1,13 @@
+/*
+ * $LynxId: LYSearch.h,v 1.12 2013/10/03 11:24:06 tom Exp $
+ */
 #ifndef LYSEARCH_H
 #define LYSEARCH_H
 
+#ifndef HTFORMS_H
+#include <HTForms.h>
+#endif
+
 #ifndef LYSTRUCTS_H
 #include <LYStructs.h>
 #endif /* LYSTRUCT_H */
@@ -8,6 +15,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+    extern BOOL field_has_target(FormInfo * field, const char *target);
     extern BOOL textsearch(DocInfo *cur_doc,
 			   bstring **prev_target,
 			   int direction);
diff --git a/src/LYStructs.h b/src/LYStructs.h
index b37e5198..70f2c063 100644
--- a/src/LYStructs.h
+++ b/src/LYStructs.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYStructs.h,v 1.30 2010/12/08 23:30:08 tom Exp $
+ * $LynxId: LYStructs.h,v 1.31 2013/10/03 08:56:47 tom Exp $
  */
 #ifndef LYSTRUCTS_H
 #define LYSTRUCTS_H
@@ -26,8 +26,6 @@ extern "C" {
 	char *lname;
 	char *target;
 	char *l_hightext;
-	char *l_hightext2;
-	int l_hightext2_offset;
 	BOOL inUnderline;	/* TRUE when this link is in underlined context. */
 	int lx;
 	int ly;
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 88fbf275..43238170 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.242 2013/07/29 00:33:32 tom Exp $
+ * $LynxId: LYUtils.c,v 1.243 2013/10/03 08:58:05 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -1106,11 +1106,6 @@ void LYhighlight(int flag,
     BOOL utf_flag = (BOOL) IS_UTF8_TTY;
     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';
 
     /*
@@ -1178,7 +1173,6 @@ void LYhighlight(int flag,
 
 #ifdef USE_COLOR_STYLE
 	} else if (flag == FALSE) {
-	    hl2_drawn = TRUE;
 	    redraw_lines_of_link(cur);
 	    CTRACE2(TRACE_STYLE,
 		    (tfp, "STYLE.highlight.off: NOFIX branch @(%d,%d).\n",
@@ -1200,50 +1194,45 @@ void LYhighlight(int flag,
 	/*
 	 * 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
-		 && LYP + hi_count <= display_lines;
-		 ++hi_count) {
-		int row = LYP + hi_count + title_adjust;
-
-		hi_offset = LYGetHilitePos(cur, hi_count);
-		if (hi_offset < 0)
-		    continue;
-		lynx_stop_link_color(flag == TRUE, links[cur].inUnderline);
-		LYmove(row, hi_offset);
+	for (hi_count = 1;
+	     (hi_string = LYGetHiliteStr(cur, hi_count)) != NULL
+	     && LYP + hi_count <= display_lines;
+	     ++hi_count) {
+	    int row = LYP + hi_count + title_adjust;
+
+	    hi_offset = LYGetHilitePos(cur, hi_count);
+	    if (hi_offset < 0)
+		continue;
+	    lynx_stop_link_color(flag == TRUE, links[cur].inUnderline);
+	    LYmove(row, hi_offset);
 
 #ifdef USE_COLOR_STYLE
-		CTRACE2(TRACE_STYLE,
-			(tfp, "STYLE.highlight.line2: @(%d,%d), style=%d.\n",
-			 row, hi_offset,
-			 flag == TRUE ? s_alink : s_a));
-		LynxChangeStyle(flag == TRUE ? s_alink : s_a, ABS_ON);
+	    CTRACE2(TRACE_STYLE,
+		    (tfp, "STYLE.highlight.line2: @(%d,%d), style=%d.\n",
+		     row, hi_offset,
+		     flag == TRUE ? s_alink : s_a));
+	    LynxChangeStyle(flag == TRUE ? s_alink : s_a, ABS_ON);
 #else
-		lynx_start_link_color(flag == TRUE, links[cur].inUnderline);
+	    lynx_start_link_color(flag == TRUE, links[cur].inUnderline);
 #endif
 
-		for (i = 0; (tmp[0] = hi_string[i]) != '\0'
-		     && (i + hi_offset) < LYcols; i++) {
-		    if (!IsSpecialAttrChar(hi_string[i])) {
-			/*
-			 * For CJK strings, by Masanobu Kimura.
-			 */
-			if (IS_CJK_TTY && is8bits(tmp[0])) {
-			    tmp[1] = hi_string[++i];
-			    LYaddstr(tmp);
-			    tmp[1] = '\0';
-			} else {
-			    LYaddstr(tmp);
-			}
+	    for (i = 0; (tmp[0] = hi_string[i]) != '\0'
+		 && (i + hi_offset) < LYcols; i++) {
+		if (!IsSpecialAttrChar(hi_string[i])) {
+		    /*
+		     * For CJK strings, by Masanobu Kimura.
+		     */
+		    if (IS_CJK_TTY && is8bits(tmp[0])) {
+			tmp[1] = hi_string[++i];
+			LYaddstr(tmp);
+			tmp[1] = '\0';
+		    } else {
+			LYaddstr(tmp);
 		    }
 		}
 	    }
-	    lynx_stop_link_color(flag == TRUE, links[cur].inUnderline);
 	}
+	lynx_stop_link_color(flag == TRUE, links[cur].inUnderline);
 #ifdef SHOW_WHEREIS_TARGETS
 	for (hi_count = target1_drawn ? 1 : 0;
 	     LYGetHiliteStr(cur, hi_count) != NULL;