Commit 13071b56 authored by Michael Reeves's avatar Michael Reeves

WIP 1

parent a6626420
Pipeline #6484 passed with stage
in 6 minutes and 43 seconds
/**
* Copyright (C) 2019 Michael Reeves <reeves.87@gmail.com>
*
* This file is part of KDiff3.
*
* KDiff3 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 2 of the License, or
* (at your option) any later version.
*
* KDiff3 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 KDiff3. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CommentParser.h"
#include <QChar>
#include <QSharedPointer>
#include <QString>
void DefaultCommentParser::proccessChar(const QString &line, const QChar &inChar)
{
switch(inChar.unicode())
{
case '\'':
case '"':
if(!mInComment)
{
}
break;
case '/':
if(!mInString && line[line.size() - 1] == '/')
{
mInComment = true;
if(line.size() < 2) mIsPureComment = true;
}
break;
case '\n':
break;
}
};
/**
* Copyright (C) 2019 Michael Reeves <reeves.87@gmail.com>
*
* This file is part of KDiff3.
*
* KDiff3 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 2 of the License, or
* (at your option) any later version.
*
* KDiff3 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 KDiff3. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMENTPARSER_H
#define COMMENTPARSER_H
#include <QChar>
#include <QString>
class CommentParser
{
public:
inline virtual void proccessChar(const QString &line, const QChar &inChar) = 0;
inline virtual bool inComment() const = 0;
inline virtual bool isPureComment() const = 0;
inline virtual void removeComments() = 0;
virtual ~CommentParser(){};
};
class DefaultCommentParser : public CommentParser
{
public:
virtual void proccessChar(const QString &line, const QChar &inChar) override;
inline bool inComment() const override { return mInComment; };
inline bool isPureComment() const override { return mIsPureComment; };
inline void removeComments() override;
private:
QChar mLastChar = QChar(0); //character that started current string.
bool mInString = false, mInComment = false;
bool mIsPureComment = false;
};
#endif // !COMMENTPASER_H
......@@ -258,7 +258,7 @@ class Diff3LineList : public std::list<Diff3Line>
//TODO: Add safety guards to prevent list from getting too large. Same problem as with QLinkedList.
int size() const
{
if(std::list<Diff3Line>::size() > std::numeric_limits<int>::max())
if(std::list<Diff3Line>::size() > (unsigned int)std::numeric_limits<int>::max())//use explicit cast to make gcc ignore this
{
qCDebug(kdiffMain) << "Diff3Line: List too large. size=" << std::list<Diff3Line>::size();
Q_ASSERT(false); //Unsupported size
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment