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

Diff for /src/usr.bin/unifdef/unifdef.c between version 1.21 and 1.22

version 1.21, 2015/10/03 20:12:53 version 1.22, 2015/10/05 06:54:59
Line 43 
Line 43 
  *   it possible to handle all "dodgy" directives correctly.   *   it possible to handle all "dodgy" directives correctly.
  */   */
   
 #include "unifdef.h"  #include <sys/stat.h>
   
   #include <ctype.h>
   #include <err.h>
   #include <stdarg.h>
   #include <stdbool.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
   #include <unistd.h>
   
 static const char copyright[] =  static const char copyright[] =
     #include "version.h"      #include "version.h"
     "@(#) $Author$\n"      "@(#) $Author$\n"
Line 243 
Line 252 
 static void             usage(void);  static void             usage(void);
 static void             version(void);  static void             version(void);
 static const char      *xstrdup(const char *, const char *);  static const char      *xstrdup(const char *, const char *);
   static FILE *           mktempmode(char *tmp, int mode);
   
 #define endsym(c) (!isalnum((unsigned char)c) && c != '_')  #define endsym(c) (!isalnum((unsigned char)c) && c != '_')
   
Line 384 
Line 394 
         if (ifn == NULL || strcmp(ifn, "-") == 0) {          if (ifn == NULL || strcmp(ifn, "-") == 0) {
                 filename = "[stdin]";                  filename = "[stdin]";
                 linefile = NULL;                  linefile = NULL;
                 input = fbinmode(stdin);                  input = stdin;
         } else {          } else {
                 filename = ifn;                  filename = ifn;
                 linefile = ifn;                  linefile = ifn;
Line 393 
Line 403 
                         err(2, "can't open %s", ifn);                          err(2, "can't open %s", ifn);
         }          }
         if (strcmp(ofn, "-") == 0) {          if (strcmp(ofn, "-") == 0) {
                 output = fbinmode(stdout);                  output = stdout;
                 process();                  process();
                 return;                  return;
         }          }
Line 418 
Line 428 
                         err(2, "can't rename \"%s\" to \"%s\"", ofn, backname);                          err(2, "can't rename \"%s\" to \"%s\"", ofn, backname);
                 free(backname);                  free(backname);
         }          }
         if (replace(tempname, ofn) < 0)          if (rename(tempname, ofn) < 0)
                 err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);                  err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);
         free(tempname);          free(tempname);
         tempname = NULL;          tempname = NULL;
Line 1570 
Line 1580 
                     filename, linenum, msg, stifline[depth], depth);                      filename, linenum, msg, stifline[depth], depth);
         closeio();          closeio();
         errx(2, "output may be truncated");          errx(2, "output may be truncated");
   }
   
   static FILE *
   mktempmode(char *tmp, int mode)
   {
           int fd = mkstemp(tmp);
           if (fd < 0)
                   return (NULL);
           fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO));
           return (fdopen(fd, "wb"));
 }  }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22