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

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0