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

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0