/[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.4 - (hide annotations)
Thu Jul 15 15:12:07 2004 UTC (13 years, 5 months ago) by bertho
Branch: MAIN
CVS Tags: REL_1_4_1, REL_1_5_0
Changes since 1.3: +16 -0 lines
Fix the author recognition for CVSNT with broken rcsfile(5) format.
This might not be a total remedy, but should fix some.
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     #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    
87     /* Here come any other 'newphrase' constructs */
88     {num}?{idchar}({idchar}|{num})* {
89     rcslval.str = xstrdup(rcstext);
90     return tNEWPHRASE;
91     }
92    
93     /* Special rules for skipping everything after a 'newphrase' part */
94     <xSKIP>[^;@\n]+ ;
95     <xSKIP>\n line_number++;
96     <xSKIP>@ BEGIN(xSKIPSTR);
97     <xSKIP>; BEGIN(INITIAL); return *rcstext;
98    
99     <xSKIPSTR>[^\n@]+ ;
100     <xSKIPSTR>\n line_number++;
101     <xSKIPSTR>@@ ;
102     <xSKIPSTR>@ BEGIN(xSKIP);
103    
104     {num} rcslval.str = xstrdup(rcstext); return tREV;
105     [:;$] return *rcstext;
106    
107     <xID>{ws}+ ;
108     <xID>\n line_number++;
109     <xID>{special} BEGIN(INITIAL); return *rcstext;
110     <xID>{num}?{idchar}({idchar}|{num})* {
111     rcslval.str = xstrdup(rcstext);
112     BEGIN(INITIAL);
113     return tID;
114     }
115 bertho 1.3 <xID>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
116 bertho 1.1
117     <xSYM>{ws}+ ;
118     <xSYM>\n line_number++;
119     <xSYM>{special} BEGIN(INITIAL); return *rcstext;
120     <xSYM>{digit}*{idchar}({idchar}|{digit})* {
121     rcslval.str = xstrdup(rcstext);
122     BEGIN(INITIAL);
123     return tSYM;
124     }
125 bertho 1.3 <xSYM>{digit}*. rcserror("Invalid character in SYMBOL '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
126 bertho 1.1
127     @ reset_str(); BEGIN(xSTR);
128     <xSTR>[^@\n]+ add_str(rcstext, rcsleng);
129     <xSTR>\n line_number++; add_str(rcstext, rcsleng);
130     <xSTR>@@ add_str(rcstext, 1);
131     <xSTR>@ rcslval.str = get_str(); BEGIN(INITIAL); skip_string = 0; return tSTRING;
132    
133 bertho 1.4 <xAUTHOR>@ reset_str(); BEGIN(xSTR);
134     <xAUTHOR>{ws}+ ;
135     <xAUTHOR>\n line_number++;
136     <xAUTHOR>{special} BEGIN(INITIAL); return *rcstext;
137     <xAUTHOR>{num}?{idchar}({idchar}|{num})* {
138     rcslval.str = xstrdup(rcstext);
139     BEGIN(INITIAL);
140     return tID;
141     }
142     <xAUTHOR>{num}?. rcserror("Invalid character in ID '%s' (0x%02x)", rcstext, rcstext[yyleng-1]);
143 bertho 1.1
144     {ws}+ ; /* Ignore whitespace */
145     \n line_number++;
146    
147     . rcserror("Unknown char/unmatched text '%c' (0x%02x)", isprint(*rcstext) ? *rcstext : ' ', *rcstext);
148    
149     %%
150    
151     int rcswrap(void)
152     {
153     return 1;
154     }
155    
156     void set_id(void)
157     {
158     BEGIN(xID);
159 bertho 1.4 }
160    
161     void set_author(void)
162     {
163     BEGIN(xAUTHOR);
164 bertho 1.1 }
165    
166     void set_sym(void)
167     {
168     BEGIN(xSYM);
169     }
170    
171     void set_skip(void)
172     {
173     BEGIN(xSKIP);
174     }
175    
176     void set_skipstr(void)
177     {
178     skip_string = 1;
179     }
180    
181     #define STRALLOCSIZE 256
182     static char *str;
183     static int nstr;
184     static int nastr;
185    
186     static void reset_str(void)
187     {
188     nstr = 0;
189     }
190    
191     static void add_str(const char *s, int l)
192     {
193     #ifdef SKIP_DELTATEXT
194     if(skip_string)
195     return;
196     #endif
197     if(nstr + l + 1 > nastr)
198     {
199     str = xrealloc(str, nastr+STRALLOCSIZE);
200     nastr += STRALLOCSIZE;
201     }
202     memcpy(str+nstr, s, l);
203     nstr += l;
204     }
205    
206     static char *get_str(void)
207     {
208     #ifdef SKIP_DELTATEXT
209     if(skip_string)
210     return xstrdup("");
211     #endif
212 bertho 1.2 if(str)
213     {
214     str[nstr] = '\0';
215     return xstrdup(str);
216     }
217     else
218     return xstrdup("");
219 bertho 1.1 }
220    

  ViewVC Help
Powered by ViewVC 1.1.0 with CvsGraph 1.7.0