version 1.1, 2001/09/18 14:55:52 |
version 1.2, 2001/09/27 11:40:33 |
|
|
#include <stddef.h> |
#include <stddef.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <err.h> |
#include <err.h> |
|
#include <stdlib.h> |
#include "mdef.h" |
#include "mdef.h" |
#include "stdd.h" |
#include "stdd.h" |
#include "extern.h" |
#include "extern.h" |
|
|
#define TRACE_INPUT 256 /* not implemented yet */ |
#define TRACE_INPUT 256 /* not implemented yet */ |
#define TRACE_ALL 512 |
#define TRACE_ALL 512 |
|
|
|
static struct t { |
|
struct t *next; |
|
char *name; |
|
int on; |
|
} *l; |
|
|
static unsigned int letter_to_flag __P((int)); |
static unsigned int letter_to_flag __P((int)); |
static void print_header __P((struct input_file *)); |
static void print_header __P((struct input_file *)); |
|
static struct t *find_trace_entry __P((const char *)); |
|
|
static unsigned int flags = TRACE_QUOTE | TRACE_EXPANSION; |
static unsigned int flags = TRACE_QUOTE | TRACE_EXPANSION; |
|
|
static struct t { |
static struct t * |
struct t *next; |
find_trace_entry(name) |
char *name; |
const char *name; |
} *l; |
{ |
|
struct t *n; |
|
|
|
for (n = l; n != NULL; n = n->next) |
|
if (STREQ(n->name, name)) |
|
return n; |
|
return NULL; |
|
} |
|
|
|
|
void |
void |
mark_traced(name) |
mark_traced(name, on) |
const char *name; |
const char *name; |
|
int on; |
{ |
{ |
struct t *n; |
struct t *n, *n2; |
|
|
traced_macros = 1; |
traced_macros = 1; |
|
|
|
if (name == NULL) { |
|
if (on) |
|
flags |= TRACE_ALL; |
|
else { |
|
flags &= ~TRACE_ALL; |
|
traced_macros = 0; |
|
} |
|
for (n = l; n != NULL; n = n2) { |
|
n2 = n->next; |
|
free(n->name); |
|
free(n); |
|
} |
|
l = NULL; |
|
} else { |
|
n = find_trace_entry(name); |
|
if (n == NULL) { |
n = xalloc(sizeof(struct t)); |
n = xalloc(sizeof(struct t)); |
n->name = xstrdup(name); |
n->name = xstrdup(name); |
n->next = l; |
n->next = l; |
l = n; |
l = n; |
|
} |
|
n->on = on; |
|
} |
} |
} |
|
|
|
|
int |
int |
is_traced(name) |
is_traced(name) |
const char *name; |
const char *name; |
{ |
{ |
struct t *n; |
struct t *n; |
|
|
if (flags & TRACE_ALL) |
|
return 1; |
|
for (n = l; n != NULL; n = n->next) |
for (n = l; n != NULL; n = n->next) |
if (STREQ(n->name, name)) |
if (STREQ(n->name, name)) |
return 1; |
return n->on; |
return 0; |
return (flags & TRACE_ALL) ? 1 : 0; |
} |
} |
|
|
void |
void |