home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / gcom / part02 < prev    next >
Encoding:
Text File  |  1992-01-13  |  48.3 KB  |  1,880 lines

  1. Newsgroups: comp.sources.misc
  2. From: murf@oakhill.sps.mot.com (Steve Murphy)
  3. Subject:  v27i073:  gcom - GEDCOM genealogical database merge utility, v1, Part02/07
  4. Message-ID: <1992Jan13.145354.25397@sparky.imd.sterling.com>
  5. X-Md4-Signature: 34d1e253fba841b322d5877cbd14e9f4
  6. Date: Mon, 13 Jan 1992 14:53:54 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: murf@oakhill.sps.mot.com (Steve Murphy)
  10. Posting-number: Volume 27, Issue 73
  11. Archive-name: gcom/part02
  12. Environment: SunOS
  13.  
  14. ---- Cut Here and unpack ----
  15. #!/bin/sh
  16. # This is part 02 of gcom
  17. if touch 2>&1 | fgrep 'amc' > /dev/null
  18.  then TOUCH=touch
  19.  else TOUCH=true
  20. fi
  21. # ============= gedcom.b ==============
  22. echo "x - extracting gedcom.b (Text)"
  23. sed 's/^X//' << 'SHAR_EOF' > gedcom.b &&
  24. X%{
  25. X#ifndef LINT
  26. Xstatic char rcs_gedcom_id[] = "$Id: gedcom.b,v 1.2 1992/01/03 17:49:44 murf Exp $";
  27. X#endif
  28. X/* # Copyright (C) 1992 Steven Michael Murphy
  29. X#
  30. X#
  31. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  32. X# 
  33. X# 
  34. X# gcom is free software; you can redistribute it and/or modify
  35. X# it under the terms of the GNU General Public License as published by
  36. X# the Free Software Foundation; either version 2, or (at your option)
  37. X# any later version.
  38. X# 
  39. X# gcom is distributed in the hope that it will be useful,
  40. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  42. X# GNU General Public License for more details.
  43. X# 
  44. X# You should have received a copy of the GNU General Public License
  45. X# along with gcom; see the file COPYING.  If not, write to
  46. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  47. X*/
  48. X
  49. X#include <stdio.h>
  50. X#include "gedcom.h"
  51. Xint lineno;
  52. Xstruct  individ curr_ind;
  53. Xstruct family curr_fam;
  54. Xstruct gedfile *curr_file;
  55. Xstruct submitter curr_submitter;
  56. Xstruct gheader curr_head;
  57. Xstruct submitt{char *submitter; char *rel;};
  58. Xint strcmp();
  59. Xstatic char rcs_stuff[] = "$Id: gedcom.b,v 1.2 1992/01/03 17:49:44 murf Exp $";
  60. X%}
  61. X
  62. X    
  63. X%union
  64. X{     int num;
  65. X    char *str;
  66. X    struct datplace *datplace;
  67. X    struct ordinance *ordinance;
  68. X    struct notelist *notelist;
  69. X    struct individ *individ;
  70. X    struct family *family;
  71. X    struct gheader *header;
  72. X    struct submitt *submit;
  73. X    struct child *child;
  74. X    struct submitt *submitt;
  75. X    struct comment *comment;
  76. X    struct stake *stake;
  77. X    struct address *address;
  78. X}
  79. X
  80. X
  81. X
  82. X%token <num> DIV LEV0 LEV1 LEV2 LEV3
  83. X%token <str> ADDR BAPL CHAR COMM CONT DATE DEST ENDL FILE9 FLAG NAME NOTE PHON
  84. X         PLAC QUAL REL SEX SOUR TEMP TITL REF
  85. X%token <str> BIC NUMB REFN  SLGC SLGS
  86. X        
  87. X
  88. X%token BIRT BURI CHIL CHR DEAT FAM FAMC FAMS HEAD HUSB INDI MARR STAL TRLR 
  89. X    WIFE SUBM
  90. X%type <datplace> marriage buried death christen datplacitem2
  91. X                            birth 
  92. X
  93. X%type <ordinance> seal2spou endow t_item tempitem3 t_item3
  94. X                             tempitem bap c2pseal c2pseal3
  95. X
  96. X%type <submitt> submitter2
  97. X%type <comment> comment ext_list
  98. X%type <notelist> note
  99. X%type <child> child
  100. X%type <address> address
  101. X%type <stake> stake
  102. X
  103. X/* these tokens are unused but part of the GEDCOM definition. If you want to expand the
  104. Xparser, here are the neccessary defs. Use the big version of the lexical analyzer */
  105. X
  106. X/*
  107. X%token <num> NUM
  108. X%token <str>  AFN  CANC  EVAL 
  109. X         TYPE  ASSD ASSI DCHR IBRZ
  110. X%token <str> ABBR ABY ACTI ACTN ADDI ADMI ADOP AENT AGE AGEF AGEM ALIA ALPH ALSO ANCE ANCI ANUL AREA ASSO
  111. X        ATLA AUTH BAPM BARM BASM BATC BEN BENT BLES BLSL BOOK BRID BYTE CALN CAUS CDAT CEME
  112. X        CENS CHAN CHEC CHEK CIFF CITA CITY CIVI CIVL CLEA CLRK CNTR CO CODE CODI COFN COLO COMP
  113. X        COND CONE CONF CONL COON COOR CORP CORR COST COUN COUP COUR COVE CREA CRFN CRIM CTRY DATA DAU
  114. X        DCR DESC DESI DIR DISC DISK DIVF DOCS DUP DWEL EDUC EMIG EMPL END ENGA ENTR ENUM ENUR EOF9
  115. X        EVEN EXCE EXCO EXEC EXPL EXTD EXTR FAMO FAMP FAMR FATH FCOM FEMA FGR FHC FILM
  116. X        FOFN FOLI FONL FORE FORG FOST FRAM FRFN FROM FSUB FUNC GENE GIVN GNRL GRAD GROO GSC GUAR HAML
  117. X        HAND HDOF HDOH HEAL HEIL HEIR HEPR HIST IBAZ ILLE ILLU IMMI INDE INFA INFL INFO
  118. X        INFT INST IRFN ITEM LANG LAST LATI LDAT LENG LINE LINK LIVE LOC LOCA LOCC LOCD LOCE LOCG LOCH
  119. X        LOCI LOCL LOCM LOCN LOCO LOCQ LOCR LOCS LOCU LOCX LONG LSF LVG MAID MALE MAP MARB MARC MARD MARL
  120. X         MARS MARY MESS MICR MILI MINR MISC MOTH MTD NAMR NAMS NATU NFCI NOTI NULL9
  121. X         NUMP NXTB OBJ OCCU OFFI OLD OPER ORDI ORDL ORDN ORG ORPH OTHE OUT OVER PACK PAGE PARE PARI
  122. X        PART PASL PATC PATR PBRZ PED PEDC PENS PERS PID PIFF POLY PORT POST POVE PREF PRES
  123. X        PREV PRIN PRIO PRNT PROB PROP PROT PROV PROX PRTR PRVB PSUB PUBL PUBR PVMG PVRL QUAY RACE RANG
  124. X        RARS RATI REAL REBA RECD RECO RECR  REGD REGI REJE RELI REMA REPO REQD REQU RES RESE RESI
  125. X        RESN REST RETI RFN SBID SCHO SEAR SELF SEQU SERI SERS SERV SHEE SHIP SIBL SIS SLGP SON SORT
  126. X        SPEC SPEI SPEP SPLI SPOU SPUR SREF STAC STAE STAT STDN STIL SUB SUBJ SURN SURO SYMB SYST
  127. X        TAPE TASK TEXT TIME TIMP TMPL TOR TOWC TOWN TRAK TRAN TRAS TWP UDER UNIF UPDA VALU VERI VITA
  128. X        VOID VOIL VOLU WAC WARD WARL WIDO WILL WITN YEAR YOUN YTD
  129. X%token FAMF SUBN 
  130. X
  131. X
  132. X*/
  133. X
  134. X
  135. X
  136. X%%
  137. X
  138. Xfile : header submitter record_list trailer;
  139. X
  140. Xheader : LEV0 HEAD { clear_head(); } head_rec_list {curr_file->header = &curr_head; };
  141. X
  142. Xhead_rec_list: headrec
  143. X    | head_rec_list headrec;
  144. X                            
  145. Xheadrec: LEV1 SOUR  {curr_head.source = $2; }
  146. X    | LEV1 DEST { curr_head.dest = $2; }
  147. X    | LEV1 DATE { curr_head.date = $2; }
  148. X    | LEV1 CHAR { curr_head.charset = $2; }
  149. X    | LEV1 FILE9 {curr_head.file = $2; };
  150. X
  151. X submitter: LEV0 REF {clear_submitter();} SUBM subm_list
  152. X        {set_subm(curr_file,$2,&curr_submitter); };
  153. X
  154. Xsubm_list: LEV1 submrec {}
  155. X    | subm_list LEV1 submrec{};
  156. X                    
  157. Xsubmrec : NAME { curr_submitter.name = $1; }
  158. X    | PHON { curr_submitter.phone = $1;}
  159. X    | comment { curr_submitter.comments = $1;}
  160. X    | address { curr_submitter.addr = $1;}
  161. X    | stake { curr_submitter.stake = $1;};
  162. X                
  163. Xaddress : ADDR ext_list { int i;
  164. X            $$ = Calloc(struct address);
  165. X            $$->addr[0] = $1;
  166. X            for(i=0; i< $2->lines; i++)
  167. X            {
  168. X                $$->addr[i+1] = $2->line[i];
  169. X            }
  170. X            $$->num = $2->lines+1;
  171. X            free($2->line);
  172. X            free($2);
  173. X             }
  174. X    | ADDR { $$ = Calloc(struct address);
  175. X            $$->addr[0] = $1;
  176. X            $$->num = 1;};
  177. X
  178. Xext_list : LEV2 CONT { $$=Calloc(struct comment);$$->line=(char **)malloc(sizeof(char *)); $$->line[0] = $2; $$->lines=1;}
  179. X    | ext_list LEV2 CONT {$$=$1; $$->line = (char **)realloc($$->line,sizeof(char *) * ($$->lines+1));
  180. X            $$->line[$$->lines++] = $3; };
  181. X                            
  182. Xcomment : COMM ext_list {int i; $$=Calloc(struct comment);$$->line=(char **)malloc(sizeof(char *) * ($2->lines+1));$$->line[0]=$1;
  183. X            for(i=0;i<$2->lines;i++){$$->line[i+1]=$2->line[i]; }$$->lines = $2->lines+1; }
  184. X    | COMM {$$=Calloc(struct comment);$$->line = (char **)malloc(sizeof(char *)); $$->line[0] = $1;$$->lines =1;};
  185. X                
  186. Xstake: STAL { $$=Calloc(struct stake);}
  187. X     | STAL LEV2 NAME {$$=Calloc(struct stake);$$->name=$3; }
  188. X     | STAL LEV2 NUMB {$$=Calloc(struct stake);$$->num=$3; }
  189. X    | STAL LEV2 NAME LEV2 NUMB {$$=Calloc(struct stake); 
  190. X                 $$->name = $3;
  191. X                 $$->num = $5;}
  192. X    | STAL LEV2 NUMB LEV2 NAME {$$=Calloc(struct stake);
  193. X                $$->name = $5;
  194. X                 $$->num = $3;};
  195. X
  196. Xrecord_list: record { }
  197. X    | record_list record { };
  198. X
  199. Xrecord : individual_rec { }
  200. X    | fam_rec { };
  201. X
  202. Xindividual_rec : LEV0 REF INDI  {clear_indi(); } indiv_stuff_list
  203. X            {set_ind(curr_file,$2,&curr_ind); };
  204. X
  205. Xindiv_stuff_list : LEV1 indivrec { }
  206. X    | indiv_stuff_list LEV1 indivrec { };
  207. X
  208. Xindivrec : NAME     { curr_ind.name = $1; }
  209. X    | TITL { curr_ind.title = $1;}
  210. X    | SEX { curr_ind.sex = ($1[0]? $1[0]:($1[1]? $1[1]: 'x'));
  211. X        if( curr_ind.sex != 'M' && curr_ind.sex != 'F' )
  212. X            fprintf(stderr,"Sex (%c) indecipherable line %d\n", curr_ind.sex,lineno);}
  213. X    | REFN { curr_ind.givenref = $1;}
  214. X    | birth { curr_ind.birth = $1;}
  215. X    | christen { curr_ind.christen = $1;}
  216. X    | death { curr_ind.death = $1;}
  217. X    | buried { curr_ind.burial = $1;}
  218. X    | bap { curr_ind.baptism = $1;}
  219. X    | endow { curr_ind.endow = $1;}
  220. X    | c2pseal { curr_ind.child_to_parent = $1;}
  221. X    | FLAG { curr_ind.flag = $1;}
  222. X    | FAMS REF { add_spouse(&curr_ind,$2);  }
  223. X    | FAMC REF { curr_ind.famc = $2;}
  224. X    | submitter2 { curr_ind.submitter = $1->submitter;curr_ind.submitter_rel = $1->rel;}
  225. X    | DEST { curr_ind.destination_flag = $1;}
  226. X    | note { if(curr_ind.notes){
  227. X        /* merge notes */
  228. X        curr_ind.notes->notes++; /* increment the num of notes */
  229. X        curr_ind.notes->note = (struct comment *)realloc(curr_ind.notes->note,sizeof(struct comment)*curr_ind.notes->notes);
  230. X        curr_ind.notes->note[curr_ind.notes->notes-1].lines = $1->note[0].lines;
  231. X        curr_ind.notes->note[curr_ind.notes->notes-1].line = $1->note[0].line;
  232. X        $1->note[0].line = 0;
  233. X        free($1->note[0]);
  234. X        free($1);
  235. X        } else {
  236. X        /* stick in */
  237. X        curr_ind.notes = $1;
  238. X        }};
  239. Xbirth: BIRT datplacitem2 { $$ = $2; };
  240. X
  241. Xdatplacitem2 : LEV2 DATE {$$ = Calloc(struct datplace); $$->date = $2; }
  242. X    | LEV2 PLAC {$$ = Calloc(struct datplace); $$->place = $2; }
  243. X    | LEV2 DATE LEV2 PLAC {$$ = Calloc(struct datplace); $$->place = $4;$$->date = $2; }
  244. X    | LEV2 PLAC LEV2 DATE {$$ = Calloc(struct datplace); $$->place = $2;$$->date = $4; };
  245. X
  246. Xchristen: CHR datplacitem2   {$$=$2; };
  247. X
  248. Xdeath: DEAT datplacitem2  {$$=$2; };
  249. X
  250. Xburied: BURI datplacitem2 {$$=$2; };
  251. X
  252. Xbap: BAPL tempitem { $$=$2; $$->val = $1;}
  253. X    | BAPL { $$= Calloc(struct ordinance); $$->val = $1;};
  254. X
  255. Xtempitem : t_item {$$=$1; }
  256. X    | tempitem t_item { $$ =$1; 
  257. X            copytempitem($$,$2);};
  258. X                    
  259. Xt_item :  LEV2 DATE { $$ = Calloc(struct ordinance); $$->date=$2;}
  260. X    | LEV2 TEMP {  $$ = Calloc(struct ordinance); strcpy($$->temp,$2);}
  261. X    | LEV2 QUAL {  $$ = Calloc(struct ordinance); $$->qual=$2;};
  262. X
  263. Xtempitem3 : t_item3 {$$=$1; }
  264. X    | tempitem3 t_item3 {$$ =$1; 
  265. X                copytempitem($$,$2); };
  266. X                
  267. Xt_item3 :  LEV3 DATE { $$ = Calloc(struct ordinance); $$->date=$2; }
  268. X    | LEV3 TEMP { $$ = Calloc(struct ordinance); strcpy($$->temp,$2); }
  269. X    | LEV3 QUAL { $$ = Calloc(struct ordinance); $$->qual=$2; };
  270. X
  271. Xendow: ENDL tempitem { $$=$2; $$->val = $1; }
  272. X    | ENDL {$$= Calloc(struct ordinance); $$->val = $1; };
  273. X
  274. Xc2pseal: SLGC tempitem { $$=$2;$$->val = $1; }
  275. X    | SLGC {$$= Calloc(struct ordinance); $$->val = $1;};
  276. X
  277. Xc2pseal3: SLGC  { $$=Calloc(struct ordinance); $$->val = $1;}
  278. X    | SLGC tempitem3 {$$=$2; $$->val = $1; };
  279. X
  280. Xsubmitter2: SUBM REF {$$=Calloc(struct submitt); $$->submitter = $2; }
  281. X    | SUBM REF LEV2 REL {$$=Calloc(struct submitt); $$->submitter = $2; $$->rel = $4; };
  282. X                    
  283. Xnote: NOTE { $$=Calloc(struct notelist); $$->note=Calloc(struct comment); $$->note[0].lines=1;
  284. X        $$->note[0].line = Calloc(char *); $$->note[0].line[0] = $1; $$->notes=1;$$->note[0].lines = 1;}
  285. X    | NOTE ext_list {int i;
  286. X        $$=Calloc(struct notelist); 
  287. X        $$->note=$2;
  288. X        $$->note[0].line = (char **)realloc($$->note[0].line,sizeof(char *)*($2->lines+1)); 
  289. X        $$->notes=1; 
  290. X        for(i=$2->lines; i; i--)
  291. X        {$2->line[i]=$2->line[i-1];}
  292. X        $2->line[0] = $1;$2->lines++;};
  293. X        
  294. X
  295. X
  296. Xfam_rec: LEV0 REF {clear_fam();} FAM fam_stuff_list
  297. X            {set_fam(curr_file,$2,&curr_fam);};
  298. X
  299. Xfam_stuff_list : LEV1 famrec { }
  300. X    | fam_stuff_list LEV1 famrec { };
  301. X
  302. Xfamrec: HUSB REF {curr_fam.husb = $2; }
  303. X    | WIFE REF {curr_fam.wife = $2; }
  304. X    | child { add_child(&curr_fam, $1); }
  305. X    | marriage {curr_fam.marriage = $1; }
  306. X    | seal2spou {curr_fam.sealspouse = $1; }
  307. X    | DIV {curr_fam.divorce = 1; }
  308. X    | DEST { curr_fam.dest = $1;}
  309. X    | FLAG { curr_fam.flag = $1;}
  310. X    | submitter2 { curr_fam.submitter = $1->submitter;
  311. X            curr_fam.submitter_rel = $1->rel;};
  312. X
  313. Xchild : CHIL REF { $$=Calloc(struct child);$$->ref=$2;}
  314. X    | CHIL REF LEV2 c2pseal3 {$$=Calloc(struct child);$$->ref = $2; $$->slgc =$4; };
  315. X            
  316. Xmarriage: MARR datplacitem2 {$$=$2; };
  317. X
  318. Xseal2spou : SLGS tempitem {$$=$2; $$->val = $1;}
  319. X    | SLGS {$$= Calloc(struct ordinance); $$->val = $1; };
  320. X
  321. Xtrailer: LEV0 TRLR{};
  322. X
  323. X%%
  324. Xvoid copytempitem(a,b)
  325. Xstruct ordinance *a,*b;
  326. X{
  327. X    if( b->val )
  328. X        a->val = b->val;
  329. X    if(b->date)
  330. X        a->date = b->date;
  331. X    if(b->temp[0] )
  332. X        strcpy(a->temp,b->temp);
  333. X    if(b->qual)
  334. X        a->qual = b->qual;
  335. X    free(b);
  336. X}
  337. X
  338. Xvoid clear_indi()
  339. X{
  340. X    curr_ind.name = 0;
  341. X    curr_ind.title = 0;
  342. X    curr_ind.sex = 0;
  343. X    curr_ind.givenref = 0;
  344. X    curr_ind.birth = 0;
  345. X    curr_ind.christen = 0;
  346. X    curr_ind.death = 0;
  347. X    curr_ind.burial = 0;
  348. X    curr_ind.baptism = 0;
  349. X    curr_ind.endow = 0;
  350. X    curr_ind.child_to_parent = 0;
  351. X    curr_ind.flag = 0;
  352. X    curr_ind.fams = 0;
  353. X    curr_ind.famc = 0;
  354. X    curr_ind.submitter = 0;
  355. X    curr_ind.submitter_rel = 0;
  356. X    curr_ind.destination_flag = 0;
  357. X    curr_ind.notes = 0;
  358. X}
  359. X
  360. Xstatic int add_ind(ged,ip)
  361. Xstruct gedfile *ged;
  362. Xstruct individ *ip;
  363. X{
  364. X    struct indivlist *x=ged->indlist;
  365. X    if( !ged->indlist )
  366. X        x = ged->indlist = Calloc(struct indivlist);
  367. X    if( !x->allocd )
  368. X    {
  369. X        x->allocd += 20;
  370. X        x->ind = Callocs(struct individ *,20);
  371. X    }
  372. X    if( x->num == x->allocd )
  373. X    {
  374. X        x->allocd += 20;
  375. X        x->ind = (struct individ **)realloc(x->ind,x->allocd*sizeof(struct individ *));
  376. X    }
  377. X    ip->index = x->num;
  378. X    x->ind[x->num++] = ip;
  379. X    return ip->index;
  380. X}
  381. X
  382. Xstruct individ *set_ind(ged,ref,curr_in)
  383. Xstruct gedfile *ged;
  384. Xchar *ref;
  385. Xstruct individ *curr_in;
  386. X{
  387. X    struct individ *ind;
  388. X    
  389. X    if( !ged->indiv )
  390. X    {
  391. X        ged->indiv = st_init_table(strcmp,st_strhash);
  392. X    }
  393. X    ind = Calloc(struct individ);
  394. X    *ind = *curr_in;
  395. X    st_insert(ged->indiv,ref,(char *)ind);
  396. X    ind->ref = ref;
  397. X    add_ind(ged,ind);
  398. X    return ind;
  399. X}
  400. X
  401. Xvoid clear_fam()
  402. X{
  403. X    curr_fam.husb = 0;
  404. X    curr_fam.wife = 0;
  405. X    curr_fam.kids = 0;
  406. X    curr_fam.marriage = 0;
  407. X    curr_fam.sealspouse = 0;
  408. X    curr_fam.divorce = 0;
  409. X    curr_fam.dest = 0;
  410. X    curr_fam.flag = 0;
  411. X    curr_fam.submitter = 0;
  412. X    curr_fam.submitter_rel = 0;
  413. X}
  414. Xstruct family *set_fam(ged,ref,curr_fa)
  415. Xchar *ref;
  416. Xstruct gedfile *ged;
  417. Xstruct family *curr_fa;
  418. X{
  419. X    struct family *fam;
  420. X    
  421. X    if( !ged->families )
  422. X    {
  423. X        ged->families = st_init_table(strcmp,st_strhash);
  424. X    }
  425. X    fam = Calloc(struct family);
  426. X    *fam = *curr_fa;
  427. X    st_insert(ged->families,ref,(char *)fam);
  428. X    fam->ref = ref;
  429. X    add_fam(ged,fam);
  430. X    return fam;
  431. X}
  432. X
  433. Xstatic int add_fam(ged,fp)
  434. Xstruct family *fp;
  435. Xstruct gedfile *ged;
  436. X{
  437. X    struct famlylist *x=ged->famlist;
  438. X    if( !ged->famlist )
  439. X        x = ged->famlist = Calloc(struct famlylist);
  440. X    if( !x->allocd )
  441. X    {
  442. X        x->allocd += 20;
  443. X        x->fam = Callocs(struct family *,20);
  444. X    }
  445. X    if( x->num == x->allocd )
  446. X    {
  447. X        x->allocd += 20;
  448. X        x->fam = (struct family **)realloc(x->fam,x->allocd*sizeof(struct family *));
  449. X    }
  450. X    fp->index = x->num;
  451. X    x->fam[x->num++] = fp;
  452. X    return fp->index;
  453. X}
  454. X
  455. Xvoid clear_head() /* blow nose? */
  456. X{
  457. X    curr_head.source = 0;
  458. X    curr_head.dest = 0;
  459. X    curr_head.date = 0;
  460. X    curr_head.file = 0;
  461. X    curr_head.charset = 0;
  462. X}
  463. X
  464. Xvoid add_submitter(ged,ip)
  465. Xstruct submitter *ip;
  466. Xstruct gedfile *ged;
  467. X{
  468. X    struct submitlist *x=ged->submitlist;
  469. X    if( !ged->submitlist )
  470. X        x = ged->submitlist = Calloc(struct submitlist);
  471. X    if( !x->allocd )
  472. X    {
  473. X        x->allocd += 20;
  474. X        x->subm = Callocs(struct submitter *,20);
  475. X    }
  476. X    if( x->num == x->allocd )
  477. X    {
  478. X        x->allocd += 20;
  479. X        x->subm = (struct submitter **)realloc(x->subm,x->allocd*sizeof(struct submitter *));
  480. X    }
  481. X    ip->index = x->num;
  482. X    x->subm[x->num++] = ip;
  483. X}
  484. Xvoid set_subm(ged,ref,curr_submitte)
  485. Xchar *ref;
  486. Xstruct gedfile *ged;
  487. Xstruct submitter *curr_submitte;
  488. X{
  489. X    struct submitter *ind;
  490. X    
  491. X    if( !ged->submits )
  492. X    {
  493. X        ged->submits = st_init_table(strcmp,st_strhash);
  494. X    }
  495. X    ind = Calloc(struct submitter);
  496. X    *ind = *curr_submitte;
  497. X    st_insert(ged->submits,ref,(char *)ind);
  498. X    add_submitter(ged,ind);
  499. X}
  500. X
  501. Xvoid clear_submitter()
  502. X{
  503. X    curr_submitter.name = 0;
  504. X     curr_submitter.addr = 0;
  505. X     curr_submitter.phone = 0;
  506. X     curr_submitter.stake = 0;
  507. X     curr_submitter.comments = 0;
  508. X     curr_submitter.index = 0;
  509. X}
  510. X
  511. Xvoid clear_gedfile()
  512. X{
  513. X    curr_file->header = 0;
  514. X    curr_file->submission = 0;
  515. X    curr_file->indiv = 0;
  516. X    curr_file->families = 0;
  517. X    curr_file->submits = 0;
  518. X    curr_file->indlist = 0;
  519. X    curr_file->famlist = 0;
  520. X    curr_file->submitlist = 0;
  521. X}
  522. X
  523. X
  524. Xvoid yyerror(s)
  525. Xchar *s;
  526. X{
  527. X    extern int lineno; 
  528. X    fprintf(stderr,"Parse error in line %d\n",lineno);
  529. X}
  530. X
  531. Xadd_spouse(ind,ref)
  532. Xstruct individ *ind;
  533. Xchar *ref;
  534. X{
  535. X    if( !ind->fams)
  536. X    {
  537. X        ind->fams = Calloc(struct famlist);
  538. X        ind->fams->family_refs = (char **)malloc(sizeof(char *));
  539. X        ind->fams->family_refs[ind->fams->num++] = ref;
  540. X    }
  541. X    else
  542. X    {
  543. X        ind->fams->family_refs = (char **)
  544. X            realloc(ind->fams->family_refs,
  545. X                    sizeof(char *)*(ind->fams->num+1));
  546. X        ind->fams->family_refs[ind->fams->num++] = ref;
  547. X    }
  548. X}
  549. X
  550. Xadd_child(fam,chil)
  551. Xstruct family *fam;
  552. Xstruct child *chil;
  553. X{
  554. X    if(!fam->kids)
  555. X    {
  556. X        fam->kids=Calloc(struct child_list);
  557. X        fam->kids->kid=Calloc(struct child);
  558. X        fam->kids->kid[0] = *chil;
  559. X        fam->kids->kids=1;
  560. X    }
  561. X    else
  562. X    {
  563. X        fam->kids->kid=(struct child *)realloc(fam->kids->kid, 
  564. X                                sizeof(struct child)*(fam->kids->kids+1));
  565. X        fam->kids->kid[fam->kids->kids++] = *chil;
  566. X    }
  567. X}
  568. SHAR_EOF
  569. $TOUCH -am 0103114992 gedcom.b &&
  570. chmod 0664 gedcom.b ||
  571. echo "restore of gedcom.b failed"
  572. set `wc -c gedcom.b`;Wc_c=$1
  573. if test "$Wc_c" != "15467"; then
  574.     echo original size 15467, current size $Wc_c
  575. fi
  576. # ============= gedcom.h ==============
  577. echo "x - extracting gedcom.h (Text)"
  578. sed 's/^X//' << 'SHAR_EOF' > gedcom.h &&
  579. X/* $Id: gedcom.h,v 1.2 1992/01/03 17:49:46 murf Exp $ */
  580. X/*
  581. X# Copyright (C) 1992 Steven Michael Murphy
  582. X#
  583. X#
  584. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  585. X# 
  586. X# 
  587. X# gcom is free software; you can redistribute it and/or modify
  588. X# it under the terms of the GNU General Public License as published by
  589. X# the Free Software Foundation; either version 2, or (at your option)
  590. X# any later version.
  591. X# 
  592. X# gcom is distributed in the hope that it will be useful,
  593. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  594. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  595. X# GNU General Public License for more details.
  596. X# 
  597. X# You should have received a copy of the GNU General Public License
  598. X# along with gcom; see the file COPYING.  If not, write to
  599. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  600. X*/
  601. X
  602. X#include "st.h"
  603. X#define Calloc(x)    (x *)calloc(sizeof(x),1)
  604. X#define Callocs(x,n)    (x *)calloc(sizeof(x),n)
  605. X
  606. X#ifdef macintosh
  607. X#define const const
  608. X#else
  609. X#define const 
  610. X#endif
  611. X
  612. X
  613. Xstruct datplace
  614. X{
  615. X    char *date;
  616. X    char *place;
  617. X};
  618. X
  619. Xstruct ordinance
  620. X{
  621. X    char *val;
  622. X    char *date;
  623. X    char temp[4];
  624. X    char *qual;
  625. X};
  626. X
  627. Xstruct address
  628. X{
  629. X    int num;
  630. X    char *addr[4];
  631. X};
  632. X
  633. Xstruct stake
  634. X{
  635. X    char *name;
  636. X    char *num;
  637. X};
  638. X
  639. Xstruct comment
  640. X{
  641. X    int lines;
  642. X    char **line; /* a ptr to an array of char ptrs. */
  643. X};
  644. X
  645. Xstruct notelist
  646. X{
  647. X    int notes;
  648. X    struct comment *note; /* an array of comment structs */
  649. X};
  650. X
  651. Xstruct gedfile
  652. X{
  653. X    struct gheader *header;
  654. X    struct submission *submission;
  655. X    st_table *families, *indiv,*submits;
  656. X    struct indivlist *indlist;
  657. X    struct famlylist *famlist;
  658. X    struct submitlist *submitlist;
  659. X};
  660. X
  661. Xstruct gheader
  662. X{
  663. X    char *source;
  664. X    char *dest;
  665. X    char *date;
  666. X    const char *file;
  667. X    char *charset;
  668. X};
  669. X
  670. Xstruct indivlist
  671. X{
  672. X    struct individ **ind;
  673. X    int num;
  674. X    int allocd;
  675. X};
  676. X
  677. Xstruct corresponds
  678. X{
  679. X    char match_ind;
  680. X    char match_fam;
  681. X    int index;
  682. X    char add;
  683. X};
  684. X
  685. Xstruct individ
  686. X{ 
  687. X    char *name;
  688. X    char *title;
  689. X    char sex;
  690. X    char *givenref;
  691. X    struct datplace *birth;
  692. X    struct datplace *christen;
  693. X    struct datplace *death;
  694. X    struct datplace *burial;
  695. X    struct ordinance *baptism;
  696. X    struct ordinance *endow;
  697. X    struct ordinance *child_to_parent;
  698. X    char *flag;
  699. X    struct famlist *fams;
  700. X    char *famc;
  701. X     char *submitter;
  702. X    char *submitter_rel;
  703. X    char *destination_flag;
  704. X    struct notelist *notes;
  705. X    int index;
  706. X    struct corresponds corr;
  707. X    char *ref;
  708. X};
  709. X
  710. Xstruct child_list
  711. X{
  712. X    int kids;
  713. X    struct child *kid; /* a ptr is also potentially an array ptr, as is this case */
  714. X};
  715. X
  716. Xstruct child
  717. X{
  718. X    char *ref;
  719. X    struct ordinance *slgc;
  720. X};
  721. X
  722. Xstruct famlist
  723. X{
  724. X    int num;
  725. X    char **family_refs; /*An array of ptrs to namerefs */
  726. X};
  727. X
  728. Xstruct family
  729. X{
  730. X    char *husb;
  731. X    char *wife;
  732. X    struct child_list *kids;
  733. X    struct datplace *marriage;
  734. X    struct ordinance *sealspouse;
  735. X    char divorce;
  736. X    char *dest;
  737. X    char *flag;
  738. X    char *submitter;
  739. X    char *submitter_rel;
  740. X    int index;
  741. X    struct corresponds corr;
  742. X    char *ref;
  743. X};
  744. X
  745. Xstruct famlylist
  746. X{
  747. X    struct family **fam;
  748. X    int num;
  749. X    int allocd;
  750. X};
  751. X
  752. Xstruct submitter
  753. X{
  754. X    char *name;
  755. X    struct address *addr;
  756. X    char *phone;
  757. X    struct stake *stake;
  758. X    struct comment *comments;
  759. X    int index;
  760. X};
  761. X
  762. Xstruct submitlist
  763. X{
  764. X    struct submitter **subm;
  765. X    int num;
  766. X    int allocd;
  767. X};
  768. X
  769. Xstruct submission
  770. X{
  771. X    char *type;
  772. X    struct comment *comments;
  773. X    char *indi_ref;
  774. X    char *fam_ref;
  775. X    char *eval;
  776. X    char *submitter_name;
  777. X    struct address *submitter_addr;
  778. X    char *submitter_phone;
  779. X    char *fam_file;
  780. X    char *temple;
  781. X    char bapl;
  782. X    char endl;
  783. X    char slgc;
  784. X    char slgs;
  785. X};
  786. Xextern struct gedfile *curr_file;
  787. X#ifdef macintosh
  788. X/* here is a list of function decls that the compiler will
  789. X      appreciate */
  790. Xvoid copytempitem(struct ordinance *,struct ordinance *);
  791. Xvoid clear_indi();
  792. Xstruct individ *set_ind(char *);
  793. Xvoid clear_fam();
  794. Xstruct family *add_fam(struct family *);
  795. Xvoid clear_head();
  796. Xvoid add_submitter(struct submitter *);
  797. Xvoid set_subm(char *);
  798. Xvoid clear_submitter();
  799. Xvoid clear_gedfile();
  800. Xvoid yyerror(char *);
  801. Xint main(int, char **);
  802. Xint group_tree(struct gedfile *);
  803. Xvoid find_correspondence(struct gedfile *, struct gedfile *);
  804. Xvoid merge_strings(char **,char **,char *);
  805. Xvoid merge_datplace(struct datplace **,struct datplace **);
  806. Xvoid merge_ordinance(struct ordinance **a,struct ordinance **);
  807. Xvoid merge_children(struct child_list **,struct child_list **);
  808. Xvoid remove_child(struct child_list *, int);
  809. Xvoid merge_notes(struct notelist **, struct notelist **);
  810. Xvoid merge_address(struct address **,struct address**);
  811. Xvoid merge_stake(struct stake **,struct stake **);
  812. Xvoid merge_comment(struct comment **,struct comment **);
  813. Xint same_individual(struct individ *,struct individ *);
  814. Xvoid merge_famlist(struct famlist **,struct famlist **);
  815. Xvoid merge_individ(struct individ *,struct individ *);
  816. Xvoid write_gedfile(struct gedfile *);
  817. Xvoid write_header(FILE *,struct gheader *);
  818. Xvoid write_submits(FILE *,struct submitlist *);
  819. Xvoid write_address(FILE *,struct address *);
  820. Xvoid write_stake(FILE *, struct stake *);
  821. Xvoid write_comments(FILE *,struct comment *);
  822. Xvoid write_notes(FILE *,struct notelist *);
  823. Xvoid write_individs(FILE *,struct indivlist *);
  824. Xvoid write_ind(FILE *, struct individ *);
  825. Xvoid write_datplace(FILE *,int, char *, struct datplace *);
  826. Xvoid write_ordinance(FILE *,int,char *, struct ordinance *);
  827. Xvoid write_fams(FILE *,struct famlylist *);
  828. Xint deref_ind(char *);
  829. Xvoid write_fam(FILE *,struct family *);
  830. X#else
  831. X/* here is a list of function decls that the compiler will
  832. X      appreciate */
  833. Xvoid copytempitem();
  834. Xvoid clear_indi();
  835. Xstruct individ *set_ind();
  836. Xvoid clear_fam();
  837. Xstruct family *set_fam();
  838. Xvoid clear_head();
  839. Xvoid add_submitter();
  840. Xvoid set_subm();
  841. Xvoid clear_submitter();
  842. Xvoid clear_gedfile();
  843. Xvoid yyerror();
  844. Xint main();
  845. Xint group_tree();
  846. Xvoid find_correspondence();
  847. Xvoid merge_strings();
  848. Xvoid merge_datplace();
  849. Xvoid merge_ordinance();
  850. Xvoid merge_children();
  851. Xvoid remove_child();
  852. Xvoid merge_notes();
  853. Xvoid merge_address();
  854. Xvoid merge_stake();
  855. Xvoid merge_comment();
  856. Xint same_individual();
  857. Xvoid merge_famlist();
  858. Xvoid merge_individ();
  859. Xvoid write_gedfile();
  860. Xvoid write_header();
  861. Xvoid write_submits();
  862. Xvoid write_address();
  863. Xvoid write_stake();
  864. Xvoid write_comments();
  865. Xvoid write_notes();
  866. Xvoid write_individs();
  867. Xvoid write_ind();
  868. Xvoid write_datplace();
  869. Xvoid write_ordinance();
  870. Xvoid write_fams();
  871. Xint deref_ind();
  872. Xvoid write_fam();
  873. X#endif
  874. SHAR_EOF
  875. $TOUCH -am 0103114992 gedcom.h &&
  876. chmod 0664 gedcom.h ||
  877. echo "restore of gedcom.h failed"
  878. set `wc -c gedcom.h`;Wc_c=$1
  879. if test "$Wc_c" != "6187"; then
  880.     echo original size 6187, current size $Wc_c
  881. fi
  882. # ============= gedwrite.c ==============
  883. echo "x - extracting gedwrite.c (Text)"
  884. sed 's/^X//' << 'SHAR_EOF' > gedwrite.c &&
  885. Xstatic char rcs_stuff[] = "$Id: gedwrite.c,v 1.2 1992/01/03 17:49:56 murf Exp $";
  886. X#include <stdio.h>
  887. X#include "gedcom.h"
  888. X#include <string.h>
  889. X/*
  890. X# Copyright (C) 1992 Steven Michael Murphy
  891. X#
  892. X#
  893. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  894. X# 
  895. X# 
  896. X# gcom is free software; you can redistribute it and/or modify
  897. X# it under the terms of the GNU General Public License as published by
  898. X# the Free Software Foundation; either version 2, or (at your option)
  899. X# any later version.
  900. X# 
  901. X# gcom is distributed in the hope that it will be useful,
  902. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  903. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  904. X# GNU General Public License for more details.
  905. X# 
  906. X# You should have received a copy of the GNU General Public License
  907. X# along with gcom; see the file COPYING.  If not, write to
  908. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  909. X*/
  910. X
  911. X/* output routines */
  912. Xstatic struct gedfile *curr_fileg;
  913. X
  914. Xvoid write_gedfile(gf)
  915. Xstruct gedfile *gf;
  916. X{
  917. X    FILE *f;
  918. X    f = fopen(gf->header->file,"w");
  919. X    if( !f )
  920. X    {
  921. X        fprintf(stderr,"Couldn't open %s for writing!\n", gf->header->file);
  922. X        return;
  923. X    }
  924. X    curr_fileg = gf;
  925. X    write_header(f,gf->header);
  926. X    write_submits(f,gf->submitlist);
  927. X    write_individs(f,gf->indlist);
  928. X    write_fams(f,gf->famlist);
  929. X    fprintf(f,"0 TRLR\n");
  930. X    fclose(f);
  931. X}
  932. X
  933. Xvoid write_header(f,h)
  934. XFILE *f;
  935. Xstruct gheader *h;
  936. X{
  937. X    
  938. X    fprintf(f,"0 HEAD\n");
  939. X    if( h->source )
  940. X         fprintf(f,"1 SOUR %s\n",h->source);
  941. X    if(h->dest)
  942. X          fprintf(f,"1 DEST %s\n",h->dest);
  943. X    if(h->date)
  944. X           fprintf(f,"1 DATE %s\n",h->date);
  945. X     if(h->file)
  946. X           fprintf(f,"1 FILE %s\n",h->file);
  947. X     if(h->charset)
  948. X           fprintf(f,"1 CHAR %s\n",h->charset);
  949. X}
  950. X
  951. Xvoid write_submits(f,s)
  952. XFILE *f;
  953. Xstruct submitlist *s;
  954. X{
  955. X    int i;
  956. X    for(i=0; i< s->num; i++)
  957. X    {
  958. X         fprintf(f,"0 @S%d@ SUBM\n",i);
  959. X         if( s->subm[i]->name )
  960. X             fprintf(f,"1 NAME %s\n",s->subm[i]->name);
  961. X        write_address(f,s->subm[i]->addr);
  962. X          if( s->subm[i]->phone )
  963. X              fprintf(f,"1 PHON %s\n",s->subm[i]->phone);
  964. X          write_stake(f,s->subm[i]->stake );
  965. X        write_comments(f,s->subm[i]->comments);
  966. X    }
  967. X}
  968. X
  969. Xvoid write_address(f,a)
  970. XFILE *f;
  971. Xstruct address *a;
  972. X{
  973. X    int i;
  974. X    if( !a )
  975. X        return;
  976. X        
  977. X    fprintf(f,"1 ADDR %s\n", a->addr[0]);
  978. X    for(i=1; i< a->num; i++)
  979. X    {
  980. X        fprintf(f,"2 CONT %s\n", a->addr[i]);
  981. X    }
  982. X}
  983. X
  984. Xvoid write_stake(f,s)
  985. XFILE *f;
  986. Xstruct stake *s;
  987. X{
  988. X    if( !s)
  989. X        return;
  990. X        
  991. X    fprintf(f,"1 STAL\n");
  992. X    if( s->name )
  993. X        fprintf(f,"2 NAME %s\n", s->name);
  994. X    if( s->num )
  995. X        fprintf(f,"2 NUMB %d\n",s->num);
  996. X}
  997. X
  998. Xvoid write_comments(f,c)
  999. XFILE *f;
  1000. Xstruct comment *c;
  1001. X{
  1002. X    int i;
  1003. X    
  1004. X    if( !c )
  1005. X        return;
  1006. X    fprintf(f,"1 COMM %s\n", c->line[0]);
  1007. X    for(i=1; i< c->lines; i++)
  1008. X    {
  1009. X        fprintf(f,"2 CONT %s\n",c->line[1]);
  1010. X    }
  1011. X}
  1012. X
  1013. Xvoid write_notes(f,n)
  1014. XFILE *f;
  1015. Xstruct notelist *n;
  1016. X{
  1017. X    int i,j;
  1018. X    if( !n )
  1019. X        return;
  1020. X    for(i=0; i< n->notes; i++)
  1021. X    {
  1022. X        fprintf(f,"1 NOTE %s\n", n->note[i].line[0]);
  1023. X        for(j=1; j< n->note[i].lines; j++)
  1024. X        {
  1025. X            fprintf(f,"2 CONT %s\n",n->note[i].line[j]);
  1026. X        }
  1027. X    }
  1028. X}
  1029. X
  1030. Xvoid write_individs(f,indl)
  1031. XFILE *f;
  1032. Xstruct indivlist *indl;
  1033. X{
  1034. X    int i;
  1035. X    struct individ *in;
  1036. X    
  1037. X    for(i = 0; i< indl->num; i++ )
  1038. X    {
  1039. X        write_ind(f,indl->ind[i]);
  1040. X    }
  1041. X}
  1042. X
  1043. Xvoid write_ind(f,in)
  1044. XFILE *f;
  1045. Xstruct individ *in;
  1046. X{
  1047. X        fprintf(f,"0 @I%d@ INDI\n", in->index);
  1048. X        if( in->name )
  1049. X            fprintf(f,"1 NAME %s\n", in->name);
  1050. X        if( in->title )
  1051. X              fprintf(f,"1 TITL %s\n", in->title);
  1052. X        if( in->sex == 'M' || in->sex == 'F' )
  1053. X            fprintf(f,"1 SEX %c\n",in->sex);
  1054. X        if( in->givenref )
  1055. X             fprintf(f,"1 REFN %s\n", in->givenref);
  1056. X         write_datplace(f,1,"BIRT",in->birth);
  1057. X         write_datplace(f,1,"CHR",in->christen);
  1058. X         write_datplace(f,1,"DEAT",in->death);
  1059. X          write_datplace(f,1,"BURI",in->burial);
  1060. X        write_ordinance(f,1,"BAPL",in->baptism);
  1061. X         write_ordinance(f,1,"ENDL", in->endow);
  1062. X         write_ordinance(f,1,"SLGC",in->child_to_parent);
  1063. X        if( in->flag )
  1064. X             fprintf(f,"1 FLAG %s\n", in->flag);
  1065. X        if( in->fams )
  1066. X        {
  1067. X            int i;
  1068. X            for(i=0; i<in->fams->num; i++)
  1069. X            {
  1070. X                struct family *fm;
  1071. X                st_lookup(curr_fileg->families, in->fams->family_refs[i],(char **)&fm);
  1072. X                fprintf(f,"1 FAMS @F%d@\n", fm->index);
  1073. X            }
  1074. X        }
  1075. X        if( in->famc )
  1076. X        {
  1077. X            struct family *fm;
  1078. X            st_lookup(curr_fileg->families, in->famc,(char **)&fm);
  1079. X            fprintf(f,"1 FAMC @F%d@\n",fm->index);
  1080. X        }
  1081. X        if( in->submitter )
  1082. X        {
  1083. X            struct  submitter *s;
  1084. X            st_lookup(curr_fileg->submits, in->submitter,(char **)&s);
  1085. X            fprintf(f,"1 SUBM @S%d@\n", s->index);
  1086. X            if( in->submitter_rel )
  1087. X                fprintf(f,"2 REL %s\n", in->submitter_rel);
  1088. X        }
  1089. X        if( in->destination_flag )
  1090. X             fprintf(f,"1 DEST %s\n", in->destination_flag);
  1091. X        write_notes(f,in->notes);
  1092. X}
  1093. X
  1094. Xvoid write_datplace(f,lev,tag,ptr)
  1095. XFILE *f;
  1096. Xint lev;
  1097. Xchar *tag;
  1098. Xstruct datplace *ptr;
  1099. X{
  1100. X    if( ptr )
  1101. X    {
  1102. X        fprintf(f,"%d %s\n", lev, tag);
  1103. X         if(ptr->date)
  1104. X               fprintf(f,"%d DATE %s\n", lev+1, ptr->date);
  1105. X         if(ptr->place)
  1106. X               fprintf(f,"%d PLAC %s\n", lev+1, ptr->place);
  1107. X    }
  1108. X}
  1109. X
  1110. Xvoid write_ordinance(f,lev,tag,ptr)
  1111. XFILE *f;
  1112. Xint lev;
  1113. Xchar *tag;
  1114. Xstruct ordinance *ptr;
  1115. X{
  1116. X    if( ptr )
  1117. X    {
  1118. X        if( ptr->val )
  1119. X            fprintf(f,"%d %s %s\n", lev, tag, ptr->val);
  1120. X        else
  1121. X            fprintf(f,"%d %s\n", lev, tag);
  1122. X         if(ptr->date)
  1123. X               fprintf(f,"%d DATE %s\n", lev+1, ptr->date);
  1124. X          if(ptr->temp[0])
  1125. X                fprintf(f,"%d TEMP %s\n", lev+1, ptr->temp);
  1126. X          if(ptr->qual)
  1127. X                fprintf(f,"%d QUAL %s\n", lev+1, ptr->qual);
  1128. X    }
  1129. X}
  1130. X
  1131. Xvoid write_fams(f,faml)
  1132. XFILE *f;
  1133. Xstruct famlylist *faml;
  1134. X{
  1135. X    int i;
  1136. X    struct family *fm;
  1137. X    
  1138. X    for(i = 0; i< faml->num; i++ )
  1139. X    {
  1140. X        write_fam(f,faml->fam[i]);
  1141. X    }
  1142. X}
  1143. X
  1144. Xint deref_ind(ref)
  1145. Xchar *ref;
  1146. X{
  1147. X    struct individ *i;
  1148. X    st_lookup(curr_fileg->indiv, ref, (char **)&i);
  1149. X    return i->index;
  1150. X}
  1151. X
  1152. Xvoid write_fam(f,fm)
  1153. XFILE *f;
  1154. Xstruct family *fm;
  1155. X{
  1156. X    int i;
  1157. X    
  1158. X    fprintf(f,"0 @F%d@ FAM\n", fm->index);
  1159. X     if( fm->husb )
  1160. X                 fprintf(f,"1 HUSB @I%d@\n", deref_ind(fm->husb));
  1161. X     if( fm->wife )
  1162. X                 fprintf(f,"1 WIFE @I%d@\n", deref_ind(fm->wife));
  1163. X    if( fm->kids )
  1164. X    {
  1165. X        for(i=0; i< fm->kids->kids; i++)
  1166. X        {
  1167. X            struct child *c;
  1168. X            c = &fm->kids->kid[i];
  1169. X             fprintf(f,"1 CHIL @I%d@\n", deref_ind(c->ref));
  1170. X            write_ordinance(f,2,"SLGC",c->slgc);
  1171. X        }
  1172. X    }
  1173. X    write_datplace(f,1,"MARR",fm->marriage);
  1174. X    if( fm->divorce )
  1175. X         fprintf(f,"1 DIV Y\n", fm->divorce);
  1176. X     if( fm->dest )
  1177. X         fprintf(f,"1 DEST %s\n", fm->dest);
  1178. X     if( fm->flag )
  1179. X         fprintf(f,"1 FLAG %s\n", fm->flag);
  1180. X    if( fm->submitter )
  1181. X    {
  1182. X        struct  submitter *s;
  1183. X        st_lookup(curr_fileg->submits, fm->submitter,(char **)&s);
  1184. X        fprintf(f,"1 SUBM @S%d@\n", s->index);
  1185. X        if( fm->submitter_rel )
  1186. X            fprintf(f,"2 REL %s\n", fm->submitter_rel);
  1187. X    }
  1188. X}
  1189. X
  1190. SHAR_EOF
  1191. $TOUCH -am 0103114992 gedwrite.c &&
  1192. chmod 0664 gedwrite.c ||
  1193. echo "restore of gedwrite.c failed"
  1194. set `wc -c gedwrite.c`;Wc_c=$1
  1195. if test "$Wc_c" != "6455"; then
  1196.     echo original size 6455, current size $Wc_c
  1197. fi
  1198. # ============= gedcom.lex ==============
  1199. echo "x - extracting gedcom.lex (Text)"
  1200. sed 's/^X//' << 'SHAR_EOF' > gedcom.lex &&
  1201. X%{
  1202. X/*
  1203. X# Copyright (C) 1992 Steven Michael Murphy
  1204. X#
  1205. X#
  1206. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  1207. X# 
  1208. X# 
  1209. X# gcom is free software; you can redistribute it and/or modify
  1210. X# it under the terms of the GNU General Public License as published by
  1211. X# the Free Software Foundation; either version 2, or (at your option)
  1212. X# any later version.
  1213. X# 
  1214. X# gcom is distributed in the hope that it will be useful,
  1215. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1216. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1217. X# GNU General Public License for more details.
  1218. X# 
  1219. X# You should have received a copy of the GNU General Public License
  1220. X# along with gcom; see the file COPYING.  If not, write to
  1221. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1222. X*/
  1223. X#include <stdio.h>
  1224. X#include <string.h>
  1225. X#include "gedcom.b.tab.h"
  1226. Xextern int lineno;
  1227. Xstatic char rcs_stuff[] = "$Id: gedcom.lex,v 1.2 1992/01/03 17:49:48 murf Exp $";
  1228. X/* below follows a list of all the tokens allowed in GEDCOM files */
  1229. X
  1230. X%}
  1231. Xoptfield        ([ ].+)?$
  1232. X
  1233. X%%
  1234. XBIC        { return BIC; }
  1235. XSTILLBORN    { return STILLBORN;}
  1236. XCLEARED        { return CLEARED; }
  1237. XUNCLEARED    { return UNCLEARED; }
  1238. XDNS        { return DNS; }
  1239. XSEENOTES    { return SEENOTES; }
  1240. XSUBMITTED    { return SUBMITTED; }
  1241. XCOMPLETED    { return COMPLETED; }
  1242. XCHILD    { return CHILD; }
  1243. XINFANT    { return INFANT; }
  1244. XCANCELLED    { return CANCELLED; }
  1245. XDNS/CAN    { return DNSCAN; }
  1246. XADDR[ ].+$        { setyystr(yytext); return ADDR;}
  1247. XBAPL([ ].+$)?        {setyystr(yytext);return BAPL;}
  1248. XBIC{optfield}    { setyystr(yytext); return BIC;}
  1249. XBIRT        {return BIRT;}
  1250. XBURI        {return BURI;}
  1251. XCHAR[ ].*$        {setyystr(yytext); return CHAR;}
  1252. XCHIL        {return CHIL;}
  1253. XCHR        {return CHR;}
  1254. XCOMM[ ].*$        {setyystr(yytext); return COMM;}
  1255. XCONT[ ].*$        {setyystr(yytext); return CONT;}
  1256. XDATE[ ].*$        {setyystr(yytext); return DATE;}
  1257. XDEAT        {return DEAT;}
  1258. XDEST[ ].*$        {setyystr(yytext); return DEST;}
  1259. XDIV[ ].*$        {if( yytext[4] == 'Y' ) yylval.num =1;
  1260. X            else yylval.num = 0; return DIV;}
  1261. XENDL        {return ENDL;}
  1262. XFAM            {return FAM;}
  1263. XFAMC        {return FAMC;}
  1264. XFAMS        {return FAMS;}
  1265. XFILE[ ].*$        {setyystr(yytext); return FILE9;}
  1266. XFLAG.+$        {setyystr(yytext); return FLAG;}
  1267. XHEAD        {return HEAD;}
  1268. XHUSB        {return HUSB;}
  1269. XINDI        {return INDI;}
  1270. XMARR        {return MARR;}
  1271. XNAME[ ].*$    {setyystr(yytext); return NAME;}
  1272. XNOTE[ ].*$        {setyystr(yytext); return NOTE;}
  1273. XNUMB[ ].*$        {yylval.num = atoi(yytext+6); return NOTE;}
  1274. XPHON[ ].*$        {setyystr(yytext); return PHON;}
  1275. XPLAC[ ].*$        {setyystr(yytext); return PLAC;}
  1276. XQUAL.*$            {setyystr(yytext); return QUAL;}
  1277. XREFN{optfield}    { setyystr(yytext); return REFN;}
  1278. XREL[ ].*$            {setyystr(yytext); return REL;}
  1279. XSEX[ ].*$        {setyystr(yytext); return SEX;}
  1280. XSLGC        {return SLGC;}
  1281. XSLGS    {return SLGS;}
  1282. XSOUR[ ].*$    {setyystr(yytext); return SOUR;}
  1283. XSTAL            {return STAL;}
  1284. XSUBM            {return SUBM;}
  1285. XTEMP[ ].+$        {setyystr(yytext); return TEMP;}
  1286. XTITL[ ].*$        {setyystr(yytext); return TITL;}
  1287. XTRLR        {return TRLR;}
  1288. XWIFE        {return WIFE;}
  1289. X@[^@]+@        {int x; 
  1290. X                        x = strlen(yytext);
  1291. X                        yylval.str = (char *)malloc(x);
  1292. X                        strncpy(yylval.str,yytext+1,x-2);
  1293. X                        yylval.str[x-2]=0;
  1294. X                        return REF;}
  1295. X^0        {yylval.num = 0; return LEV0; }
  1296. X^1        {yylval.num = 0; return LEV1; }
  1297. X^2        {yylval.num = 0; return LEV2; }
  1298. X^3        {yylval.num = 0; return LEV3; }
  1299. X^[4-9]+        {yylval.num = atoi(yytext); return LEV3;}
  1300. X\n                    {lineno++;}
  1301. X[     ]*                {}
  1302. X%%
  1303. Xsetyystr(txt)
  1304. Xchar *txt;
  1305. X{
  1306. X    int x=strlen(txt);
  1307. X    char *y = txt;
  1308. X    while( *y && *y != ' ' )
  1309. X        y++;
  1310. X    if( *y )
  1311. X    {
  1312. X        /* there is a space */
  1313. X        x -= (y-txt);
  1314. X        y++;
  1315. X        yylval.str = (char *)malloc(x);
  1316. X        strcpy(yylval.str,y);
  1317. X    }
  1318. X    else
  1319. X        yylval.str = "";
  1320. X}
  1321. SHAR_EOF
  1322. $TOUCH -am 0103114992 gedcom.lex &&
  1323. chmod 0664 gedcom.lex ||
  1324. echo "restore of gedcom.lex failed"
  1325. set `wc -c gedcom.lex`;Wc_c=$1
  1326. if test "$Wc_c" != "3522"; then
  1327.     echo original size 3522, current size $Wc_c
  1328. fi
  1329. # ============= mylex.c ==============
  1330. echo "x - extracting mylex.c (Text)"
  1331. sed 's/^X//' << 'SHAR_EOF' > mylex.c &&
  1332. Xstatic char rcs_stuff[] = "$Id: mylex.c,v 1.2 1992/01/03 17:49:59 murf Exp $";
  1333. X#include <stdio.h>
  1334. X#include "gedcom.b.tab.h"
  1335. X/*
  1336. X# Copyright (C) 1992 Steven Michael Murphy
  1337. X#
  1338. X#
  1339. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  1340. X# 
  1341. X# 
  1342. X# gcom is free software; you can redistribute it and/or modify
  1343. X# it under the terms of the GNU General Public License as published by
  1344. X# the Free Software Foundation; either version 2, or (at your option)
  1345. X# any later version.
  1346. X# 
  1347. X# gcom is distributed in the hope that it will be useful,
  1348. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1349. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1350. X# GNU General Public License for more details.
  1351. X# 
  1352. X# You should have received a copy of the GNU General Public License
  1353. X# along with gcom; see the file COPYING.  If not, write to
  1354. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1355. X*/
  1356. X
  1357. XFILE *yyin;
  1358. X
  1359. Xstruct keyword
  1360. X{
  1361. X    char *name;
  1362. X    int val;
  1363. X};
  1364. X
  1365. Xstatic struct keyword keylist[] = 
  1366. X{
  1367. X    {"ADDR",ADDR},
  1368. X    {"BAPL",BAPL},
  1369. X    {"CHAR",CHAR},
  1370. X    {"COMM",COMM},
  1371. X    {"CONT",CONT},
  1372. X    {"DATE",DATE},
  1373. X    {"DEST",DEST},
  1374. X    {"ENDL",ENDL},
  1375. X    {"FILE",FILE9},
  1376. X    {"FLAG",FLAG},
  1377. X    {"NAME",NAME},
  1378. X    {"NOTE",NOTE},
  1379. X    {"PHON",PHON},
  1380. X    {"PLAC",PLAC},
  1381. X    {"QUAL",QUAL},
  1382. X    {"REL",REL},
  1383. X    {"SEX",SEX},
  1384. X    {"SOUR",SOUR},
  1385. X    {"TEMP",TEMP},
  1386. X    {"TITL",TITL},
  1387. X    {"BIC",BIC},
  1388. X    {"NUMB",NUMB},
  1389. X    {"REFN",REFN},
  1390. X    {"BIRT",BIRT},
  1391. X    {"BURI",BURI},
  1392. X    {"CHIL",CHIL},
  1393. X    {"CHR",CHR},
  1394. X    {"DEAT",DEAT},
  1395. X    {"FAM",FAM},
  1396. X    {"FAMC",FAMC},
  1397. X    {"FAMS",FAMS},
  1398. X    {"HEAD",HEAD},
  1399. X    {"HUSB",HUSB},
  1400. X    {"INDI",INDI},
  1401. X    {"MARR",MARR},
  1402. X    {"STAL",STAL},
  1403. X    {"TRLR",TRLR},
  1404. X    {"WIFE",WIFE},
  1405. X    {"SUBM",SUBM},
  1406. X    {"SLGC",SLGC},
  1407. X    {"SLGS",SLGS},
  1408. X    {0,0}
  1409. X};
  1410. X
  1411. Xextern int lineno;
  1412. Xstatic char buff[300]; /* Actually, 80 may be enough */
  1413. Xstatic char *buff_ptr = &buff[0];
  1414. X
  1415. Xyylex()
  1416. X{
  1417. X    char *p;
  1418. X    int i;
  1419. X    
  1420. X    if( !(*buff_ptr) )
  1421. X    {
  1422. X        int lev;
  1423. X        if( !fgets(buff,300,yyin) )
  1424. X        {
  1425. X            return 0; /* end of file */
  1426. X        }
  1427. X        buff[strlen(buff)-1] = 0; /* blast the newline */
  1428. X        lineno++;
  1429. X        buff_ptr = &buff[0]; /* get a new line */
  1430. X        /* the first thing on a line is the level number, get it */
  1431. X        lev = strtol(buff,&p,10);
  1432. X        if( p == buff_ptr )
  1433. X        {
  1434. X            fprintf(stderr,"No level number at the beginning of the line on line %d\n",
  1435. X                    lineno);
  1436. X            return LEV0;
  1437. X        }
  1438. X        buff_ptr = p;
  1439. X        return LEV0+lev;
  1440. X    }
  1441. X    else
  1442. X    {
  1443. X        /* either a type or a reference */
  1444. X        while(*buff_ptr &&
  1445. X              (*buff_ptr == ' ' || *buff_ptr == '\t') )
  1446. X            buff_ptr++;
  1447. X        /* collect next token */
  1448. X        p = buff_ptr;
  1449. X        while( *buff_ptr && (*buff_ptr != ' ' && *buff_ptr != '\t' &&
  1450. X                             *buff_ptr != '\n' ) )
  1451. X            buff_ptr++;
  1452. X        if( *p == '@' )
  1453. X        {
  1454. X            char x,*y;
  1455. X            
  1456. X            x = *buff_ptr;
  1457. X            *buff_ptr = 0;
  1458. X            p++; /* skip the @ stuff and just pass the ref id */
  1459. X            yylval.str = (char *)malloc(buff_ptr-p);
  1460. X            strncpy(yylval.str,p,buff_ptr-p);
  1461. X            yylval.str[buff_ptr-p-1] = 0; /* leave out the '@'s */
  1462. X            *buff_ptr = x;
  1463. X            return REF;
  1464. X        }
  1465. X        if( !strncmp(p,"DIV",3) ) /* DIV is a slightly special case ... ? */
  1466. X        {
  1467. X            if( *(p+4) == 'Y' ) yylval.num = 1;
  1468. X            else yylval.num = 0;
  1469. X            *buff_ptr = 0; /* we are done here */
  1470. X            return DIV;
  1471. X        }
  1472. X        *buff_ptr = 0;
  1473. X        /* then match on the token, and return the rest of the line as
  1474. X           the value */
  1475. X        /* the tokens are arranged in a ______table. */
  1476. X        for(i=0; keylist[i].name; i++)
  1477. X        {
  1478. X            if( !strcmp(keylist[i].name,p) )
  1479. X            {
  1480. X                *buff_ptr = ' ';
  1481. X                if( *(buff_ptr+1) == '@' )
  1482. X                {
  1483. X                    return keylist[i].val;
  1484. X                }
  1485. X                setyystr(p);
  1486. X                *buff_ptr = 0; /* this will reset the lexer and read in a
  1487. X                                  new line next time.... */
  1488. X                return keylist[i].val;
  1489. X            }
  1490. X        }
  1491. X        /* else report error */
  1492. X        fprintf(stderr,"HEY, '%s' is not a keyword I understand! (line %d)\n",
  1493. X                p, lineno);
  1494. X    }
  1495. X}
  1496. X
  1497. X
  1498. Xsetyystr(txt)
  1499. Xchar *txt;
  1500. X{
  1501. X    int x=strlen(txt);
  1502. X    char *y = txt;
  1503. X    while( *y && *y != ' ' )
  1504. X        y++;
  1505. X    if( *y )
  1506. X    {
  1507. X        /* there is a space */
  1508. X        x -= (y-txt);
  1509. X        y++;
  1510. X        yylval.str = (char *)malloc(x);
  1511. X        strcpy(yylval.str,y);
  1512. X    }
  1513. X    else
  1514. X        yylval.str = "";
  1515. X}
  1516. X
  1517. SHAR_EOF
  1518. $TOUCH -am 0103114992 mylex.c &&
  1519. chmod 0664 mylex.c ||
  1520. echo "restore of mylex.c failed"
  1521. set `wc -c mylex.c`;Wc_c=$1
  1522. if test "$Wc_c" != "3915"; then
  1523.     echo original size 3915, current size $Wc_c
  1524. fi
  1525. # ============= mylex2.dist ==============
  1526. echo "x - extracting mylex2.dist (Text)"
  1527. sed 's/^X//' << 'SHAR_EOF' > mylex2.dist &&
  1528. X/* starting time is 11:41:09 */
  1529. X/* C code produced by gperf version 2.5 (GNU C++ version) */
  1530. X/* Command-line: gperf -G -k 1,3,4 -p -S 1 -t keys.gperf  */
  1531. Xstatic char rcs_stuff[] = "$Id: keys.gperf,v 1.1.1.1 1992/01/03 17:10:27 murf Exp $";
  1532. X/*
  1533. X# Copyright (C) 1992 Steven Michael Murphy
  1534. X#
  1535. X#
  1536. X# This file is part of gcom, the GEDCOM file merging utility for UNIX,
  1537. X# 
  1538. X# 
  1539. X# gcom is free software; you can redistribute it and/or modify
  1540. X# it under the terms of the GNU General Public License as published by
  1541. X# the Free Software Foundation; either version 2, or (at your option)
  1542. X# any later version.
  1543. X# 
  1544. X# gcom is distributed in the hope that it will be useful,
  1545. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1546. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1547. X# GNU General Public License for more details.
  1548. X# 
  1549. X# You should have received a copy of the GNU General Public License
  1550. X# along with gcom; see the file COPYING.  If not, write to
  1551. X# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  1552. X*/
  1553. X#include <stdio.h>
  1554. X#include "gedcom.b.tab.h"
  1555. Xextern int lineno;
  1556. Xstatic char buff[300]; /* Actually, 80 may be enough */
  1557. Xstatic char *buff_ptr = &buff[0];
  1558. X
  1559. X
  1560. XFILE *yyin;
  1561. Xstruct keyword {    char *name;     int val; };
  1562. X
  1563. X#define TOTAL_KEYWORDS 41
  1564. X#define MIN_WORD_LENGTH 3
  1565. X#define MAX_WORD_LENGTH 4
  1566. X#define MIN_HASH_VALUE 4
  1567. X#define MAX_HASH_VALUE 155
  1568. X/* maximum key range = 152, duplicates = 0 */
  1569. X
  1570. Xstatic unsigned int
  1571. Xhash (str, len)
  1572. X     register char *str;
  1573. X     register int unsigned len;
  1574. X{
  1575. X  static unsigned char asso_values[] =
  1576. X    {
  1577. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1578. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1579. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1580. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1581. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1582. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1583. X     156, 156, 156, 156, 156,  10,  50,  11,  41,  15,
  1584. X      55,   6,  35,  55, 156, 156,  25,   0,  15,   0,
  1585. X       1,  40,   0,   0,   6,   5, 156,  10,   5, 156,
  1586. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1587. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1588. X     156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
  1589. X     156, 156, 156, 156, 156, 156, 156, 156,
  1590. X    };
  1591. X  register int hval = len;
  1592. X
  1593. X  switch (hval)
  1594. X    {
  1595. X      default:
  1596. X      case 4:
  1597. X        hval += asso_values[str[3]];
  1598. X      case 3:
  1599. X        hval += asso_values[str[2]];
  1600. X      case 2:
  1601. X      case 1:
  1602. X        hval += asso_values[str[0]];
  1603. X    }
  1604. X  return hval;
  1605. X}
  1606. X
  1607. Xstatic struct keyword wordlist[] =
  1608. X{
  1609. X      {"",}, {"",}, {"",}, {"",}, 
  1610. X      {"MARR",  MARR},
  1611. X      {"SEX",  SEX},
  1612. X      {"SOUR",  SOUR},
  1613. X      {"SLGS",  SLGS},
  1614. X      {"TEMP",  TEMP},
  1615. X      {"CHR",  CHR},
  1616. X      {"COMM",  COMM},
  1617. X      {"PHON",  PHON},
  1618. X      {"SLGC",  SLGC},
  1619. X      {"CHAR",  CHAR},
  1620. X      {"PLAC",  PLAC},
  1621. X      {"REL",  REL},
  1622. X      {"NAME",  NAME},
  1623. X      {"TRLR",  TRLR},
  1624. X      {"CONT",  CONT},
  1625. X      {"STAL",  STAL},
  1626. X      {"NOTE",  NOTE},
  1627. X      {"TITL",  TITL},
  1628. X      {"DEST",  DEST},
  1629. X      {"SUBM",  SUBM},
  1630. X      {"ADDR",  ADDR},
  1631. X      {"FAM",  FAM},
  1632. X      {"FAMS",  FAMS},
  1633. X      {"BIRT",  BIRT},
  1634. X      {"DEAT",  DEAT},
  1635. X      {"BIC",  BIC},
  1636. X      {"DATE",  DATE},
  1637. X      {"NUMB",  NUMB},
  1638. X      {"FAMC",  FAMC},
  1639. X      {"REFN",  REFN},
  1640. X      {"FLAG",  FLAG},
  1641. X      {"QUAL",  QUAL},
  1642. X      {"BAPL",  BAPL},
  1643. X      {"WIFE",  WIFE},
  1644. X      {"ENDL",  ENDL},
  1645. X      {"HUSB",  HUSB},
  1646. X      {"HEAD",  HEAD},
  1647. X      {"CHIL",  CHIL},
  1648. X      {"FILE",  FILE9},
  1649. X      {"BURI",  BURI},
  1650. X      {"INDI",  INDI},
  1651. X};
  1652. X
  1653. Xstruct keyword *
  1654. Xin_word_set (str, len)
  1655. X     register char *str;
  1656. X     register unsigned int len;
  1657. X{
  1658. X  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  1659. X    {
  1660. X      register int key = hash (str, len);
  1661. X
  1662. X      if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
  1663. X        {
  1664. X            {
  1665. X              struct keyword  *resword; 
  1666. X
  1667. X              switch (key)
  1668. X                {
  1669. X                case    4:
  1670. X                  resword = &wordlist[4]; break;
  1671. X                case    8:
  1672. X                  resword = &wordlist[5]; break;
  1673. X                case    9:
  1674. X                  resword = &wordlist[6]; break;
  1675. X                case   10:
  1676. X                  resword = &wordlist[7]; break;
  1677. X                case   11:
  1678. X                  resword = &wordlist[8]; break;
  1679. X                case   14:
  1680. X                  resword = &wordlist[9]; break;
  1681. X                case   15:
  1682. X                  resword = &wordlist[10]; break;
  1683. X                case   20:
  1684. X                  resword = &wordlist[11]; break;
  1685. X                case   21:
  1686. X                  resword = &wordlist[12]; break;
  1687. X                case   25:
  1688. X                  resword = &wordlist[13]; break;
  1689. X                case   26:
  1690. X                  resword = &wordlist[14]; break;
  1691. X                case   28:
  1692. X                  resword = &wordlist[15]; break;
  1693. X                case   34:
  1694. X                  resword = &wordlist[16]; break;
  1695. X                case   35:
  1696. X                  resword = &wordlist[17]; break;
  1697. X                case   36:
  1698. X                  resword = &wordlist[18]; break;
  1699. X                case   39:
  1700. X                  resword = &wordlist[19]; break;
  1701. X                case   40:
  1702. X                  resword = &wordlist[20]; break;
  1703. X                case   41:
  1704. X                  resword = &wordlist[21]; break;
  1705. X                case   51:
  1706. X                  resword = &wordlist[22]; break;
  1707. X                case   54:
  1708. X                  resword = &wordlist[23]; break;
  1709. X                case   55:
  1710. X                  resword = &wordlist[24]; break;
  1711. X                case   58:
  1712. X                  resword = &wordlist[25]; break;
  1713. X                case   59:
  1714. X                  resword = &wordlist[26]; break;
  1715. X                case   60:
  1716. X                  resword = &wordlist[27]; break;
  1717. X                case   61:
  1718. X                  resword = &wordlist[28]; break;
  1719. X                case   64:
  1720. X                  resword = &wordlist[29]; break;
  1721. X                case   66:
  1722. X                  resword = &wordlist[30]; break;
  1723. X                case   69:
  1724. X                  resword = &wordlist[31]; break;
  1725. X                case   70:
  1726. X                  resword = &wordlist[32]; break;
  1727. X                case   74:
  1728. X                  resword = &wordlist[33]; break;
  1729. X                case   75:
  1730. X                  resword = &wordlist[34]; break;
  1731. X                case   79:
  1732. X                  resword = &wordlist[35]; break;
  1733. X                case   80:
  1734. X                  resword = &wordlist[36]; break;
  1735. X                case   84:
  1736. X                  resword = &wordlist[37]; break;
  1737. X                case   85:
  1738. X                  resword = &wordlist[38]; break;
  1739. X                case   89:
  1740. X                  resword = &wordlist[39]; break;
  1741. X                case   90:
  1742. X                  resword = &wordlist[40]; break;
  1743. X                case   95:
  1744. X                  resword = &wordlist[41]; break;
  1745. X                case   99:
  1746. X                  resword = &wordlist[42]; break;
  1747. X                case  109:
  1748. X                  resword = &wordlist[43]; break;
  1749. X                case  155:
  1750. X                  resword = &wordlist[44]; break;
  1751. X                default: return 0;
  1752. X                }
  1753. X              if (*str == *resword->name && !strcmp (str + 1, resword->name + 1))
  1754. X                return resword;
  1755. X              return 0;
  1756. X            }
  1757. X         }
  1758. X    }
  1759. X  return 0;
  1760. X}
  1761. X
  1762. X
  1763. Xyylex()
  1764. X{
  1765. X    struct keyword *kw;
  1766. X    char *p;
  1767. X    int i;
  1768. X    
  1769. X    if( !(*buff_ptr) )
  1770. X    {
  1771. X        int lev;
  1772. X        if( !fgets(buff,300,yyin) )
  1773. X        {
  1774. X            return 0; /* end of file */
  1775. X        }
  1776. X        buff[strlen(buff)-1] = 0; /* blast the newline */
  1777. X        lineno++;
  1778. X        buff_ptr = &buff[0]; /* get a new line */
  1779. X        /* the first thing on a line is the level number, get it */
  1780. X        lev = strtol(buff,&p,10);
  1781. X        if( p == buff_ptr )
  1782. X        {
  1783. X            fprintf(stderr,"No level number at the beginning of the line on line %d\n",
  1784. X                    lineno);
  1785. X            return LEV0;
  1786. X        }
  1787. X        buff_ptr = p;
  1788. X        return LEV0+lev;
  1789. X    }
  1790. X    else
  1791. X    {
  1792. X        /* either a type or a reference */
  1793. X        while(*buff_ptr &&
  1794. X              (*buff_ptr == ' ' || *buff_ptr == '\t') )
  1795. X            buff_ptr++;
  1796. X        /* collect next token */
  1797. X        p = buff_ptr;
  1798. X        while( *buff_ptr && (*buff_ptr != ' ' && *buff_ptr != '\t' &&
  1799. X                             *buff_ptr != '\n' ) )
  1800. X            buff_ptr++;
  1801. X        if( *p == '@' )
  1802. X        {
  1803. X            char x,*y;
  1804. X            
  1805. X            x = *buff_ptr;
  1806. X            *buff_ptr = 0;
  1807. X            p++; /* skip the @ stuff and just pass the ref id */
  1808. X            yylval.str = (char *)malloc(buff_ptr-p);
  1809. X            strncpy(yylval.str,p,buff_ptr-p);
  1810. X            yylval.str[buff_ptr-p-1] = 0; /* leave out the '@'s */
  1811. X            *buff_ptr = x;
  1812. X            return REF;
  1813. X        }
  1814. X        if( !strncmp(p,"DIV",3) ) /* DIV is a slightly special case ... ? */
  1815. X        {
  1816. X            if( *(p+4) == 'Y' ) yylval.num = 1;
  1817. X            else yylval.num = 0;
  1818. X            *buff_ptr = 0; /* we are done here */
  1819. X            return DIV;
  1820. X        }
  1821. X        *buff_ptr = 0;
  1822. X        /* then match on the token, and return the rest of the line as
  1823. X           the value */
  1824. X        /* the tokens are arranged in a ______table. */
  1825. X        kw = in_word_set(p,strlen(p));
  1826. X        if( kw )
  1827. X        {
  1828. X            *buff_ptr = ' ';
  1829. X            if( *(buff_ptr+1) == '@' )
  1830. X            {
  1831. X                return kw->val;
  1832. X            }
  1833. X            setyystr(p);
  1834. X            *buff_ptr = 0; /* this will reset the lexer and read in a
  1835. X                              new line next time.... */
  1836. X            return kw->val;
  1837. X        }
  1838. X        else
  1839. X        {
  1840. X            /* else report error */
  1841. X            fprintf(stderr,"HEY, '%s' is not a keyword I understand! (line %d)\n",
  1842. X                    p, lineno);
  1843. X        }
  1844. X    }
  1845. X}
  1846. X
  1847. X
  1848. Xsetyystr(txt)
  1849. Xchar *txt;
  1850. X{
  1851. X    int x=strlen(txt);
  1852. X    char *y = txt;
  1853. X    while( *y && *y != ' ' )
  1854. X        y++;
  1855. X    if( *y )
  1856. X    {
  1857. X        /* there is a space */
  1858. X        x -= (y-txt);
  1859. X        y++;
  1860. X        yylval.str = (char *)malloc(x);
  1861. X        strcpy(yylval.str,y);
  1862. X    }
  1863. X    else
  1864. X        yylval.str = "";
  1865. X}
  1866. X
  1867. X/* ending time is 11:41:09 */
  1868. SHAR_EOF
  1869. $TOUCH -am 0103114692 mylex2.dist &&
  1870. chmod 0664 mylex2.dist ||
  1871. echo "restore of mylex2.dist failed"
  1872. set `wc -c mylex2.dist`;Wc_c=$1
  1873. if test "$Wc_c" != "9447"; then
  1874.     echo original size 9447, current size $Wc_c
  1875. fi
  1876. echo "End of part 2, continue with part 3"
  1877. exit 0
  1878.  
  1879. exit 0 # Just in case...
  1880.