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

Diff for /src/usr.bin/awk/run.c between version 1.59 and 1.60

version 1.59, 2020/06/13 01:21:01 version 1.60, 2020/06/26 15:57:39
Line 120 
Line 120 
                 if (rminlen)                  if (rminlen)
                         minlen += quantum - rminlen;                          minlen += quantum - rminlen;
                 tbuf = realloc(*pbuf, minlen);                  tbuf = realloc(*pbuf, minlen);
                 DPRINTF( ("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf) );                  DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf);
                 if (tbuf == NULL) {                  if (tbuf == NULL) {
                         if (whatrtn)                          if (whatrtn)
                                 FATAL("out of memory in %s", whatrtn);                                  FATAL("out of memory in %s", whatrtn);
Line 247 
Line 247 
         for (ncall = 0, x = a[1]; x != NULL; x = x->nnext)      /* args in call */          for (ncall = 0, x = a[1]; x != NULL; x = x->nnext)      /* args in call */
                 ncall++;                  ncall++;
         ndef = (int) fcn->fval;                 /* args in defn */          ndef = (int) fcn->fval;                 /* args in defn */
            DPRINTF( ("calling %s, %d args (%d in defn), frp=%d\n", s, ncall, ndef, (int) (frp-frame)) );          DPRINTF("calling %s, %d args (%d in defn), frp=%d\n", s, ncall, ndef, (int) (frp-frame));
         if (ncall > ndef)          if (ncall > ndef)
                 WARNING("function %s called with %d args, uses only %d",                  WARNING("function %s called with %d args, uses only %d",
                         s, ncall, ndef);                          s, ncall, ndef);
         if (ncall + ndef > NARGS)          if (ncall + ndef > NARGS)
                 FATAL("function %s has %d arguments, limit %d", s, ncall+ndef, NARGS);                  FATAL("function %s has %d arguments, limit %d", s, ncall+ndef, NARGS);
         for (i = 0, x = a[1]; x != NULL; i++, x = x->nnext) {   /* get call args */          for (i = 0, x = a[1]; x != NULL; i++, x = x->nnext) {   /* get call args */
                    DPRINTF( ("evaluate args[%d], frp=%d:\n", i, (int) (frp-frame)) );                  DPRINTF("evaluate args[%d], frp=%d:\n", i, (int) (frp-frame));
                 y = execute(x);                  y = execute(x);
                 oargs[i] = y;                  oargs[i] = y;
                    DPRINTF( ("args[%d]: %s %f <%s>, t=%o\n",                  DPRINTF("args[%d]: %s %f <%s>, t=%o\n",
                            i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval) );                          i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval);
                 if (isfcn(y))                  if (isfcn(y))
                         FATAL("can't use function %s as argument in %s", y->nval, s);                          FATAL("can't use function %s as argument in %s", y->nval, s);
                 if (isarr(y))                  if (isarr(y))
Line 284 
Line 284 
         frp->nargs = ndef;      /* number defined with (excess are locals) */          frp->nargs = ndef;      /* number defined with (excess are locals) */
         frp->retval = gettemp();          frp->retval = gettemp();
   
            DPRINTF( ("start exec of %s, frp=%d\n", s, (int) (frp-frame)) );          DPRINTF("start exec of %s, frp=%d\n", s, (int) (frp-frame));
         y = execute((Node *)(fcn->sval));       /* execute body */          y = execute((Node *)(fcn->sval));       /* execute body */
            DPRINTF( ("finished exec of %s, frp=%d\n", s, (int) (frp-frame)) );          DPRINTF("finished exec of %s, frp=%d\n", s, (int) (frp-frame));
   
         for (i = 0; i < ndef; i++) {          for (i = 0; i < ndef; i++) {
                 Cell *t = frp->args[i];                  Cell *t = frp->args[i];
Line 319 
Line 319 
                 tempfree(y);    /* don't free twice! */                  tempfree(y);    /* don't free twice! */
         }          }
         z = frp->retval;                        /* return value */          z = frp->retval;                        /* return value */
            DPRINTF( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) );          DPRINTF("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval);
         frp--;          frp--;
         return(z);          return(z);
 }  }
Line 347 
Line 347 
 {  {
   
         n = ptoi(a[0]); /* argument number, counting from 0 */          n = ptoi(a[0]); /* argument number, counting from 0 */
            DPRINTF( ("arg(%d), frp->nargs=%d\n", n, frp->nargs) );          DPRINTF("arg(%d), frp->nargs=%d\n", n, frp->nargs);
         if (n+1 > frp->nargs)          if (n+1 > frp->nargs)
                 FATAL("argument #%d of function %s was not supplied",                  FATAL("argument #%d of function %s was not supplied",
                         n+1, frp->fcncell->nval);                          n+1, frp->fcncell->nval);
Line 512 
Line 512 
         x = execute(a[0]);      /* Cell* for symbol table */          x = execute(a[0]);      /* Cell* for symbol table */
         buf = makearraystring(a[1], __func__);          buf = makearraystring(a[1], __func__);
         if (!isarr(x)) {          if (!isarr(x)) {
                    DPRINTF( ("making %s into an array\n", NN(x->nval)) );                  DPRINTF("making %s into an array\n", NN(x->nval));
                 if (freeable(x))                  if (freeable(x))
                         xfree(x->sval);                          xfree(x->sval);
                 x->tval &= ~(STR|NUM|DONTFREE);                  x->tval &= ~(STR|NUM|DONTFREE);
Line 558 
Line 558 
   
         ap = execute(a[1]);     /* array name */          ap = execute(a[1]);     /* array name */
         if (!isarr(ap)) {          if (!isarr(ap)) {
                    DPRINTF( ("making %s into an array\n", ap->nval) );                  DPRINTF("making %s into an array\n", ap->nval);
                 if (freeable(ap))                  if (freeable(ap))
                         xfree(ap->sval);                          xfree(ap->sval);
                 ap->tval &= ~(STR|NUM|DONTFREE);                  ap->tval &= ~(STR|NUM|DONTFREE);
Line 687 
Line 687 
 void tfree(Cell *a)     /* free a tempcell */  void tfree(Cell *a)     /* free a tempcell */
 {  {
         if (freeable(a)) {          if (freeable(a)) {
                    DPRINTF( ("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval) );                  DPRINTF("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval);
                 xfree(a->sval);                  xfree(a->sval);
         }          }
         if (a == tmps)          if (a == tmps)
Line 774 
Line 774 
                 n = 0;                  n = 0;
         else if (n > k - m)          else if (n > k - m)
                 n = k - m;                  n = k - m;
            DPRINTF( ("substr: m=%d, n=%d, s=%s\n", m, n, s) );          DPRINTF("substr: m=%d, n=%d, s=%s\n", m, n, s);
         y = gettemp();          y = gettemp();
         temp = s[n+m-1];        /* with thanks to John Linderman */          temp = s[n+m-1];        /* with thanks to John Linderman */
         s[n+m-1] = '\0';          s[n+m-1] = '\0';
Line 1281 
Line 1281 
         sep = *fs;          sep = *fs;
         ap = execute(a[1]);     /* array name */          ap = execute(a[1]);     /* array name */
         freesymtab(ap);          freesymtab(ap);
            DPRINTF( ("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs) );          DPRINTF("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs);
         ap->tval &= ~STR;          ap->tval &= ~STR;
         ap->tval |= ARR;          ap->tval |= ARR;
         ap->sval = (char *) makesymtab(NSYMTAB);          ap->sval = (char *) makesymtab(NSYMTAB);

Legend:
Removed from v.1.59  
changed lines
  Added in v.1.60