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

Diff for /src/usr.bin/m4/eval.c between version 1.76 and 1.77

version 1.76, 2017/10/23 15:21:19 version 1.77, 2017/11/11 12:55:59
Line 120 
Line 120 
 expand_builtin(const char *argv[], int argc, int td)  expand_builtin(const char *argv[], int argc, int td)
 {  {
         int c, n;          int c, n;
           const char *errstr;
         int ac;          int ac;
         static int sysval = 0;          static int sysval = 0;
   
Line 175 
Line 176 
         {          {
                 int base = 10;                  int base = 10;
                 int maxdigits = 0;                  int maxdigits = 0;
                 const char *errstr;  
   
                 if (argc > 3) {                  if (argc > 3) {
                         base = strtonum(argv[3], 2, 36, &errstr);                          base = strtonum(argv[3], 2, 36, &errstr);
                         if (errstr) {                          if (errstr) {
                                 m4errx(1, "expr: base %s invalid.", argv[3]);                                  m4errx(1, "expr: base is %s: %s.",
                                       errstr, argv[3]);
                         }                          }
                 }                  }
                 if (argc > 4) {                  if (argc > 4) {
                         maxdigits = strtonum(argv[4], 0, INT_MAX, &errstr);                          maxdigits = strtonum(argv[4], 0, INT_MAX, &errstr);
                         if (errstr) {                          if (errstr) {
                                 m4errx(1, "expr: maxdigits %s invalid.", argv[4]);                                  m4errx(1, "expr: maxdigits is %s: %s.",
                                       errstr, argv[4]);
                         }                          }
                 }                  }
                 if (argc > 2)                  if (argc > 2)
Line 225 
Line 227 
          * doincr - increment the value of the           * doincr - increment the value of the
          * argument           * argument
          */           */
                 if (argc > 2)                  if (argc > 2) {
                         pbnum(atoi(argv[2]) + 1);                          n = strtonum(argv[2], INT_MIN, INT_MAX-1, &errstr);
                           if (errstr != NULL)
                                   m4errx(1, "incr: argument is %s: %s.",
                                       errstr, argv[2]);
                           pbnum(n + 1);
                   }
                 break;                  break;
   
         case DECRTYPE:          case DECRTYPE:
Line 234 
Line 241 
          * dodecr - decrement the value of the           * dodecr - decrement the value of the
          * argument           * argument
          */           */
                 if (argc > 2)                  if (argc > 2) {
                         pbnum(atoi(argv[2]) - 1);                          n = strtonum(argv[2], INT_MIN+1, INT_MAX, &errstr);
                           if (errstr)
                                   m4errx(1, "decr: argument is %s: %s.",
                                       errstr, argv[2]);
                           pbnum(n - 1);
                   }
                 break;                  break;
   
         case SYSCTYPE:          case SYSCTYPE:
Line 336 
Line 348 
                 break;                  break;
   
         case DIVRTYPE:          case DIVRTYPE:
                 if (argc > 2 && (n = atoi(argv[2])) != 0)                  if (argc > 2) {
                         dodiv(n);                          n = strtonum(argv[2], INT_MIN, INT_MAX, &errstr);
                 else {                          if (errstr)
                         active = stdout;                                  m4errx(1, "divert: argument is %s: %s.",
                         oindex = 0;                                      errstr, argv[2]);
                           if (n != 0) {
                                   dodiv(n);
                                   break;
                           }
                 }                  }
                   active = stdout;
                   oindex = 0;
                 break;                  break;
   
         case UNDVTYPE:          case UNDVTYPE:

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77