[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.29 and 1.30

version 1.29, 2008/06/04 14:04:42 version 1.30, 2008/10/06 20:38:33
Line 50 
Line 50 
 }  }
 */  */
   
 #ifdef _NFILE  /* do we really need these? */
 #ifndef FOPEN_MAX  /* #ifdef _NFILE */
 #define FOPEN_MAX _NFILE  /* #ifndef FOPEN_MAX */
 #endif  /* #define FOPEN_MAX _NFILE */
 #endif  /* #endif */
   /* #endif */
   /*  */
   /* #ifndef      FOPEN_MAX */
   /* #define      FOPEN_MAX       40 */   /* max number of open files */
   /* #endif */
   /*  */
   /* #ifndef RAND_MAX */
   /* #define RAND_MAX     32767 */        /* all that ansi guarantees */
   /* #endif */
   
 #ifndef FOPEN_MAX  
 #define FOPEN_MAX       40      /* max number of open files */  
 #endif  
   
 #ifndef RAND_MAX  
 #define RAND_MAX        32767   /* all that ansi guarantees */  
 #endif  
   
 jmp_buf env;  jmp_buf env;
 int use_arc4 = 1;  int use_arc4 = 1;
 extern  int     pairstack[];  extern  int     pairstack[];
Line 115 
Line 116 
                 if (rminlen)                  if (rminlen)
                         minlen += quantum - rminlen;                          minlen += quantum - rminlen;
                 tbuf = (char *) realloc(*pbuf, minlen);                  tbuf = (char *) realloc(*pbuf, minlen);
                   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 466 
Line 468 
         for (np = a[1]; np; np = np->nnext) {          for (np = a[1]; np; np = np->nnext) {
                 y = execute(np);        /* subscript */                  y = execute(np);        /* subscript */
                 s = getsval(y);                  s = getsval(y);
                 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))                  if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "array"))
                         FATAL("out of memory for %s[%s...]", x->nval, buf);                          FATAL("out of memory for %s[%s...]", x->nval, buf);
                 strlcat(buf, s, bufsz);                  strlcat(buf, s, bufsz);
                 if (np->nnext)                  if (np->nnext)
Line 513 
Line 515 
                 for (np = a[1]; np; np = np->nnext) {                  for (np = a[1]; np; np = np->nnext) {
                         y = execute(np);        /* subscript */                          y = execute(np);        /* subscript */
                         s = getsval(y);                          s = getsval(y);
                         if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))                          if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "awkdelete"))
                                 FATAL("out of memory deleting %s[%s...]", x->nval, buf);                                  FATAL("out of memory deleting %s[%s...]", x->nval, buf);
                         strlcat(buf, s, bufsz);                          strlcat(buf, s, bufsz);
                         if (np->nnext)                          if (np->nnext)
Line 552 
Line 554 
         for (p = a[0]; p; p = p->nnext) {          for (p = a[0]; p; p = p->nnext) {
                 x = execute(p); /* expr */                  x = execute(p); /* expr */
                 s = getsval(x);                  s = getsval(x);
                 if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0))                  if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, "intest"))
                         FATAL("out of memory deleting %s[%s...]", x->nval, buf);                          FATAL("out of memory deleting %s[%s...]", x->nval, buf);
                 strlcat(buf, s, bufsz);                  strlcat(buf, s, bufsz);
                 tempfree(x);                  tempfree(x);
Line 822 
Line 824 
         if ((fmt = (char *) malloc(fmtsz)) == NULL)          if ((fmt = (char *) malloc(fmtsz)) == NULL)
                 FATAL("out of memory in format()");                  FATAL("out of memory in format()");
         while (*s) {          while (*s) {
                 adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format");                  adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format1");
                 if (*s != '%') {                  if (*s != '%') {
                         *p++ = *s++;                          *p++ = *s++;
                         continue;                          continue;
Line 836 
Line 838 
                 fmtwd = atoi(s+1);                  fmtwd = atoi(s+1);
                 if (fmtwd < 0)                  if (fmtwd < 0)
                         fmtwd = -fmtwd;                          fmtwd = -fmtwd;
                 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");                  adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format2");
                 for (t = fmt; (*t++ = *s) != '\0'; s++) {                  for (t = fmt; (*t++ = *s) != '\0'; s++) {
                         if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, 0))                          if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3"))
                                 FATAL("format item %.30s... ran format() out of memory", os);                                  FATAL("format item %.30s... ran format() out of memory", os);
                         if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')                          if (isalpha((uschar)*s) && *s != 'l' && *s != 'h' && *s != 'L')
                                 break;  /* the ansi panoply */                                  break;  /* the ansi panoply */
Line 858 
Line 860 
                 *t = '\0';                  *t = '\0';
                 if (fmtwd < 0)                  if (fmtwd < 0)
                         fmtwd = -fmtwd;                          fmtwd = -fmtwd;
                 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format");                  adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4");
   
                 switch (*s) {                  switch (*s) {
                 case 'f': case 'e': case 'g': case 'E': case 'G':                  case 'f': case 'e': case 'g': case 'E': case 'G':
Line 892 
Line 894 
                 n = MAXNUMSIZE;                  n = MAXNUMSIZE;
                 if (fmtwd > n)                  if (fmtwd > n)
                         n = fmtwd;                          n = fmtwd;
                 adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format");                  adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5");
                 switch (flag) {                  switch (flag) {
                 case '?':       /* unknown, so dump it too */                  case '?':       /* unknown, so dump it too */
                         snprintf(p, buf + bufsize - p, "%s", fmt);                          snprintf(p, buf + bufsize - p, "%s", fmt);
Line 900 
Line 902 
                         n = strlen(t);                          n = strlen(t);
                         if (fmtwd > n)                          if (fmtwd > n)
                                 n = fmtwd;                                  n = fmtwd;
                         adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format");                          adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6");
                         p += strlen(p);                          p += strlen(p);
                         snprintf(p, buf + bufsize - p, "%s", t);                          snprintf(p, buf + bufsize - p, "%s", t);
                         break;                          break;
Line 912 
Line 914 
                         n = strlen(t);                          n = strlen(t);
                         if (fmtwd > n)                          if (fmtwd > n)
                                 n = fmtwd;                                  n = fmtwd;
                         if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, 0))                          if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7"))
                                 FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);                                  FATAL("huge string/format (%d chars) in printf %.30s... ran format() out of memory", n, t);
                         snprintf(p, buf + bufsize - p, fmt, t);                          snprintf(p, buf + bufsize - p, fmt, t);
                         break;                          break;

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30