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