/[CvsGraph]/cvsgraph/rcsy.y
ViewVC logotype

Annotate of /cvsgraph/rcsy.y

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations)
Tue Jan 1 21:03:23 2002 UTC (15 years, 11 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_2_0
Changes since 1.2: +2 -1 lines
Major code update to enable some more features. The new formatting scheme is
not yet 100%. This should be close to version 1.2.0.
1 bertho 1.1 /*
2     * CvsGraph graphical representation generator of brances and revisions
3     * of a file in cvs/rcs.
4     *
5     * Copyright (C) 2001 B. Stultiens
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20     */
21    
22     %{
23 bertho 1.3 #define YYERROR_VERBOSE 1
24    
25 bertho 1.1 #include <stdio.h>
26     #include <stdlib.h>
27     #include <string.h>
28     #include <assert.h>
29    
30     #include "utils.h"
31     #include "rcs.h"
32    
33     rcsfile_t *rcsfile;
34    
35     static tag_t *new_tag(char *s, char *r);
36     static tags_t *new_tags(tag_t *s);
37     static tags_t *add_tags(tags_t *s, tag_t *t);
38     static idrev_t *new_idrev(char *s, char *r);
39     static idrevs_t *new_idrevs(idrev_t *s);
40     static idrevs_t *add_idrevs(idrevs_t *s, idrev_t *t);
41     static ids_t *new_ids(char *s);
42     static ids_t *add_ids(ids_t *s, char *t);
43     static revs_t *new_revs(char *s);
44     static revs_t *add_revs(revs_t *s, char *t);
45     static dtext_t *new_dtext(char *n, char *l, char *t);
46     static dtexts_t *add_dtexts(dtexts_t *s, dtext_t *t);
47     static delta_t *new_delta(char *rev, char *date, char *author, char *state, revs_t *branches, char *next);
48     static deltas_t *add_deltas(deltas_t *s, delta_t *t);
49     static rcsfile_t *new_rcsfile(char *head, char *branch, ids_t *access, tags_t *tags,
50     idrevs_t *locks, int strict, char *comment, char *expand);
51    
52     %}
53    
54     %union{
55     int i;
56     char *str;
57     tag_t *tag;
58     tags_t *tags;
59     idrev_t *idrev;
60     idrevs_t *idrevs;
61     ids_t *ids;
62     revs_t *revs;
63     dtext_t *dtext;
64     dtexts_t *dtexts;
65     delta_t *delta;
66     deltas_t *deltas;
67     rcsfile_t *rcsfile;
68     }
69    
70     %token tHEAD tBRANCH tACCESS tSYMBOLS tLOCKS tSTRICT tCOMMENT
71     %token tEXPAND tDATE tAUTHOR tSTATE tBRANCHES tNEXT
72     %token tDESC tLOG tTEXT
73     %token tOWNER tGROUP tPERMISSIONS tSPECIAL tSYMLINK tHARDLINKS
74     %token tNAMESPACE tDEAD
75     %token <str> tNEWPHRASE
76     %token <str> tSTRING tREV tID tSYM
77    
78    
79     %type <str> ostr orev oid obranch ocomment oexpand desc
80     %type <tag> tag
81     %type <tags> tags otags
82     %type <idrev> idrev
83     %type <idrevs> idrevs oidrevs
84     %type <ids> ids oids
85     %type <revs> revs orevs
86     %type <i> ostrict
87     %type <dtext> dtext
88     %type <dtexts> dtexts
89     %type <delta> delta
90     %type <deltas> deltas
91     %type <rcsfile> admin
92    
93     %%
94     rcsfile : admin deltas desc dtexts {
95     rcsfile = $1;
96     rcsfile->deltas = $2;
97     rcsfile->desc = $3;
98     rcsfile->dtexts = $4;
99     if(rcsfile->head)
100     {
101     char *h = xstrdup("HEAD");
102     char *r = xstrdup(rcsfile->head->rev);
103     tag_t *t = new_tag(h, r);
104     rcsfile->tags = add_tags(rcsfile->tags, t);
105     }
106     if(rcsfile->branch)
107     {
108     char *h = xstrdup("MAIN");
109     char *r = xstrdup(rcsfile->branch->rev);
110     tag_t *t = new_tag(h, r);
111     t->rev->isbranch = 1;
112     rcsfile->tags = add_tags(rcsfile->tags, t);
113     }
114     /* Else we need to add the main tag later because the
115     * trunk is reversed in order and the primary revision
116     * numbers can vary.
117     */
118     }
119     ;
120    
121     admin : tHEAD orev ';'
122     obranch
123     tACCESS { set_id(); } oids ';'
124     tSYMBOLS { set_sym(); } otags ';'
125 bertho 1.2 tLOCKS { set_id(); } oidrevs ';' ostrict
126 bertho 1.1 ocomment
127     oexpand
128 bertho 1.2 ophrases { $$ = new_rcsfile($2, $4, $7, $11, $15, $17, $18, $19); }
129 bertho 1.1 ;
130    
131     ostrict : /* Empty */ { $$ = 0; }
132     | tSTRICT ';' { $$ = 1; }
133     ;
134    
135     obranch : /* Empty */ { $$ = NULL; }
136     | tBRANCH orev ';' { $$ = $2; }
137     ;
138    
139     ocomment: /* Empty */ { $$ = NULL; }
140     | tCOMMENT ostr ';' { $$ = $2; }
141     ;
142    
143     oexpand : /* Empty */ { $$ = NULL; }
144     | tEXPAND ostr ';' { $$ = $2; }
145     ;
146    
147     deltas : /* Empty */ { $$ = NULL; }
148     | deltas delta { $$ = add_deltas($1, $2); }
149     ;
150    
151     delta : tREV
152     tDATE tREV ';'
153     tAUTHOR { set_id(); } tID ';'
154     tSTATE { set_id(); } oid ';'
155     tBRANCHES orevs ';'
156     tNEXT orev ';'
157     ophrases { $$ = new_delta($1, $3, $7, $11, $14, $17); }
158     ;
159    
160     desc : tDESC tSTRING { $$ = $2; }
161     ;
162    
163     dtexts : /* Empty */ { $$ = NULL; }
164     | dtexts dtext { $$ = add_dtexts($1, $2); }
165     ;
166    
167     dtext : tREV
168     tLOG tSTRING
169     ophrases
170     tTEXT { set_skipstr(); } tSTRING { $$ = new_dtext($1, $3, $7); }
171     ;
172    
173     ophrases: /* Empty */
174     | ophrases phrase
175     ;
176    
177     phrase : tNEWPHRASE { set_skip(); } ';' {
178     yywarning("Unrecognised `newphrase´ keyword '%s' skipped", $1);
179     xfree($1);
180     }
181     | cvskw { set_skip(); } ';' { yywarning("CVS extended keyword skipped"); }
182     | otherkw { set_skip(); } ';' { yywarning("Other extended keyword"); }
183     ;
184    
185     cvskw : tOWNER
186     | tGROUP
187     | tPERMISSIONS
188     | tSPECIAL
189     | tSYMLINK
190     | tHARDLINKS
191     ;
192    
193     otherkw : tNAMESPACE
194     | tDEAD
195     ;
196    
197     ostr : /* Empty */ { $$ = NULL; }
198     | tSTRING { $$ = $1; }
199     ;
200    
201     orev : /* Empty */ { $$ = NULL; }
202     | tREV { $$ = $1; }
203     ;
204    
205     orevs : /* Empty */ { $$ = NULL; }
206     | revs { $$ = $1; }
207     ;
208    
209     revs : tREV { $$ = new_revs($1); }
210     | revs tREV { $$ = add_revs($1, $2); }
211     ;
212    
213     oid : /* Empty */ { $$ = NULL; }
214     | tID { $$ = $1; }
215     ;
216    
217     oids : /* Empty */ { $$ = NULL; }
218     | ids { $$ = $1; }
219     ;
220    
221     ids : tID { $$ = new_ids($1); }
222     | ids tID { set_id(); $$ = add_ids($1, $2); }
223     ;
224    
225     oidrevs : /* Empty */ { $$ = NULL; }
226     | idrevs { $$ = $1; }
227     ;
228    
229     idrevs : idrev { $$ = new_idrevs($1); }
230     | idrevs idrev { $$ = add_idrevs($1, $2); }
231     ;
232    
233     idrev : tID ':' tREV { set_id(); $$ = new_idrev($1, $3); }
234     ;
235    
236     otags : /* Empty */ { $$ = NULL; }
237     | tags { $$ = $1; }
238     ;
239    
240     tags : tag { $$ = new_tags($1); }
241     | tags tag { $$ = add_tags($1, $2); }
242     ;
243    
244     tag : tSYM ':' tREV { set_sym(); $$ = new_tag($1, $3); }
245     ;
246    
247     %%
248     static rev_t *make_rev(char *s)
249     {
250     char *cptr;
251     int dots = 0;
252     rev_t *r;
253    
254     if(!s)
255     return NULL;
256    
257     r = xmalloc(sizeof(*r));
258    
259     for(cptr = s; *cptr; cptr++)
260     {
261     if(*cptr == '.')
262     dots++;
263     }
264     if(!dots)
265     {
266     r->rev = xstrdup("");
267     r->branch = xstrdup(s);
268     r->isbranch = 1;
269     }
270     else if(!*s)
271     {
272     r->rev = xstrdup("?.?");
273     r->branch = xstrdup("?");
274     }
275     else if(dots & 1)
276     {
277     char *t;
278     r->rev = s;
279     r->branch = xstrdup(s);
280     cptr = strrchr(r->branch, '.');
281     assert(cptr != NULL);
282     *cptr = '\0';
283     t = strrchr(r->branch, '.');
284     if((t&& !strcmp(t+1, "0")) || (!t && !strcmp(r->branch, "0")))
285     {
286     /* Magic branch numbers "x.x.0.x" */
287     r->isbranch = 1;
288     if(t)
289     strcpy(t+1, cptr+1);
290     else
291     strcpy(r->branch, cptr+1);
292     }
293     }
294     else
295     {
296     r->isbranch = 1;
297     r->branch = s;
298     r->rev = xmalloc(strlen(s) + 3);
299     strcpy(r->rev, s);
300     strcat(r->rev, ".?");
301     }
302     return r;
303     }
304    
305    
306     static tag_t *new_tag(char *s, char *r)
307     {
308     tag_t *t = xmalloc(sizeof(*t));
309     t->tag = s;
310     t->rev = make_rev(r);
311     return t;
312     }
313    
314     static tags_t *new_tags(tag_t *s)
315     {
316     tags_t *t = xmalloc(sizeof(*t));
317     t->ntags = 1;
318     t->tags = xmalloc(sizeof(t->tags[0]));
319     t->tags[0] = s;
320     return t;
321     }
322    
323     static tags_t *add_tags(tags_t *s, tag_t *t)
324     {
325     if(!s)
326     return new_tags(t);
327     s->tags = xrealloc(s->tags, (s->ntags+1) * sizeof(s->tags[0]));
328     s->tags[s->ntags] = t;
329     s->ntags++;
330     return s;
331     }
332    
333     static idrev_t *new_idrev(char *s, char *r)
334     {
335     idrev_t *t = xmalloc(sizeof(*t));
336     t->id = s;
337     t->rev = make_rev(r);
338     return t;
339     }
340    
341     static idrevs_t *new_idrevs(idrev_t *s)
342     {
343     idrevs_t *t = xmalloc(sizeof(*t));
344     t->nidrevs = 1;
345     t->idrevs = xmalloc(sizeof(t->idrevs[0]));
346     t->idrevs[0] = s;
347     return t;
348     }
349    
350     static idrevs_t *add_idrevs(idrevs_t *s, idrev_t *t)
351     {
352     if(!s)
353     return new_idrevs(t);
354     s->idrevs = xrealloc(s->idrevs, (s->nidrevs+1) * sizeof(s->idrevs[0]));
355     s->idrevs[s->nidrevs] = t;
356     s->nidrevs++;
357     return s;
358     }
359    
360     static ids_t *new_ids(char *s)
361     {
362     ids_t *t = xmalloc(sizeof(*t));
363     t->nids = 1;
364     t->ids = xmalloc(sizeof(t->ids[0]));
365     t->ids[0] = s;
366     return t;
367     }
368    
369     static ids_t *add_ids(ids_t *s, char *t)
370     {
371     s->ids = xrealloc(s->ids, (s->nids+1) * sizeof(s->ids[0]));
372     s->ids[s->nids] = t;
373     s->nids++;
374     return s;
375     }
376    
377     static revs_t *new_revs(char *s)
378     {
379     revs_t *t = xmalloc(sizeof(*t));
380     t->nrevs = 1;
381     t->revs = xmalloc(sizeof(t->revs[0]));
382     t->revs[0] = make_rev(s);
383     return t;
384     }
385    
386     static revs_t *add_revs(revs_t *s, char *t)
387     {
388     s->revs = xrealloc(s->revs, (s->nrevs+1) * sizeof(s->revs[0]));
389     s->revs[s->nrevs] = make_rev(t);
390     s->nrevs++;
391     return s;
392     }
393    
394     static dtext_t *new_dtext(char *n, char *l, char *t)
395     {
396     dtext_t *d = xmalloc(sizeof(*d));
397     d->rev = make_rev(n);
398     d->log = l;
399     d->text = t;
400     return d;
401     }
402    
403     static dtexts_t *add_dtexts(dtexts_t *s, dtext_t *t)
404     {
405     if(!s)
406     s = xmalloc(sizeof(*s));
407     s->dtexts = xrealloc(s->dtexts, (s->ndtexts+1) * sizeof(s->dtexts[0]));
408     s->dtexts[s->ndtexts] = t;
409     s->ndtexts++;
410     return s;
411     }
412    
413     static delta_t *new_delta(char *rev, char *date, char *author, char *state, revs_t *branches, char *next)
414     {
415     delta_t *d = xmalloc(sizeof(*d));
416     d->rev = make_rev(rev);
417     d->date = date;
418     d->author = author;
419     d->state = state;
420     d->branches = branches;
421     d->next = make_rev(next);
422     return d;
423     }
424    
425     static deltas_t *add_deltas(deltas_t *s, delta_t *t)
426     {
427     if(!s)
428     s = xmalloc(sizeof(*s));
429     s->deltas = xrealloc(s->deltas, (s->ndeltas+1) * sizeof(s->deltas[0]));
430     s->deltas[s->ndeltas] = t;
431     s->ndeltas++;
432     return s;
433     }
434    
435     static rcsfile_t *new_rcsfile(char *head, char *branch, ids_t *access, tags_t *tags,
436     idrevs_t *locks, int strict, char *comment, char *expand)
437     {
438     rcsfile_t *r = xmalloc(sizeof(*r));
439     r->head = make_rev(head);
440     r->branch = make_rev(branch);
441     r->access = access;
442     r->tags = tags;
443     r->locks = locks;
444     r->strict = strict;
445     r->comment = comment;
446     r->expand = expand;
447     return r;
448     }
449    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0