/[CvsGraph]/cvsgraph/rcsl.l
ViewVC logotype

Annotate of /cvsgraph/rcsl.l

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


Revision 1.5 - (show annotations)
Wed Oct 20 22:03:36 2004 UTC (13 years, 1 month ago) by bertho
Branch: MAIN
Changes since 1.4: +1 -0 lines
Added patch from Gordon Hollingworth <Gordon.Hollingworth {at} TTP.com> to use
mergepoints as implemented by CVSNT. Adapted the patch to enable both
tag-detected merges and mergepoints to be shows at the same time.
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 %x xSTR
23 %x xID
24 %x xSYM
25 %x xSKIP
26 %x xSKIPSTR
27 %x xAUTHOR
28
29 %{
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <ctype.h>
34
35 #include "utils.h"
36 #include "readconf.h"
37 #include "rcs.h"
38 #include "rcs.tab.h"
39
40 #define SKIP_DELTATEXT 1
41
42 static void reset_str(void);
43 static void add_str(const char *s, int l);
44 static char *get_str(void);
45
46 static int skip_string = 0;
47
48 #define YY_NO_UNPUT 1
49
50 %}
51
52 ws [\b\t\v\f\r ]
53 num [0-9.]+
54 digit [0-9]
55 idchar [!-#%-+\-/<-?A-~\240-\377]
56 special [$,.:;@]
57
58 %%
59 /* RCS keywords */
60 head return tHEAD;
61 branch return tBRANCH;
62 access return tACCESS;
63 symbols return tSYMBOLS;
64 locks return tLOCKS;
65 strict return tSTRICT;
66 comment return tCOMMENT;
67 expand return tEXPAND;
68 date return tDATE;
69 author return tAUTHOR;
70 state return tSTATE;
71 branches return tBRANCHES;
72 next return tNEXT;
73 desc return tDESC;
74 log return tLOG;
75 text return tTEXT;
76 /* CVS extensions */
77 owner return tOWNER;
78 group return tGROUP;
79 permissions return tPERMISSIONS;
80 special return tSPECIAL;
81 symlnk return tSYMLINK;
82 hardlinks return tHARDLINKS;
83 /* Other known extensions */
84 namespace return tNAMESPACE;
85 dead return tDEAD;
86 mergepoint1 return tMERGEPOINT;
87
88 /* Here come any other 'newphrase' constructs */
89 {num}?{idchar}({idchar}|{num})* {
90 rcslval.str = xstrdup(rcstext);
91 return tNEWPHRASE;
92 }
93
94 /* Special rules for skipping everything after a 'newphrase' part */
95 <xSKIP>[^;@\n]+ ;
96 <xSKIP>\n line_number++;
97 <xSKIP>@ BEGIN(xSKIPSTR);
98 <xSKIP>; BEGIN(INITIAL); return *rcstext;
99
100 <xSKIPSTR>[^\n@]+ ;
101 <xSKIPSTR>\n line_number++;
102 <xSKIPSTR>@@ ;
103 <xSKIPSTR>@ BEGIN(xSKIP);
104
105 {num} rcslval.str = xstrdup(rcstext); return tREV;
106 [:;$] return *rcstext;
107
108 <xID>{ws}+ ;
109 <xID>\n line_number++;
110 <xID>{special} BEGIN(INITIAL); return *rcstext;
111 <xID>{num}?{idchar}({idchar}|{num})* {
112 rcslval.str = xstrdup(rcstext);
113 BEGIN(INITIAL);
114 return tID;
115 }
116 <xID>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
117
118 <xSYM>{ws}+ ;
119 <xSYM>\n line_number++;
120 <xSYM>{special} BEGIN(INITIAL); return *rcstext;
121 <xSYM>{digit}*{idchar}({idchar}|{digit})* {
122 rcslval.str = xstrdup(rcstext);
123 BEGIN(INITIAL);
124 return tSYM;
125 }
126 <xSYM>{digit}*. rcserror("Invalid character in SYMBOL '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
127
128 @ reset_str(); BEGIN(xSTR);
129 <xSTR>[^@\n]+ add_str(rcstext, rcsleng);
130 <xSTR>\n line_number++; add_str(rcstext, rcsleng);
131 <xSTR>@@ add_str(rcstext, 1);
132 <xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
133
134 <xAUTHOR>@ reset_str(); BEGIN(xSTR);
135 <xAUTHOR>{ws}+ ;
136 <xAUTHOR>\n line_number++;
137 <xAUTHOR>{special} BEGIN(INITIAL); return *rcstext;
138 <xAUTHOR>{num}?{idchar}({idchar}|{num})* {
139 rcslval.str = xstrdup(rcstext);
140 BEGIN(INITIAL);
141 return tID;
142 }
143 <xAUTHOR>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
144
145 {ws}+ ; /* Ignore whitespace */
146 \n line_number++;
147
148 . rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
149
150 %%
151
152 int rcswrap(void)
153 {
154 return 1;
155 }
156
157 void set_id(void)
158 {
159 BEGIN(xID);
160 }
161
162 void set_author(void)
163 {
164 BEGIN(xAUTHOR);
165 }
166
167 void set_sym(void)
168 {
169 BEGIN(xSYM);
170 }
171
172 void set_skip(void)
173 {
174 BEGIN(xSKIP);
175 }
176
177 void set_skipstr(void)
178 {
179 skip_string = 1;
180 }
181
182 #define STRALLOCSIZE 256
183 static char *str;
184 static int nstr;
185 static int nastr;
186
187 static void reset_str(void)
188 {
189 nstr = 0;
190 }
191
192 static void add_str(const char *s, int l)
193 {
194 #ifdef SKIP_DELTATEXT
195 if(skip_string)
196 return;
197 #endif
198 if(nstr + l + 1 > nastr)
199 {
200 str = xrealloc(str, nastr+STRALLOCSIZE);
201 nastr += STRALLOCSIZE;
202 }
203 memcpy(str+nstr, s, l);
204 nstr += l;
205 }
206
207 static char *get_str(void)
208 {
209 #ifdef SKIP_DELTATEXT
210 if(skip_string)
211 return xstrdup("");
212 #endif
213 if(str)
214 {
215 str[nstr] = '\0';
216 return xstrdup(str);
217 }
218 else
219 return xstrdup("");
220 }
221

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0