461
/* sanity check lineage links */
462
check_fam_lineage_links(fam1);
463
check_fam_lineage_links(fam2);
430
465
/* Check restrictions on families */
431
466
split_fam(fam1, &fref1, &husb1, &wife1, &chil1, &rest1);
432
467
split_fam(fam2, &fref2, &husb2, &wife2, &chil2, &rest2);
433
468
if (traditional) {
434
470
if (husb1 && husb2 && nestr(nval(husb1), nval(husb2))) {
435
471
message(_(qSdhusb));
436
join_fam(fam1, fref1, husb1, wife1, chil1, rest1);
437
join_fam(fam2, fref2, husb2, wife2, chil2, rest2);
440
if (wife1 && wife2 && nestr(nval(wife1), nval(wife2))) {
474
if (ok && wife1 && wife2 && nestr(nval(wife1), nval(wife2))) {
441
475
message(_(qSdwife));
442
479
join_fam(fam1, fref1, husb1, wife1, chil1, rest1);
443
480
join_fam(fam2, fref2, husb2, wife2, chil2, rest2);
743
/*=================================================
744
* check_indi_lineage_links -- Check all families of
745
* this person to make sure they point back to this person
746
*===============================================*/
748
check_indi_lineage_links (NODE indi)
750
NODE name=0, refn=0, sex=0, body=0, famc=0, fams=0;
751
NODE curs=0; /* for travesing node lists */
752
TABLE memtab = memtab = create_table_int();
754
CNSTRING famkey=0; /* used inside traversal loops */
756
CNSTRING ikey = nxref(indi);
758
/* sanity check record is not deleted */
759
ASSERT(is_key_in_use(ikey));
761
/* Now validate lineage links of this person */
762
split_indi_old(indi, &name, &refn, &sex, &body, &famc, &fams);
765
Make table listing all families this person is spouse in
766
(& how many times each)
768
for (curs = fams; curs; curs = nsibling(curs)) {
769
famkey = rmvat(nval(curs));
770
if (!eqstr(ntag(curs), "FAMS")) {
772
snprintf(msg, sizeof(msg)/sizeof(msg[0]), _("Bad spouse tag: %s"), ntag(curs));
775
increment_table_int(memtab, famkey);
779
Check that all listed families contain person as spouse as many times
782
tabit = begin_table_iter(memtab);
783
while (next_table_int(tabit, &famkey, &count)) {
784
NODE fam = key_to_fam(famkey);
786
count how many times our main person (ikey)
787
occurs in this family (fam) as a spouse (HUSB or WIFE)
790
for (curs = nchild(fam); curs; curs = nsibling(curs)) {
791
if (eqstr(ntag(curs), "HUSB") || eqstr(ntag(curs), "WIFE")) {
792
if (eqstr(nval(curs), ikey)) {
797
if (count != occur) {
799
snprintf(msg, sizeof(msg)/sizeof(msg[0])
800
, _("Mismatched lineage spouse links between %s and %s: %ld and %ld")
801
, ikey, famkey, count, occur);
805
destroy_table(memtab);
806
memtab = create_table_int();
809
Make table listing all families this person is child in
810
(& how many times each)
812
for (curs = famc; curs; curs = nsibling(curs)) {
813
famkey = rmvat(nval(curs));
814
if (!eqstr(ntag(curs), "FAMC")) {
816
snprintf(msg, sizeof(msg)/sizeof(msg[0]), _("Bad child tag: %s"), ntag(curs));
819
increment_table_int(memtab, famkey);
823
Check that all listed families contain person as child (CHIL) as many times
826
tabit = begin_table_iter(memtab);
827
while (next_table_int(tabit, &famkey, &count)) {
828
NODE fam = key_to_fam(famkey);
830
count how many times our main person (ikey)
831
occurs in this family (fam) as a child (CHIL)
834
for (curs = nchild(fam); curs; curs = nsibling(curs)) {
835
if (eqstr(ntag(curs), "CHIL")) {
836
if (eqstr(nval(curs), ikey)) {
841
if (count != occur) {
843
snprintf(msg, sizeof(msg)/sizeof(msg[0])
844
, _("Mismatched lineage child links between %s and %s: %ld and %ld")
845
, ikey, famkey, count, occur);
850
join_indi(indi, name, refn, sex, body, famc, fams);
851
destroy_table(memtab);
853
/*=================================================
854
* check_fam_lineage_links -- Check all persons of
855
* this family to make sure they point back to this family
856
*===============================================*/
858
check_fam_lineage_links (NODE fam)
860
NODE fref=0, husb=0, wife=0, chil=0, rest=0;
861
NODE curs=0; /* for travesing node lists */
862
TABLE memtab = memtab = create_table_int();
864
CNSTRING indikey=0; /* used inside traversal loops */
866
CNSTRING fkey = nxref(fam);
868
/* sanity check record is not deleted */
869
ASSERT(is_key_in_use(fkey));
871
/* Now validate lineage links of this family */
872
split_fam(fam, &fref, &husb, &wife, &chil, &rest);
875
Make table listing all spouses in this family
876
(& how many times each)
878
for (curs = husb; curs; curs = nsibling(curs)) {
879
indikey = rmvat(nval(curs));
880
if (!eqstr(ntag(curs), "HUSB")) {
882
snprintf(msg, sizeof(msg)/sizeof(msg[0]), _("Bad HUSB tag: %s"), ntag(curs));
885
increment_table_int(memtab, indikey);
887
for (curs = wife; curs; curs = nsibling(curs)) {
888
indikey = rmvat(nval(curs));
889
if (!eqstr(ntag(curs), "WIFE")) {
891
snprintf(msg, sizeof(msg)/sizeof(msg[0]), _("Bad HUSB tag: %s"), ntag(curs));
894
increment_table_int(memtab, indikey);
898
Check that all listed persons contain family as FAMS as many times
901
tabit = begin_table_iter(memtab);
902
while (next_table_int(tabit, &indikey, &count)) {
903
NODE indi = key_to_indi(indikey);
905
count how many times our main family (fkey)
906
occurs in this person (indi) as a spousal family (FAMS)
909
for (curs = nchild(indi); curs; curs = nsibling(curs)) {
910
if (eqstr(ntag(curs), "FAMS")) {
911
if (eqstr(nval(curs), fkey)) {
916
if (count != occur) {
918
snprintf(msg, sizeof(msg)/sizeof(msg[0])
919
, _("Mismatched lineage spouse links between %s and %s: %ld and %ld")
920
, fkey, indikey, count, occur);
924
destroy_table(memtab);
925
memtab = create_table_int();
928
Make table listing all families this person is child in
929
(& how many times each)
931
for (curs = chil; curs; curs = nsibling(curs)) {
932
indikey = rmvat(nval(curs));
933
if (!eqstr(ntag(curs), "CHIL")) {
935
snprintf(msg, sizeof(msg)/sizeof(msg[0]), _("Bad child tag: %s"), ntag(curs));
938
increment_table_int(memtab, indikey);
942
Check that all listed families contain person as FAMC as many times
945
tabit = begin_table_iter(memtab);
946
while (next_table_int(tabit, &indikey, &count)) {
947
NODE indi = key_to_indi(indikey);
949
count how many times our main family (fkey)
950
occurs in this person (indi) as a parental family (FAMC)
953
for (curs = nchild(indi); curs; curs = nsibling(curs)) {
954
if (eqstr(ntag(curs), "FAMC")) {
955
if (eqstr(nval(curs), fkey)) {
960
if (count != occur) {
962
snprintf(msg, sizeof(msg)/sizeof(msg[0])
963
, _("Mismatched lineage child links between %s and %s: %ld and %ld")
964
, fkey, indikey, count, occur);
970
join_fam(fam, fref, husb, wife, chil, rest);