[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.90 and 1.91

version 1.90, 2012/08/25 08:12:56 version 1.91, 2012/10/02 10:29:31
Line 83 
Line 83 
 #include "memory.h"  #include "memory.h"
 #include "symtable.h"  #include "symtable.h"
 #include "gnode.h"  #include "gnode.h"
   #include "dump.h"
   #include "lowparse.h"
   
 /*  /*
  * This is a harmless return value for Var_Parse that can be used by Var_Subst   * This is a harmless return value for Var_Parse that can be used by Var_Subst
Line 439 
Line 441 
         memcpy(ctxt, &sym_template, sizeof(*ctxt));          memcpy(ctxt, &sym_template, sizeof(*ctxt));
 }  }
   
 /* free symtable.  
  */  
 #ifdef CLEANUP  
 void  
 SymTable_Destroy(SymTable *ctxt)  
 {  
         int i;  
   
         for (i = 0; i < LOCAL_SIZE; i++)  
                 if (ctxt->locals[i] != NULL)  
                         delete_var(ctxt->locals[i]);  
 }  
 #endif  
   
 /***  /***
  ***    Global variable handling.   ***    Global variable handling.
  ***/   ***/
Line 948 
Line 936 
                                 *freePtr = true;                                  *freePtr = true;
                                 val = Str_dupi(str, tstr);                                  val = Str_dupi(str, tstr);
                         } else {                          } else {
                         /* somehow, this should have been expanded already. */                                  Location origin;
                                 GNode *n;  
   
                                 /* XXX */                                  Parse_FillLocation(&origin);
                                 n = (GNode *)(((char *)ctxt) -  
                                     offsetof(GNode, context));  
                                 if (idx >= LOCAL_SIZE)                                  if (idx >= LOCAL_SIZE)
                                         idx = EXTENDED2SIMPLE(idx);                                          idx = EXTENDED2SIMPLE(idx);
                                 switch(idx) {                                  switch(idx) {
                                 case IMPSRC_INDEX:                                  case IMPSRC_INDEX:
                                         Fatal(                                          Fatal(
 "Using $< in a non-suffix rule context is a GNUmake idiom (line %lu of %s)",  "Using $< in a non-suffix rule context is a GNUmake idiom (line %lu of %s)",
                                             n->origin.lineno, n->origin.fname);                                              origin.lineno, origin.fname);
                                         break;                                          break;
                                 default:                                  default:
                                         Error(                                          Error(
 "Using undefined dynamic variable $%s (line %lu of %s)",  "Using undefined dynamic variable $%s (line %lu of %s)",
                                             varnames[idx], n->origin.lineno,                                              varnames[idx], origin.lineno,
                                             n->origin.fname);                                              origin.fname);
                                         break;                                          break;
                                 }                                  }
                         }                          }
Line 1233 
Line 1218 
 }  }
   
   
 #ifdef CLEANUP  
 void  
 Var_End(void)  
 {  
         Var *v;  
         unsigned int i;  
   
         for (v = ohash_first(&global_variables, &i); v != NULL;  
             v = ohash_next(&global_variables, &i))  
                 delete_var(v);  
 }  
 #endif  
   
 static const char *interpret(int);  static const char *interpret(int);
   
 static const char *  static const char *
Line 1264 
Line 1236 
             (v->flags & VAR_DUMMY) == 0 ? var_get_value(v) : "(none)");              (v->flags & VAR_DUMMY) == 0 ? var_get_value(v) : "(none)");
 }  }
   
   
 void  void
 Var_Dump(void)  Var_Dump(void)
 {  {
         Var *v;          Var **t;
   
         unsigned int i;          unsigned int i;
           const char *banner;
           bool first = true;
   
         printf("#*** Global Variables:\n");          t = sort_ohash_by_name(&global_variables);
   /* somewhat dirty, but does the trick */
   
         for (v = ohash_first(&global_variables, &i); v != NULL;  #define LOOP(mask, value, do_stuff) \
             v = ohash_next(&global_variables, &i))          for (i = 0; t[i] != NULL; i++) \
                 print_var(v);                  if ((t[i]->flags & (mask)) == (value)) { \
                           if (banner) { \
                                   if (first) \
                                           first = false; \
                                   else \
                                           putchar('\n'); \
                                   fputs(banner, stdout); \
                                   banner = NULL; \
                           } \
                       do_stuff; \
                   }
   
           banner = "#variables from command line:\n";
           LOOP(VAR_FROM_CMD | VAR_DUMMY, VAR_FROM_CMD, print_var(t[i]));
   
           banner = "#global variables:\n";
           LOOP(VAR_FROM_ENV| VAR_FROM_CMD | VAR_DUMMY, 0, print_var(t[i]));
   
           banner = "#variables from env:\n";
           LOOP(VAR_FROM_ENV|VAR_DUMMY, VAR_FROM_ENV, print_var(t[i]));
   
           banner = "#variable name seen, but not defined:";
           LOOP(VAR_DUMMY|POISONS, VAR_DUMMY, printf(" %s", t[i]->name));
   
   #undef LOOP
   
           printf("\n\n");
   
           for (i = 0; t[i] != NULL; i++)
                   switch(t[i]->flags & POISONS) {
                   case POISON_NORMAL:
                           printf(".poison %s\n", t[i]->name);
                           break;
                   case POISON_EMPTY:
                           printf(".poison empty(%s)\n", t[i]->name);
                           break;
                   case POISON_NOT_DEFINED:
                           printf(".poison !defined(%s)\n", t[i]->name);
                           break;
                   default:
                           break;
                   }
           free(t);
           printf("\n");
 }  }
   
 static const char *quotable = " \t\n\\'\"";  static const char *quotable = " \t\n\\'\"";

Legend:
Removed from v.1.90  
changed lines
  Added in v.1.91