static struct token *token_list;
static unsigned nr_tokens;
+static _Bool verbose;
+
+#define debug(fmt, ...) do { if (verbose) printf(fmt, ## __VA_ARGS__); } while (0)
static int directive_compare(const void *_key, const void *_pdir)
{
dlen = strlen(dir);
clen = (dlen < token->size) ? dlen : token->size;
- //printf("cmp(%*.*s,%s) = ",
+ //debug("cmp(%*.*s,%s) = ",
// (int)token->size, (int)token->size, token->value,
// dir);
val = memcmp(token->value, dir, clen);
if (val != 0) {
- //printf("%d [cmp]\n", val);
+ //debug("%d [cmp]\n", val);
return val;
}
if (dlen == token->size) {
- //printf("0\n");
+ //debug("0\n");
return 0;
}
- //printf("%d\n", (int)dlen - (int)token->size);
+ //debug("%d\n", (int)dlen - (int)token->size);
return dlen - token->size; /* shorter -> negative */
}
}
nr_tokens = tix;
- printf("Extracted %u tokens\n", nr_tokens);
+ debug("Extracted %u tokens\n", nr_tokens);
#if 0
{
int n;
for (n = 0; n < nr_tokens; n++)
- printf("Token %3u: '%*.*s'\n",
+ debug("Token %3u: '%*.*s'\n",
n,
(int)token_list[n].size, (int)token_list[n].size,
token_list[n].value);
ssize_t readlen;
FILE *out, *hdr;
char *buffer, *p;
+ char *kbuild_verbose;
int fd;
if (argc != 4) {
exit(2);
}
+ kbuild_verbose = getenv("KBUILD_VERBOSE");
+ if (kbuild_verbose)
+ verbose = atoi(kbuild_verbose);
+
filename = argv[1];
outputname = argv[2];
headername = argv[3];
qsort(type_index, nr, sizeof(type_index[0]), type_index_compare);
- printf("Extracted %u types\n", nr_types);
+ debug("Extracted %u types\n", nr_types);
#if 0
for (n = 0; n < nr_types; n++) {
struct type *type = type_index[n];
- printf("- %*.*s\n",
+ debug("- %*.*s\n",
(int)type->name->size,
(int)type->name->size,
type->name->value);
} while (type++, !(type->flags & TYPE_STOP_MARKER));
- printf("Extracted %u actions\n", nr_actions);
+ debug("Extracted %u actions\n", nr_actions);
}
static struct element *element_list;
}
/* We do two passes - the first one calculates all the offsets */
- printf("Pass 1\n");
+ debug("Pass 1\n");
nr_entries = 0;
root = &type_list[0];
render_element(NULL, root->element, NULL);
e->flags &= ~ELEMENT_RENDERED;
/* And then we actually render */
- printf("Pass 2\n");
+ debug("Pass 2\n");
fprintf(out, "\n");
fprintf(out, "static const unsigned char %s_machine[] = {\n",
grammar_name);