File: relink.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 (74 lines) | stat: -rw-r--r-- 2,684 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
/*
 * @progname       relink.ll
 * @version        1995-06
 * @author         J.F. Chandler
 * @category       
 * @output         GEDCOM
 * @description

LifeLines program to reconstruct pointers from persons to families when
these pointers are missing, but can be deduced from the corresponding
pointers from families to persons.  Do this only for persons with no
pointers to families at all.  Similarly, reconstruct pointers from
families to persons where necessary.

The output is a GEDCOM file which includes only the individual and family
records from the database.  Other record types must be recovered separately
because there is no iterator in the language for those record types.

relink - J.F. Chandler - 1995 Jun
*/

proc main() {
"0 HEAD\n1 SOUR RELINK\n1 DEST ANY\n"
forindi(i,n) {
        traverse(inode(i),node,level) {
                d(level) " "
                if(eq(level,0)) { "@" key(i) "@ " }
                tag(node)
                if(v,value(node)) { " " v }
                nl()
        }
        if(not(or(nfamilies(i),parents(i)))) {
                set(indk,save(key(i)))
                forfam(f,k) {
                        if(or(eq(0,strcmp(indk,key(wife(f)))),
                                eq(0,strcmp(indk,key(husband(f)))))) {
                                "1 FAMS @" key(f) "@\n"
                        } elsif(nchildren(f)) {
                                children(f,child,l) {
                                        if(eq(0,strcmp(indk,key(child)))) {
                                                "1 FAMC @" key(f) "@\n"
                                                break()
                                        }
                                }
                        }
                }
        }
}
forfam(f,k) {
        traverse(fnode(f),node,level) {
                d(level) " "
                if(eq(level,0)) { "@" key(f) "@ " }
                tag(node)
                if(v,value(node)) { " " v }
                nl()
        }
        if(not(or(husband(f),wife(f),nchildren(f)))) {
                set(famk,save(key(f)))
                forindi(i,n) {
                        families(i,fam,spo,l) {
                                if(eq(0,strcmp(famk,key(fam)))) {
                                        if(male(i)) {"1 HUSB @" key(i) "@\n"}
                                        else {"1 WIFE @" key(i) "@\n"}
                                        break()
                                }
                        }
                        if(eq(0,strcmp(famk,key(parents(i))))) {
                                "1 CHIL @" key(i) "@\n"
                        }
                }
        }
}
"0 TRLR\n"
}