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

Diff for /src/usr.bin/make/var.c between version 1.15 and 1.16

version 1.15, 1999/11/11 11:35:17 version 1.16, 1999/12/06 22:24:32
Line 159 
Line 159 
   
 typedef struct {  typedef struct {
     char          *lhs;     /* String to match */      char          *lhs;     /* String to match */
     int           leftLen;  /* Length of string */      size_t        leftLen;  /* Length of string */
     char          *rhs;     /* Replacement string (w/ &'s removed) */      char          *rhs;     /* Replacement string (w/ &'s removed) */
     int           rightLen; /* Length of replacement */      size_t        rightLen; /* Length of replacement */
     int           flags;      int           flags;
 } VarPattern;  } VarPattern;
   
Line 193 
Line 193 
 static Boolean VarRESubstitute __P((char *, Boolean, Buffer, ClientData));  static Boolean VarRESubstitute __P((char *, Boolean, Buffer, ClientData));
 #endif  #endif
 static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));  static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
 static char *VarGetPattern __P((GNode *, int, char **, int, int *, int *,  static char *VarGetPattern __P((GNode *, int, char **, int, int *, size_t *,
                                 VarPattern *));                                  VarPattern *));
 static char *VarQuote __P((char *));  static char *VarQuote __P((char *));
 static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,  static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
