about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LYCharSets.c11
-rw-r--r--src/LYHistory.c33
-rw-r--r--src/LYHistory.h1
-rw-r--r--src/LYMain.c6
-rw-r--r--src/LYMainLoop.c106
-rw-r--r--src/LYUtils.c22
-rw-r--r--src/LYUtils.h9
-rw-r--r--src/descrip.mms2
8 files changed, 119 insertions, 71 deletions
diff --git a/src/LYCharSets.c b/src/LYCharSets.c
index f4bd9b39..837f4d9a 100644
--- a/src/LYCharSets.c
+++ b/src/LYCharSets.c
@@ -868,12 +868,6 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1(
     /*
      *	Try UC_entity_info unicode_entities[].
      */
-#ifdef    NOT_ASCII  /* S/390 -- gil -- 1656 */
-    for (i = 0; i < number_of_unicode_entities; i++ ) {
-	/*
-	**  Linear search for NOT_ASCII.
-	*/
-#else  /* NOT_ASCII */
     for (low = 0, high = number_of_unicode_entities;
 	 high > low;
 	 diff < 0 ? (low = i+1) : (high = i)) {
@@ -881,15 +875,12 @@ PUBLIC UCode_t HTMLGetEntityUCValue ARGS1(
 	**  Binary search.
 	*/
 	i = (low + (high-low)/2);
-#endif /* NOT_ASCII  S/390 -- gil -- 1662 */
-	diff = strcmp(unicode_entities[i].name, name);	/* Case sensitive! */
+	diff = AS_cmp(unicode_entities[i].name, name);	/* Case sensitive! */
 	if (diff == 0) {
 	    value = unicode_entities[i].code;
 	    break;
 	}
     }
-    /* } NOT_ASCII */
-
     return(value);
 }
 
diff --git a/src/LYHistory.c b/src/LYHistory.c
index fa1eeaab..a345b31f 100644
--- a/src/LYHistory.c
+++ b/src/LYHistory.c
@@ -677,6 +677,7 @@ PUBLIC int LYshow_statusline_messages ARGS1(
     fprintf(fp0, "<pre>\n");
     fprintf(fp0, "<ol>\n");
 
+    /* print messages in reverse order: */
     i = topOfStack;
     while (--i >= 0) {
 	if (buffstack[i] != NULL)
@@ -708,6 +709,38 @@ PUBLIC int LYshow_statusline_messages ARGS1(
     return(NORMAL);
 }
 
+/*
+ * Dump statusline messages into the buffer.
+ * Called from mainloop() when exit immediately with an error:
+ * can not access startfile (first_file) so a couple of alert messages
+ * will be very useful on exit.
+ * (Don't expect everyone will look a trace log in case of difficulties:))
+ */
+PUBLIC void LYprint_statusline_messages_on_exit ARGS1(
+	char **,	buf)
+{
+    int i;
+
+    StrAllocCat(*buf, "\n");
+    /* print messages in chronological order:
+     * probably a single message but let's do it.
+     */
+    i = topOfStack - 1;
+    while (++i <= STATUSBUFSIZE) {
+	if (buffstack[i] != NULL) {
+	    StrAllocCat(*buf, buffstack[i]);
+	    StrAllocCat(*buf, "\n");
+	}
+    }
+    i = -1;
+    while (++i < topOfStack) {
+	if (buffstack[i] != NULL) {
+	    StrAllocCat(*buf, buffstack[i]);
+	    StrAllocCat(*buf, "\n");
+	}
+    }
+}
+
 
 PUBLIC void LYstore_message2 ARGS2(
 	CONST char *,	message,
diff --git a/src/LYHistory.h b/src/LYHistory.h
index 054b2a30..e65e2ea8 100644
--- a/src/LYHistory.h
+++ b/src/LYHistory.h
@@ -17,5 +17,6 @@ extern void LYpush PARAMS((document *doc, BOOLEAN force_push));
 extern void LYstore_message2 PARAMS((CONST char *message, CONST char *argument));
 extern void LYstore_message PARAMS((CONST char *message));
 extern int LYshow_statusline_messages PARAMS((document *newdoc));
+extern void LYprint_statusline_messages_on_exit PARAMS((char **buf));
 
 #endif /* LYHISTORY_H */
diff --git a/src/LYMain.c b/src/LYMain.c
index a5e2485e..9d9d7e03 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1369,7 +1369,7 @@ PUBLIC int main ARGS2(
      */
     StrAllocCopy(LynxHome, startfile);
     LYFillLocalFileURL((char **)&LynxHome, "file://localhost");
-    LYEnsureAbsoluteURL((char **)&LynxHome, "LynxHome");
+    LYEnsureAbsoluteURL((char **)&LynxHome, "LynxHome", FALSE);
 
     /*
      *  Process any command line arguments not already handled. - FM
@@ -1692,7 +1692,7 @@ PUBLIC int main ARGS2(
      *	make it one. - FM
      */
     LYFillLocalFileURL((char **)&startfile, "file://localhost");
-    LYEnsureAbsoluteURL((char **)&startfile, "STARTFILE");
+    LYEnsureAbsoluteURL((char **)&startfile, "STARTFILE", FALSE);
 
     /*
      *	If homepage was specified and is a file URL with the
@@ -1701,7 +1701,7 @@ PUBLIC int main ARGS2(
      */
     if (homepage) {
 	LYFillLocalFileURL((char **)&homepage, "file://localhost");
-	LYEnsureAbsoluteURL((char **)&homepage, "HOMEPAGE");
+	LYEnsureAbsoluteURL((char **)&homepage, "HOMEPAGE", FALSE);
     }
 
     /*
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 685b82ab..41cc0c8e 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -55,6 +55,7 @@
 #include <LYLeaks.h>
 
 
+PRIVATE void exit_immediately_with_error_message PARAMS((int state, BOOLEAN first_file));
 PRIVATE void print_status_message PARAMS((CONST linkstruct curlink, char **cp));
 PRIVATE BOOL confirm_post_resub PARAMS((
     CONST char*		address,
@@ -647,25 +648,7 @@ try_again:
 			/*
 			 *  If nhist = 0 then it must be the first file.
 			 */
-			if (!dump_output_immediately)
-			    cleanup();
-#ifdef UNIX
-			if (dump_output_immediately)
-			    fprintf(stderr, gettext("\nlynx: Can't access startfile %s\n"),
-				    startfile);
-			else
-#endif /* UNIX */
-			{
-
-			    SetOutputMode( O_TEXT );
-			    printf(gettext("\nlynx: Can't access startfile %s\n"),
-				   startfile);
-			    SetOutputMode( O_BINARY );
-			}
-
-			if (!dump_output_immediately) {
-			    exit_immediately(-1);
-			}
+			exit_immediately_with_error_message(NOT_FOUND, first_file);
 			return(-1);
 		    }
 
@@ -738,28 +721,8 @@ try_again:
 			   newdoc.internal_link = FALSE;
 			   goto try_again;
 			} else {
-			    if (!dump_output_immediately)
-			       cleanup();
-#ifdef UNIX
-			    if (dump_output_immediately) {
-			       fprintf(stderr,
- gettext("\nlynx: Start file could not be found or is not text/html or text/plain\n"));
-				fprintf(stderr, gettext("      Exiting...\n"));
-			    } else
-#endif /* UNIX */
-			    {
-				SetOutputMode( O_TEXT );
-
-				printf(
- gettext("\nlynx: Start file could not be found or is not text/html or text/plain\n"));
-				printf(gettext("      Exiting...\n"));
-
-				SetOutputMode( O_BINARY );
-			    }
-			    if (!dump_output_immediately) {
-				exit_immediately(-1);
-			    }
-			    return(-1);
+			   exit_immediately_with_error_message(NULLFILE, first_file);
+			   return(-1);
 			}
 		    }
 
@@ -3641,7 +3604,7 @@ check_goto_URL:
 		if ( user_input_buffer[1] &&
 		     HTFindPoundSelector(user_input_buffer+1) ) {
 		     /* HTFindPoundSelector will initialize www_search_result,
-		        so we do nothing else. */
+			so we do nothing else. */
 		    HTAddGotoURL(user_input_buffer);
 		}
 		break;
@@ -3651,7 +3614,7 @@ check_goto_URL:
 	     */
 	    StrAllocCopy(temp, user_input_buffer);
 	    LYFillLocalFileURL((char **)&temp, "file://localhost");
-	    LYEnsureAbsoluteURL((char **)&temp, "");
+	    LYEnsureAbsoluteURL((char **)&temp, "", TRUE);
 	    sprintf(user_input_buffer, "%.*s",
 		    (int)(sizeof(user_input_buffer) - 1), temp);
 	    FREE(temp);
@@ -6237,3 +6200,60 @@ PRIVATE void print_status_message ARGS2(
     /* turn off cursor since now it's probably on statusline -HV */
     move((LYlines - 1), (LYcols - 1));
 }
+
+
+PRIVATE void exit_immediately_with_error_message ARGS2(
+	int,		state,
+	BOOLEAN,	first_file)
+{
+    char *buf = 0;
+    char *buf2 = 0;
+
+    if (first_file) {
+	/* print statusline messages as a hint, if any */
+	LYprint_statusline_messages_on_exit(&buf2);
+    }
+
+    if (state == NOT_FOUND)
+    {
+	HTSprintf0(&buf, "%s\n%s %s\n",
+		   buf2,
+		   gettext("lynx: Can't access startfile"),
+		   /*
+		    * hack: if we fail in HTAccess.c
+		    * avoid duplicating URL, oh.
+		    */
+		   strstr(buf2, gettext("Can't Access")) ? "" : startfile);
+    }
+
+    if (state == NULLFILE)
+    {
+	HTSprintf0(&buf, "%s\n%s\n%s\n",
+		   buf2,
+		   gettext("lynx: Start file could not be found or is not text/html or text/plain"),
+		   gettext("      Exiting..."));
+    }
+
+    FREE(buf2);
+
+    if (!dump_output_immediately)
+	cleanup();
+
+#ifdef UNIX
+    if (dump_output_immediately) {
+	fprintf(stderr, buf);
+    } else
+#endif /* UNIX */
+    {
+	SetOutputMode( O_TEXT );
+	printf(buf);
+	SetOutputMode( O_BINARY );
+    }
+
+    FREE(buf);
+
+    if (!dump_output_immediately) {
+	exit_immediately(-1);
+    }
+    /* else: return(-1) in mainloop */
+}
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 7a7ed0ce..7b397219 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2514,7 +2514,7 @@ PUBLIC int LYCheckForProxyURL ARGS1(
      *	Don't crash on an empty argument.
      */
     if (cp == NULL || *cp == '\0')
-	return(0);
+	return(NOT_A_URL_TYPE);
 
     /* kill beginning spaces */
     cp = LYSkipBlanks(cp);
@@ -2535,11 +2535,11 @@ PUBLIC int LYCheckForProxyURL ARGS1(
 	FREE(cp2);
 #if defined (DOSPATH)
 	if (cp[1] == ':')
-	    return(0);		/* could be drive letter? - kw */
+	    return(NOT_A_URL_TYPE);	/* could be drive letter? - kw */
 #endif
 	cp1++;
 	if (!*cp) {
-	    return(0);
+	    return(NOT_A_URL_TYPE);
 	} else if (isdigit((unsigned char)*cp1)) {
 	    while (*cp1 && isdigit((unsigned char)*cp1))
 		cp1++;
@@ -2550,7 +2550,7 @@ PUBLIC int LYCheckForProxyURL ARGS1(
 	}
     }
 
-    return(0);
+    return(NOT_A_URL_TYPE);
 }
 
 /*
@@ -3791,9 +3791,10 @@ PUBLIC void LYCheckMail NOARGS
 **  an 'g'oto entries, after they have been
 **  passed to LYFillLocalFileURL(). - FM
 */
-PUBLIC void LYEnsureAbsoluteURL ARGS2(
+PUBLIC void LYEnsureAbsoluteURL ARGS3(
 	char **,	href,
-	CONST char *,	name)
+	CONST char *,	name,
+	int,		fixit)
 {
     char *temp = NULL;
 
@@ -3812,7 +3813,7 @@ PUBLIC void LYEnsureAbsoluteURL ARGS2(
     if (!is_url(*href)) {
 	CTRACE(tfp, "%s%s'%s' is not a URL\n",
 		    (name ? name : ""), (name ? " " : ""), *href);
-	LYConvertToURL(href);
+	LYConvertToURL(href, fixit);
     }
     if ((temp = HTParse(*href, "", PARSE_ALL)) != NULL && *temp != '\0')
 	StrAllocCopy(*href, temp);
@@ -3825,8 +3826,9 @@ PUBLIC void LYEnsureAbsoluteURL ARGS2(
  *  directory on the local system, otherwise as an
  *  http URL. - FM
  */
-PUBLIC void LYConvertToURL ARGS1(
-	char **,	AllocatedString)
+PUBLIC void LYConvertToURL ARGS2(
+	char **,	AllocatedString,
+	int,		fixit)
 {
     char *old_string = *AllocatedString;
     char *temp = NULL;
@@ -4183,7 +4185,7 @@ have_VMS_URL:
 		    } else {
 			StrAllocCopy(*AllocatedString, old_string);
 		    }
-		} else {
+		} else if (fixit) {
 		  /* RW 1998Mar16  Restore AllocatedString to 'old_string' */
 		    StrAllocCopy(*AllocatedString, old_string);
 		}
diff --git a/src/LYUtils.h b/src/LYUtils.h
index bf9cfed7..f205eec1 100644
--- a/src/LYUtils.h
+++ b/src/LYUtils.h
@@ -98,9 +98,9 @@ extern void LYCheckMail NOPARAMS;
 extern void LYCleanupTemp NOPARAMS;
 extern void LYCloseTemp PARAMS((char *name));
 extern void LYCloseTempFP PARAMS((FILE *fp));
-extern void LYConvertToURL PARAMS((char **AllocatedString));
+extern void LYConvertToURL PARAMS((char **AllocatedString, int fixit));
 extern void LYDoCSI PARAMS((char *url, CONST char *comment, char **csi));
-extern void LYEnsureAbsoluteURL PARAMS((char **href, CONST char *name));
+extern void LYEnsureAbsoluteURL PARAMS((char **href, CONST char *name, int fixit));
 extern void LYFakeZap PARAMS((BOOL set));
 extern void LYLocalFileToURL PARAMS((char **target, CONST char *source));
 extern void LYLocalhostAliases_free NOPARAMS;
@@ -141,10 +141,11 @@ extern BOOLEAN mustshow;
 /*
  *  For is_url().
  *
- *  Universal document id types.
+ *  Universal document id types (see LYCheckForProxyURL)
  */
 typedef enum {
-    UNKNOWN_URL_TYPE = 0,
+    NOT_A_URL_TYPE = 0,
+    UNKNOWN_URL_TYPE = 1,	/* must be nonzero */
 
     HTTP_URL_TYPE,
     FILE_URL_TYPE,
diff --git a/src/descrip.mms b/src/descrip.mms
index f4ce9e1a..be7aef30 100644
--- a/src/descrip.mms
+++ b/src/descrip.mms
@@ -84,7 +84,7 @@ CDEF = __VMS_CURSES
 TCP = SOCKETSHR_TCP
 TCPOPT = SOCKETSHR_TCP
 .ifdef DEC_C
-CDEF = __VMS_CURSES
+CDEF = _DECC_V4_SOURCE,__VMS_CURSES
 .endif
 .endif