about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c96
-rw-r--r--src/GridText.h1
-rw-r--r--src/HTAlert.c8
-rw-r--r--src/LYMainLoop.c16
-rw-r--r--src/LYOptions.c37
-rw-r--r--src/LYStrings.c4
-rw-r--r--src/LYStyle.c18
7 files changed, 114 insertions, 66 deletions
diff --git a/src/GridText.c b/src/GridText.c
index b0e3238b..d3d7e2ea 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -6145,6 +6145,13 @@ PUBLIC void HTuncache_current_document NOARGS
     if (HTMainText) {
 	HTParentAnchor * htmain_anchor = HTMainText->node_anchor;
 
+	if (HText_HaveUserChangedForms()) {
+	    /*
+	     * Issue a warning.  User forms content will be lost.
+	     */
+	    HTAlert(RELOADING_FORM);
+	}
+
 	if (htmain_anchor) {
 	    if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) {
 		FREE(htmain_anchor->UCStages);
@@ -6218,11 +6225,9 @@ PUBLIC BOOLEAN HTreparse_document NOARGS
 	display_partial = display_partial_flag;  /* restore */
 	Newline_partial = Newline;  /* initialize */
 #endif
-	if (lynx_mode == FORMS_LYNX_MODE) {
+	if (HText_HaveUserChangedForms()) {
 	    /*
-	     *  Note that if there are no form links on the current
-	     *  page, lynx_mode won't have this setting and we won't
-	     *  know that this warning should be issued. - FM
+	     * Issue a warning.  Will not restore changed forms, currently.
 	     */
 	    HTAlert(RELOADING_FORM);
 	}
@@ -6266,11 +6271,9 @@ PUBLIC BOOLEAN HTreparse_document NOARGS
 	display_partial = display_partial_flag;  /* restore */
 	Newline_partial = Newline;  /* initialize */
 #endif
-	if (lynx_mode == FORMS_LYNX_MODE) {
+	if (HText_HaveUserChangedForms()) {
 	    /*
-	     *  Note that if there are no form links on the current
-	     *  page, lynx_mode won't have this setting and we won't
-	     *  know that this warning should be issued. - FM
+	     * Issue a warning.  Will not restore changed forms, currently.
 	     */
 	    HTAlert(RELOADING_FORM);
 	}
@@ -8869,7 +8872,6 @@ PUBLIC void HText_DisableCurrentForm NOARGS
 	if (anchor_ptr == HTMainText->last_anchor)
 	    break;
 
-
 	anchor_ptr = anchor_ptr->next;
     }
 
@@ -8882,49 +8884,99 @@ PUBLIC void HText_ResetForm ARGS1(
     TextAnchor * anchor_ptr;
 
     _statusline(RESETTING_FORM);
-    if (!HTMainText)
+    if (HTMainText == 0)
 	return;
 
     /*
      *  Go through list of anchors and reset values.
      */
     anchor_ptr = HTMainText->first_anchor;
-    while (anchor_ptr) {
+    while (anchor_ptr != 0) {
 	if (anchor_ptr->link_type == INPUT_ANCHOR) {
 	    if (anchor_ptr->input_field->number == form->number) {
 
-		 if (anchor_ptr->input_field->type == F_RADIO_TYPE ||
-		     anchor_ptr->input_field->type == F_CHECKBOX_TYPE) {
+		if (anchor_ptr->input_field->type == F_RADIO_TYPE ||
+		    anchor_ptr->input_field->type == F_CHECKBOX_TYPE) {
 
 		    if (anchor_ptr->input_field->orig_value[0] == '0')
 			anchor_ptr->input_field->num_value = 0;
 		    else
 			anchor_ptr->input_field->num_value = 1;
 
-		 } else if (anchor_ptr->input_field->type ==
-			    F_OPTION_LIST_TYPE) {
+		} else if (anchor_ptr->input_field->type ==
+			   F_OPTION_LIST_TYPE) {
 		    anchor_ptr->input_field->value =
 				anchor_ptr->input_field->orig_value;
 
 		    anchor_ptr->input_field->cp_submit_value =
 				anchor_ptr->input_field->orig_submit_value;
 
-		 } else {
+		} else {
 		    StrAllocCopy(anchor_ptr->input_field->value,
-					anchor_ptr->input_field->orig_value);
-		 }
-	     } else if (anchor_ptr->input_field->number > form->number) {
-		 break;
-	     }
-
+				 anchor_ptr->input_field->orig_value);
+		}
+	    } else if (anchor_ptr->input_field->number > form->number) {
+		break;
+	    }
 	}
 
 	if (anchor_ptr == HTMainText->last_anchor)
 	    break;
 
+	anchor_ptr = anchor_ptr->next;
+    }
+}
+
+/*
+ * This function is called before reloading/reparsing current document to find
+ * whether any forms content was changed by user so any information will be
+ * lost.
+ */
+PUBLIC BOOLEAN HText_HaveUserChangedForms NOARGS
+{
+    TextAnchor * anchor_ptr;
+
+    if (HTMainText == 0)
+       return FALSE;
+
+    /*
+     *  Go through list of anchors to check if any value was changed.
+     *  This code based on HText_ResetForm()
+     */
+    anchor_ptr = HTMainText->first_anchor;
+    while (anchor_ptr != 0) {
+	if (anchor_ptr->link_type == INPUT_ANCHOR) {
+
+	    if (anchor_ptr->input_field->type == F_RADIO_TYPE ||
+		anchor_ptr->input_field->type == F_CHECKBOX_TYPE) {
+
+		if ((anchor_ptr->input_field->orig_value[0] == '0' &&
+		     anchor_ptr->input_field->num_value == 1) ||
+		    (anchor_ptr->input_field->orig_value[0] != '0' &&
+		     anchor_ptr->input_field->num_value == 0))
+		    return TRUE;
+
+	    } else if (anchor_ptr->input_field->type == F_OPTION_LIST_TYPE) {
+		if (strcmp(anchor_ptr->input_field->value,
+			   anchor_ptr->input_field->orig_value))
+		    return TRUE;
+
+		if (strcmp(anchor_ptr->input_field->cp_submit_value,
+			   anchor_ptr->input_field->orig_submit_value))
+		    return TRUE;
+
+	    } else {
+		if (strcmp(anchor_ptr->input_field->value,
+			   anchor_ptr->input_field->orig_value))
+		    return TRUE;
+	    }
+	}
+	if (anchor_ptr == HTMainText->last_anchor)
+	   break;
 
 	anchor_ptr = anchor_ptr->next;
     }
+    return FALSE;
 }
 
 PUBLIC void HText_activateRadioButton ARGS1(
diff --git a/src/GridText.h b/src/GridText.h
index f82dd2d2..1eeba7b2 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -232,6 +232,7 @@ extern void HText_SubmitForm PARAMS((
 extern void HText_DisableCurrentForm NOPARAMS;
 extern void HText_ResetForm PARAMS((FormInfo *form));
 extern void HText_activateRadioButton PARAMS((FormInfo *form));
+extern BOOLEAN HText_HaveUserChangedForms NOPARAMS;
 
 extern HTList * search_queries; /* Previous isindex and whereis queries */
 extern void HTSearchQueries_free NOPARAMS;
diff --git a/src/HTAlert.c b/src/HTAlert.c
index d16b2665..40d3c3d5 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -521,10 +521,10 @@ PUBLIC BOOL HTConfirmCookie ARGS4(
 	**  the whole cookie.  Reduce them both by a percentage.
 	**  This should be smarter.
 	*/
-	float percentage;
-	percentage = (float)space_free/(float)(namelen + valuelen);
-	namelen = (int)(percentage*(float)namelen);
-	valuelen = (int)(percentage*(float)valuelen);
+        int percentage;  /* no float */
+        percentage = (100 * space_free) / (namelen + valuelen);
+        namelen = (percentage * namelen) / 100;
+        valuelen = (percentage * valuelen) / 100;
     }
     if(!LYAcceptAllCookies) {
 	char *message = 0;
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 1ddee54e..8bdc0ae0 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -1945,14 +1945,6 @@ new_cmd:  /*
 	     *	 this.	As the problems show up, we'll try to fix them,
 	     *	 or add warnings.  - FM)
 	     */
-	    if (lynx_mode == FORMS_LYNX_MODE) {
-		/*
-		 *  Note that if there are no form links on the current
-		 *  page, lynx_mode won't have this setting and we won't
-		 *  know that this warning should be issued. - FM
-		 */
-		HTAlert(RELOADING_FORM);
-	    }
 	    newdoc.line = curdoc.line;
 	    newdoc.link = curdoc.link;
 #endif /* NO_ASSUME_SAME_DOC */
@@ -3920,14 +3912,6 @@ if (!LYUseFormsOptions) {
 			}
 		    }
 #endif
-		    if (lynx_mode == FORMS_LYNX_MODE) {
-			/*
-			 *  Note that if there are no form links on the current
-			 *  page, lynx_mode won't have this setting and we won't
-			 *  know that this warning should be issued. - FM
-			 */
-			HTAlert(RELOADING_FORM);
-		    }
 		    HEAD_request = HTLoadedDocumentIsHEAD();
 		    HTuncache_current_document();
 #ifdef NO_ASSUME_SAME_DOC
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 6d52e11f..0884d18a 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -1931,7 +1931,7 @@ draw_bookmark_list:
 
     if (LYlines < (MBM_V_MAXFILES + MULTI_OFFSET)) {
 	for (a = ((MBM_V_MAXFILES/2 + 1) * (MBM_current - 1));
-		      a <= ((float)MBM_V_MAXFILES/2 * MBM_current); a++) {
+		      a <= (MBM_current * MBM_V_MAXFILES/2 ); a++) {
 	    move((3 + a) - ((MBM_V_MAXFILES/2 + 1)*(MBM_current - 1)), 5);
 	    addch((unsigned char)(a + 'A'));
 	    addstr(" : ");
@@ -3513,7 +3513,7 @@ PRIVATE int gen_options PARAMS((char **newfile));
  * manually (e.g., doing 'e'dit in 'o'ptions) and submit it to access the
  * restricted items.  Prevent spoofing attempts from index overrun. - LP
  *
- * Exit status: NULLFILE (reloading) or NORMAL (from HText cache).
+ * Exit status: NULLFILE (reload) or NORMAL (use HText cache).
  *
  * On exit, got the document which was current before the Options menu:
  *
@@ -3943,6 +3943,10 @@ PUBLIC int postoptions ARGS1(
      *  Being out of mainloop()/getfile() cycle, do things manually.
      */
     CTRACE(tfp, "\nLYOptions.c/postoptions(): exiting...\n");
+    CTRACE(tfp, "                            need_reload = %s\n",
+                    need_reload ? "TRUE" : "FALSE");
+    CTRACE(tfp, "                            need_end_reload = %s\n",
+                    need_end_reload ? "TRUE" : "FALSE");
 
     /*  Options menu was pushed before postoptions(), so pop-up. */
     LYpop(newdoc);
@@ -3965,7 +3969,8 @@ PUBLIC int postoptions ARGS1(
     if (!HTLoadAbsolute(&WWWDoc))
 	return(NOT_FOUND);
 
-    HTuncache_current_document(); /* will never use again */
+    /* comment out to avoid warning when removing forms content... */
+    /* HTuncache_current_document(); */ /* will never use again */
 
     /*
      *  Return to previous doc, not to options menu!
@@ -3991,6 +3996,11 @@ PUBLIC int postoptions ARGS1(
     if (!HTLoadAbsolute(&WWWDoc))
        return(NOT_FOUND);
 
+    /*
+     * Now most interesting part: reload document when necessary.
+     * **********************************************************
+     */
+
     reloading = FALSE;  /* set manually */
     /*  force end-to-end reload from remote server if change LYUserAgent
      *  or language or pref_charset (marked by need_end_reload flag above),
@@ -4011,7 +4021,7 @@ PUBLIC int postoptions ARGS1(
 	 *  case LYK_RELOAD (see comments there). - KW
 	 */
 	reloading = TRUE;  /* global flag */
-	need_reload = TRUE;
+	need_reload = TRUE;  /* this was probably already TRUE, don't worry */
     }
 
     if (need_reload == FALSE) {
@@ -4022,8 +4032,7 @@ PUBLIC int postoptions ARGS1(
 	/*  update HText cache */
 
 	/*
-	 *  Check to see if should reload source, or load html
-	 *  (from LYK_RELOAD & LYK_OPTIONS)
+	 *  see LYK_RELOAD & LYK_OPTIONS in mainloop for details...
 	 */
 	if (HTisDocumentSource()) {
 #ifndef USE_PSRC
@@ -4035,14 +4044,6 @@ PUBLIC int postoptions ARGS1(
 		HTOutputFormat = WWW_SOURCE;
 #endif
 	}
-	if (lynx_mode == FORMS_LYNX_MODE) {
-	    /* Sorry! lynx_mode set according the last display_page() state,
-	     * it always in form mode since we came from form-based option menu
-	     * so the information from mainloop() apperently lost.
-	     * reset here until we learn how to do it properly.
-	     */
-	    lynx_mode = NORMAL_LYNX_MODE;
-	}
 #ifdef SOURCE_CACHE
 	if (reloading == FALSE) {
 	    /* one more attempt to be smart enough: */
@@ -4053,10 +4054,14 @@ PUBLIC int postoptions ARGS1(
 	}
 #endif
 	HEAD_request = HTLoadedDocumentIsHEAD();
-	/*  no uncache, already loaded */
+	/*  uncache and load again */
+	HTuncache_current_document();
+	LYpush(newdoc, FALSE);
 	CTRACE(tfp, "LYOptions.c/postoptions(): now really exit.\n\n");
-	return(NORMAL);
+	return(NULLFILE);
     }
+
+    /******** Done! **************************************************/
 }
 
 PRIVATE char *NewSecureValue NOARGS
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 1e725ee1..0b493dd7 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -245,10 +245,10 @@ PRIVATE int set_clicked_link ARGS3(
 		if (cur_err == 0) {
 		    int cury, curx;
 
+		    LYGetYX(cury,curx);
 		    if (code != FOR_INPUT
 			/* Do not pick up the current input field */
-			|| !(LYGetYX(cury,curx),
-			     (cury == y && (curx >= lx) && ((curx - lx) <= len)))) {
+			|| !((cury == y && (curx >= lx) && ((curx - lx) <= len)))) {
 			if (is_text)
 			    have_levent = 1;
 			mouse_link = i;
diff --git a/src/LYStyle.c b/src/LYStyle.c
index f2be6970..a2accfb8 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.27 Wed, 05 May 1999 18:33:59 -0600 dickey @
+ * $Id: LYStyle.c,v 1.21 1999/05/28 14:18:50 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTML.h>
@@ -477,16 +477,22 @@ PUBLIC void FastTrimColorClass ARGS5 (
 	    int*,		 phcode)	/*will be modified*/
 {
     char* tag_start = *pstylename_end;
+    BOOLEAN found = FALSE;
 
     while (tag_start >= stylename)
     {
-	for (; tag_start >= stylename &&  *tag_start!=';' ; --tag_start)
+	for (; (tag_start >= stylename) && (*tag_start != ';') ; --tag_start)
 	    ;
-	if ( !strncasecomp(tag_start+1, tag_name, name_len) ) break;
-	    --tag_start;
+	if ( !strncasecomp(tag_start+1, tag_name, name_len) ) {
+	    found = TRUE;
+	    break;
+	}
+	--tag_start;
+    }
+    if (found) {
+	*tag_start = '\0';
+	*pstylename_end = tag_start;
     }
-    *tag_start = '\0';
-    *pstylename_end = tag_start;
     *phcode = hash_code(tag_start+1);
 }