lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev pre3 (patch) startfile failure now more user friendly:)


From: Leonid Pauzner
Subject: lynx-dev pre3 (patch) startfile failure now more user friendly:)
Date: Thu, 13 May 1999 21:53:36 +0400 (MSD)

* When STARTFILE could not be loaded lynx now exit with more understandable
  status: all important statusline messages now printed to stderr/stdout.



diff -u old/lyhistor.c ./lyhistor.c
--- old/lyhistor.c      Wed May  5 17:34:00 1999
+++ ./lyhistor.c        Thu May 13 19:55:46 1999
@@ -677,6 +677,7 @@
     fprintf(fp0, "<pre>\n");
     fprintf(fp0, "<ol>\n");

+    /* print messages in reverse order: */
     i = topOfStack;
     while (--i >= 0) {
        if (buffstack[i] != NULL)
@@ -706,6 +707,38 @@
     if (!HTLoadAbsolute(&WWWDoc))
        return(NOT_FOUND);
     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 lets 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");
+       }
+    }
 }


diff -u old/lyhistor.h ./lyhistor.h
--- old/lyhistor.h      Fri Apr 23 07:56:36 1999
+++ ./lyhistor.h        Thu May 13 18:51:22 1999
@@ -17,5 +17,6 @@
 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 -u old/lymainlo.c ./lymainlo.c
--- old/lymainlo.c      Thu May 13 11:14:52 1999
+++ ./lymainlo.c        Thu May 13 21:27:34 1999
@@ -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 @@
                        /*
                         *  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 @@
                           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);
                        }
                    }

@@ -6236,4 +6199,60 @@
     }
     /* 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 -u old/htaccess.c ./htaccess.c
--- old/htaccess.c      Wed May  5 17:34:00 1999
+++ ./htaccess.c        Thu May 13 20:24:04 1999
@@ -1011,7 +1011,8 @@

     /* Failure in accessing a document */
     cp = NULL;
-    StrAllocCopy(cp, "Can't Access `");
+    StrAllocCopy(cp, gettext("Can't Access"));
+    StrAllocCat(cp, " `");
     StrAllocCat(cp, full_address);
     StrAllocCat(cp, "'");
     _HTProgress(cp);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]