help
Line | |
---|
1 | |
---|
2 | #include "mgraph.hh" |
---|
3 | #include "thesymbols.hh" |
---|
4 | #include "const.hh" |
---|
5 | #include "common.h" |
---|
6 | |
---|
7 | #include <stdio.h> |
---|
8 | |
---|
9 | int MGraph::add_node(char* seg) |
---|
10 | { |
---|
11 | nodes[n].clear(); |
---|
12 | |
---|
13 | char field1[80], field3[80], descr[256], gph[256]; |
---|
14 | char* cat; |
---|
15 | |
---|
16 | getfield(seg,"1",field1); |
---|
17 | nodes[n].pos=atoi(field1); |
---|
18 | |
---|
19 | getfield(seg,"3",field3); |
---|
20 | if(!getfield(seg,"lem",descr)) strcpy(descr,"?,?"); |
---|
21 | |
---|
22 | cat=descr; |
---|
23 | while(*cat!=',' && *cat ) ++cat; |
---|
24 | if(*cat) ++cat; |
---|
25 | |
---|
26 | Cat::add(cat); |
---|
27 | nodes[n].cat=cat; |
---|
28 | |
---|
29 | nodes[n].pred.clear(); |
---|
30 | |
---|
31 | char* tok; |
---|
32 | int previd; |
---|
33 | |
---|
34 | if(!getfield(seg,"gph",gph)) |
---|
35 | { |
---|
36 | fprintf(stderr,"No gph field. Aborting (sorry).\n"); |
---|
37 | exit(1); |
---|
38 | } |
---|
39 | |
---|
40 | char* ids=strtok(gph,":"); |
---|
41 | if(n!=atoi(ids)){fprintf(stderr,"Invalid node id in line ?. Program aborted.\n"); exit(1); } |
---|
42 | |
---|
43 | char *preds; |
---|
44 | while(preds=strtok(NULL,",")) |
---|
45 | { |
---|
46 | previd=atoi(preds); |
---|
47 | nodes[n].pred.push_back(&nodes[previd]); |
---|
48 | } |
---|
49 | |
---|
50 | return n++; |
---|
51 | } |
---|
52 | |
---|
Note: See
TracBrowser
for help on using the repository browser.