Commit fd3d2967 authored by Michael Reeves's avatar Michael Reeves

move isEndOfLine to Utils

parent 147b59ce
......@@ -810,7 +810,7 @@ void SourceData::FileData::removeComments()
bool SourceData::isLineOrBufEnd(const QChar* p, int i, int size)
{
return i >= size // End of file
|| isEndOfLine(p[i]) // Normal end of line
|| Utils::isEndOfLine(p[i]) // Normal end of line
// No support for Mac-end of line yet, because incompatible with GNU-diff-routines.
// || ( p[i]=='\r' && (i>=size-1 || p[i+1]!='\n')
......
/**
* Copyright (C) 2018 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 UTILS_H
......@@ -28,6 +28,7 @@ class Utils{
public:
static bool wildcardMultiMatch(const QString& wildcard, const QString& testString, bool bCaseSensitive);
static QString getArguments(QString cmd, QString& program, QStringList& args);
inline static bool isEndOfLine( QChar c ) { return c=='\n' || c=='\r' || c=='\x0b'; }
};
#endif
......@@ -24,6 +24,8 @@
#ifndef GNUDIFF_DIFF_H
#define GNUDIFF_DIFF_H
#include "LineRef.h"
#include "Utils.h"
#include <stdint.h>
#include <sys/types.h>
......@@ -40,7 +42,6 @@
#include <QtGlobal>
#include <QString>
#include "LineRef.h"
/* The integer type of a line number. */
typedef qint64 GNULineRef;
#define GNULINEREF_MAX std::numeric_limits<GNULineRef>::max()
......@@ -48,11 +49,6 @@ static_assert(sizeof(int) >= sizeof(qint32), "Legacy LP32 systems/compilers not
static_assert(std::is_signed<GNULineRef>::value, "GNULineRef must be signed.");
static_assert(sizeof(GNULineRef) >= sizeof(size_t),"GNULineRef must be able to receive size_t values.");
inline bool isEndOfLine( QChar c )
{
return c=='\n' || c=='\r' || c=='\x0b';
}
#define TAB_WIDTH 8
class GnuDiff
......
......@@ -164,7 +164,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
switch(ignore_white_space)
{
case IGNORE_ALL_SPACE:
while(p < bufend && !isEndOfLine(c = *p))
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.toLower().unicode());
......@@ -173,7 +173,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
break;
default:
while(p < bufend && !isEndOfLine(c = *p))
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.toLower().unicode());
++p;
......@@ -184,7 +184,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
switch(ignore_white_space)
{
case IGNORE_ALL_SPACE:
while(p < bufend && !isEndOfLine(c = *p))
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
if(!(isWhite(c) || (bIgnoreNumbers && (c.isDigit() || c == '-' || c == '.'))))
h = HASH(h, c.unicode());
......@@ -193,7 +193,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
break;
default:
while(p < bufend && !isEndOfLine(c = *p))
while(p < bufend && !Utils::isEndOfLine(c = *p))
{
h = HASH(h, c.unicode());
++p;
......@@ -293,7 +293,7 @@ void GnuDiff::find_and_hash_each_line(struct file_data *current)
line++;
while(p < bufend && !isEndOfLine(*p++))
while(p < bufend && !Utils::isEndOfLine(*p++))
continue;
}
......@@ -350,7 +350,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[])
/* Now P0 and P1 point at the first nonmatching characters. */
/* Skip back to last line-beginning in the prefix. */
while(p0 != buffer0 && !isEndOfLine(p0[-1]))
while(p0 != buffer0 && !Utils::isEndOfLine(p0[-1]))
p0--, p1--;
/* Record the prefix. */
......@@ -387,7 +387,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[])
{
if(*p0 != *p1)
++p0;
while(p0 < pEnd0 && !isEndOfLine(*p0++))
while(p0 < pEnd0 && !Utils::isEndOfLine(*p0++))
continue;
}
......@@ -449,7 +449,7 @@ void GnuDiff::find_identical_ends(struct file_data filevec[])
linbuf0 = (const QChar **)xrealloc(linbuf0, alloc_lines0 * sizeof(*linbuf0));
}
linbuf0[l] = p0;
while(p0 < pEnd0 && !isEndOfLine(*p0++))
while(p0 < pEnd0 && !Utils::isEndOfLine(*p0++))
continue;
}
}
......
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