File: sources.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (83 lines) | stat: -rw-r--r-- 2,096 bytes parent folder | download | duplicates (5)
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
73
74
75
76
77
78
79
80
81
82
83
/*
 * @progname       sources.ll
 * @version        1.0
 * @author         
 * @category       
 * @output         Text
 * @description    
 *
 * Print the sources associated with an individual.
 */
global(refn)    /* root node of references record */
global(reftab)  /* table of reference keys reported on */
global(ref1)

proc main ()
{
    getindi(refn, "Enter name of record that hold the references")
    if (eq(refn, 0)) {
        print("The references could not be found; program not run\n")
    } else {
        set(refn, inode(refn))
        call foundrefs()
    }
}

proc foundrefs ()
{
    table(refs)
    set(ref1, 0)
    getindi(indi, "Enter a person to show sources for.")
    while (indi) {
        call showperson(indi)
        "\n"
        getindi(indi, "Enter another person to show sources for.")
    }
    print("Program over!\n")
}

proc showperson (indi)
{
    call showvitals(indi)
    call showsources(indi)
}

proc showvitals (i)
{
    name(i) ".\n"
    set(e,birth(i))
    if(and(e,long(e))) { "Born " long(e) ".\n" }
    set(e,death(i))
    if(and(e,long(e))) { "Died " long(e) ".\n" }
}

proc showsources (i)    /* finds all SOUR lines in a record */
{
    table(reftab)
    set(ref1, 0)
    traverse (inode(i), s, n) {
        if (eq(0, strcmp("SOUR", tag(s)))) {
            call showsource(value(s))
        }
    }
}

proc showsource (v)     /* process each SOUR line in a record */
{
    set(ref, 0)
    fornodes (refn, s) {  /* look at each REFN line in references */
        if (eq(0, strcmp(v, value(s)))) { /* found one with matching code! */
            set(ref, s)  /* so set ref to this REFN node */
        }
    }
    if (ref) {  /* non-null if matching code were found */
        if (not(lookup(reftab, v))) {   /* and we hadn't seen it yet */
            if (not(ref1)) {    /* Print "References:" before first one */
                "References:\n"
                set(ref1, 1)
            }
            "\t" value(child(ref)) "\n"  /* This could be much better! */
            insert(reftab, v, 1)  /* So we won't show it again! */
        }
    }
}