[BACK]Return to os.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / less

Diff for /src/usr.bin/less/os.c between version 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2011/09/16 17:47:07 version 1.1.1.4, 2014/04/25 13:33:49
Line 1 
Line 1 
 /*  /*
  * Copyright (C) 1984-2011  Mark Nudelman   * Copyright (C) 1984-2012  Mark Nudelman
  *   *
  * You may distribute under the terms of either the GNU General Public   * You may distribute under the terms of either the GNU General Public
  * License or the Less License, as specified in the README file.   * License or the Less License, as specified in the README file.
  *   *
  * For more information about less, or for information on how to   * For more information, see the README file.
  * contact the author, see the README file.  
  */   */
   
   
Line 23 
Line 22 
   
 #include "less.h"  #include "less.h"
 #include <signal.h>  #include <signal.h>
 #include <setjmp.h>  
 #if HAVE_TIME_H  #if HAVE_TIME_H
 #include <time.h>  #include <time.h>
 #endif  #endif
Line 40 
Line 38 
 #define time_type       long  #define time_type       long
 #endif  #endif
   
 /*  extern volatile sig_atomic_t sigs;
  * BSD setjmp() saves (and longjmp() restores) the signal mask.  
  * This costs a system call or two per setjmp(), so if possible we clear the  
  * signal mask with sigsetmask(), and use _setjmp()/_longjmp() instead.  
  * On other systems, setjmp() doesn't affect the signal mask and so  
  * _setjmp() does not exist; we just use setjmp().  
  */  
 #if HAVE__SETJMP && HAVE_SIGSETMASK  
 #define SET_JUMP        _setjmp  
 #define LONG_JUMP       _longjmp  
 #else  
 #define SET_JUMP        setjmp  
 #define LONG_JUMP       longjmp  
 #endif  
   
 public int reading;  
   
 static jmp_buf read_label;  
   
 extern int sigs;  
   
 /*  /*
  * Like read() system call, but is deliberately interruptible.   * Like read() system call, but is deliberately interruptible.
  * A call to intread() from a signal handler will interrupt  
  * any pending iread().  
  */   */
         public int          public int
 iread(fd, buf, len)  iread(fd, buf, len)
Line 91 
Line 68 
         }          }
 #endif  #endif
 #endif  #endif
         if (SET_JUMP(read_label))  
         {  
                 /*  
                  * We jumped here from intread.  
                  */  
                 reading = 0;  
 #if HAVE_SIGPROCMASK  
                 {  
                   sigset_t mask;  
                   sigemptyset(&mask);  
                   sigprocmask(SIG_SETMASK, &mask, NULL);  
                 }  
 #else  
 #if HAVE_SIGSETMASK  
                 sigsetmask(0);  
 #else  
 #ifdef _OSK  
                 sigmask(~0);  
 #endif  
 #endif  
 #endif  
                 return (READ_INTR);  
         }  
   
         flush();          flush();
         reading = 1;  
 #if MSDOS_COMPILER==DJGPPC  #if MSDOS_COMPILER==DJGPPC
         if (isatty(fd))          if (isatty(fd))
         {          {
Line 155 
Line 108 
                 }                  }
         }          }
 #endif  #endif
         reading = 0;  
         if (n < 0)          if (n < 0)
         {          {
 #if HAVE_ERRNO  #if HAVE_ERRNO
Line 167 
Line 119 
 #endif  #endif
 #ifdef EINTR  #ifdef EINTR
                 if (errno == EINTR)                  if (errno == EINTR)
                         goto start;                          return (READ_INTR);
 #endif  #endif
 #ifdef EAGAIN  #ifdef EAGAIN
                 if (errno == EAGAIN)                  if (errno == EAGAIN)
Line 180 
Line 132 
 }  }
   
 /*  /*
  * Interrupt a pending iread().  
  */  
         public void  
 intread()  
 {  
         LONG_JUMP(read_label, 1);  
 }  
   
 /*  
  * Return the current time.   * Return the current time.
  */   */
 #if HAVE_TIME  #if HAVE_TIME
Line 218 
Line 161 
   
         if (err < sys_nerr)          if (err < sys_nerr)
                 return sys_errlist[err];                  return sys_errlist[err];
         sprintf(buf, "Error %d", err);          snprintf(buf, sizeof(buf), "Error %d", err);
         return buf;          return buf;
 #else  #else
         return ("cannot open");          return ("cannot open");
Line 235 
Line 178 
 {  {
         register char *p;          register char *p;
         register char *m;          register char *m;
         int len;          size_t len;
 #if HAVE_ERRNO  #if HAVE_ERRNO
 #if MUST_DEFINE_ERRNO  #if MUST_DEFINE_ERRNO
         extern int errno;          extern int errno;

Legend:
Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4