[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.151 and 1.152

version 1.151, 2009/02/18 21:06:47 version 1.152, 2009/06/16 05:44:06
Line 205  static int var_exportedVars = VAR_EXPORT
Line 205  static int var_exportedVars = VAR_EXPORT
  * We pass this to Var_Export when doing the initial export   * We pass this to Var_Export when doing the initial export
  * or after updating an exported var.   * or after updating an exported var.
  */   */
 #define VAR_EXPORT_FORCE 1  #define VAR_EXPORT_PARENT 1
   
 /* Var*Pattern flags */  /* Var*Pattern flags */
 #define VAR_SUB_GLOBAL  0x01    /* Apply substitution globally */  #define VAR_SUB_GLOBAL  0x01    /* Apply substitution globally */
Line 541  Var_Delete(const char *name, GNode *ctxt
Line 541  Var_Delete(const char *name, GNode *ctxt
  * We ignore make internal variables (those which start with '.')   * We ignore make internal variables (those which start with '.')
  * Also we jump through some hoops to avoid calling setenv   * Also we jump through some hoops to avoid calling setenv
  * more than necessary since it can leak.   * more than necessary since it can leak.
    * We only manipulate flags of vars if 'parent' is set.
  */   */
 static int  static int
 Var_Export1(const char *name, int force)  Var_Export1(const char *name, int parent)
 {  {
     char tmp[BUFSIZ];      char tmp[BUFSIZ];
     Var *v;      Var *v;
Line 571  Var_Export1(const char *name, int force)
Line 572  Var_Export1(const char *name, int force)
     if (v == NULL) {      if (v == NULL) {
         return 0;          return 0;
     }      }
     if (!force &&      if (!parent &&
         (v->flags & (VAR_EXPORTED|VAR_REEXPORT)) == VAR_EXPORTED) {          (v->flags & (VAR_EXPORTED|VAR_REEXPORT)) == VAR_EXPORTED) {
         return 0;                       /* nothing to do */          return 0;                       /* nothing to do */
     }      }
     val = Buf_GetAll(&v->val, NULL);      val = Buf_GetAll(&v->val, NULL);
     if (strchr(val, '$')) {      if (strchr(val, '$')) {
         /* Flag this as something we need to re-export */          if (parent) {
         v->flags |= (VAR_EXPORTED|VAR_REEXPORT);  
         if (force) {  
             /*              /*
                * Flag this as something we need to re-export.
              * No point actually exporting it now though,               * No point actually exporting it now though,
              * the child can do it at the last minute.               * the child can do it at the last minute.
              */               */
               v->flags |= (VAR_EXPORTED|VAR_REEXPORT);
             return 1;              return 1;
         }          }
         n = snprintf(tmp, sizeof(tmp), "${%s}", name);          n = snprintf(tmp, sizeof(tmp), "${%s}", name);
Line 593  Var_Export1(const char *name, int force)
Line 594  Var_Export1(const char *name, int force)
             free(val);              free(val);
         }          }
     } else {      } else {
         v->flags &= ~VAR_REEXPORT;      /* once will do */          if (parent) {
         if (force || !(v->flags & VAR_EXPORTED)) {              v->flags &= ~VAR_REEXPORT;  /* once will do */
           }
           if (parent || !(v->flags & VAR_EXPORTED)) {
             setenv(name, val, 1);              setenv(name, val, 1);
         }          }
     }      }
     /*      /*
      * This is so Var_Set knows to call Var_Export again...       * This is so Var_Set knows to call Var_Export again...
      */       */
     v->flags |= VAR_EXPORTED;      if (parent) {
           v->flags |= VAR_EXPORTED;
       }
     return 1;      return 1;
 }  }
   
Line 693  Var_Export(char *str, int isExport)
Line 698  Var_Export(char *str, int isExport)
                 continue;                  continue;
             }              }
         }          }
         if (Var_Export1(name, VAR_EXPORT_FORCE)) {          if (Var_Export1(name, VAR_EXPORT_PARENT)) {
             if (VAR_EXPORTED_ALL != var_exportedVars)              if (VAR_EXPORTED_ALL != var_exportedVars)
                 var_exportedVars = VAR_EXPORTED_YES;                  var_exportedVars = VAR_EXPORTED_YES;
             if (isExport) {              if (isExport) {
Line 781  Var_Set(const char *name, const char *va
Line 786  Var_Set(const char *name, const char *va
             fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);              fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
         }          }
         if ((v->flags & VAR_EXPORTED)) {          if ((v->flags & VAR_EXPORTED)) {
             Var_Export1(name, VAR_EXPORT_FORCE);              Var_Export1(name, VAR_EXPORT_PARENT);
         }          }
     }      }
     /*      /*

Legend:
Removed from v.1.151  
changed lines
  Added in v.1.152

CVSweb <webmaster@jp.NetBSD.org>