/[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.5 - (show annotations)
Thu Jul 15 15:12:07 2004 UTC (13 years, 5 months ago) by bertho
Branch: MAIN
Changes since 1.4: +6 -2 lines
Fix the author recognition for CVSNT with broken rcsfile(5) format.
This might not be a total remedy, but should fix some.
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 #define YYERROR_VERBOSE 1
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <assert.h>
29
30 #include <gd.h> /* For gdFontPtr in cvsgraph.h */
31 #include "cvsgraph.h"
32 #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 idorstr
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 rcsfile : admin deltas desc {
97 rcsfile = $1;
98 rcsfile->deltas = $2;
99 rcsfile->desc = $3;
100 rcsfile->dtexts = NULL;
101 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 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 }
129
130 /* This is trailing deltatext context and possibly ignored */
131 dtexts { rcsfile->dtexts = $5; }
132 ;
133
134 admin : tHEAD orev ';'
135 obranch
136 tACCESS { set_id(); } oids ';'
137 tSYMBOLS { set_sym(); } otags ';'
138 tLOCKS { set_id(); } oidrevs ';' ostrict
139 ocomment
140 oexpand
141 ophrases { $$ = new_rcsfile($2, $4, $7, $11, $15, $17, $18, $19); }
142 ;
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_author(); } idorstr ';'
167 tSTATE { set_id(); } oid ';'
168 tBRANCHES orevs ';'
169 tNEXT orev ';'
170 ophrases { $$ = new_delta($1, $3, $7, $11, $14, $17); }
171 ;
172
173 idorstr : tID { $$ = $1; }
174 | tSTRING { $$ = $1; }
175 ;
176
177 desc : tDESC tSTRING { $$ = $2; }
178 ;
179
180 dtexts : /* Empty */ { $$ = NULL; }
181 | dtexts dtext { $$ = add_dtexts($1, $2); }
182 ;
183
184 dtext : tREV
185 tLOG tSTRING
186 ophrases
187 tTEXT { set_skipstr(); } tSTRING { $$ = new_dtext($1, $3, $7); }
188 ;
189
190 ophrases: /* Empty */
191 | ophrases phrase
192 ;
193
194 phrase : tNEWPHRASE { set_skip(); } ';' {
195 yywarning("Unrecognised `newphrase´ keyword '%s' skipped", $1);
196 xfree($1);
197 }
198 | cvskw { set_skip(); } ';' { yywarning("CVS extended keyword skipped"); }
199 | otherkw { set_skip(); } ';' { yywarning("Other extended keyword"); }
200 ;
201
202 cvskw : tOWNER
203 | tGROUP
204 | tPERMISSIONS
205 | tSPECIAL
206 | tSYMLINK
207 | tHARDLINKS
208 ;
209
210 otherkw : tNAMESPACE
211 | tDEAD
212 ;
213
214 ostr : /* Empty */ { $$ = NULL; }
215 | tSTRING { $$ = $1; }
216 ;
217
218 orev : /* Empty */ { $$ = NULL; }
219 | tREV { $$ = $1; }
220 ;
221
222 orevs : /* Empty */ { $$ = NULL; }
223 | revs { $$ = $1; }
224 ;
225
226 revs : tREV { $$ = new_revs($1); }
227 | revs tREV { $$ = add_revs($1, $2); }
228 ;
229
230 oid : /* Empty */ { $$ = NULL; }
231 | tID { $$ = $1; }
232 ;
233
234 oids : /* Empty */ { $$ = NULL; }
235 | ids { $$ = $1; }
236 ;
237
238 ids : tID { $$ = new_ids($1); }
239 | ids tID { set_id(); $$ = add_ids($1, $2); }
240 ;
241
242 oidrevs : /* Empty */ { $$ = NULL; }
243 | idrevs { $$ = $1; }
244 ;
245
246 idrevs : idrev { $$ = new_idrevs($1); }
247 | idrevs idrev { $$ = add_idrevs($1, $2); }
248 ;
249
250 idrev : tID ':' tREV { set_id(); $$ = new_idrev($1, $3); }
251 ;
252
253 otags : /* Empty */ { $$ = NULL; }
254 | tags { $$ = $1; }
255 ;
256
257 tags : tag { $$ = new_tags($1); }
258 | tags tag { $$ = add_tags($1, $2); }
259 ;
260
261 tag : tSYM ':' tREV { set_sym(); $$ = new_tag($1, $3); }
262 ;
263
264 %%
265 static rev_t *make_rev(char *s)
266 {
267 char *cptr;
268 int dots = 0;
269 rev_t *r;
270
271 if(!s)
272 return NULL;
273
274 r = xmalloc(sizeof(*r));
275
276 for(cptr = s; *cptr; cptr++)
277 {
278 if(*cptr == '.')
279 dots++;
280 }
281 if(!dots)
282 {
283 r->rev = xstrdup("");
284 r->branch = xstrdup(s);
285 r->isbranch = 1;
286 }
287 else if(!*s)
288 {
289 r->rev = xstrdup("?.?");
290 r->branch = xstrdup("?");
291 }
292 else if(dots & 1)
293 {
294 char *t;
295 r->rev = s;
296 r->branch = xstrdup(s);
297 cptr = strrchr(r->branch, '.');
298 assert(cptr != NULL);
299 *cptr = '\0';
300 t = strrchr(r->branch, '.');
301 if((t&& !strcmp(t+1, "0")) || (!t && !strcmp(r->branch, "0")))
302 {
303 /* Magic branch numbers "x.x.0.x" */
304 r->isbranch = 1;
305 if(t)
306 strcpy(t+1, cptr+1);
307 else
308 strcpy(r->branch, cptr+1);
309 }
310 }
311 else
312 {
313 r->isbranch = 1;
314 r->branch = s;
315 r->rev = xmalloc(strlen(s) + 3);
316 strcpy(r->rev, s);
317 strcat(r->rev, ".?");
318 }
319 return r;
320 }
321
322
323 static tag_t *new_tag(char *s, char *r)
324 {
325 tag_t *t = xmalloc(sizeof(*t));
326 t->tag = s;
327 t->rev = make_rev(r);
328 return t;
329 }
330
331 static tags_t *new_tags(tag_t *s)
332 {
333 tags_t *t = xmalloc(sizeof(*t));
334 t->ntags = 1;
335 t->tags = xmalloc(sizeof(t->tags[0]));
336 t->tags[0] = s;
337 return t;
338 }
339
340 static tags_t *add_tags(tags_t *s, tag_t *t)
341 {
342 if(!s)
343 return new_tags(t);
344 s->tags = xrealloc(s->tags, (s->ntags+1) * sizeof(s->tags[0]));
345 s->tags[s->ntags] = t;
346 s->ntags++;
347 return s;
348 }
349
350 static idrev_t *new_idrev(char *s, char *r)
351 {
352 idrev_t *t = xmalloc(sizeof(*t));
353 t->id = s;
354 t->rev = make_rev(r);
355 return t;
356 }
357
358 static idrevs_t *new_idrevs(idrev_t *s)
359 {
360 idrevs_t *t = xmalloc(sizeof(*t));
361 t->nidrevs = 1;
362 t->idrevs = xmalloc(sizeof(t->idrevs[0]));
363 t->idrevs[0] = s;
364 return t;
365 }
366
367 static idrevs_t *add_idrevs(idrevs_t *s, idrev_t *t)
368 {
369 if(!s)
370 return new_idrevs(t);
371 s->idrevs = xrealloc(s->idrevs, (s->nidrevs+1) * sizeof(s->idrevs[0]));
372 s->idrevs[s->nidrevs] = t;
373 s->nidrevs++;
374 return s;
375 }
376
377 static ids_t *new_ids(char *s)
378 {
379 ids_t *t = xmalloc(sizeof(*t));
380 t->nids = 1;
381 t->ids = xmalloc(sizeof(t->ids[0]));
382 t->ids[0] = s;
383 return t;
384 }
385
386 static ids_t *add_ids(ids_t *s, char *t)
387 {
388 s->ids = xrealloc(s->ids, (s->nids+1) * sizeof(s->ids[0]));
389 s->ids[s->nids] = t;
390 s->nids++;
391 return s;
392 }
393
394 static revs_t *new_revs(char *s)
395 {
396 revs_t *t = xmalloc(sizeof(*t));
397 t->nrevs = 1;
398 t->revs = xmalloc(sizeof(t->revs[0]));
399 t->revs[0] = make_rev(s);
400 return t;
401 }
402
403 static revs_t *add_revs(revs_t *s, char *t)
404 {
405 s->revs = xrealloc(s->revs, (s->nrevs+1) * sizeof(s->revs[0]));
406 s->revs[s->nrevs] = make_rev(t);
407 s->nrevs++;
408 return s;
409 }
410
411 static dtext_t *new_dtext(char *n, char *l, char *t)
412 {
413 dtext_t *d = xmalloc(sizeof(*d));
414 d->rev = make_rev(n);
415 d->log = l;
416 d->text = t;
417 return d;
418 }
419
420 static dtexts_t *add_dtexts(dtexts_t *s, dtext_t *t)
421 {
422 if(!s)
423 s = xmalloc(sizeof(*s));
424 s->dtexts = xrealloc(s->dtexts, (s->ndtexts+1) * sizeof(s->dtexts[0]));
425 s->dtexts[s->ndtexts] = t;
426 s->ndtexts++;
427 return s;
428 }
429
430 static delta_t *new_delta(char *rev, char *date, char *author, char *state, revs_t *branches, char *next)
431 {
432 delta_t *d = xmalloc(sizeof(*d));
433 d->rev = make_rev(rev);
434 d->date = date;
435 d->author = author;
436 d->state = state;
437 d->branches = branches;
438 d->next = make_rev(next);
439 return d;
440 }
441
442 static deltas_t *add_deltas(deltas_t *s, delta_t *t)
443 {
444 if(!s)
445 s = xmalloc(sizeof(*s));
446 s->deltas = xrealloc(s->deltas, (s->ndeltas+1) * sizeof(s->deltas[0]));
447 s->deltas[s->ndeltas] = t;
448 s->ndeltas++;
449 return s;
450 }
451
452 static rcsfile_t *new_rcsfile(char *head, char *branch, ids_t *access, tags_t *tags,
453 idrevs_t *locks, int strict, char *comment, char *expand)
454 {
455 rcsfile_t *r = xmalloc(sizeof(*r));
456 r->head = make_rev(head);
457 r->branch = make_rev(branch);
458 r->access = access;
459 r->tags = tags;
460 r->locks = locks;
461 r->strict = strict;
462 r->comment = comment;
463 r->expand = expand;
464 return r;
465 }
466

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0