lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev lynx2.8.2dev.15


From: pg
Subject: Re: lynx-dev lynx2.8.2dev.15
Date: Fri, 29 Jan 1999 15:33:25 -0700 (MST)

In a recent note, address@hidden said:

> Date: Thu, 28 Jan 1999 11:49:40 -0500 (EST)
> 
> * add pattern to script which customizes pathnames in lynx.cfg to support
>     GLOBAL_MAILCAP:/PATH_TO/lynx_doc/samples/mailcap
>   (request by PG) - TD
> * export $PATH when calling cfg_defs.sh - PG
> * add a simple test to check if the temporary directory is actually writable
>   if we cannot create a temporary file in LYOpenTemp (reported by PG) - TD

Thank you, thank you, and thank you.  They all seem to work.

I'll suggest a modification.

1. There are several ways creating a file may fail.  I think of:
   EEXIST, ENODEV, ENFILE, EMFILE, and ENOSPC.  Of these, the only
   one that can plausibly be recovered by choosing a different
   filename is EEXIST.  The attached patch breaks the loop if any
   error other than EEXIST occurs.

2. Since there are several possible failure reasons, the reason should
   be logged.  This is done by:

   o Converting PRIVATE facility LYStrerror in LYCgi to a PUBLIC
     facility in LYStrings.

   o Adding a CTRACE using that facility in LYUtils to log the
     failure reason.

-- gil
=================================================================
%%% Created Fri Jan 29 14:24:11 MST 1999 by target lynx.patch. %%%
diff -brc orig/lynx2-8-2/src/LYCgi.c lynx2-8-2/src/LYCgi.c
*** orig/lynx2-8-2/src/LYCgi.c  Thu Jan 28 09:31:29 1999
--- lynx2-8-2/src/LYCgi.c       Fri Jan 29 12:52:55 1999
***************
*** 70,86 ****
  
  #define PERROR(msg) CTRACE(tfp, "LYNXCGI: %s: %s\n", msg, LYStrerror(errno))
  
- #ifdef HAVE_STRERROR
- #define LYStrerror(n) strerror(n)
- #else
- PRIVATE char *LYStrerror ARGS1(int, code)
- {
-     static char temp[80];
-     sprintf(temp, "System errno is %d.\r\n", code);
-     return temp;
- }
- #endif /* HAVE_STRERROR */
- 
  PRIVATE void free_alloced_lynxcgi NOARGS
  {
      void *ptr;
--- 70,75 ----
diff -brc orig/lynx2-8-2/src/LYStrings.c lynx2-8-2/src/LYStrings.c
*** orig/lynx2-8-2/src/LYStrings.c      Mon Jan 18 05:29:20 1999
--- lynx2-8-2/src/LYStrings.c   Fri Jan 29 14:01:51 1999
***************
*** 288,293 ****
--- 288,308 ----
  
  
  /*
+  *  LYstrerror emulates the ANSI strerror() function.
+  */
+ #ifdef LYStrerror
+     /* defined as macro in .h file. */
+ #else
+ PUBLIC char *LYStrerror ARGS1(int, code)
+ {
+     static char temp[80];
+     sprintf(temp, "System errno is %d.\r\n", code);
+     return temp;
+ }
+ #endif /* HAVE_STRERROR */
+ 
+ 
+ /*
   *  LYstrncpy() terminates strings with a null byte.
   *  Writes a null byte into the n+1 byte of dst.
   */
diff -brc orig/lynx2-8-2/src/LYStrings.h lynx2-8-2/src/LYStrings.h
*** orig/lynx2-8-2/src/LYStrings.h      Wed Jan 13 04:37:34 1999
--- lynx2-8-2/src/LYStrings.h   Fri Jan 29 14:05:24 1999
***************
*** 13,18 ****
--- 13,25 ----
  extern int peek_mouse_levent NOPARAMS;
  extern int fancy_mouse PARAMS((WINDOW *win, int row, int *position));
  
+ #ifdef HAVE_STRERROR
+ #define LYStrerror strerror
+ #else
+ extern char *LYStrerror PARAMS((
+       int             code));
+ #endif /* HAVE_STRERROR */
+ 
  extern char * LYstrncpy PARAMS((
        char *          dst,
        CONST char *    src,
diff -brc orig/lynx2-8-2/src/LYUtils.c lynx2-8-2/src/LYUtils.c
*** orig/lynx2-8-2/src/LYUtils.c        Thu Jan 28 09:31:29 1999
--- lynx2-8-2/src/LYUtils.c     Fri Jan 29 13:10:44 1999
***************
*** 5638,5644 ****
        CONST char *,   mode)
  {
      FILE *fp = 0;
-     BOOL first = TRUE;
      BOOL txt = TRUE;
      BOOL wrt = 'r';
      LY_TEMP *p;
--- 5638,5643 ----
***************
*** 5674,5693 ****
            fp = LYNewBinFile (result);
        }
        /*
!        * If we get a failure to make a temporary file, double check if the
!        * directory is writable.
         */
! #ifdef W_OK   /* FIXME (need a better test) in fcntl.h or unistd.h */
!       if (first) {
!           first = FALSE;
!           if (fp == 0) {
!               *LYPathLeaf(result) = 0;
!               if (*result == 0)
!                   strcpy(result, ".");
!               if (access(result, W_OK) < 0)
                    return 0;
            }
-       }
  #endif
      } while (fp == 0);
  
--- 5673,5688 ----
            fp = LYNewBinFile (result);
        }
        /*
!        * If we get a failure to make a temporary file, dont bother to try
!        * a different name unless the failure was because the file already
!        * exists.
         */
! #ifdef EEXIST /* FIXME (need a better test) in fcntl.h or unistd.h */
!       if ((fp == 0) && (errno != EEXIST)) {    
!           CTRACE(tfp, "... LYOpenTemp(%s) failed: %s\n",
!               result, LYStrerror(errno));
            return 0;
        }
  #endif
      } while (fp == 0);
  

reply via email to

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