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

Diff for /src/usr.bin/diff/diff.c between version 1.41 and 1.42

version 1.41, 2003/09/07 18:50:58 version 1.42, 2003/09/07 22:05:30
Line 27 
Line 27 
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
   #include <ctype.h>
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <getopt.h>  #include <getopt.h>
Line 84 
Line 85 
 {  {
         char *ep, **oargv;          char *ep, **oargv;
         long  l;          long  l;
         int   ch, lastch, gotstdin;          int   ch, lastch, gotstdin, prevoptind, newarg;
   
         oargv = argv;          oargv = argv;
         gotstdin = 0;          gotstdin = 0;
   
         lastch = 0;          lastch = '\0';
           prevoptind = 1;
           newarg = 1;
         while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) {          while ((ch = getopt_long(argc, argv, OPTIONS, longopts, NULL)) != -1) {
                 switch (ch) {                  switch (ch) {
                 case '0': case '1': case '2': case '3': case '4':                  case '0': case '1': case '2': case '3': case '4':
                 case '5': case '6': case '7': case '8': case '9':                  case '5': case '6': case '7': case '8': case '9':
                         if (!(lastch == 'c' || lastch == 'u' ||                          if (newarg)
                             (lastch >= '0' && lastch <= '9')))                                  usage();        /* disallow -[0-9]+ */
                                 usage();                          else if (lastch == 'c' || lastch == 'u')
                         if (lastch == 'c' || lastch == 'u')  
                                 context = 0;                                  context = 0;
                         context = context * 10 + ch - '0';                          else if (!isdigit(lastch) || context > INT_MAX / 10)
                                   usage();
                           context = (context * 10) + (ch - '0');
                         break;                          break;
                 case 'a':                  case 'a':
                         aflag = 1;                          aflag = 1;
Line 196 
Line 200 
                         break;                          break;
                 }                  }
                 lastch = ch;                  lastch = ch;
                   newarg = optind != prevoptind;
                   prevoptind = optind;
         }          }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.42