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

Diff for /src/usr.bin/patch/util.c between version 1.3 and 1.4

version 1.3, 1996/09/24 04:19:30 version 1.4, 1997/09/22 05:45:27
Line 10 
Line 10 
 #include "util.h"  #include "util.h"
 #include "backupfile.h"  #include "backupfile.h"
   
   #ifdef __GNUC__
   void my_exit() __attribute__((noreturn));
   #else
 void my_exit();  void my_exit();
   #endif
   
 /* Rename a file, copying it if necessary. */  /* Rename a file, copying it if necessary. */
   
Line 18 
Line 22 
 move_file(from,to)  move_file(from,to)
 char *from, *to;  char *from, *to;
 {  {
     char bakname[512];      char bakname[MAXPATHLEN];
     Reg1 char *s;      Reg1 char *s;
     Reg2 int i;      Reg2 int i;
     Reg3 int fromfd;      Reg3 int fromfd;
Line 30 
Line 34 
         if (debug & 4)          if (debug & 4)
             say2("Moving %s to stdout.\n", from);              say2("Moving %s to stdout.\n", from);
 #endif  #endif
         fromfd = open(from, 0);          fromfd = open(from, O_RDONLY);
         if (fromfd < 0)          if (fromfd < 0)
             pfatal2("internal error, can't reopen %s", from);              pfatal2("internal error, can't reopen %s", from);
         while ((i=read(fromfd, buf, sizeof buf)) > 0)          while ((i=read(fromfd, buf, sizeof buf)) > 0)
Line 95 
Line 99 
                      strerror(errno));                       strerror(errno));
                 return -1;                  return -1;
             }              }
             tofd = open(to, 0);              tofd = open(to, O_RDONLY);
             if (tofd < 0)              if (tofd < 0)
                 pfatal2("internal error, can't open %s", to);                  pfatal2("internal error, can't open %s", to);
             while ((i=read(tofd, buf, sizeof buf)) > 0)              while ((i=read(tofd, buf, sizeof buf)) > 0)
Line 119 
Line 123 
               to, from, strerror(errno));                to, from, strerror(errno));
             return -1;              return -1;
         }          }
         fromfd = open(from, 0);          fromfd = open(from, O_RDONLY);
         if (fromfd < 0)          if (fromfd < 0)
             pfatal2("internal error, can't reopen %s", from);              pfatal2("internal error, can't reopen %s", from);
         while ((i=read(fromfd, buf, sizeof buf)) > 0)          while ((i=read(fromfd, buf, sizeof buf)) > 0)
Line 145 
Line 149 
     tofd = creat(to, 0666);      tofd = creat(to, 0666);
     if (tofd < 0)      if (tofd < 0)
         pfatal2("can't create %s", to);          pfatal2("can't create %s", to);
     fromfd = open(from, 0);      fromfd = open(from, O_RDONLY);
     if (fromfd < 0)      if (fromfd < 0)
         pfatal2("internal error, can't reopen %s", from);          pfatal2("internal error, can't reopen %s", from);
     while ((i=read(fromfd, buf, sizeof buf)) > 0)      while ((i=read(fromfd, buf, sizeof buf)) > 0)
Line 177 
Line 181 
     }      }
     else {      else {
         t = rv;          t = rv;
         while (*t++ = *s++);          while ((*t++ = *s++))
               ;
     }      }
     return rv;      return rv;
 }  }
Line 255 
Line 260 
         write(1, buf, strlen(buf));          write(1, buf, strlen(buf));
         r = read(1, buf, sizeof buf);          r = read(1, buf, sizeof buf);
     }      }
     else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) {      else if ((ttyfd = open(_PATH_TTY, O_RDWR)) >= 0 && isatty(ttyfd)) {
                                         /* might be deleted or unwriteable */                                          /* might be deleted or unwriteable */
         write(ttyfd, buf, strlen(buf));          write(ttyfd, buf, strlen(buf));
         r = read(ttyfd, buf, sizeof buf);          r = read(ttyfd, buf, sizeof buf);
Line 286 
Line 291 
 int reset;  int reset;
 {  {
 #ifndef lint  #ifndef lint
 #ifdef VOIDSIG      static sig_t hupval, intval;
     static void (*hupval)(),(*intval)();  
 #else  
     static int (*hupval)(),(*intval)();  
 #endif  
   
     if (!reset) {      if (!reset) {
         hupval = signal(SIGHUP, SIG_IGN);          hupval = signal(SIGHUP, SIG_IGN);
         if (hupval != SIG_IGN)          if (hupval != SIG_IGN)
 #ifdef VOIDSIG              hupval = (sig_t)my_exit;
             hupval = my_exit;  
 #else  
             hupval = (int(*)())my_exit;  
 #endif  
         intval = signal(SIGINT, SIG_IGN);          intval = signal(SIGINT, SIG_IGN);
         if (intval != SIG_IGN)          if (intval != SIG_IGN)
 #ifdef VOIDSIG              intval = (sig_t)my_exit;
             intval = my_exit;  
 #else  
             intval = (int(*)())my_exit;  
 #endif  
     }      }
     Signal(SIGHUP, hupval);      Signal(SIGHUP, hupval);
     Signal(SIGINT, intval);      Signal(SIGINT, intval);
Line 430 
Line 423 
   
 #define try(f, a1, a2) (Snprintf(tmpbuf + pathlen, sizeof tmpbuf - pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)  #define try(f, a1, a2) (Snprintf(tmpbuf + pathlen, sizeof tmpbuf - pathlen, f, a1, a2), stat(tmpbuf, &filestat) == 0)
         if (   try("RCS/%s%s", filebase, RCSSUFFIX)          if (   try("RCS/%s%s", filebase, RCSSUFFIX)
             || try("RCS/%s"  , filebase,         0)              || try("RCS/%s%s", filebase,        "")
             || try(    "%s%s", filebase, RCSSUFFIX)              || try(    "%s%s", filebase, RCSSUFFIX)
             || try("SCCS/%s%s", SCCSPREFIX, filebase)              || try("SCCS/%s%s", SCCSPREFIX, filebase)
             || try(     "%s%s", SCCSPREFIX, filebase))              || try(     "%s%s", SCCSPREFIX, filebase))

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4