~kubuntu-members/kompare/4.11

« back to all changes in this revision

Viewing changes to libdiff2/cvsdiffparser.cpp

  • Committer: Otto Bruggeman
  • Date: 2003-08-22 20:54:19 UTC
  • Revision ID: git-v1:d09a8c32a5056998bdb6f604549a5f24c8f6fe75
Die make_it_cool, die kompare! :)

svn path=/trunk/kdesdk/kompare/; revision=244089

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
**                              cvsdiffparser.cpp
 
3
**                              -----------------
 
4
**      begin                   : Sun Aug  4 15:05:35 2002
 
5
**      copyright               : (C) 2002-2003 by Otto Bruggeman
 
6
**      email                   : otto.bruggeman@home.nl
 
7
**
 
8
***************************************************************************/
 
9
/***************************************************************************
 
10
**
 
11
**   This program is free software; you can redistribute it and/or modify
 
12
**   it under the terms of the GNU General Public License as published by
 
13
**   the Free Software Foundation; either version 2 of the License, or
 
14
**   ( at your option ) any later version.
 
15
**
 
16
***************************************************************************/
 
17
 
 
18
#include <qregexp.h>
 
19
 
 
20
#include <kdebug.h>
 
21
 
 
22
#include "cvsdiffparser.h"
 
23
 
 
24
using namespace Diff2;
 
25
 
 
26
CVSDiffParser::CVSDiffParser( const QStringList& diff ) : ParserBase( diff )
 
27
{
 
28
        // The regexps needed for context cvs diff parsing, the rest is the same as in parserbase.cpp
 
29
        // third capture in header1 is non optional for cvs diff, it is the revision
 
30
        m_contextDiffHeader1.setPattern( "^\\*\\*\\* ([^\\t]+)\\t([^\\t]+)\\t(.*)$" );
 
31
        m_contextDiffHeader2.setPattern( "^--- ([^\\t]+)\\t([^\\t]+)(|\\t(.*))$" );
 
32
}
 
33
 
 
34
CVSDiffParser::~CVSDiffParser()
 
35
{
 
36
}
 
37
 
 
38
enum Kompare::Format CVSDiffParser::determineFormat()
 
39
{
 
40
//      kdDebug(8101) << "Determining the format of the CVSDiff" << endl;
 
41
 
 
42
        QRegExp normalRE ( "^[0-9]+[0-9,]*[acd][0-9]+[0-9,]*$" );
 
43
        QRegExp unifiedRE( "^--- [^\\t]+\\t" );
 
44
        QRegExp contextRE( "^\\*\\*\\* [^\\t]+\\t" );
 
45
        QRegExp rcsRE    ( "^[acd][0-9]+ [0-9]+" );
 
46
        QRegExp edRE     ( "^[0-9]+[0-9,]*[acd]" );
 
47
 
 
48
        QStringList::ConstIterator it = m_diffLines.begin();
 
49
 
 
50
        while( it != m_diffLines.end() )
 
51
        {
 
52
                if( (*it).find( normalRE, 0 ) == 0 )
 
53
                {
 
54
//                      kdDebug(8101) << "Difflines are from a Normal diff..." << endl;
 
55
                        return Kompare::Normal;
 
56
                }
 
57
                else if( (*it).find( unifiedRE, 0 ) == 0 )
 
58
                {
 
59
//                      kdDebug(8101) << "Difflines are from a Unified diff..." << endl;
 
60
                        return Kompare::Unified;
 
61
                }
 
62
                else if( (*it).find( contextRE, 0 ) == 0 )
 
63
                {
 
64
//                      kdDebug(8101) << "Difflines are from a Context diff..." << endl;
 
65
                        return Kompare::Context;
 
66
                }
 
67
                else if( (*it).find( rcsRE, 0 ) == 0 )
 
68
                {
 
69
//                      kdDebug(8101) << "Difflines are from a RCS diff..." << endl;
 
70
                        return Kompare::RCS;
 
71
                }
 
72
                else if( (*it).find( edRE, 0 ) == 0 )
 
73
                {
 
74
//                      kdDebug(8101) << "Difflines are from an ED diff..." << endl;
 
75
                        return Kompare::Ed;
 
76
                }
 
77
                ++it;
 
78
        }
 
79
//      kdDebug(8101) << "Difflines are from an unknown diff..." << endl;
 
80
        return Kompare::UnknownFormat;
 
81
}
 
82
 
 
83
bool CVSDiffParser::parseEdDiffHeader()
 
84
{
 
85
        return false;
 
86
}
 
87
 
 
88
bool CVSDiffParser::parseRCSDiffHeader()
 
89
{
 
90
        return false;
 
91
}
 
92
 
 
93
bool CVSDiffParser::parseEdHunkHeader()
 
94
{
 
95
        return false;
 
96
}
 
97
 
 
98
bool CVSDiffParser::parseRCSHunkHeader()
 
99
{
 
100
        return false;
 
101
}
 
102
 
 
103
bool CVSDiffParser::parseEdHunkBody()
 
104
{
 
105
        return false;
 
106
}
 
107
 
 
108
bool CVSDiffParser::parseRCSHunkBody()
 
109
{
 
110
        return false;
 
111
}
 
112