Line 306 
Line 306 
         char *env;          char *env;
   
         if ((env = getenv (name)) != NULL) {          if ((env = getenv (name)) != NULL) {
             int         len;              size_t      len;
   
             v = (Var *) emalloc(sizeof(Var));              v = (Var *) emalloc(sizeof(Var));
             v->name = estrdup(name);              v->name = estrdup(name);
Line 314 
Line 314 
             len = strlen(env);              len = strlen(env);
   
             v->val = Buf_Init(len);              v->val = Buf_Init(len);
             Buf_AddBytes(v->val, len, (Byte *)env);              Buf_AddChars(v->val, len, env);
   
             v->flags = VAR_FROM_ENV;              v->flags = VAR_FROM_ENV;
             return (v);              return (v);
Line 366 
Line 366 
   
     len = val ? strlen(val) : 0;      len = val ? strlen(val) : 0;
     v->val = Buf_Init(len+1);      v->val = Buf_Init(len+1);
     Buf_AddBytes(v->val, len, (Byte *)val);      Buf_AddChars(v->val, len, val);
   
     v->flags = 0;      v->flags = 0;
   
Line 476 
Line 476 
         VarAdd (name, val, ctxt);          VarAdd (name, val, ctxt);
     } else {      } else {
         Buf_Discard(v->val, Buf_Size(v->val));          Buf_Discard(v->val, Buf_Size(v->val));
         Buf_AddBytes(v->val, strlen(val), (Byte *)val);          Buf_AddChars(v->val, strlen(val), val);
   
         if (DEBUG(VAR)) {          if (DEBUG(VAR)) {
             printf("%s:%s = %s\n", ctxt->name, name, val);              printf("%s:%s = %s\n", ctxt->name, name, val);
Line 526 
Line 526 
     if (v == (Var *) NIL) {      if (v == (Var *) NIL) {
         VarAdd (name, val, ctxt);          VarAdd (name, val, ctxt);
     } else {      } else {
         Buf_AddByte(v->val, (Byte)' ');          Buf_AddChar(v->val, ' ');
         Buf_AddBytes(v->val, strlen(val), (Byte *)val);          Buf_AddChars(v->val, strlen(val), val);
   
         if (DEBUG(VAR)) {          if (DEBUG(VAR)) {
             printf("%s:%s = %s\n", ctxt->name, name,              printf("%s:%s = %s\n", ctxt->name, name,
                    (char *) Buf_GetAll(v->val, (int *)NULL));                     Buf_GetAll(v->val, NULL));
         }          }
   
         if (v->flags & VAR_FROM_ENV) {          if (v->flags & VAR_FROM_ENV) {
Line 602 
Line 602 
     v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);      v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD);
     *frp = NULL;      *frp = NULL;
     if (v != (Var *) NIL) {      if (v != (Var *) NIL) {
         char *p = ((char *)Buf_GetAll(v->val, (int *)NULL));          char *p = Buf_GetAll(v->val, NULL);
         if (v->flags & VAR_FROM_ENV) {          if (v->flags & VAR_FROM_ENV) {
             Buf_Destroy(v->val, FALSE);              Buf_Destroy(v->val, FALSE);
             free((Address) v);              free((Address) v);
Line 639 
Line 639 
     size_t len = strlen(word);      size_t len = strlen(word);
   
     if (addSpace) {      if (addSpace) {
         Buf_AddByte (buf, (Byte)' ');          Buf_AddChar(buf, ' ');
     }      }
   
     while (len--) {      while (len--) {
         Buf_AddByte (buf, toupper(*word++));          Buf_AddChar(buf, toupper(*word++));
     }      }
     return (TRUE);      return (TRUE);
 }  }
Line 673 
Line 673 
     size_t len = strlen(word);      size_t len = strlen(word);
   
     if (addSpace) {      if (addSpace) {
         Buf_AddByte (buf, (Byte)' ');          Buf_AddChar(buf, ' ');
     }      }
   
     while (len--) {      while (len--) {
         Buf_AddByte (buf, tolower(*word++));          Buf_AddChar(buf, tolower(*word++));
     }      }
     return (TRUE);      return (TRUE);
 }  }
Line 710 
Line 710 
     slash = strrchr (word, '/');      slash = strrchr (word, '/');
     if (slash != (char *)NULL) {      if (slash != (char *)NULL) {
         if (addSpace) {          if (addSpace) {
             Buf_AddByte (buf, (Byte)' ');              Buf_AddChar(buf, ' ');
         }          }
         *slash = '\0';          *slash = '\0';
         Buf_AddBytes (buf, strlen (word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
         *slash = '/';          *slash = '/';
         return (TRUE);          return (TRUE);
     } else {      } else {
Line 721 
Line 721 
          * If no directory part, give . (q.v. the POSIX standard)           * If no directory part, give . (q.v. the POSIX standard)
          */           */
         if (addSpace) {          if (addSpace) {
             Buf_AddBytes(buf, 2, (Byte *)" .");              Buf_AddChars(buf, 2, " .");
         } else {          } else {
             Buf_AddByte(buf, (Byte)'.');              Buf_AddChar(buf, '.');
         }          }
     }      }
     return(dummy ? TRUE : TRUE);      return(dummy ? TRUE : TRUE);
Line 755 
Line 755 
     register char *slash;      register char *slash;
   
     if (addSpace) {      if (addSpace) {
         Buf_AddByte (buf, (Byte)' ');          Buf_AddChar(buf, ' ');
     }      }
   
     slash = strrchr (word, '/');      slash = strrchr (word, '/');
     if (slash != (char *)NULL) {      if (slash != (char *)NULL) {
         *slash++ = '\0';          *slash++ = '\0';
         Buf_AddBytes (buf, strlen(slash), (Byte *)slash);          Buf_AddChars(buf, strlen(slash), slash);
         slash[-1] = '/';          slash[-1] = '/';
     } else {      } else {
         Buf_AddBytes (buf, strlen(word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
     }      }
     return (dummy ? TRUE : TRUE);      return (dummy ? TRUE : TRUE);
 }  }
Line 796 
Line 796 
     dot = strrchr (word, '.');      dot = strrchr (word, '.');
     if (dot != (char *)NULL) {      if (dot != (char *)NULL) {
         if (addSpace) {          if (addSpace) {
             Buf_AddByte (buf, (Byte)' ');              Buf_AddChar(buf, ' ');
         }          }
         *dot++ = '\0';          *dot++ = '\0';
         Buf_AddBytes (buf, strlen (dot), (Byte *)dot);          Buf_AddChars(buf, strlen(dot), dot);
         dot[-1] = '.';          dot[-1] = '.';
         addSpace = TRUE;          addSpace = TRUE;
     }      }
Line 832 
Line 832 
     register char *dot;      register char *dot;
   
     if (addSpace) {      if (addSpace) {
         Buf_AddByte (buf, (Byte)' ');          Buf_AddChar(buf, ' ');
     }      }
   
     dot = strrchr (word, '.');      dot = strrchr (word, '.');
     if (dot != (char *)NULL) {      if (dot != (char *)NULL) {
         *dot = '\0';          *dot = '\0';
         Buf_AddBytes (buf, strlen (word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
         *dot = '.';          *dot = '.';
     } else {      } else {
         Buf_AddBytes (buf, strlen(word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
     }      }
     return (dummy ? TRUE : TRUE);      return (dummy ? TRUE : TRUE);
 }  }
Line 872 
Line 872 
 {  {
     if (Str_Match(word, (char *) pattern)) {      if (Str_Match(word, (char *) pattern)) {
         if (addSpace) {          if (addSpace) {
             Buf_AddByte(buf, (Byte)' ');              Buf_AddChar(buf, ' ');
         }          }
         addSpace = TRUE;          addSpace = TRUE;
         Buf_AddBytes(buf, strlen(word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
     }      }
     return(addSpace);      return(addSpace);
 }  }
Line 912 
Line 912 
   
     if (*word) {      if (*word) {
             if (addSpace)              if (addSpace)
                 Buf_AddByte(buf, (Byte)' ');                  Buf_AddChar(buf, ' ');
   
             addSpace = TRUE;              addSpace = TRUE;
   
             if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL)              if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL)
                 Str_SYSVSubst(buf, pat->rhs, ptr, len);                  Str_SYSVSubst(buf, pat->rhs, ptr, len);
             else              else
                 Buf_AddBytes(buf, strlen(word), (Byte *) word);                  Buf_AddChars(buf, strlen(word), word);
     }      }
     return(addSpace);      return(addSpace);
 }  }
Line 952 
Line 952 
 {  {
     if (!Str_Match(word, (char *) pattern)) {      if (!Str_Match(word, (char *) pattern)) {
         if (addSpace) {          if (addSpace) {
             Buf_AddByte(buf, (Byte)' ');              Buf_AddChar(buf, ' ');
         }          }
         addSpace = TRUE;          addSpace = TRUE;
         Buf_AddBytes(buf, strlen(word), (Byte *)word);          Buf_AddChars(buf, strlen(word), word);
     }      }
     return(addSpace);      return(addSpace);
 }  }
Line 983 
Line 983 
     Buffer              buf;        /* Buffer for result */      Buffer              buf;        /* Buffer for result */
     ClientData          patternp;   /* Pattern for substitution */      ClientData          patternp;   /* Pattern for substitution */
 {  {
     register int        wordLen;    /* Length of word */      register size_t     wordLen;    /* Length of word */
     register char       *cp;        /* General pointer */      register char       *cp;        /* General pointer */
     VarPattern  *pattern = (VarPattern *) patternp;      VarPattern  *pattern = (VarPattern *) patternp;
   
Line 1008 
Line 1008 
                          */                           */
                         if (pattern->rightLen != 0) {                          if (pattern->rightLen != 0) {
                             if (addSpace) {                              if (addSpace) {
                                 Buf_AddByte(buf, (Byte)' ');                                  Buf_AddChar(buf, ' ');
                             }                              }
                             addSpace = TRUE;                              addSpace = TRUE;
                             Buf_AddBytes(buf, pattern->rightLen,                              Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
                                          (Byte *)pattern->rhs);  
                         }                          }
                         pattern->flags |= VAR_SUB_MATCHED;                          pattern->flags |= VAR_SUB_MATCHED;
                 } else if (pattern->flags & VAR_MATCH_END) {                  } else if (pattern->flags & VAR_MATCH_END) {
Line 1026 
Line 1025 
                      */                       */
                     if ((pattern->rightLen + wordLen - pattern->leftLen) != 0){                      if ((pattern->rightLen + wordLen - pattern->leftLen) != 0){
                         if (addSpace) {                          if (addSpace) {
                             Buf_AddByte(buf, (Byte)' ');                              Buf_AddChar(buf, ' ');
                         }                          }
                         addSpace = TRUE;                          addSpace = TRUE;
                     }                      }
                     Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);                      Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
                     Buf_AddBytes(buf, wordLen - pattern->leftLen,                      Buf_AddChars(buf, wordLen - pattern->leftLen,
                                  (Byte *)(word + pattern->leftLen));                                   word + pattern->leftLen);
                     pattern->flags |= VAR_SUB_MATCHED;                      pattern->flags |= VAR_SUB_MATCHED;
                 }                  }
         } else if (pattern->flags & VAR_MATCH_START) {          } else if (pattern->flags & VAR_MATCH_START) {
Line 1058 
Line 1057 
                  */                   */
                 if (((cp - word) + pattern->rightLen) != 0) {                  if (((cp - word) + pattern->rightLen) != 0) {
                     if (addSpace) {                      if (addSpace) {
                         Buf_AddByte(buf, (Byte)' ');                          Buf_AddChar(buf, ' ');
                     }                      }
                     addSpace = TRUE;                      addSpace = TRUE;
                 }                  }
                 Buf_AddBytes(buf, cp - word, (Byte *)word);                  Buf_AddChars(buf, cp - word, word);
                 Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);                  Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
                 pattern->flags |= VAR_SUB_MATCHED;                  pattern->flags |= VAR_SUB_MATCHED;
             } else {              } else {
                 /*                  /*
Line 1084 
Line 1083 
              * buffer.               * buffer.
              */               */
             register Boolean done;              register Boolean done;
             int origSize;              size_t origSize;
   
             done = FALSE;              done = FALSE;
             origSize = Buf_Size(buf);              origSize = Buf_Size(buf);
Line 1092 
Line 1091 
                 cp = strstr(word, pattern->lhs);                  cp = strstr(word, pattern->lhs);
                 if (cp != (char *)NULL) {                  if (cp != (char *)NULL) {
                     if (addSpace && (((cp - word) + pattern->rightLen) != 0)){                      if (addSpace && (((cp - word) + pattern->rightLen) != 0)){
                         Buf_AddByte(buf, (Byte)' ');                          Buf_AddChar(buf, ' ');
                         addSpace = FALSE;                          addSpace = FALSE;
                     }                      }
                     Buf_AddBytes(buf, cp-word, (Byte *)word);                      Buf_AddChars(buf, cp-word, word);
                     Buf_AddBytes(buf, pattern->rightLen, (Byte *)pattern->rhs);                      Buf_AddChars(buf, pattern->rightLen, pattern->rhs);
                     wordLen -= (cp - word) + pattern->leftLen;                      wordLen -= (cp - word) + pattern->leftLen;
                     word = cp + pattern->leftLen;                      word = cp + pattern->leftLen;
                     if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0){                      if (wordLen == 0 || (pattern->flags & VAR_SUB_GLOBAL) == 0){
Line 1109 
Line 1108 
             }              }
             if (wordLen != 0) {              if (wordLen != 0) {
                 if (addSpace) {                  if (addSpace) {
                     Buf_AddByte(buf, (Byte)' ');                      Buf_AddChar(buf, ' ');
                 }                  }
                 Buf_AddBytes(buf, wordLen, (Byte *)word);                  Buf_AddChars(buf, wordLen, word);
             }              }
             /*              /*
              * If added characters to the buffer, need to add a space               * If added characters to the buffer, need to add a space
              * before we add any more. If we didn't add any, just return               * before we add any more. If we didn't add any, just return
              * the previous value of addSpace.               * the previous value of addSpace.
              */               */
             return ((Buf_Size(buf) != origSize) || addSpace);              return (Buf_Size(buf) != origSize || addSpace);
         }          }
         return (addSpace);          return (addSpace);
     }      }
  nosub:   nosub:
     if (addSpace) {      if (addSpace) {
         Buf_AddByte(buf, (Byte)' ');          Buf_AddChar(buf, ' ');
     }      }
     Buf_AddBytes(buf, wordLen, (Byte *)word);      Buf_AddChars(buf, wordLen, word);
     return(TRUE);      return(TRUE);
 }  }
   
Line 1189 
Line 1188 
   
 #define MAYBE_ADD_SPACE()               \  #define MAYBE_ADD_SPACE()               \
         if (addSpace && !added)         \          if (addSpace && !added)         \
             Buf_AddByte(buf, ' ');      \              Buf_AddChar(buf, ' ');      \
         added = 1          added = 1
   
     added = 0;      added = 0;
Line 1209 
Line 1208 
         pat->flags |= VAR_SUB_MATCHED;          pat->flags |= VAR_SUB_MATCHED;
         if (pat->matches[0].rm_so > 0) {          if (pat->matches[0].rm_so > 0) {
             MAYBE_ADD_SPACE();              MAYBE_ADD_SPACE();
             Buf_AddBytes(buf, pat->matches[0].rm_so, wp);              Buf_AddChars(buf, pat->matches[0].rm_so, wp);
         }          }
   
         for (rp = pat->replace; *rp; rp++) {          for (rp = pat->replace; *rp; rp++) {
             if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {              if ((*rp == '\\') && ((rp[1] == '&') || (rp[1] == '\\'))) {
                 MAYBE_ADD_SPACE();                  MAYBE_ADD_SPACE();
                 Buf_AddByte(buf,rp[1]);                  Buf_AddChar(buf, rp[1]);
                 rp++;                  rp++;
             }              }
             else if ((*rp == '&') || ((*rp == '\\') && isdigit(rp[1]))) {              else if ((*rp == '&') || ((*rp == '\\') && isdigit(rp[1]))) {
Line 1252 
Line 1251 
   
                 if (sublen > 0) {                  if (sublen > 0) {
                     MAYBE_ADD_SPACE();                      MAYBE_ADD_SPACE();
                     Buf_AddBytes(buf, sublen, subbuf);                      Buf_AddChars(buf, sublen, subbuf);
                 }                  }
             } else {              } else {
                 MAYBE_ADD_SPACE();                  MAYBE_ADD_SPACE();
                 Buf_AddByte(buf, *rp);                  Buf_AddChar(buf, *rp);
             }              }
         }          }
         wp += pat->matches[0].rm_eo;          wp += pat->matches[0].rm_eo;
Line 1264 
Line 1263 
             goto tryagain;              goto tryagain;
         if (*wp) {          if (*wp) {
             MAYBE_ADD_SPACE();              MAYBE_ADD_SPACE();
             Buf_AddBytes(buf, strlen(wp), wp);              Buf_AddChars(buf, strlen(wp), wp);
         }          }
         break;          break;
     default:      default:
Line 1273 
Line 1272 
     case REG_NOMATCH:      case REG_NOMATCH:
         if (*wp) {          if (*wp) {
             MAYBE_ADD_SPACE();              MAYBE_ADD_SPACE();
             Buf_AddBytes(buf,strlen(wp),wp);              Buf_AddChars(buf, strlen(wp), wp);
         }          }
         break;          break;
     }      }
Line 1310 
Line 1309 
     char *as;                       /* word list memory */      char *as;                       /* word list memory */
     int ac, i;      int ac, i;
   
     buf = Buf_Init (0);      buf = Buf_Init(0);
     addSpace = FALSE;      addSpace = FALSE;
   
     av = brk_string(str, &ac, FALSE, &as);      av = brk_string(str, &ac, FALSE, &as);
Line 1320 
Line 1319 
   
     free(as);      free(as);
     free(av);      free(av);
     Buf_AddByte (buf, '\0');      Buf_AddChar(buf, '\0');
     str = (char *)Buf_GetAll (buf, (int *)NULL);      str = Buf_GetAll(buf, NULL);
     Buf_Destroy (buf, FALSE);      Buf_Destroy(buf, FALSE);
     return (str);      return (str);
 }  }
   
Line 1354 
Line 1353 
     char **tstr;      char **tstr;
     int delim;      int delim;
     int *flags;      int *flags;
     int *length;      size_t *length;
     VarPattern *pattern;      VarPattern *pattern;
 {  {
     char *cp;      char *cp;
Line 1375 
Line 1374 
      */       */
     for (cp = *tstr; *cp && (*cp != delim); cp++) {      for (cp = *tstr; *cp && (*cp != delim); cp++) {
         if (IS_A_MATCH(cp, delim)) {          if (IS_A_MATCH(cp, delim)) {
             Buf_AddByte(buf, (Byte) cp[1]);              Buf_AddChar(buf, cp[1]);
             cp++;              cp++;
         } else if (*cp == '$') {          } else if (*cp == '$') {
             if (cp[1] == delim) {              if (cp[1] == delim) {
                 if (flags == NULL)                  if (flags == NULL)
                     Buf_AddByte(buf, (Byte) *cp);                      Buf_AddChar(buf, *cp);
                 else                  else
                     /*                      /*
                      * Unescaped $ at end of pattern => anchor                       * Unescaped $ at end of pattern => anchor
Line 1399 
Line 1398 
                  * substitution and recurse.                   * substitution and recurse.
                  */                   */
                 cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);                  cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt);
                 Buf_AddBytes(buf, strlen(cp2), (Byte *) cp2);                  Buf_AddChars(buf, strlen(cp2), cp2);
                 if (freeIt)                  if (freeIt)
                     free(cp2);                      free(cp2);
                 cp += len - 1;                  cp += len - 1;
             }              }
         }          }
         else if (pattern && *cp == '&')          else if (pattern && *cp == '&')
             Buf_AddBytes(buf, pattern->leftLen, (Byte *)pattern->lhs);              Buf_AddChars(buf, pattern->leftLen, pattern->lhs);
         else          else
             Buf_AddByte(buf, (Byte) *cp);              Buf_AddChar(buf, *cp);
     }      }
   
     Buf_AddByte(buf, (Byte) '\0');      Buf_AddChar(buf, '\0');
   
     if (*cp != delim) {      if (*cp != delim) {
         *tstr = cp;          *tstr = cp;
Line 1420 
Line 1419 
     }      }
     else {      else {
         *tstr = ++cp;          *tstr = ++cp;
         cp = (char *) Buf_GetAll(buf, length);          cp = Buf_GetAll(buf, length);
         *length -= 1;   /* Don't count the NULL */          *length -= 1;   /* Don't count the NULL */
         Buf_Destroy(buf, FALSE);          Buf_Destroy(buf, FALSE);
         return cp;          return cp;
Line 1449 
Line 1448 
     /* This should cover most shells :-( */      /* This should cover most shells :-( */
     static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";      static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
   
     buf = Buf_Init (MAKE_BSIZE);      buf = Buf_Init(MAKE_BSIZE);
     for (; *str; str++) {      for (; *str; str++) {
         if (strchr(meta, *str) != NULL)          if (strchr(meta, *str) != NULL)
             Buf_AddByte(buf, (Byte)'\\');              Buf_AddChar(buf, '\\');
         Buf_AddByte(buf, (Byte)*str);          Buf_AddChar(buf, *str);
     }      }
     Buf_AddByte(buf, (Byte) '\0');      Buf_AddChar(buf, '\0');
     str = (char *)Buf_GetAll (buf, (int *)NULL);      str = Buf_GetAll(buf, NULL);
     Buf_Destroy (buf, FALSE);      Buf_Destroy(buf, FALSE);
     return str;      return str;
 }  }
   
