-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcheck.c
72 lines (62 loc) · 1.27 KB
/
check.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Check structures for make.
*/
#include "make.h"
static void
print_name(struct name *np)
{
if (np == firstname)
printf("# default target\n");
printf("%s:", np->n_name);
if ((np->n_flag & N_DOUBLE))
putchar(':');
}
static void
print_prerequisites(struct rule *rp)
{
struct depend *dp;
for (dp = rp->r_dep; dp; dp = dp->d_next)
printf(" %s", dp->d_name->n_name);
}
static void
print_commands(struct rule *rp)
{
struct cmd *cp;
for (cp = rp->r_cmd; cp; cp = cp->c_next)
printf("\t%s\n", cp->c_cmd);
}
void
print_details(void)
{
int i;
struct macro *mp;
struct name *np;
struct rule *rp;
for (i = 0; i < HTABSIZE; i++)
for (mp = macrohead[i]; mp; mp = mp->m_next)
printf("%s = %s\n", mp->m_name, mp->m_val);
putchar('\n');
for (i = 0; i < HTABSIZE; i++) {
for (np = namehead[i]; np; np = np->n_next) {
if (!(np->n_flag & N_DOUBLE)) {
print_name(np);
for (rp = np->n_rule; rp; rp = rp->r_next) {
print_prerequisites(rp);
}
putchar('\n');
for (rp = np->n_rule; rp; rp = rp->r_next) {
print_commands(rp);
}
putchar('\n');
} else {
for (rp = np->n_rule; rp; rp = rp->r_next) {
print_name(np);
print_prerequisites(rp);
putchar('\n');
print_commands(rp);
putchar('\n');
}
}
}
}
}