[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.15 and 1.16

version 1.15, 2003/07/21 14:32:21 version 1.16, 2003/07/22 17:18:49
Line 1 
Line 1 
 /*      $OpenBSD$       */  /*      $OpenBSD$       */
   
 #ifndef lint  #ifndef lint
 static char     rcsid[] = "$OpenBSD$";  static const char     rcsid[] = "$OpenBSD$";
 #endif                          /* not lint */  #endif                          /* not lint */
   
   #include <sys/param.h>
   #include <sys/stat.h>
   
   #include <ctype.h>
   #include <errno.h>
   #include <fcntl.h>
   #include <libgen.h>
   #include <paths.h>
   #include <stdarg.h>
   #include <stdlib.h>
   #include <string.h>
   #include <unistd.h>
   
 #include "EXTERN.h"  #include "EXTERN.h"
 #include "common.h"  #include "common.h"
 #include "INTERN.h"  #include "INTERN.h"
 #include "util.h"  #include "util.h"
 #include "backupfile.h"  #include "backupfile.h"
   
 void            my_exit(int) __attribute__((noreturn));  
   
 /* Rename a file, copying it if necessary. */  /* Rename a file, copying it if necessary. */
   
Line 31 
Line 43 
                 if (fromfd < 0)                  if (fromfd < 0)
                         pfatal("internal error, can't reopen %s", from);                          pfatal("internal error, can't reopen %s", from);
                 while ((i = read(fromfd, buf, sizeof buf)) > 0)                  while ((i = read(fromfd, buf, sizeof buf)) > 0)
                         if (write(1, buf, i) != 1)                          if (write(STDOUT_FILENO, buf, i) != i)
                                 pfatal("write failed");                                  pfatal("write failed");
                 close(fromfd);                  close(fromfd);
                 return 0;                  return 0;
Line 167 
Line 179 
         while (*t++)          while (*t++)
                 ;                  ;
         rv = malloc((size_t) (t - s));          rv = malloc((size_t) (t - s));
         if (rv == Nullch) {          if (rv == NULL) {
                 if (using_plan_a)                  if (using_plan_a)
                         out_of_mem = TRUE;                          out_of_mem = TRUE;
                 else                  else
Line 275 
Line 287 
 void  void
 set_signals(int reset)  set_signals(int reset)
 {  {
 #ifndef lint  
         static sig_t    hupval, intval;          static sig_t    hupval, intval;
   
         if (!reset) {          if (!reset) {
Line 288 
Line 299 
         }          }
         signal(SIGHUP, hupval);          signal(SIGHUP, hupval);
         signal(SIGINT, intval);          signal(SIGINT, intval);
 #endif  
 }  }
   
 /*  /*
Line 297 
Line 307 
 void  void
 ignore_signals(void)  ignore_signals(void)
 {  {
 #ifndef lint  
         signal(SIGHUP, SIG_IGN);          signal(SIGHUP, SIG_IGN);
         signal(SIGINT, SIG_IGN);          signal(SIGINT, SIG_IGN);
 #endif  
 }  }
   
 /*  /*
Line 340 
Line 348 
         int     sleading = strip_leading;          int     sleading = strip_leading;
   
         if (!at || *at == '\0')          if (!at || *at == '\0')
                 return Nullch;                  return NULL;
         while (isspace(*at))          while (isspace(*at))
                 at++;                  at++;
 #ifdef DEBUGGING  #ifdef DEBUGGING
Line 348 
Line 356 
                 say("fetchname %s %d %d\n", at, strip_leading, assume_exists);                  say("fetchname %s %d %d\n", at, strip_leading, assume_exists);
 #endif  #endif
         if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */          if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */
                 return Nullch;  /* against /dev/null. */                  return NULL;    /* against /dev/null. */
         name = fullname = t = savestr(at);          name = fullname = t = savestr(at);
   
         /* Strip off up to `sleading' leading slashes and null terminate.  */          /* Strip off up to `sleading' leading slashes and null terminate.  */
Line 387 
Line 395 
                     try("%s/%s%s", filedir, SCCSPREFIX, filebase))                      try("%s/%s%s", filedir, SCCSPREFIX, filebase))
                         return name;                          return name;
                 free(name);                  free(name);
                 name = Nullch;                  name = NULL;
         }          }
         return name;          return name;
 }  }
Line 397 
Line 405 
 {  {
         fprintf(stderr, "Patch version 2.0-12u8-OpenBSD\n");          fprintf(stderr, "Patch version 2.0-12u8-OpenBSD\n");
         my_exit(0);          my_exit(0);
   }
   
   /*
    * Exit with cleanup.
    */
   void
   my_exit(int status)
   {
           unlink(TMPINNAME);
           if (!toutkeep)
                   unlink(TMPOUTNAME);
           if (!trejkeep)
                   unlink(TMPREJNAME);
           unlink(TMPPATNAME);
           exit(status);
 }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16