Line 1616 
Line 1615 
                          * the only one who sets these things and we sure don't                           * the only one who sets these things and we sure don't
                          * but nested invocations in them...                           * but nested invocations in them...
                          */                           */
                         val = (char *)Buf_GetAll(v->val, (int *)NULL);                          val = Buf_GetAll(v->val, NULL);
   
                         if (str[3] == 'D') {                          if (str[3] == 'D') {
                             val = VarModify(val, VarHead, (ClientData)0);                              val = VarModify(val, VarHead, (ClientData)0);
Line 1720 
Line 1719 
      * been dynamically-allocated, so it will need freeing when we       * been dynamically-allocated, so it will need freeing when we
      * return.       * return.
      */       */
     str = (char *)Buf_GetAll(v->val, (int *)NULL);      str = Buf_GetAll(v->val, NULL);
     if (strchr (str, '$') != (char *)NULL) {      if (strchr (str, '$') != (char *)NULL) {
         str = Var_Subst(NULL, str, ctxt, err);          str = Var_Subst(NULL, str, ctxt, err);
         *freePtr = TRUE;          *freePtr = TRUE;
Line 2110 
Line 2109 
     if (v->flags & VAR_FROM_ENV) {      if (v->flags & VAR_FROM_ENV) {
         Boolean   destroy = FALSE;          Boolean   destroy = FALSE;
   
         if (str != (char *)Buf_GetAll(v->val, (int *)NULL)) {          if (str != Buf_GetAll(v->val, NULL)) {
             destroy = TRUE;              destroy = TRUE;
         } else {          } else {
             /*              /*
Line 2181 
Line 2180 
                                      * been reported to prevent a plethora                                       * been reported to prevent a plethora
                                      * of messages when recursing */                                       * of messages when recursing */
   
     buf = Buf_Init (MAKE_BSIZE);      buf = Buf_Init(MAKE_BSIZE);
     errorReported = FALSE;      errorReported = FALSE;
   
     while (*str) {      while (*str) {
Line 2192 
Line 2191 
              * dollar sign into the buffer directly.               * dollar sign into the buffer directly.
              */               */
             str++;              str++;
             Buf_AddByte(buf, (Byte)*str);              Buf_AddChar(buf, *str);
             str++;              str++;
         } else if (*str != '$') {          } else if (*str != '$') {
             /*              /*
Line 2203 
Line 2202 
   
             for (cp = str++; *str != '$' && *str != '\0'; str++)              for (cp = str++; *str != '$' && *str != '\0'; str++)
                 continue;                  continue;
             Buf_AddBytes(buf, str - cp, (Byte *)cp);              Buf_AddChars(buf, str - cp, cp);
         } else {          } else {
             if (var != NULL) {              if (var != NULL) {
                 int expand;                  int expand;
                 for (;;) {                  for (;;) {
                     if (str[1] != '(' && str[1] != '{') {                      if (str[1] != '(' && str[1] != '{') {
                         if (str[1] != *var || var[1] != '\0') {                          if (str[1] != *var || var[1] != '\0') {
                             Buf_AddBytes(buf, 2, (Byte *) str);                              Buf_AddChars(buf, 2, str);
                             str += 2;                              str += 2;
                             expand = FALSE;                              expand = FALSE;
                         }                          }
Line 2234 
Line 2233 
                          * the nested one                           * the nested one
                          */                           */
                         if (*p == '$') {                          if (*p == '$') {
                             Buf_AddBytes(buf, p - str, (Byte *) str);                              Buf_AddChars(buf, p - str, str);
                             str = p;                              str = p;
                             continue;                              continue;
                         }                          }
Line 2247 
Line 2246 
                              */                               */
                             for (;*p != '$' && *p != '\0'; p++)                              for (;*p != '$' && *p != '\0'; p++)
                                 continue;                                  continue;
                             Buf_AddBytes(buf, p - str, (Byte *) str);                              Buf_AddChars(buf, p - str, str);
                             str = p;                              str = p;
                             expand = FALSE;                              expand = FALSE;
                         }                          }
Line 2290 
Line 2289 
                     str += length;                      str += length;
                     errorReported = TRUE;                      errorReported = TRUE;
                 } else {                  } else {
                     Buf_AddByte (buf, (Byte)*str);                      Buf_AddChar(buf, *str);
                     str += 1;                      str += 1;
                 }                  }
             } else {              } else {
Line 2304 
Line 2303 
                  * Copy all the characters from the variable value straight                   * Copy all the characters from the variable value straight
                  * into the new string.                   * into the new string.
                  */                   */
                 Buf_AddBytes (buf, strlen (val), (Byte *)val);                  Buf_AddChars(buf, strlen(val), val);
                 if (doFree) {                  if (doFree) {
                     free ((Address)val);                      free ((Address)val);
                 }                  }
Line 2312 
Line 2311 
         }          }
     }      }
   
     Buf_AddByte (buf, '\0');      Buf_AddChar(buf, '\0');
     str = (char *)Buf_GetAll (buf, (int *)NULL);      str = Buf_GetAll(buf, NULL);
     Buf_Destroy (buf, FALSE);      Buf_Destroy(buf, FALSE);
     return (str);      return (str);
 }  }
   
Line 2397 
Line 2396 
     ClientData dummy;      ClientData dummy;
 {  {
     Var    *v = (Var *) vp;      Var    *v = (Var *) vp;
     printf ("%-16s = %s\n", v->name, (char *) Buf_GetAll(v->val, (int *)NULL));      printf ("%-16s = %s\n", v->name, Buf_GetAll(v->val, NULL));
     return (dummy ? 0 : 0);      return (dummy ? 0 : 0);
 }  }
   

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16