diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-10-02 10:29:32 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-10-02 10:29:32 +0000 |
commit | f52927cb1ba328594c8f4b934c14bca4916ef8e5 (patch) | |
tree | 14c58f1946f28de41a69025afb0f588293831ec2 /usr.bin/make/var.c | |
parent | 6624e8c7ba7439673221e27b9603d172cd60d99a (diff) |
more changes, discussed and tested by various people.
- put back some job control, turns out it's necessary when we don't run a
shell.
- zap old #ifdef CLEANUP code... probably doesn't even compile.
- kill most of the OP_LIB code. Just keep a wee little bit for compatibility
(deprecated .LIBS and .INCLUDES, warns for weird dependencies instead of
erroring out).
- much improved debugging and -p output: sort variables, targets, rules,
output stuff in a nicer format mimicing input.
- better error message when no command is found, explain where the target comes from.
- sort final error list by file.
- show system files in errors as <bsd.prog.mk>
- reincorporate random delay, that was dropped
- optimize siginfo output by not regenerating the whole string each time.
- finish zapping old LocationInfo field that's no longer used.
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r-- | usr.bin/make/var.c | 102 |
1 files changed, 61 insertions, 41 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 0a86d32b345..eadb3d9dbe0 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $OpenBSD: var.c,v 1.90 2012/08/25 08:12:56 espie Exp $ */ +/* $OpenBSD: var.c,v 1.91 2012/10/02 10:29:31 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -83,6 +83,8 @@ #include "memory.h" #include "symtable.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 @@ -439,20 +441,6 @@ SymTable_Init(SymTable *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. ***/ @@ -948,25 +936,22 @@ Var_Parse(const char *str, /* The string to parse */ *freePtr = true; val = Str_dupi(str, tstr); } else { - /* somehow, this should have been expanded already. */ - GNode *n; + Location origin; - /* XXX */ - n = (GNode *)(((char *)ctxt) - - offsetof(GNode, context)); + Parse_FillLocation(&origin); if (idx >= LOCAL_SIZE) idx = EXTENDED2SIMPLE(idx); switch(idx) { case IMPSRC_INDEX: Fatal( "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; default: Error( "Using undefined dynamic variable $%s (line %lu of %s)", - varnames[idx], n->origin.lineno, - n->origin.fname); + varnames[idx], origin.lineno, + origin.fname); break; } } @@ -1233,19 +1218,6 @@ Var_Init(void) } -#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 * @@ -1264,17 +1236,65 @@ print_var(Var *v) (v->flags & VAR_DUMMY) == 0 ? var_get_value(v) : "(none)"); } + void Var_Dump(void) { - Var *v; + Var **t; + unsigned int i; + const char *banner; + bool first = true; + + t = sort_ohash_by_name(&global_variables); +/* somewhat dirty, but does the trick */ + +#define LOOP(mask, value, do_stuff) \ + for (i = 0; t[i] != NULL; i++) \ + if ((t[i]->flags & (mask)) == (value)) { \ + if (banner) { \ + if (first) \ + first = false; \ + else \ + putchar('\n'); \ + fputs(banner, stdout); \ + banner = NULL; \ + } \ + do_stuff; \ + } - printf("#*** Global Variables:\n"); + banner = "#variables from command line:\n"; + LOOP(VAR_FROM_CMD | VAR_DUMMY, VAR_FROM_CMD, print_var(t[i])); - for (v = ohash_first(&global_variables, &i); v != NULL; - v = ohash_next(&global_variables, &i)) - print_var(v); + 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\\'\""; |