[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.44 and 1.45

version 1.44, 2000/07/17 23:26:50 version 1.45, 2000/07/17 23:29:35
Line 203 
Line 203 
 static const char *context_name __P((GSymT *));  static const char *context_name __P((GSymT *));
 static Var *new_var __P((const char *, const char *));  static Var *new_var __P((const char *, const char *));
 static Var *getvar __P((GSymT *, const char *, const char *, u_int32_t));  static Var *getvar __P((GSymT *, const char *, const char *, u_int32_t));
   static Var *var_name_with_dollar __P((char *, char **, SymTable *, Boolean, char));
   
 void  void
 SymTable_Init(ctxt)  SymTable_Init(ctxt)
Line 755 
Line 756 
         return NULL;          return NULL;
 }  }
   
   /*
    *-----------------------------------------------------------------------
    * v = var_name_with_dollar(str, &pos, ctxt, err, endc)
    *   handle variable name that contains a dollar
    *   str points to the first letter of the variable name,
    *   &pos to the current position in the name (first dollar at invocation,
    *   end of name specification at return).
    *   returns the corresponding variable.
    *-----------------------------------------------------------------------
    */
   static Var *
   var_name_with_dollar(str, pos, ctxt, err, endc)
       char *str;                  /* First dollar in variable name */
       char **pos;                 /* Current position in variable spec */
       SymTable    *ctxt;          /* The context for the variable */
       Boolean     err;            /* TRUE if undefined variables are an error */
       char        endc;           /* End character for spec */
   {
       BUFFER buf;                 /* Store the variable name */
       size_t sublen;              /* Deal with recursive expansions */
       Boolean subfree;
       char *n;                    /* Sub name */
       Var *v;
   
       Buf_Init(&buf, MAKE_BSIZE);
   
       while (1) {
           Buf_AddInterval(&buf, str, *pos);
           n = Var_Parse(*pos, ctxt, err, &sublen, &subfree);
           if (n != NULL)
               Buf_AddString(&buf, n);
           if (subfree)
               free(n);
           *pos += sublen;
           str = *pos;
           for (; **pos != '$'; (*pos)++) {
               if (**pos == '\0' || **pos == endc || **pos == ':') {
                   v = VarFind(Buf_Retrieve(&buf), ctxt, FIND_ENV | FIND_MINE);
                   Buf_Destroy(&buf);
                   return v;
               }
           }
       }
   }
   
 /*-  /*-
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  * Var_Parse --   * Var_Parse --
Line 792 
Line 838 
     start = str++;      start = str++;
   
     val = NULL;      val = NULL;
       v = NULL;
       idx = 0;
   
     if (*str != '(' && *str != '{') {      if (*str != '(' && *str != '{') {
         tstr = str + 1;          tstr = str + 1;
Line 802 
Line 850 
         str++;          str++;
   
         /* Find eventual modifiers in the variable */          /* Find eventual modifiers in the variable */
         for (tstr = str; *tstr != ':'; tstr++)          for (tstr = str; *tstr != ':'; tstr++) {
             if (*tstr == '\0' || *tstr == endc) {              if (*tstr == '$') {
                   v = var_name_with_dollar(str, &tstr, ctxt, err, endc);
                   if (*tstr == '\0' || *tstr == endc)
                       endc = '\0';
                   break;
               } else if (*tstr == '\0' || *tstr == endc) {
                 endc = '\0';                  endc = '\0';
                 break;                  break;
             }              }
           }
         *lengthPtr = tstr+1 - start;          *lengthPtr = tstr+1 - start;
     }      }
   
     idx = quick_lookup(str, &tstr, &k);      if (v == NULL) {
     v = varfind(str, tstr, ctxt, FIND_ENV | FIND_MINE, idx, k);          idx = quick_lookup(str, &tstr, &k);
           v = varfind(str, tstr, ctxt, FIND_ENV | FIND_MINE, idx, k);
       }
     if (v == NULL) {      if (v == NULL) {
         /* Find out about D and F forms of local variables. */          /* Find out about D and F forms of local variables. */
         if (idx == -1 && tstr == str+2 && (str[1] == 'D' || str[1] == 'F')) {          if (idx == -1 && tstr == str+2 && (str[1] == 'D' || str[1] == 'F')) {

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45