1
/**************************************************************************
4
** begin : Sun Aug 4 15:05:35 2002
5
** copyright : (C) 2002-2003 by Otto Bruggeman
6
** email : otto.bruggeman@home.nl
8
***************************************************************************/
9
/***************************************************************************
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.
16
***************************************************************************/
22
#include "cvsdiffparser.h"
24
using namespace Diff2;
26
CVSDiffParser::CVSDiffParser( const QStringList& diff ) : ParserBase( diff )
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(.*))$" );
34
CVSDiffParser::~CVSDiffParser()
38
enum Kompare::Format CVSDiffParser::determineFormat()
40
// kdDebug(8101) << "Determining the format of the CVSDiff" << endl;
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]" );
48
QStringList::ConstIterator it = m_diffLines.begin();
50
while( it != m_diffLines.end() )
52
if( (*it).find( normalRE, 0 ) == 0 )
54
// kdDebug(8101) << "Difflines are from a Normal diff..." << endl;
55
return Kompare::Normal;
57
else if( (*it).find( unifiedRE, 0 ) == 0 )
59
// kdDebug(8101) << "Difflines are from a Unified diff..." << endl;
60
return Kompare::Unified;
62
else if( (*it).find( contextRE, 0 ) == 0 )
64
// kdDebug(8101) << "Difflines are from a Context diff..." << endl;
65
return Kompare::Context;
67
else if( (*it).find( rcsRE, 0 ) == 0 )
69
// kdDebug(8101) << "Difflines are from a RCS diff..." << endl;
72
else if( (*it).find( edRE, 0 ) == 0 )
74
// kdDebug(8101) << "Difflines are from an ED diff..." << endl;
79
// kdDebug(8101) << "Difflines are from an unknown diff..." << endl;
80
return Kompare::UnknownFormat;
83
bool CVSDiffParser::parseEdDiffHeader()
88
bool CVSDiffParser::parseRCSDiffHeader()
93
bool CVSDiffParser::parseEdHunkHeader()
98
bool CVSDiffParser::parseRCSHunkHeader()
103
bool CVSDiffParser::parseEdHunkBody()
108
bool CVSDiffParser::parseRCSHunkBody()