Debian Codegraph @

reports/sources.ll

raw
1 /*
2 * @progname sources.ll
3 * @version 1.0
4 * @author
5 * @category
6 * @output Text
7 * @description
8 *
9 * Print the sources associated with an individual.
10 */
11 global(refn) /* root node of references record */
12 global(reftab) /* table of reference keys reported on */
13 global(ref1)
14
15 proc main ()
16 {
17 getindi(refn, "Enter name of record that hold the references")
18 if (eq(refn, 0)) {
19 print("The references could not be found; program not run\n")
20 } else {
21 set(refn, inode(refn))
22 call foundrefs()
23 }
24 }
25
26 proc foundrefs ()
27 {
28 table(refs)
29 set(ref1, 0)
30 getindi(indi, "Enter a person to show sources for.")
31 while (indi) {
32 call showperson(indi)
33 "\n"
34 getindi(indi, "Enter another person to show sources for.")
35 }
36 print("Program over!\n")
37 }
38
39 proc showperson (indi)
40 {
41 call showvitals(indi)
42 call showsources(indi)
43 }
44
45 proc showvitals (i)
46 {
47 name(i) ".\n"
48 set(e,birth(i))
49 if(and(e,long(e))) { "Born " long(e) ".\n" }
50 set(e,death(i))
51 if(and(e,long(e))) { "Died " long(e) ".\n" }
52 }
53
54 proc showsources (i) /* finds all SOUR lines in a record */
55 {
56 table(reftab)
57 set(ref1, 0)
58 traverse (inode(i), s, n) {
59 if (eq(0, strcmp("SOUR", tag(s)))) {
60 call showsource(value(s))
61 }
62 }
63 }
64
65 proc showsource (v) /* process each SOUR line in a record */
66 {
67 set(ref, 0)
68 fornodes (refn, s) { /* look at each REFN line in references */
69 if (eq(0, strcmp(v, value(s)))) { /* found one with matching code! */
70 set(ref, s) /* so set ref to this REFN node */
71 }
72 }
73 if (ref) { /* non-null if matching code were found */
74 if (not(lookup(reftab, v))) { /* and we hadn't seen it yet */
75 if (not(ref1)) { /* Print "References:" before first one */
76 "References:\n"
77 set(ref1, 1)
78 }
79 "\t" value(child(ref)) "\n" /* This could be much better! */
80 insert(reftab, v, 1) /* So we won't show it again! */
81 }
82 }
83 }