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

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0