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

Diff for /src/usr.bin/awk/tran.c between version 1.22 and 1.23

version 1.22, 2020/06/10 21:02:33 version 1.23, 2020/06/10 21:03:36
Line 165 
Line 165 
         Array *ap;          Array *ap;
         Cell **tp;          Cell **tp;
   
         ap = (Array *) malloc(sizeof(Array));          ap = malloc(sizeof(*ap));
         tp = (Cell **) calloc(n, sizeof(Cell *));          tp = calloc(n, sizeof(*tp));
         if (ap == NULL || tp == NULL)          if (ap == NULL || tp == NULL)
                 FATAL("out of space in makesymtab");                  FATAL("out of space in makesymtab");
         ap->nelem = 0;          ap->nelem = 0;
Line 236 
Line 236 
                         (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval) );                          (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval) );
                 return(p);                  return(p);
         }          }
         p = (Cell *) malloc(sizeof(Cell));          p = malloc(sizeof(*p));
         if (p == NULL)          if (p == NULL)
                 FATAL("out of space for symbol table at %s", n);                  FATAL("out of space for symbol table at %s", n);
         p->nval = tostring(n);          p->nval = tostring(n);
Line 271 
Line 271 
         Cell *cp, *op, **np;          Cell *cp, *op, **np;
   
         nsz = GROWTAB * tp->size;          nsz = GROWTAB * tp->size;
         np = (Cell **) calloc(nsz, sizeof(Cell *));          np = calloc(nsz, sizeof(*np));
         if (np == NULL)         /* can't do it, but can keep running. */          if (np == NULL)         /* can't do it, but can keep running. */
                 return;         /* someone else will run out later. */                  return;         /* someone else will run out later. */
         for (i = 0; i < tp->size; i++) {          for (i = 0; i < tp->size; i++) {
Line 360 
Line 360 
                 fldno = atoi(vp->nval);                  fldno = atoi(vp->nval);
                 if (fldno > *NF)                  if (fldno > *NF)
                         newfld(fldno);                          newfld(fldno);
                    DPRINTF( ("setting field %d to %s (%p)\n", fldno, s, (void *) s) );                     DPRINTF( ("setting field %d to %s (%p)\n", fldno, s, s) );
         } else if (isrec(vp)) {          } else if (isrec(vp)) {
                 donefld = 0;    /* mark $1... invalid */                  donefld = 0;    /* mark $1... invalid */
                 donerec = 1;                  donerec = 1;
Line 377 
Line 377 
         vp->fmt = NULL;          vp->fmt = NULL;
         setfree(vp);          setfree(vp);
            DPRINTF( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",             DPRINTF( ("setsval %p: %s = \"%s (%p) \", t=%o r,f=%d,%d\n",
                 (void*)vp, NN(vp->nval), t, (void *) t, vp->tval, donerec, donefld) );                  (void*)vp, NN(vp->nval), t, t, vp->tval, donerec, donefld) );
         vp->sval = t;          vp->sval = t;
         if (&vp->fval == NF) {          if (&vp->fval == NF) {
                 donerec = 0;    /* mark $0 invalid */                  donerec = 0;    /* mark $0 invalid */
Line 492 
Line 492 
         }          }
 done:  done:
            DPRINTF( ("getsval %p: %s = \"%s (%p)\", t=%o\n",             DPRINTF( ("getsval %p: %s = \"%s (%p)\", t=%o\n",
                 (void*)vp, NN(vp->nval), vp->sval, (void *) vp->sval, vp->tval) );                  (void*)vp, NN(vp->nval), vp->sval, vp->sval, vp->tval) );
         return(vp->sval);          return(vp->sval);
 }  }
   
Line 509 
Line 509 
   
 char *tostring(const char *s)   /* make a copy of string s */  char *tostring(const char *s)   /* make a copy of string s */
 {  {
         char *p;          char *p = strdup(s);
   
         p = strdup(s);  
         if (p == NULL)          if (p == NULL)
                 FATAL("out of space in tostring on %s", s);                  FATAL("out of space in tostring on %s", s);
         return p;          return(p);
 }  }
   
 Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */  Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */
Line 537 
Line 535 
 {  {
         const char *os = is;          const char *os = is;
         int c, n;          int c, n;
         uschar *s = (uschar *) is;          const uschar *s = (const uschar *) is;
         uschar *buf, *bp;          uschar *buf, *bp;
   
         if ((buf = (uschar *) malloc(strlen(is)+3)) == NULL)          if ((buf = malloc(strlen(is)+3)) == NULL)
                 FATAL( "out of space in qstring(%s)", s);                  FATAL( "out of space in qstring(%s)", s);
         for (bp = buf; (c = *s) != delim; s++) {          for (bp = buf; (c = *s) != delim; s++) {
                 if (c == '\n')                  if (c == '\n')

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