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

Diff for /src/usr.bin/sdiff/sdiff.c between version 1.27 and 1.28

version 1.27, 2009/06/07 13:15:13 version 1.28, 2009/06/07 13:29:50
Line 65 
Line 65 
 int      Iflag = 0;     /* ignore sets matching regexp */  int      Iflag = 0;     /* ignore sets matching regexp */
 int      lflag;         /* print only left column for identical lines */  int      lflag;         /* print only left column for identical lines */
 int      sflag;         /* skip identical lines */  int      sflag;         /* skip identical lines */
 FILE    *outfile;       /* file to save changes to */  FILE    *outfp;         /* file to save changes to */
 const char *tmpdir;     /* TMPDIR or /tmp */  const char *tmpdir;     /* TMPDIR or /tmp */
   
 static struct option longopts[] = {  static struct option longopts[] = {
Line 160 
Line 160 
         size_t diffargc = 0, wflag = WIDTH;          size_t diffargc = 0, wflag = WIDTH;
         int ch, fd[2], status;          int ch, fd[2], status;
         pid_t pid;          pid_t pid;
           const char *outfile = NULL;
         char **diffargv, *diffprog = "diff", *filename1, *filename2,          char **diffargv, *diffprog = "diff", *filename1, *filename2,
             *tmp1, *tmp2, *s1, *s2;              *tmp1, *tmp2, *s1, *s2;
   
Line 218 
Line 219 
                         lflag = 1;                          lflag = 1;
                         break;                          break;
                 case 'o':                  case 'o':
                         if ((outfile = fopen(optarg, "w")) == NULL)                          outfile = optarg;
                                 err(2, "could not open: %s", optarg);  
                         break;                          break;
                 case 'S':                  case 'S':
                         diffargv[diffargc++] = "--strip-trailing-cr";                          diffargv[diffargc++] = "--strip-trailing-cr";
Line 250 
Line 250 
         if (argc != 2)          if (argc != 2)
                 usage();                  usage();
   
           if (outfile && (outfp = fopen(outfile, "w")) == NULL)
                   err(2, "could not open: %s", optarg);
   
         if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')          if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0')
                 tmpdir = _PATH_TMP;                  tmpdir = _PATH_TMP;
   
Line 375 
Line 378 
 static void  static void
 printcol(const char *s, size_t *col, const size_t col_max)  printcol(const char *s, size_t *col, const size_t col_max)
 {  {
   
         for (; *s && *col < col_max; ++s) {          for (; *s && *col < col_max; ++s) {
                 size_t new_col;                  size_t new_col;
   
Line 441 
Line 443 
                 case '1':                  case '1':
                         /* Choose left column as-is. */                          /* Choose left column as-is. */
                         if (s1 != NULL)                          if (s1 != NULL)
                                 fprintf(outfile, "%s\n", s1);                                  fprintf(outfp, "%s\n", s1);
   
                         /* End of command parsing. */                          /* End of command parsing. */
                         break;                          break;
Line 453 
Line 455 
                 case '2':                  case '2':
                         /* Choose right column as-is. */                          /* Choose right column as-is. */
                         if (s2 != NULL)                          if (s2 != NULL)
                                 fprintf(outfile, "%s\n", s2);                                  fprintf(outfp, "%s\n", s2);
   
                         /* End of command parsing. */                          /* End of command parsing. */
                         break;                          break;
Line 486 
Line 488 
          * should quit.           * should quit.
          */           */
 QUIT:  QUIT:
         fclose(outfile);          fclose(outfp);
         exit(0);          exit(0);
 }  }
   
Line 886 
Line 888 
                 freediff(diffp);                  freediff(diffp);
         }          }
   
         /* Write to outfile, prompting user if lines are different. */          /* Write to outfp, prompting user if lines are different. */
         if (outfile)          if (outfp)
                 switch (divc) {                  switch (divc) {
                 case ' ': case '(': case ')':                  case ' ': case '(': case ')':
                         fprintf(outfile, "%s\n", left);                          fprintf(outfp, "%s\n", left);
                         break;                          break;
                 case '|': case '<': case '>':                  case '|': case '<': case '>':
                         prompt(left, right);                          prompt(left, right);

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28