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

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/make/var.c between version 1.568 and 1.569

version 1.568, 2020/10/05 19:39:30 version 1.569, 2020/10/06 07:52:47
Line 253  typedef enum {
Line 253  typedef enum {
     VARP_ANCHOR_END     = 0x08  /* Match at end of word */      VARP_ANCHOR_END     = 0x08  /* Match at end of word */
 } VarPatternFlags;  } VarPatternFlags;
   
   static Var *
   VarNew(char *name, const char *value, VarFlags flags)
   {
       size_t value_len = strlen(value);
       Var *var = bmake_malloc(sizeof *var);
       var->name = name;
       Buf_Init(&var->val, value_len + 1);
       Buf_AddBytes(&var->val, value, value_len);
       var->flags = flags;
       return var;
   }
   
 /*-  /*-
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  * VarFind --   * VarFind --
Line 348  VarFind(const char *name, GNode *ctxt, V
Line 360  VarFind(const char *name, GNode *ctxt, V
     if (var == NULL && (flags & FIND_ENV)) {      if (var == NULL && (flags & FIND_ENV)) {
         char *env;          char *env;
   
         if ((env = getenv(name)) != NULL) {          if ((env = getenv(name)) != NULL)
             Var *v = bmake_malloc(sizeof(Var));              return VarNew(bmake_strdup(name), env, VAR_FROM_ENV);
             size_t len;  
             v->name = bmake_strdup(name);  
   
             len = strlen(env);  
             Buf_Init(&v->val, len + 1);  
             Buf_AddBytes(&v->val, env, len);  
   
             v->flags = VAR_FROM_ENV;  
             return v;  
         }  
   
         if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {          if (checkEnvFirst && (flags & FIND_GLOBAL) && ctxt != VAR_GLOBAL) {
             var = Hash_FindValue(&VAR_GLOBAL->context, name);              var = Hash_FindValue(&VAR_GLOBAL->context, name);
Line 403  VarFreeEnv(Var *v, Boolean destroy)
Line 405  VarFreeEnv(Var *v, Boolean destroy)
 static void  static void
 VarAdd(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)  VarAdd(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)
 {  {
     Var *v = bmake_malloc(sizeof(Var));      Hash_Entry *he = Hash_CreateEntry(&ctxt->context, name, NULL);
     size_t len = strlen(val);      Var *v = VarNew(he->name, val, flags & VAR_SET_READONLY ? VAR_READONLY : 0);
     Hash_Entry *he;  
   
     Buf_Init(&v->val, len + 1);  
     Buf_AddBytes(&v->val, val, len);  
   
     v->flags = 0;  
     if (flags & VAR_SET_READONLY)  
         v->flags |= VAR_READONLY;  
   
     he = Hash_CreateEntry(&ctxt->context, name, NULL);  
     Hash_SetValue(he, v);      Hash_SetValue(he, v);
     v->name = he->name;  
     if (!(ctxt->flags & INTERNAL)) {      if (!(ctxt->flags & INTERNAL)) {
         VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);          VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
     }      }
Line 3639  Var_Parse(const char **pp, GNode *ctxt, 
Line 3630  Var_Parse(const char **pp, GNode *ctxt, 
              * At the end, after applying all modifiers, if the expression               * At the end, after applying all modifiers, if the expression
              * is still undefined, Var_Parse will return an empty string               * is still undefined, Var_Parse will return an empty string
              * instead of the actually computed value. */               * instead of the actually computed value. */
             v = bmake_malloc(sizeof(Var));              v = VarNew(varname, "", 0);
             v->name = varname;  
             Buf_Init(&v->val, 1);  
             v->flags = 0;  
             exprFlags = VEF_UNDEF;              exprFlags = VEF_UNDEF;
         } else          } else
             free(varname);              free(varname);

Legend:
Removed from v.1.568  
changed lines
  Added in v.1.569

CVSweb <webmaster@jp.NetBSD.org>