~ubuntu-branches/ubuntu/lucid/gnome-commander/lucid

« back to all changes in this revision

Viewing changes to plugins/cvs/parser.l

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-02-17 19:55:31 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217195531-wnv3t4hjpv5vys39
Tags: 1.2.8.5-0ubuntu1
* New upstream release.
* Bump Standards-Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    GNOME Commander - A GNOME based file manager
3
 
    Copyright (C) 2001-2006 Marcus Bjurman
4
 
    Copyright (C) 2007-2009 Piotr Eljasiak
5
 
 
6
 
    This program is free software; you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation; either version 2 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    This program is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with this program; if not, write to the Free Software
18
 
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19
 
*/
20
 
 
21
 
 
22
 
/*
23
 
 
24
 
RCS file: /cvsroot/gcmd/gnome-commander/src/main.c,v
25
 
Working file: main.c
26
 
head: 1.14
27
 
branch:
28
 
locks: strict
29
 
access list:
30
 
symbolic names:
31
 
        DEV11: 1.14.0.2
32
 
        start: 1.1.1.1
33
 
        gnome-commander: 1.1.1
34
 
keyword substitution: kv
35
 
total revisions: 17;    selected revisions: 17
36
 
description:
37
 
----------------------------
38
 
revision 1.14
39
 
date: 2003/01/30 02:42:59;  author: opum;  state: Exp;  lines: +2 -0
40
 
branches:  1.14.2;
41
 
Added automatic download of remove files when opening them or viewing them
42
 
 
43
 
 
44
 
 
45
 
branches:[:alnum:]*;  {
46
 
    gchar tmp[256];
47
 
    sscanf (yytext+9,"%s", tmp);
48
 
    printf ("BranchesTEST: %s\n", tmp);
49
 
}
50
 
 
51
 
 
52
 
*/
53
 
 
54
 
%option noyywrap
55
 
%option nounput
56
 
%option prefix="parser"
57
 
%option outfile="parser.c"
58
 
 
59
 
%{
60
 
#include <stdio.h>
61
 
#include <stdlib.h>
62
 
#include <string.h>
63
 
#include <time.h>
64
 
#include <sys/param.h>                        // for NAME_MAX
65
 
#include "parser.h"
66
 
 
67
 
static Revision *rev = NULL;
68
 
static Revision *rev_new ();
69
 
static LogHistory *log = NULL;
70
 
%}
71
 
 
72
 
 
73
 
 
74
 
%%
75
 
 
76
 
----\nrevision.*\n    {
77
 
    gchar tmp[256];
78
 
 
79
 
    fprintf (stderr, "LEX: Creating revision\n");
80
 
    sscanf (yytext+14,"%s", tmp);
81
 
 
82
 
    rev = rev_new ();
83
 
    rev->number = g_strdup (tmp);
84
 
    log->revisions = g_list_append (log->revisions, rev);
85
 
    log->rev_names = g_list_append (log->rev_names, rev->number);
86
 
    g_hash_table_insert (log->rev_map, rev->number, rev);
87
 
}
88
 
 
89
 
date:.*$  {
90
 
    gchar d[16], t[16], a[64], s[32], l1[8], l2[8];
91
 
 
92
 
    fprintf (stderr, "LEX: Creating date\n");
93
 
    sscanf (yytext, "date: %s %s  author: %s  state: %s  lines: %s %s",
94
 
        d, t, a, s, l1, l2);
95
 
 
96
 
    g_strdelimit (t, ";", '\0');
97
 
    g_strdelimit (a, ";", '\0');
98
 
    g_strdelimit (s, ";", '\0');
99
 
 
100
 
    rev->date = g_strdup_printf ("%s %s", d, t);
101
 
    rev->author = g_strdup (a);
102
 
    rev->state = g_strdup (s);
103
 
    rev->lines = g_strdup_printf ("%s %s", l1, l2);
104
 
}
105
 
 
106
 
 
107
 
^.*\n---   {
108
 
    fprintf (stderr, "LEX: Found message1\n");
109
 
    if (rev)
110
 
        rev->message = g_strdup (yytext);
111
 
}
112
 
 
113
 
^.*\n===========================   {
114
 
    fprintf (stderr, "LEX: Found message2\n");
115
 
    if (rev)
116
 
        rev->message = g_strdup (yytext);
117
 
    yyterminate();
118
 
}
119
 
 
120
 
 
121
 
%%
122
 
 
123
 
static Revision *rev_new ()
124
 
{
125
 
    return g_new0 (Revision, 1);
126
 
}
127
 
 
128
 
 
129
 
static void rev_free (Revision *rev)
130
 
{
131
 
    if (rev) 
132
 
    {
133
 
        g_free (rev->number);
134
 
        g_free (rev->date);
135
 
        g_free (rev->author);
136
 
        g_free (rev->state);
137
 
        g_free (rev->lines);
138
 
        g_free (rev->message);
139
 
        g_free (rev);
140
 
    }
141
 
}
142
 
 
143
 
 
144
 
static LogHistory *log_new ()
145
 
{
146
 
    LogHistory *log = g_new (LogHistory, 1);
147
 
    log->revisions = NULL;
148
 
    log->rev_names = NULL;
149
 
    log->rev_map = g_hash_table_new (g_str_hash, g_str_equal);
150
 
    return log;
151
 
}
152
 
 
153
 
 
154
 
void log_free (LogHistory *log)
155
 
{
156
 
    GList *revs = NULL;
157
 
    for (revs = log->revisions; revs; revs = revs->next)
158
 
    {
159
 
        Revision *rev = (Revision *) revs->data;
160
 
        rev_free (rev);
161
 
    }
162
 
}
163
 
 
164
 
 
165
 
LogHistory *log_create (CvsPlugin *plugin, const gchar *fname)
166
 
{
167
 
    gchar *cmd;
168
 
 
169
 
    log = log_new ();
170
 
    log->fname = g_strdup (fname);
171
 
    log->plugin = plugin;
172
 
    cmd = g_strdup_printf ("cvs -z%d log %s",
173
 
                           plugin->compression_level,
174
 
                           log->fname);
175
 
 
176
 
    yyin = popen (cmd, "r");
177
 
    if (!yyin) return NULL;
178
 
 
179
 
    fprintf (stderr, "LEX: 1\n");
180
 
    yylex ();
181
 
    fprintf (stderr, "LEX: 2\n");
182
 
 
183
 
    pclose (yyin);
184
 
 
185
 
    return log;
186
 
}