Permalink
Browse files

Added parser ParserDiff.

  • Loading branch information...
danfis committed Oct 14, 2008
1 parent 7280c11 commit 81ef771b9ea33bcb9c887fabb722ea8ec8f1311c
Showing with 57 additions and 1 deletion.
  1. +13 −1 src/parser/choose_parser.cpp
  2. +44 −0 src/parser/parser_diff.hpp
@@ -30,26 +30,30 @@ using namespace std;
#include "parser/parser_svn.hpp"
#include "parser/parser_bzr.hpp"
#include "parser/parser_diffr.hpp"
#include "parser/parser_diff.hpp"
static QRegExp git("^diff --git.*$");
static QRegExp bzr("^=== (added|removed|modified) file .*$");
static QRegExp svn("^Index: [^ ]+.*$");
static QRegExp diffr("^diff -r[a-zA-Z]* .*$");
static QRegExp diff("^[0-9]+(,[0-9]*)?c[0-9]+(,[0-9])?$");
enum Type {
NONE = -1,
GIT = 0,
BZR,
SVN,
DIFFR,
DIFF,
NUM_TYPES
};
const char *types[] = {
"git",
"bzr",
"svn",
"diffr"
"diffr",
"diff"
};
@@ -74,6 +78,9 @@ Parser *chooseParser(In &in)
if (diffr.exactMatch(line))
type = DIFFR;
if (diff.exactMatch(line))
type = DIFF;
line = in.line();
}
@@ -92,6 +99,8 @@ Parser *chooseParser(In &in)
return new ParserSvn(in);
case DIFFR:
return new ParserDiffR(in);
case DIFF:
return new ParserDiff(in);
default:
return 0;
}
@@ -111,6 +120,9 @@ Parser *chooseParser(In &in, const char *type)
}else if (strcasecmp(type, "diffr") == 0){
MSG("Chosen type '" << types[DIFFR] << "'");
return new ParserDiffR(in);
}else if (strcasecmp(type, "diff") == 0){
MSG("Chosen type '" << types[DIFF] << "'");
return new ParserDiff(in);
}
return 0;
View
@@ -0,0 +1,44 @@
/**
* QShowDiff
* ----------
* Copyright (c)2007 Daniel Fiser <danfis (at) danfis (dot) cz>
*
*
* This file is part of QShowDiff
*
* QShowDiff is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QShowDiff is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QShowDiff. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PARSER_DIFF_HPP_
#define _PARSER_DIFF_HPP_
#include "parser/parser_big.hpp"
class ParserDiff : public ParserBig {
protected:
void _start()
{ if (_matchLine(THunk)) _changeState(SHunk); }
public:
ParserDiff(In &in)
: ParserBig(in,
"^$",
"^([0-9]+)(,[0-9]*){0,1}c([0-9]+)(,[0-9]*){0,1}$",
"^ (.*)$",
"^> (.*)$",
"^< (.*)$"){}
virtual ~ParserDiff(){}
};
#endif

0 comments on commit 81ef771

Please sign in to comment.