home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-13 | 48.3 KB | 1,880 lines |
- Newsgroups: comp.sources.misc
- From: murf@oakhill.sps.mot.com (Steve Murphy)
- Subject: v27i073: gcom - GEDCOM genealogical database merge utility, v1, Part02/07
- Message-ID: <1992Jan13.145354.25397@sparky.imd.sterling.com>
- X-Md4-Signature: 34d1e253fba841b322d5877cbd14e9f4
- Date: Mon, 13 Jan 1992 14:53:54 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: murf@oakhill.sps.mot.com (Steve Murphy)
- Posting-number: Volume 27, Issue 73
- Archive-name: gcom/part02
- Environment: SunOS
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # This is part 02 of gcom
- if touch 2>&1 | fgrep 'amc' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= gedcom.b ==============
- echo "x - extracting gedcom.b (Text)"
- sed 's/^X//' << 'SHAR_EOF' > gedcom.b &&
- X%{
- X#ifndef LINT
- Xstatic char rcs_gedcom_id[] = "$Id: gedcom.b,v 1.2 1992/01/03 17:49:44 murf Exp $";
- X#endif
- X/* # Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X
- X#include <stdio.h>
- X#include "gedcom.h"
- Xint lineno;
- Xstruct individ curr_ind;
- Xstruct family curr_fam;
- Xstruct gedfile *curr_file;
- Xstruct submitter curr_submitter;
- Xstruct gheader curr_head;
- Xstruct submitt{char *submitter; char *rel;};
- Xint strcmp();
- Xstatic char rcs_stuff[] = "$Id: gedcom.b,v 1.2 1992/01/03 17:49:44 murf Exp $";
- X%}
- X
- X
- X%union
- X{ int num;
- X char *str;
- X struct datplace *datplace;
- X struct ordinance *ordinance;
- X struct notelist *notelist;
- X struct individ *individ;
- X struct family *family;
- X struct gheader *header;
- X struct submitt *submit;
- X struct child *child;
- X struct submitt *submitt;
- X struct comment *comment;
- X struct stake *stake;
- X struct address *address;
- X}
- X
- X
- X
- X%token <num> DIV LEV0 LEV1 LEV2 LEV3
- X%token <str> ADDR BAPL CHAR COMM CONT DATE DEST ENDL FILE9 FLAG NAME NOTE PHON
- X PLAC QUAL REL SEX SOUR TEMP TITL REF
- X%token <str> BIC NUMB REFN SLGC SLGS
- X
- X
- X%token BIRT BURI CHIL CHR DEAT FAM FAMC FAMS HEAD HUSB INDI MARR STAL TRLR
- X WIFE SUBM
- X%type <datplace> marriage buried death christen datplacitem2
- X birth
- X
- X%type <ordinance> seal2spou endow t_item tempitem3 t_item3
- X tempitem bap c2pseal c2pseal3
- X
- X%type <submitt> submitter2
- X%type <comment> comment ext_list
- X%type <notelist> note
- X%type <child> child
- X%type <address> address
- X%type <stake> stake
- X
- X/* these tokens are unused but part of the GEDCOM definition. If you want to expand the
- Xparser, here are the neccessary defs. Use the big version of the lexical analyzer */
- X
- X/*
- X%token <num> NUM
- X%token <str> AFN CANC EVAL
- X TYPE ASSD ASSI DCHR IBRZ
- X%token <str> ABBR ABY ACTI ACTN ADDI ADMI ADOP AENT AGE AGEF AGEM ALIA ALPH ALSO ANCE ANCI ANUL AREA ASSO
- X ATLA AUTH BAPM BARM BASM BATC BEN BENT BLES BLSL BOOK BRID BYTE CALN CAUS CDAT CEME
- X CENS CHAN CHEC CHEK CIFF CITA CITY CIVI CIVL CLEA CLRK CNTR CO CODE CODI COFN COLO COMP
- X COND CONE CONF CONL COON COOR CORP CORR COST COUN COUP COUR COVE CREA CRFN CRIM CTRY DATA DAU
- X DCR DESC DESI DIR DISC DISK DIVF DOCS DUP DWEL EDUC EMIG EMPL END ENGA ENTR ENUM ENUR EOF9
- X EVEN EXCE EXCO EXEC EXPL EXTD EXTR FAMO FAMP FAMR FATH FCOM FEMA FGR FHC FILM
- X FOFN FOLI FONL FORE FORG FOST FRAM FRFN FROM FSUB FUNC GENE GIVN GNRL GRAD GROO GSC GUAR HAML
- X HAND HDOF HDOH HEAL HEIL HEIR HEPR HIST IBAZ ILLE ILLU IMMI INDE INFA INFL INFO
- X INFT INST IRFN ITEM LANG LAST LATI LDAT LENG LINE LINK LIVE LOC LOCA LOCC LOCD LOCE LOCG LOCH
- X LOCI LOCL LOCM LOCN LOCO LOCQ LOCR LOCS LOCU LOCX LONG LSF LVG MAID MALE MAP MARB MARC MARD MARL
- X MARS MARY MESS MICR MILI MINR MISC MOTH MTD NAMR NAMS NATU NFCI NOTI NULL9
- X NUMP NXTB OBJ OCCU OFFI OLD OPER ORDI ORDL ORDN ORG ORPH OTHE OUT OVER PACK PAGE PARE PARI
- X PART PASL PATC PATR PBRZ PED PEDC PENS PERS PID PIFF POLY PORT POST POVE PREF PRES
- X PREV PRIN PRIO PRNT PROB PROP PROT PROV PROX PRTR PRVB PSUB PUBL PUBR PVMG PVRL QUAY RACE RANG
- X RARS RATI REAL REBA RECD RECO RECR REGD REGI REJE RELI REMA REPO REQD REQU RES RESE RESI
- X RESN REST RETI RFN SBID SCHO SEAR SELF SEQU SERI SERS SERV SHEE SHIP SIBL SIS SLGP SON SORT
- X SPEC SPEI SPEP SPLI SPOU SPUR SREF STAC STAE STAT STDN STIL SUB SUBJ SURN SURO SYMB SYST
- X TAPE TASK TEXT TIME TIMP TMPL TOR TOWC TOWN TRAK TRAN TRAS TWP UDER UNIF UPDA VALU VERI VITA
- X VOID VOIL VOLU WAC WARD WARL WIDO WILL WITN YEAR YOUN YTD
- X%token FAMF SUBN
- X
- X
- X*/
- X
- X
- X
- X%%
- X
- Xfile : header submitter record_list trailer;
- X
- Xheader : LEV0 HEAD { clear_head(); } head_rec_list {curr_file->header = &curr_head; };
- X
- Xhead_rec_list: headrec
- X | head_rec_list headrec;
- X
- Xheadrec: LEV1 SOUR {curr_head.source = $2; }
- X | LEV1 DEST { curr_head.dest = $2; }
- X | LEV1 DATE { curr_head.date = $2; }
- X | LEV1 CHAR { curr_head.charset = $2; }
- X | LEV1 FILE9 {curr_head.file = $2; };
- X
- X submitter: LEV0 REF {clear_submitter();} SUBM subm_list
- X {set_subm(curr_file,$2,&curr_submitter); };
- X
- Xsubm_list: LEV1 submrec {}
- X | subm_list LEV1 submrec{};
- X
- Xsubmrec : NAME { curr_submitter.name = $1; }
- X | PHON { curr_submitter.phone = $1;}
- X | comment { curr_submitter.comments = $1;}
- X | address { curr_submitter.addr = $1;}
- X | stake { curr_submitter.stake = $1;};
- X
- Xaddress : ADDR ext_list { int i;
- X $$ = Calloc(struct address);
- X $$->addr[0] = $1;
- X for(i=0; i< $2->lines; i++)
- X {
- X $$->addr[i+1] = $2->line[i];
- X }
- X $$->num = $2->lines+1;
- X free($2->line);
- X free($2);
- X }
- X | ADDR { $$ = Calloc(struct address);
- X $$->addr[0] = $1;
- X $$->num = 1;};
- X
- Xext_list : LEV2 CONT { $$=Calloc(struct comment);$$->line=(char **)malloc(sizeof(char *)); $$->line[0] = $2; $$->lines=1;}
- X | ext_list LEV2 CONT {$$=$1; $$->line = (char **)realloc($$->line,sizeof(char *) * ($$->lines+1));
- X $$->line[$$->lines++] = $3; };
- X
- Xcomment : COMM ext_list {int i; $$=Calloc(struct comment);$$->line=(char **)malloc(sizeof(char *) * ($2->lines+1));$$->line[0]=$1;
- X for(i=0;i<$2->lines;i++){$$->line[i+1]=$2->line[i]; }$$->lines = $2->lines+1; }
- X | COMM {$$=Calloc(struct comment);$$->line = (char **)malloc(sizeof(char *)); $$->line[0] = $1;$$->lines =1;};
- X
- Xstake: STAL { $$=Calloc(struct stake);}
- X | STAL LEV2 NAME {$$=Calloc(struct stake);$$->name=$3; }
- X | STAL LEV2 NUMB {$$=Calloc(struct stake);$$->num=$3; }
- X | STAL LEV2 NAME LEV2 NUMB {$$=Calloc(struct stake);
- X $$->name = $3;
- X $$->num = $5;}
- X | STAL LEV2 NUMB LEV2 NAME {$$=Calloc(struct stake);
- X $$->name = $5;
- X $$->num = $3;};
- X
- Xrecord_list: record { }
- X | record_list record { };
- X
- Xrecord : individual_rec { }
- X | fam_rec { };
- X
- Xindividual_rec : LEV0 REF INDI {clear_indi(); } indiv_stuff_list
- X {set_ind(curr_file,$2,&curr_ind); };
- X
- Xindiv_stuff_list : LEV1 indivrec { }
- X | indiv_stuff_list LEV1 indivrec { };
- X
- Xindivrec : NAME { curr_ind.name = $1; }
- X | TITL { curr_ind.title = $1;}
- X | SEX { curr_ind.sex = ($1[0]? $1[0]:($1[1]? $1[1]: 'x'));
- X if( curr_ind.sex != 'M' && curr_ind.sex != 'F' )
- X fprintf(stderr,"Sex (%c) indecipherable line %d\n", curr_ind.sex,lineno);}
- X | REFN { curr_ind.givenref = $1;}
- X | birth { curr_ind.birth = $1;}
- X | christen { curr_ind.christen = $1;}
- X | death { curr_ind.death = $1;}
- X | buried { curr_ind.burial = $1;}
- X | bap { curr_ind.baptism = $1;}
- X | endow { curr_ind.endow = $1;}
- X | c2pseal { curr_ind.child_to_parent = $1;}
- X | FLAG { curr_ind.flag = $1;}
- X | FAMS REF { add_spouse(&curr_ind,$2); }
- X | FAMC REF { curr_ind.famc = $2;}
- X | submitter2 { curr_ind.submitter = $1->submitter;curr_ind.submitter_rel = $1->rel;}
- X | DEST { curr_ind.destination_flag = $1;}
- X | note { if(curr_ind.notes){
- X /* merge notes */
- X curr_ind.notes->notes++; /* increment the num of notes */
- X curr_ind.notes->note = (struct comment *)realloc(curr_ind.notes->note,sizeof(struct comment)*curr_ind.notes->notes);
- X curr_ind.notes->note[curr_ind.notes->notes-1].lines = $1->note[0].lines;
- X curr_ind.notes->note[curr_ind.notes->notes-1].line = $1->note[0].line;
- X $1->note[0].line = 0;
- X free($1->note[0]);
- X free($1);
- X } else {
- X /* stick in */
- X curr_ind.notes = $1;
- X }};
- Xbirth: BIRT datplacitem2 { $$ = $2; };
- X
- Xdatplacitem2 : LEV2 DATE {$$ = Calloc(struct datplace); $$->date = $2; }
- X | LEV2 PLAC {$$ = Calloc(struct datplace); $$->place = $2; }
- X | LEV2 DATE LEV2 PLAC {$$ = Calloc(struct datplace); $$->place = $4;$$->date = $2; }
- X | LEV2 PLAC LEV2 DATE {$$ = Calloc(struct datplace); $$->place = $2;$$->date = $4; };
- X
- Xchristen: CHR datplacitem2 {$$=$2; };
- X
- Xdeath: DEAT datplacitem2 {$$=$2; };
- X
- Xburied: BURI datplacitem2 {$$=$2; };
- X
- Xbap: BAPL tempitem { $$=$2; $$->val = $1;}
- X | BAPL { $$= Calloc(struct ordinance); $$->val = $1;};
- X
- Xtempitem : t_item {$$=$1; }
- X | tempitem t_item { $$ =$1;
- X copytempitem($$,$2);};
- X
- Xt_item : LEV2 DATE { $$ = Calloc(struct ordinance); $$->date=$2;}
- X | LEV2 TEMP { $$ = Calloc(struct ordinance); strcpy($$->temp,$2);}
- X | LEV2 QUAL { $$ = Calloc(struct ordinance); $$->qual=$2;};
- X
- Xtempitem3 : t_item3 {$$=$1; }
- X | tempitem3 t_item3 {$$ =$1;
- X copytempitem($$,$2); };
- X
- Xt_item3 : LEV3 DATE { $$ = Calloc(struct ordinance); $$->date=$2; }
- X | LEV3 TEMP { $$ = Calloc(struct ordinance); strcpy($$->temp,$2); }
- X | LEV3 QUAL { $$ = Calloc(struct ordinance); $$->qual=$2; };
- X
- Xendow: ENDL tempitem { $$=$2; $$->val = $1; }
- X | ENDL {$$= Calloc(struct ordinance); $$->val = $1; };
- X
- Xc2pseal: SLGC tempitem { $$=$2;$$->val = $1; }
- X | SLGC {$$= Calloc(struct ordinance); $$->val = $1;};
- X
- Xc2pseal3: SLGC { $$=Calloc(struct ordinance); $$->val = $1;}
- X | SLGC tempitem3 {$$=$2; $$->val = $1; };
- X
- Xsubmitter2: SUBM REF {$$=Calloc(struct submitt); $$->submitter = $2; }
- X | SUBM REF LEV2 REL {$$=Calloc(struct submitt); $$->submitter = $2; $$->rel = $4; };
- X
- Xnote: NOTE { $$=Calloc(struct notelist); $$->note=Calloc(struct comment); $$->note[0].lines=1;
- X $$->note[0].line = Calloc(char *); $$->note[0].line[0] = $1; $$->notes=1;$$->note[0].lines = 1;}
- X | NOTE ext_list {int i;
- X $$=Calloc(struct notelist);
- X $$->note=$2;
- X $$->note[0].line = (char **)realloc($$->note[0].line,sizeof(char *)*($2->lines+1));
- X $$->notes=1;
- X for(i=$2->lines; i; i--)
- X {$2->line[i]=$2->line[i-1];}
- X $2->line[0] = $1;$2->lines++;};
- X
- X
- X
- Xfam_rec: LEV0 REF {clear_fam();} FAM fam_stuff_list
- X {set_fam(curr_file,$2,&curr_fam);};
- X
- Xfam_stuff_list : LEV1 famrec { }
- X | fam_stuff_list LEV1 famrec { };
- X
- Xfamrec: HUSB REF {curr_fam.husb = $2; }
- X | WIFE REF {curr_fam.wife = $2; }
- X | child { add_child(&curr_fam, $1); }
- X | marriage {curr_fam.marriage = $1; }
- X | seal2spou {curr_fam.sealspouse = $1; }
- X | DIV {curr_fam.divorce = 1; }
- X | DEST { curr_fam.dest = $1;}
- X | FLAG { curr_fam.flag = $1;}
- X | submitter2 { curr_fam.submitter = $1->submitter;
- X curr_fam.submitter_rel = $1->rel;};
- X
- Xchild : CHIL REF { $$=Calloc(struct child);$$->ref=$2;}
- X | CHIL REF LEV2 c2pseal3 {$$=Calloc(struct child);$$->ref = $2; $$->slgc =$4; };
- X
- Xmarriage: MARR datplacitem2 {$$=$2; };
- X
- Xseal2spou : SLGS tempitem {$$=$2; $$->val = $1;}
- X | SLGS {$$= Calloc(struct ordinance); $$->val = $1; };
- X
- Xtrailer: LEV0 TRLR{};
- X
- X%%
- Xvoid copytempitem(a,b)
- Xstruct ordinance *a,*b;
- X{
- X if( b->val )
- X a->val = b->val;
- X if(b->date)
- X a->date = b->date;
- X if(b->temp[0] )
- X strcpy(a->temp,b->temp);
- X if(b->qual)
- X a->qual = b->qual;
- X free(b);
- X}
- X
- Xvoid clear_indi()
- X{
- X curr_ind.name = 0;
- X curr_ind.title = 0;
- X curr_ind.sex = 0;
- X curr_ind.givenref = 0;
- X curr_ind.birth = 0;
- X curr_ind.christen = 0;
- X curr_ind.death = 0;
- X curr_ind.burial = 0;
- X curr_ind.baptism = 0;
- X curr_ind.endow = 0;
- X curr_ind.child_to_parent = 0;
- X curr_ind.flag = 0;
- X curr_ind.fams = 0;
- X curr_ind.famc = 0;
- X curr_ind.submitter = 0;
- X curr_ind.submitter_rel = 0;
- X curr_ind.destination_flag = 0;
- X curr_ind.notes = 0;
- X}
- X
- Xstatic int add_ind(ged,ip)
- Xstruct gedfile *ged;
- Xstruct individ *ip;
- X{
- X struct indivlist *x=ged->indlist;
- X if( !ged->indlist )
- X x = ged->indlist = Calloc(struct indivlist);
- X if( !x->allocd )
- X {
- X x->allocd += 20;
- X x->ind = Callocs(struct individ *,20);
- X }
- X if( x->num == x->allocd )
- X {
- X x->allocd += 20;
- X x->ind = (struct individ **)realloc(x->ind,x->allocd*sizeof(struct individ *));
- X }
- X ip->index = x->num;
- X x->ind[x->num++] = ip;
- X return ip->index;
- X}
- X
- Xstruct individ *set_ind(ged,ref,curr_in)
- Xstruct gedfile *ged;
- Xchar *ref;
- Xstruct individ *curr_in;
- X{
- X struct individ *ind;
- X
- X if( !ged->indiv )
- X {
- X ged->indiv = st_init_table(strcmp,st_strhash);
- X }
- X ind = Calloc(struct individ);
- X *ind = *curr_in;
- X st_insert(ged->indiv,ref,(char *)ind);
- X ind->ref = ref;
- X add_ind(ged,ind);
- X return ind;
- X}
- X
- Xvoid clear_fam()
- X{
- X curr_fam.husb = 0;
- X curr_fam.wife = 0;
- X curr_fam.kids = 0;
- X curr_fam.marriage = 0;
- X curr_fam.sealspouse = 0;
- X curr_fam.divorce = 0;
- X curr_fam.dest = 0;
- X curr_fam.flag = 0;
- X curr_fam.submitter = 0;
- X curr_fam.submitter_rel = 0;
- X}
- Xstruct family *set_fam(ged,ref,curr_fa)
- Xchar *ref;
- Xstruct gedfile *ged;
- Xstruct family *curr_fa;
- X{
- X struct family *fam;
- X
- X if( !ged->families )
- X {
- X ged->families = st_init_table(strcmp,st_strhash);
- X }
- X fam = Calloc(struct family);
- X *fam = *curr_fa;
- X st_insert(ged->families,ref,(char *)fam);
- X fam->ref = ref;
- X add_fam(ged,fam);
- X return fam;
- X}
- X
- Xstatic int add_fam(ged,fp)
- Xstruct family *fp;
- Xstruct gedfile *ged;
- X{
- X struct famlylist *x=ged->famlist;
- X if( !ged->famlist )
- X x = ged->famlist = Calloc(struct famlylist);
- X if( !x->allocd )
- X {
- X x->allocd += 20;
- X x->fam = Callocs(struct family *,20);
- X }
- X if( x->num == x->allocd )
- X {
- X x->allocd += 20;
- X x->fam = (struct family **)realloc(x->fam,x->allocd*sizeof(struct family *));
- X }
- X fp->index = x->num;
- X x->fam[x->num++] = fp;
- X return fp->index;
- X}
- X
- Xvoid clear_head() /* blow nose? */
- X{
- X curr_head.source = 0;
- X curr_head.dest = 0;
- X curr_head.date = 0;
- X curr_head.file = 0;
- X curr_head.charset = 0;
- X}
- X
- Xvoid add_submitter(ged,ip)
- Xstruct submitter *ip;
- Xstruct gedfile *ged;
- X{
- X struct submitlist *x=ged->submitlist;
- X if( !ged->submitlist )
- X x = ged->submitlist = Calloc(struct submitlist);
- X if( !x->allocd )
- X {
- X x->allocd += 20;
- X x->subm = Callocs(struct submitter *,20);
- X }
- X if( x->num == x->allocd )
- X {
- X x->allocd += 20;
- X x->subm = (struct submitter **)realloc(x->subm,x->allocd*sizeof(struct submitter *));
- X }
- X ip->index = x->num;
- X x->subm[x->num++] = ip;
- X}
- Xvoid set_subm(ged,ref,curr_submitte)
- Xchar *ref;
- Xstruct gedfile *ged;
- Xstruct submitter *curr_submitte;
- X{
- X struct submitter *ind;
- X
- X if( !ged->submits )
- X {
- X ged->submits = st_init_table(strcmp,st_strhash);
- X }
- X ind = Calloc(struct submitter);
- X *ind = *curr_submitte;
- X st_insert(ged->submits,ref,(char *)ind);
- X add_submitter(ged,ind);
- X}
- X
- Xvoid clear_submitter()
- X{
- X curr_submitter.name = 0;
- X curr_submitter.addr = 0;
- X curr_submitter.phone = 0;
- X curr_submitter.stake = 0;
- X curr_submitter.comments = 0;
- X curr_submitter.index = 0;
- X}
- X
- Xvoid clear_gedfile()
- X{
- X curr_file->header = 0;
- X curr_file->submission = 0;
- X curr_file->indiv = 0;
- X curr_file->families = 0;
- X curr_file->submits = 0;
- X curr_file->indlist = 0;
- X curr_file->famlist = 0;
- X curr_file->submitlist = 0;
- X}
- X
- X
- Xvoid yyerror(s)
- Xchar *s;
- X{
- X extern int lineno;
- X fprintf(stderr,"Parse error in line %d\n",lineno);
- X}
- X
- Xadd_spouse(ind,ref)
- Xstruct individ *ind;
- Xchar *ref;
- X{
- X if( !ind->fams)
- X {
- X ind->fams = Calloc(struct famlist);
- X ind->fams->family_refs = (char **)malloc(sizeof(char *));
- X ind->fams->family_refs[ind->fams->num++] = ref;
- X }
- X else
- X {
- X ind->fams->family_refs = (char **)
- X realloc(ind->fams->family_refs,
- X sizeof(char *)*(ind->fams->num+1));
- X ind->fams->family_refs[ind->fams->num++] = ref;
- X }
- X}
- X
- Xadd_child(fam,chil)
- Xstruct family *fam;
- Xstruct child *chil;
- X{
- X if(!fam->kids)
- X {
- X fam->kids=Calloc(struct child_list);
- X fam->kids->kid=Calloc(struct child);
- X fam->kids->kid[0] = *chil;
- X fam->kids->kids=1;
- X }
- X else
- X {
- X fam->kids->kid=(struct child *)realloc(fam->kids->kid,
- X sizeof(struct child)*(fam->kids->kids+1));
- X fam->kids->kid[fam->kids->kids++] = *chil;
- X }
- X}
- SHAR_EOF
- $TOUCH -am 0103114992 gedcom.b &&
- chmod 0664 gedcom.b ||
- echo "restore of gedcom.b failed"
- set `wc -c gedcom.b`;Wc_c=$1
- if test "$Wc_c" != "15467"; then
- echo original size 15467, current size $Wc_c
- fi
- # ============= gedcom.h ==============
- echo "x - extracting gedcom.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > gedcom.h &&
- X/* $Id: gedcom.h,v 1.2 1992/01/03 17:49:46 murf Exp $ */
- X/*
- X# Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X
- X#include "st.h"
- X#define Calloc(x) (x *)calloc(sizeof(x),1)
- X#define Callocs(x,n) (x *)calloc(sizeof(x),n)
- X
- X#ifdef macintosh
- X#define const const
- X#else
- X#define const
- X#endif
- X
- X
- Xstruct datplace
- X{
- X char *date;
- X char *place;
- X};
- X
- Xstruct ordinance
- X{
- X char *val;
- X char *date;
- X char temp[4];
- X char *qual;
- X};
- X
- Xstruct address
- X{
- X int num;
- X char *addr[4];
- X};
- X
- Xstruct stake
- X{
- X char *name;
- X char *num;
- X};
- X
- Xstruct comment
- X{
- X int lines;
- X char **line; /* a ptr to an array of char ptrs. */
- X};
- X
- Xstruct notelist
- X{
- X int notes;
- X struct comment *note; /* an array of comment structs */
- X};
- X
- Xstruct gedfile
- X{
- X struct gheader *header;
- X struct submission *submission;
- X st_table *families, *indiv,*submits;
- X struct indivlist *indlist;
- X struct famlylist *famlist;
- X struct submitlist *submitlist;
- X};
- X
- Xstruct gheader
- X{
- X char *source;
- X char *dest;
- X char *date;
- X const char *file;
- X char *charset;
- X};
- X
- Xstruct indivlist
- X{
- X struct individ **ind;
- X int num;
- X int allocd;
- X};
- X
- Xstruct corresponds
- X{
- X char match_ind;
- X char match_fam;
- X int index;
- X char add;
- X};
- X
- Xstruct individ
- X{
- X char *name;
- X char *title;
- X char sex;
- X char *givenref;
- X struct datplace *birth;
- X struct datplace *christen;
- X struct datplace *death;
- X struct datplace *burial;
- X struct ordinance *baptism;
- X struct ordinance *endow;
- X struct ordinance *child_to_parent;
- X char *flag;
- X struct famlist *fams;
- X char *famc;
- X char *submitter;
- X char *submitter_rel;
- X char *destination_flag;
- X struct notelist *notes;
- X int index;
- X struct corresponds corr;
- X char *ref;
- X};
- X
- Xstruct child_list
- X{
- X int kids;
- X struct child *kid; /* a ptr is also potentially an array ptr, as is this case */
- X};
- X
- Xstruct child
- X{
- X char *ref;
- X struct ordinance *slgc;
- X};
- X
- Xstruct famlist
- X{
- X int num;
- X char **family_refs; /*An array of ptrs to namerefs */
- X};
- X
- Xstruct family
- X{
- X char *husb;
- X char *wife;
- X struct child_list *kids;
- X struct datplace *marriage;
- X struct ordinance *sealspouse;
- X char divorce;
- X char *dest;
- X char *flag;
- X char *submitter;
- X char *submitter_rel;
- X int index;
- X struct corresponds corr;
- X char *ref;
- X};
- X
- Xstruct famlylist
- X{
- X struct family **fam;
- X int num;
- X int allocd;
- X};
- X
- Xstruct submitter
- X{
- X char *name;
- X struct address *addr;
- X char *phone;
- X struct stake *stake;
- X struct comment *comments;
- X int index;
- X};
- X
- Xstruct submitlist
- X{
- X struct submitter **subm;
- X int num;
- X int allocd;
- X};
- X
- Xstruct submission
- X{
- X char *type;
- X struct comment *comments;
- X char *indi_ref;
- X char *fam_ref;
- X char *eval;
- X char *submitter_name;
- X struct address *submitter_addr;
- X char *submitter_phone;
- X char *fam_file;
- X char *temple;
- X char bapl;
- X char endl;
- X char slgc;
- X char slgs;
- X};
- Xextern struct gedfile *curr_file;
- X#ifdef macintosh
- X/* here is a list of function decls that the compiler will
- X appreciate */
- Xvoid copytempitem(struct ordinance *,struct ordinance *);
- Xvoid clear_indi();
- Xstruct individ *set_ind(char *);
- Xvoid clear_fam();
- Xstruct family *add_fam(struct family *);
- Xvoid clear_head();
- Xvoid add_submitter(struct submitter *);
- Xvoid set_subm(char *);
- Xvoid clear_submitter();
- Xvoid clear_gedfile();
- Xvoid yyerror(char *);
- Xint main(int, char **);
- Xint group_tree(struct gedfile *);
- Xvoid find_correspondence(struct gedfile *, struct gedfile *);
- Xvoid merge_strings(char **,char **,char *);
- Xvoid merge_datplace(struct datplace **,struct datplace **);
- Xvoid merge_ordinance(struct ordinance **a,struct ordinance **);
- Xvoid merge_children(struct child_list **,struct child_list **);
- Xvoid remove_child(struct child_list *, int);
- Xvoid merge_notes(struct notelist **, struct notelist **);
- Xvoid merge_address(struct address **,struct address**);
- Xvoid merge_stake(struct stake **,struct stake **);
- Xvoid merge_comment(struct comment **,struct comment **);
- Xint same_individual(struct individ *,struct individ *);
- Xvoid merge_famlist(struct famlist **,struct famlist **);
- Xvoid merge_individ(struct individ *,struct individ *);
- Xvoid write_gedfile(struct gedfile *);
- Xvoid write_header(FILE *,struct gheader *);
- Xvoid write_submits(FILE *,struct submitlist *);
- Xvoid write_address(FILE *,struct address *);
- Xvoid write_stake(FILE *, struct stake *);
- Xvoid write_comments(FILE *,struct comment *);
- Xvoid write_notes(FILE *,struct notelist *);
- Xvoid write_individs(FILE *,struct indivlist *);
- Xvoid write_ind(FILE *, struct individ *);
- Xvoid write_datplace(FILE *,int, char *, struct datplace *);
- Xvoid write_ordinance(FILE *,int,char *, struct ordinance *);
- Xvoid write_fams(FILE *,struct famlylist *);
- Xint deref_ind(char *);
- Xvoid write_fam(FILE *,struct family *);
- X#else
- X/* here is a list of function decls that the compiler will
- X appreciate */
- Xvoid copytempitem();
- Xvoid clear_indi();
- Xstruct individ *set_ind();
- Xvoid clear_fam();
- Xstruct family *set_fam();
- Xvoid clear_head();
- Xvoid add_submitter();
- Xvoid set_subm();
- Xvoid clear_submitter();
- Xvoid clear_gedfile();
- Xvoid yyerror();
- Xint main();
- Xint group_tree();
- Xvoid find_correspondence();
- Xvoid merge_strings();
- Xvoid merge_datplace();
- Xvoid merge_ordinance();
- Xvoid merge_children();
- Xvoid remove_child();
- Xvoid merge_notes();
- Xvoid merge_address();
- Xvoid merge_stake();
- Xvoid merge_comment();
- Xint same_individual();
- Xvoid merge_famlist();
- Xvoid merge_individ();
- Xvoid write_gedfile();
- Xvoid write_header();
- Xvoid write_submits();
- Xvoid write_address();
- Xvoid write_stake();
- Xvoid write_comments();
- Xvoid write_notes();
- Xvoid write_individs();
- Xvoid write_ind();
- Xvoid write_datplace();
- Xvoid write_ordinance();
- Xvoid write_fams();
- Xint deref_ind();
- Xvoid write_fam();
- X#endif
- SHAR_EOF
- $TOUCH -am 0103114992 gedcom.h &&
- chmod 0664 gedcom.h ||
- echo "restore of gedcom.h failed"
- set `wc -c gedcom.h`;Wc_c=$1
- if test "$Wc_c" != "6187"; then
- echo original size 6187, current size $Wc_c
- fi
- # ============= gedwrite.c ==============
- echo "x - extracting gedwrite.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > gedwrite.c &&
- Xstatic char rcs_stuff[] = "$Id: gedwrite.c,v 1.2 1992/01/03 17:49:56 murf Exp $";
- X#include <stdio.h>
- X#include "gedcom.h"
- X#include <string.h>
- X/*
- X# Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X
- X/* output routines */
- Xstatic struct gedfile *curr_fileg;
- X
- Xvoid write_gedfile(gf)
- Xstruct gedfile *gf;
- X{
- X FILE *f;
- X f = fopen(gf->header->file,"w");
- X if( !f )
- X {
- X fprintf(stderr,"Couldn't open %s for writing!\n", gf->header->file);
- X return;
- X }
- X curr_fileg = gf;
- X write_header(f,gf->header);
- X write_submits(f,gf->submitlist);
- X write_individs(f,gf->indlist);
- X write_fams(f,gf->famlist);
- X fprintf(f,"0 TRLR\n");
- X fclose(f);
- X}
- X
- Xvoid write_header(f,h)
- XFILE *f;
- Xstruct gheader *h;
- X{
- X
- X fprintf(f,"0 HEAD\n");
- X if( h->source )
- X fprintf(f,"1 SOUR %s\n",h->source);
- X if(h->dest)
- X fprintf(f,"1 DEST %s\n",h->dest);
- X if(h->date)
- X fprintf(f,"1 DATE %s\n",h->date);
- X if(h->file)
- X fprintf(f,"1 FILE %s\n",h->file);
- X if(h->charset)
- X fprintf(f,"1 CHAR %s\n",h->charset);
- X}
- X
- Xvoid write_submits(f,s)
- XFILE *f;
- Xstruct submitlist *s;
- X{
- X int i;
- X for(i=0; i< s->num; i++)
- X {
- X fprintf(f,"0 @S%d@ SUBM\n",i);
- X if( s->subm[i]->name )
- X fprintf(f,"1 NAME %s\n",s->subm[i]->name);
- X write_address(f,s->subm[i]->addr);
- X if( s->subm[i]->phone )
- X fprintf(f,"1 PHON %s\n",s->subm[i]->phone);
- X write_stake(f,s->subm[i]->stake );
- X write_comments(f,s->subm[i]->comments);
- X }
- X}
- X
- Xvoid write_address(f,a)
- XFILE *f;
- Xstruct address *a;
- X{
- X int i;
- X if( !a )
- X return;
- X
- X fprintf(f,"1 ADDR %s\n", a->addr[0]);
- X for(i=1; i< a->num; i++)
- X {
- X fprintf(f,"2 CONT %s\n", a->addr[i]);
- X }
- X}
- X
- Xvoid write_stake(f,s)
- XFILE *f;
- Xstruct stake *s;
- X{
- X if( !s)
- X return;
- X
- X fprintf(f,"1 STAL\n");
- X if( s->name )
- X fprintf(f,"2 NAME %s\n", s->name);
- X if( s->num )
- X fprintf(f,"2 NUMB %d\n",s->num);
- X}
- X
- Xvoid write_comments(f,c)
- XFILE *f;
- Xstruct comment *c;
- X{
- X int i;
- X
- X if( !c )
- X return;
- X fprintf(f,"1 COMM %s\n", c->line[0]);
- X for(i=1; i< c->lines; i++)
- X {
- X fprintf(f,"2 CONT %s\n",c->line[1]);
- X }
- X}
- X
- Xvoid write_notes(f,n)
- XFILE *f;
- Xstruct notelist *n;
- X{
- X int i,j;
- X if( !n )
- X return;
- X for(i=0; i< n->notes; i++)
- X {
- X fprintf(f,"1 NOTE %s\n", n->note[i].line[0]);
- X for(j=1; j< n->note[i].lines; j++)
- X {
- X fprintf(f,"2 CONT %s\n",n->note[i].line[j]);
- X }
- X }
- X}
- X
- Xvoid write_individs(f,indl)
- XFILE *f;
- Xstruct indivlist *indl;
- X{
- X int i;
- X struct individ *in;
- X
- X for(i = 0; i< indl->num; i++ )
- X {
- X write_ind(f,indl->ind[i]);
- X }
- X}
- X
- Xvoid write_ind(f,in)
- XFILE *f;
- Xstruct individ *in;
- X{
- X fprintf(f,"0 @I%d@ INDI\n", in->index);
- X if( in->name )
- X fprintf(f,"1 NAME %s\n", in->name);
- X if( in->title )
- X fprintf(f,"1 TITL %s\n", in->title);
- X if( in->sex == 'M' || in->sex == 'F' )
- X fprintf(f,"1 SEX %c\n",in->sex);
- X if( in->givenref )
- X fprintf(f,"1 REFN %s\n", in->givenref);
- X write_datplace(f,1,"BIRT",in->birth);
- X write_datplace(f,1,"CHR",in->christen);
- X write_datplace(f,1,"DEAT",in->death);
- X write_datplace(f,1,"BURI",in->burial);
- X write_ordinance(f,1,"BAPL",in->baptism);
- X write_ordinance(f,1,"ENDL", in->endow);
- X write_ordinance(f,1,"SLGC",in->child_to_parent);
- X if( in->flag )
- X fprintf(f,"1 FLAG %s\n", in->flag);
- X if( in->fams )
- X {
- X int i;
- X for(i=0; i<in->fams->num; i++)
- X {
- X struct family *fm;
- X st_lookup(curr_fileg->families, in->fams->family_refs[i],(char **)&fm);
- X fprintf(f,"1 FAMS @F%d@\n", fm->index);
- X }
- X }
- X if( in->famc )
- X {
- X struct family *fm;
- X st_lookup(curr_fileg->families, in->famc,(char **)&fm);
- X fprintf(f,"1 FAMC @F%d@\n",fm->index);
- X }
- X if( in->submitter )
- X {
- X struct submitter *s;
- X st_lookup(curr_fileg->submits, in->submitter,(char **)&s);
- X fprintf(f,"1 SUBM @S%d@\n", s->index);
- X if( in->submitter_rel )
- X fprintf(f,"2 REL %s\n", in->submitter_rel);
- X }
- X if( in->destination_flag )
- X fprintf(f,"1 DEST %s\n", in->destination_flag);
- X write_notes(f,in->notes);
- X}
- X
- Xvoid write_datplace(f,lev,tag,ptr)
- XFILE *f;
- Xint lev;
- Xchar *tag;
- Xstruct datplace *ptr;
- X{
- X if( ptr )
- X {
- X fprintf(f,"%d %s\n", lev, tag);
- X if(ptr->date)
- X fprintf(f,"%d DATE %s\n", lev+1, ptr->date);
- X if(ptr->place)
- X fprintf(f,"%d PLAC %s\n", lev+1, ptr->place);
- X }
- X}
- X
- Xvoid write_ordinance(f,lev,tag,ptr)
- XFILE *f;
- Xint lev;
- Xchar *tag;
- Xstruct ordinance *ptr;
- X{
- X if( ptr )
- X {
- X if( ptr->val )
- X fprintf(f,"%d %s %s\n", lev, tag, ptr->val);
- X else
- X fprintf(f,"%d %s\n", lev, tag);
- X if(ptr->date)
- X fprintf(f,"%d DATE %s\n", lev+1, ptr->date);
- X if(ptr->temp[0])
- X fprintf(f,"%d TEMP %s\n", lev+1, ptr->temp);
- X if(ptr->qual)
- X fprintf(f,"%d QUAL %s\n", lev+1, ptr->qual);
- X }
- X}
- X
- Xvoid write_fams(f,faml)
- XFILE *f;
- Xstruct famlylist *faml;
- X{
- X int i;
- X struct family *fm;
- X
- X for(i = 0; i< faml->num; i++ )
- X {
- X write_fam(f,faml->fam[i]);
- X }
- X}
- X
- Xint deref_ind(ref)
- Xchar *ref;
- X{
- X struct individ *i;
- X st_lookup(curr_fileg->indiv, ref, (char **)&i);
- X return i->index;
- X}
- X
- Xvoid write_fam(f,fm)
- XFILE *f;
- Xstruct family *fm;
- X{
- X int i;
- X
- X fprintf(f,"0 @F%d@ FAM\n", fm->index);
- X if( fm->husb )
- X fprintf(f,"1 HUSB @I%d@\n", deref_ind(fm->husb));
- X if( fm->wife )
- X fprintf(f,"1 WIFE @I%d@\n", deref_ind(fm->wife));
- X if( fm->kids )
- X {
- X for(i=0; i< fm->kids->kids; i++)
- X {
- X struct child *c;
- X c = &fm->kids->kid[i];
- X fprintf(f,"1 CHIL @I%d@\n", deref_ind(c->ref));
- X write_ordinance(f,2,"SLGC",c->slgc);
- X }
- X }
- X write_datplace(f,1,"MARR",fm->marriage);
- X if( fm->divorce )
- X fprintf(f,"1 DIV Y\n", fm->divorce);
- X if( fm->dest )
- X fprintf(f,"1 DEST %s\n", fm->dest);
- X if( fm->flag )
- X fprintf(f,"1 FLAG %s\n", fm->flag);
- X if( fm->submitter )
- X {
- X struct submitter *s;
- X st_lookup(curr_fileg->submits, fm->submitter,(char **)&s);
- X fprintf(f,"1 SUBM @S%d@\n", s->index);
- X if( fm->submitter_rel )
- X fprintf(f,"2 REL %s\n", fm->submitter_rel);
- X }
- X}
- X
- SHAR_EOF
- $TOUCH -am 0103114992 gedwrite.c &&
- chmod 0664 gedwrite.c ||
- echo "restore of gedwrite.c failed"
- set `wc -c gedwrite.c`;Wc_c=$1
- if test "$Wc_c" != "6455"; then
- echo original size 6455, current size $Wc_c
- fi
- # ============= gedcom.lex ==============
- echo "x - extracting gedcom.lex (Text)"
- sed 's/^X//' << 'SHAR_EOF' > gedcom.lex &&
- X%{
- X/*
- X# Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X#include <stdio.h>
- X#include <string.h>
- X#include "gedcom.b.tab.h"
- Xextern int lineno;
- Xstatic char rcs_stuff[] = "$Id: gedcom.lex,v 1.2 1992/01/03 17:49:48 murf Exp $";
- X/* below follows a list of all the tokens allowed in GEDCOM files */
- X
- X%}
- Xoptfield ([ ].+)?$
- X
- X%%
- XBIC { return BIC; }
- XSTILLBORN { return STILLBORN;}
- XCLEARED { return CLEARED; }
- XUNCLEARED { return UNCLEARED; }
- XDNS { return DNS; }
- XSEENOTES { return SEENOTES; }
- XSUBMITTED { return SUBMITTED; }
- XCOMPLETED { return COMPLETED; }
- XCHILD { return CHILD; }
- XINFANT { return INFANT; }
- XCANCELLED { return CANCELLED; }
- XDNS/CAN { return DNSCAN; }
- XADDR[ ].+$ { setyystr(yytext); return ADDR;}
- XBAPL([ ].+$)? {setyystr(yytext);return BAPL;}
- XBIC{optfield} { setyystr(yytext); return BIC;}
- XBIRT {return BIRT;}
- XBURI {return BURI;}
- XCHAR[ ].*$ {setyystr(yytext); return CHAR;}
- XCHIL {return CHIL;}
- XCHR {return CHR;}
- XCOMM[ ].*$ {setyystr(yytext); return COMM;}
- XCONT[ ].*$ {setyystr(yytext); return CONT;}
- XDATE[ ].*$ {setyystr(yytext); return DATE;}
- XDEAT {return DEAT;}
- XDEST[ ].*$ {setyystr(yytext); return DEST;}
- XDIV[ ].*$ {if( yytext[4] == 'Y' ) yylval.num =1;
- X else yylval.num = 0; return DIV;}
- XENDL {return ENDL;}
- XFAM {return FAM;}
- XFAMC {return FAMC;}
- XFAMS {return FAMS;}
- XFILE[ ].*$ {setyystr(yytext); return FILE9;}
- XFLAG.+$ {setyystr(yytext); return FLAG;}
- XHEAD {return HEAD;}
- XHUSB {return HUSB;}
- XINDI {return INDI;}
- XMARR {return MARR;}
- XNAME[ ].*$ {setyystr(yytext); return NAME;}
- XNOTE[ ].*$ {setyystr(yytext); return NOTE;}
- XNUMB[ ].*$ {yylval.num = atoi(yytext+6); return NOTE;}
- XPHON[ ].*$ {setyystr(yytext); return PHON;}
- XPLAC[ ].*$ {setyystr(yytext); return PLAC;}
- XQUAL.*$ {setyystr(yytext); return QUAL;}
- XREFN{optfield} { setyystr(yytext); return REFN;}
- XREL[ ].*$ {setyystr(yytext); return REL;}
- XSEX[ ].*$ {setyystr(yytext); return SEX;}
- XSLGC {return SLGC;}
- XSLGS {return SLGS;}
- XSOUR[ ].*$ {setyystr(yytext); return SOUR;}
- XSTAL {return STAL;}
- XSUBM {return SUBM;}
- XTEMP[ ].+$ {setyystr(yytext); return TEMP;}
- XTITL[ ].*$ {setyystr(yytext); return TITL;}
- XTRLR {return TRLR;}
- XWIFE {return WIFE;}
- X@[^@]+@ {int x;
- X x = strlen(yytext);
- X yylval.str = (char *)malloc(x);
- X strncpy(yylval.str,yytext+1,x-2);
- X yylval.str[x-2]=0;
- X return REF;}
- X^0 {yylval.num = 0; return LEV0; }
- X^1 {yylval.num = 0; return LEV1; }
- X^2 {yylval.num = 0; return LEV2; }
- X^3 {yylval.num = 0; return LEV3; }
- X^[4-9]+ {yylval.num = atoi(yytext); return LEV3;}
- X\n {lineno++;}
- X[ ]* {}
- X%%
- Xsetyystr(txt)
- Xchar *txt;
- X{
- X int x=strlen(txt);
- X char *y = txt;
- X while( *y && *y != ' ' )
- X y++;
- X if( *y )
- X {
- X /* there is a space */
- X x -= (y-txt);
- X y++;
- X yylval.str = (char *)malloc(x);
- X strcpy(yylval.str,y);
- X }
- X else
- X yylval.str = "";
- X}
- SHAR_EOF
- $TOUCH -am 0103114992 gedcom.lex &&
- chmod 0664 gedcom.lex ||
- echo "restore of gedcom.lex failed"
- set `wc -c gedcom.lex`;Wc_c=$1
- if test "$Wc_c" != "3522"; then
- echo original size 3522, current size $Wc_c
- fi
- # ============= mylex.c ==============
- echo "x - extracting mylex.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > mylex.c &&
- Xstatic char rcs_stuff[] = "$Id: mylex.c,v 1.2 1992/01/03 17:49:59 murf Exp $";
- X#include <stdio.h>
- X#include "gedcom.b.tab.h"
- X/*
- X# Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X
- XFILE *yyin;
- X
- Xstruct keyword
- X{
- X char *name;
- X int val;
- X};
- X
- Xstatic struct keyword keylist[] =
- X{
- X {"ADDR",ADDR},
- X {"BAPL",BAPL},
- X {"CHAR",CHAR},
- X {"COMM",COMM},
- X {"CONT",CONT},
- X {"DATE",DATE},
- X {"DEST",DEST},
- X {"ENDL",ENDL},
- X {"FILE",FILE9},
- X {"FLAG",FLAG},
- X {"NAME",NAME},
- X {"NOTE",NOTE},
- X {"PHON",PHON},
- X {"PLAC",PLAC},
- X {"QUAL",QUAL},
- X {"REL",REL},
- X {"SEX",SEX},
- X {"SOUR",SOUR},
- X {"TEMP",TEMP},
- X {"TITL",TITL},
- X {"BIC",BIC},
- X {"NUMB",NUMB},
- X {"REFN",REFN},
- X {"BIRT",BIRT},
- X {"BURI",BURI},
- X {"CHIL",CHIL},
- X {"CHR",CHR},
- X {"DEAT",DEAT},
- X {"FAM",FAM},
- X {"FAMC",FAMC},
- X {"FAMS",FAMS},
- X {"HEAD",HEAD},
- X {"HUSB",HUSB},
- X {"INDI",INDI},
- X {"MARR",MARR},
- X {"STAL",STAL},
- X {"TRLR",TRLR},
- X {"WIFE",WIFE},
- X {"SUBM",SUBM},
- X {"SLGC",SLGC},
- X {"SLGS",SLGS},
- X {0,0}
- X};
- X
- Xextern int lineno;
- Xstatic char buff[300]; /* Actually, 80 may be enough */
- Xstatic char *buff_ptr = &buff[0];
- X
- Xyylex()
- X{
- X char *p;
- X int i;
- X
- X if( !(*buff_ptr) )
- X {
- X int lev;
- X if( !fgets(buff,300,yyin) )
- X {
- X return 0; /* end of file */
- X }
- X buff[strlen(buff)-1] = 0; /* blast the newline */
- X lineno++;
- X buff_ptr = &buff[0]; /* get a new line */
- X /* the first thing on a line is the level number, get it */
- X lev = strtol(buff,&p,10);
- X if( p == buff_ptr )
- X {
- X fprintf(stderr,"No level number at the beginning of the line on line %d\n",
- X lineno);
- X return LEV0;
- X }
- X buff_ptr = p;
- X return LEV0+lev;
- X }
- X else
- X {
- X /* either a type or a reference */
- X while(*buff_ptr &&
- X (*buff_ptr == ' ' || *buff_ptr == '\t') )
- X buff_ptr++;
- X /* collect next token */
- X p = buff_ptr;
- X while( *buff_ptr && (*buff_ptr != ' ' && *buff_ptr != '\t' &&
- X *buff_ptr != '\n' ) )
- X buff_ptr++;
- X if( *p == '@' )
- X {
- X char x,*y;
- X
- X x = *buff_ptr;
- X *buff_ptr = 0;
- X p++; /* skip the @ stuff and just pass the ref id */
- X yylval.str = (char *)malloc(buff_ptr-p);
- X strncpy(yylval.str,p,buff_ptr-p);
- X yylval.str[buff_ptr-p-1] = 0; /* leave out the '@'s */
- X *buff_ptr = x;
- X return REF;
- X }
- X if( !strncmp(p,"DIV",3) ) /* DIV is a slightly special case ... ? */
- X {
- X if( *(p+4) == 'Y' ) yylval.num = 1;
- X else yylval.num = 0;
- X *buff_ptr = 0; /* we are done here */
- X return DIV;
- X }
- X *buff_ptr = 0;
- X /* then match on the token, and return the rest of the line as
- X the value */
- X /* the tokens are arranged in a ______table. */
- X for(i=0; keylist[i].name; i++)
- X {
- X if( !strcmp(keylist[i].name,p) )
- X {
- X *buff_ptr = ' ';
- X if( *(buff_ptr+1) == '@' )
- X {
- X return keylist[i].val;
- X }
- X setyystr(p);
- X *buff_ptr = 0; /* this will reset the lexer and read in a
- X new line next time.... */
- X return keylist[i].val;
- X }
- X }
- X /* else report error */
- X fprintf(stderr,"HEY, '%s' is not a keyword I understand! (line %d)\n",
- X p, lineno);
- X }
- X}
- X
- X
- Xsetyystr(txt)
- Xchar *txt;
- X{
- X int x=strlen(txt);
- X char *y = txt;
- X while( *y && *y != ' ' )
- X y++;
- X if( *y )
- X {
- X /* there is a space */
- X x -= (y-txt);
- X y++;
- X yylval.str = (char *)malloc(x);
- X strcpy(yylval.str,y);
- X }
- X else
- X yylval.str = "";
- X}
- X
- SHAR_EOF
- $TOUCH -am 0103114992 mylex.c &&
- chmod 0664 mylex.c ||
- echo "restore of mylex.c failed"
- set `wc -c mylex.c`;Wc_c=$1
- if test "$Wc_c" != "3915"; then
- echo original size 3915, current size $Wc_c
- fi
- # ============= mylex2.dist ==============
- echo "x - extracting mylex2.dist (Text)"
- sed 's/^X//' << 'SHAR_EOF' > mylex2.dist &&
- X/* starting time is 11:41:09 */
- X/* C code produced by gperf version 2.5 (GNU C++ version) */
- X/* Command-line: gperf -G -k 1,3,4 -p -S 1 -t keys.gperf */
- Xstatic char rcs_stuff[] = "$Id: keys.gperf,v 1.1.1.1 1992/01/03 17:10:27 murf Exp $";
- X/*
- X# Copyright (C) 1992 Steven Michael Murphy
- X#
- X#
- X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
- X#
- X#
- X# gcom is free software; you can redistribute it and/or modify
- X# it under the terms of the GNU General Public License as published by
- X# the Free Software Foundation; either version 2, or (at your option)
- X# any later version.
- X#
- X# gcom is distributed in the hope that it will be useful,
- X# but WITHOUT ANY WARRANTY; without even the implied warranty of
- X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X# GNU General Public License for more details.
- X#
- X# You should have received a copy of the GNU General Public License
- X# along with gcom; see the file COPYING. If not, write to
- X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X*/
- X#include <stdio.h>
- X#include "gedcom.b.tab.h"
- Xextern int lineno;
- Xstatic char buff[300]; /* Actually, 80 may be enough */
- Xstatic char *buff_ptr = &buff[0];
- X
- X
- XFILE *yyin;
- Xstruct keyword { char *name; int val; };
- X
- X#define TOTAL_KEYWORDS 41
- X#define MIN_WORD_LENGTH 3
- X#define MAX_WORD_LENGTH 4
- X#define MIN_HASH_VALUE 4
- X#define MAX_HASH_VALUE 155
- X/* maximum key range = 152, duplicates = 0 */
- X
- Xstatic unsigned int
- Xhash (str, len)
- X register char *str;
- X register int unsigned len;
- X{
- X static unsigned char asso_values[] =
- X {
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 10, 50, 11, 41, 15,
- X 55, 6, 35, 55, 156, 156, 25, 0, 15, 0,
- X 1, 40, 0, 0, 6, 5, 156, 10, 5, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
- X 156, 156, 156, 156, 156, 156, 156, 156,
- X };
- X register int hval = len;
- X
- X switch (hval)
- X {
- X default:
- X case 4:
- X hval += asso_values[str[3]];
- X case 3:
- X hval += asso_values[str[2]];
- X case 2:
- X case 1:
- X hval += asso_values[str[0]];
- X }
- X return hval;
- X}
- X
- Xstatic struct keyword wordlist[] =
- X{
- X {"",}, {"",}, {"",}, {"",},
- X {"MARR", MARR},
- X {"SEX", SEX},
- X {"SOUR", SOUR},
- X {"SLGS", SLGS},
- X {"TEMP", TEMP},
- X {"CHR", CHR},
- X {"COMM", COMM},
- X {"PHON", PHON},
- X {"SLGC", SLGC},
- X {"CHAR", CHAR},
- X {"PLAC", PLAC},
- X {"REL", REL},
- X {"NAME", NAME},
- X {"TRLR", TRLR},
- X {"CONT", CONT},
- X {"STAL", STAL},
- X {"NOTE", NOTE},
- X {"TITL", TITL},
- X {"DEST", DEST},
- X {"SUBM", SUBM},
- X {"ADDR", ADDR},
- X {"FAM", FAM},
- X {"FAMS", FAMS},
- X {"BIRT", BIRT},
- X {"DEAT", DEAT},
- X {"BIC", BIC},
- X {"DATE", DATE},
- X {"NUMB", NUMB},
- X {"FAMC", FAMC},
- X {"REFN", REFN},
- X {"FLAG", FLAG},
- X {"QUAL", QUAL},
- X {"BAPL", BAPL},
- X {"WIFE", WIFE},
- X {"ENDL", ENDL},
- X {"HUSB", HUSB},
- X {"HEAD", HEAD},
- X {"CHIL", CHIL},
- X {"FILE", FILE9},
- X {"BURI", BURI},
- X {"INDI", INDI},
- X};
- X
- Xstruct keyword *
- Xin_word_set (str, len)
- X register char *str;
- X register unsigned int len;
- X{
- X if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
- X {
- X register int key = hash (str, len);
- X
- X if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
- X {
- X {
- X struct keyword *resword;
- X
- X switch (key)
- X {
- X case 4:
- X resword = &wordlist[4]; break;
- X case 8:
- X resword = &wordlist[5]; break;
- X case 9:
- X resword = &wordlist[6]; break;
- X case 10:
- X resword = &wordlist[7]; break;
- X case 11:
- X resword = &wordlist[8]; break;
- X case 14:
- X resword = &wordlist[9]; break;
- X case 15:
- X resword = &wordlist[10]; break;
- X case 20:
- X resword = &wordlist[11]; break;
- X case 21:
- X resword = &wordlist[12]; break;
- X case 25:
- X resword = &wordlist[13]; break;
- X case 26:
- X resword = &wordlist[14]; break;
- X case 28:
- X resword = &wordlist[15]; break;
- X case 34:
- X resword = &wordlist[16]; break;
- X case 35:
- X resword = &wordlist[17]; break;
- X case 36:
- X resword = &wordlist[18]; break;
- X case 39:
- X resword = &wordlist[19]; break;
- X case 40:
- X resword = &wordlist[20]; break;
- X case 41:
- X resword = &wordlist[21]; break;
- X case 51:
- X resword = &wordlist[22]; break;
- X case 54:
- X resword = &wordlist[23]; break;
- X case 55:
- X resword = &wordlist[24]; break;
- X case 58:
- X resword = &wordlist[25]; break;
- X case 59:
- X resword = &wordlist[26]; break;
- X case 60:
- X resword = &wordlist[27]; break;
- X case 61:
- X resword = &wordlist[28]; break;
- X case 64:
- X resword = &wordlist[29]; break;
- X case 66:
- X resword = &wordlist[30]; break;
- X case 69:
- X resword = &wordlist[31]; break;
- X case 70:
- X resword = &wordlist[32]; break;
- X case 74:
- X resword = &wordlist[33]; break;
- X case 75:
- X resword = &wordlist[34]; break;
- X case 79:
- X resword = &wordlist[35]; break;
- X case 80:
- X resword = &wordlist[36]; break;
- X case 84:
- X resword = &wordlist[37]; break;
- X case 85:
- X resword = &wordlist[38]; break;
- X case 89:
- X resword = &wordlist[39]; break;
- X case 90:
- X resword = &wordlist[40]; break;
- X case 95:
- X resword = &wordlist[41]; break;
- X case 99:
- X resword = &wordlist[42]; break;
- X case 109:
- X resword = &wordlist[43]; break;
- X case 155:
- X resword = &wordlist[44]; break;
- X default: return 0;
- X }
- X if (*str == *resword->name && !strcmp (str + 1, resword->name + 1))
- X return resword;
- X return 0;
- X }
- X }
- X }
- X return 0;
- X}
- X
- X
- Xyylex()
- X{
- X struct keyword *kw;
- X char *p;
- X int i;
- X
- X if( !(*buff_ptr) )
- X {
- X int lev;
- X if( !fgets(buff,300,yyin) )
- X {
- X return 0; /* end of file */
- X }
- X buff[strlen(buff)-1] = 0; /* blast the newline */
- X lineno++;
- X buff_ptr = &buff[0]; /* get a new line */
- X /* the first thing on a line is the level number, get it */
- X lev = strtol(buff,&p,10);
- X if( p == buff_ptr )
- X {
- X fprintf(stderr,"No level number at the beginning of the line on line %d\n",
- X lineno);
- X return LEV0;
- X }
- X buff_ptr = p;
- X return LEV0+lev;
- X }
- X else
- X {
- X /* either a type or a reference */
- X while(*buff_ptr &&
- X (*buff_ptr == ' ' || *buff_ptr == '\t') )
- X buff_ptr++;
- X /* collect next token */
- X p = buff_ptr;
- X while( *buff_ptr && (*buff_ptr != ' ' && *buff_ptr != '\t' &&
- X *buff_ptr != '\n' ) )
- X buff_ptr++;
- X if( *p == '@' )
- X {
- X char x,*y;
- X
- X x = *buff_ptr;
- X *buff_ptr = 0;
- X p++; /* skip the @ stuff and just pass the ref id */
- X yylval.str = (char *)malloc(buff_ptr-p);
- X strncpy(yylval.str,p,buff_ptr-p);
- X yylval.str[buff_ptr-p-1] = 0; /* leave out the '@'s */
- X *buff_ptr = x;
- X return REF;
- X }
- X if( !strncmp(p,"DIV",3) ) /* DIV is a slightly special case ... ? */
- X {
- X if( *(p+4) == 'Y' ) yylval.num = 1;
- X else yylval.num = 0;
- X *buff_ptr = 0; /* we are done here */
- X return DIV;
- X }
- X *buff_ptr = 0;
- X /* then match on the token, and return the rest of the line as
- X the value */
- X /* the tokens are arranged in a ______table. */
- X kw = in_word_set(p,strlen(p));
- X if( kw )
- X {
- X *buff_ptr = ' ';
- X if( *(buff_ptr+1) == '@' )
- X {
- X return kw->val;
- X }
- X setyystr(p);
- X *buff_ptr = 0; /* this will reset the lexer and read in a
- X new line next time.... */
- X return kw->val;
- X }
- X else
- X {
- X /* else report error */
- X fprintf(stderr,"HEY, '%s' is not a keyword I understand! (line %d)\n",
- X p, lineno);
- X }
- X }
- X}
- X
- X
- Xsetyystr(txt)
- Xchar *txt;
- X{
- X int x=strlen(txt);
- X char *y = txt;
- X while( *y && *y != ' ' )
- X y++;
- X if( *y )
- X {
- X /* there is a space */
- X x -= (y-txt);
- X y++;
- X yylval.str = (char *)malloc(x);
- X strcpy(yylval.str,y);
- X }
- X else
- X yylval.str = "";
- X}
- X
- X/* ending time is 11:41:09 */
- SHAR_EOF
- $TOUCH -am 0103114692 mylex2.dist &&
- chmod 0664 mylex2.dist ||
- echo "restore of mylex2.dist failed"
- set `wc -c mylex2.dist`;Wc_c=$1
- if test "$Wc_c" != "9447"; then
- echo original size 9447, current size $Wc_c
- fi
- echo "End of part 2, continue with part 3"
- exit 0
-
- exit 0 # Just in case...
-