summaryrefslogtreecommitdiffstats
path: root/src/gnudiff_io.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-27 05:58:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-27 05:58:16 +0000
commitf636ba5ba2df9d34d56b1c85f24c6598fa1cb645 (patch)
tree5365045e6bce685a7cbaeb81b4797a719e86089f /src/gnudiff_io.cpp
parent63862fdfcb61f302ef69e86d40772bb1318d3763 (diff)
downloadkdiff3-f636ba5ba2df9d34d56b1c85f24c6598fa1cb645.tar.gz
kdiff3-f636ba5ba2df9d34d56b1c85f24c6598fa1cb645.zip
TQt4 port kdiff3
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1238464 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/gnudiff_io.cpp')
-rw-r--r--src/gnudiff_io.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/gnudiff_io.cpp b/src/gnudiff_io.cpp
index 922bce7..4241d36 100644
--- a/src/gnudiff_io.cpp
+++ b/src/gnudiff_io.cpp
@@ -42,7 +42,7 @@ struct equivclass
{
lin next; /* Next item in this bucket. */
hash_value hash; /* Hash of lines in this class. */
- const QChar *line; /* A line that fits this class. */
+ const TQChar *line; /* A line that fits this class. */
size_t length; /* That line's length, not counting its newline. */
};
@@ -78,12 +78,12 @@ static lin equivs_alloc;
but an option like -i might cause us to ignore the difference.
Return nonzero if the lines differ. */
-bool GnuDiff::lines_differ (const QChar *s1, size_t len1, const QChar *s2, size_t len2 )
+bool GnuDiff::lines_differ (const TQChar *s1, size_t len1, const TQChar *s2, size_t len2 )
{
- const QChar *t1 = s1;
- const QChar *t2 = s2;
- const QChar *s1end = s1+len1;
- const QChar *s2end = s2+len2;
+ const TQChar *t1 = s1;
+ const TQChar *t2 = s2;
+ const TQChar *s1end = s1+len1;
+ const TQChar *s2end = s2+len2;
for ( ; ; ++t1, ++t2 )
{
@@ -134,13 +134,13 @@ bool GnuDiff::lines_differ (const QChar *s1, size_t len1, const QChar *s2, size_
void GnuDiff::find_and_hash_each_line (struct file_data *current)
{
hash_value h;
- const QChar *p = current->prefix_end;
- QChar c;
+ const TQChar *p = current->prefix_end;
+ TQChar c;
lin i, *bucket;
size_t length;
/* Cache often-used quantities in local variables to help the compiler. */
- const QChar **linbuf = current->linbuf;
+ const TQChar **linbuf = current->linbuf;
lin alloc_lines = current->alloc_lines;
lin line = 0;
lin linbuf_base = current->linbuf_base;
@@ -148,8 +148,8 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
struct equivclass *eqs = equivs;
lin eqs_index = equivs_index;
lin eqs_alloc = equivs_alloc;
- const QChar *suffix_begin = current->suffix_begin;
- const QChar *bufend = current->buffer + current->buffered;
+ const TQChar *suffix_begin = current->suffix_begin;
+ const TQChar *bufend = current->buffer + current->buffered;
bool diff_length_compare_anyway =
ignore_white_space != IGNORE_NO_WHITE_SPACE || bIgnoreNumbers;
bool same_length_diff_contents_compare_anyway =
@@ -157,7 +157,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
while ( p < suffix_begin)
{
- const QChar *ip = p;
+ const TQChar *ip = p;
h = 0;
@@ -169,7 +169,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
while ( p<bufend && (c = *p) != '\n' )
{
if (! (isWhite(c) || bIgnoreNumbers && (c.isDigit() || c=='-' || c=='.' ) ))
- h = HASH (h, c.lower().unicode());
+ h = HASH (h, c.lower().tqunicode());
++p;
}
break;
@@ -177,7 +177,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
default:
while ( p<bufend && (c = *p) != '\n' )
{
- h = HASH (h, c.lower().unicode());
+ h = HASH (h, c.lower().tqunicode());
++p;
}
break;
@@ -189,7 +189,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
while ( p<bufend && (c = *p) != '\n')
{
if (! (isWhite(c)|| bIgnoreNumbers && (c.isDigit() || c=='-' || c=='.' ) ))
- h = HASH (h, c.unicode());
+ h = HASH (h, c.tqunicode());
++p;
}
break;
@@ -197,7 +197,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
default:
while ( p<bufend && (c = *p) != '\n')
{
- h = HASH (h, c.unicode());
+ h = HASH (h, c.tqunicode());
++p;
}
break;
@@ -228,7 +228,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
}
else if (eqs[i].hash == h)
{
- const QChar *eqline = eqs[i].line;
+ const TQChar *eqline = eqs[i].line;
/* Reuse existing class if lines_differ reports the lines
equal. */
@@ -237,7 +237,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
/* Reuse existing equivalence class if the lines are identical.
This detects the common case of exact identity
faster than lines_differ would. */
- if (memcmp (eqline, ip, length*sizeof(QChar)) == 0)
+ if (memcmp (eqline, ip, length*sizeof(TQChar)) == 0)
break;
if (!same_length_diff_contents_compare_anyway)
continue;
@@ -260,7 +260,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
alloc_lines = 2 * alloc_lines - linbuf_base;
cureqs =(lin*) xrealloc (cureqs, alloc_lines * sizeof *cureqs);
linbuf += linbuf_base;
- linbuf = (const QChar**) xrealloc (linbuf,
+ linbuf = (const TQChar**) xrealloc (linbuf,
(alloc_lines - linbuf_base) * sizeof *linbuf);
linbuf -= linbuf_base;
}
@@ -285,7 +285,7 @@ void GnuDiff::find_and_hash_each_line (struct file_data *current)
xalloc_die ();
alloc_lines = 2 * alloc_lines - linbuf_base;
linbuf += linbuf_base;
- linbuf = (const QChar**)xrealloc (linbuf,
+ linbuf = (const TQChar**)xrealloc (linbuf,
(alloc_lines - linbuf_base) * sizeof *linbuf);
linbuf -= linbuf_base;
}
@@ -322,7 +322,7 @@ guess_lines (lin n, size_t s, size_t t)
{
size_t guessed_bytes_per_line = n < 10 ? 32 : s / (n - 1);
lin guessed_lines = MAX (1, t / guessed_bytes_per_line);
- return MIN (guessed_lines, (lin)(PTRDIFF_MAX / (2 * sizeof (QChar *) + 1) - 5)) + 5;
+ return MIN (guessed_lines, (lin)(PTRDIFF_MAX / (2 * sizeof (TQChar *) + 1) - 5)) + 5;
}
/* Given a vector of two file_data objects, find the identical
@@ -331,14 +331,14 @@ guess_lines (lin n, size_t s, size_t t)
void GnuDiff::find_identical_ends (struct file_data filevec[])
{
/* Find identical prefix. */
- const QChar *p0, *p1, *buffer0, *buffer1;
+ const TQChar *p0, *p1, *buffer0, *buffer1;
p0 = buffer0 = filevec[0].buffer;
p1 = buffer1 = filevec[1].buffer;
size_t n0, n1;
n0 = filevec[0].buffered;
n1 = filevec[1].buffered;
- const QChar* const pEnd0 = p0 + n0;
- const QChar* const pEnd1 = p1 + n1;
+ const TQChar* const pEnd0 = p0 + n0;
+ const TQChar* const pEnd1 = p1 + n1;
if (p0 == p1)
/* The buffers are the same; sentinels won't work. */
@@ -369,7 +369,7 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
p0 = buffer0 + n0;
p1 = buffer1 + n1;
- const QChar *end0, *beg0;
+ const TQChar *end0, *beg0;
end0 = p0; /* Addr of last char in file 0. */
/* Get value of P0 at which we should stop scanning backward:
@@ -417,9 +417,9 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
Handle 1 more line than the context says (because we count 1 too many),
rounded up to the next power of 2 to speed index computation. */
- const QChar **linbuf0, **linbuf1;
+ const TQChar **linbuf0, **linbuf1;
lin alloc_lines0, alloc_lines1;
- lin buffered_prefix, prefix_count, prefix_mask;
+ lin buffered_prefix, prefix_count, prefix_tqmask;
lin middle_guess, suffix_guess;
if (no_diff_means_no_output
&& context < (lin)(LIN_MAX / 4) && context < (lin)(n0))
@@ -437,9 +437,9 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
alloc_lines0 = guess_lines (0, 0, n0);
}
- prefix_mask = prefix_count - 1;
+ prefix_tqmask = prefix_count - 1;
lin lines = 0;
- linbuf0 = (const QChar**) xmalloc (alloc_lines0 * sizeof(*linbuf0));
+ linbuf0 = (const TQChar**) xmalloc (alloc_lines0 * sizeof(*linbuf0));
p0 = buffer0;
/* If the prefix is needed, find the prefix lines. */
@@ -450,13 +450,13 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
end0 = filevec[0].prefix_end;
while (p0 != end0)
{
- lin l = lines++ & prefix_mask;
+ lin l = lines++ & prefix_tqmask;
if (l == alloc_lines0)
{
if ((lin)(PTRDIFF_MAX / (2 * sizeof *linbuf0)) <= alloc_lines0)
xalloc_die ();
alloc_lines0 *= 2;
- linbuf0 = (const QChar**) xrealloc (linbuf0, alloc_lines0 * sizeof(*linbuf0));
+ linbuf0 = (const TQChar**) xrealloc (linbuf0, alloc_lines0 * sizeof(*linbuf0));
}
linbuf0[l] = p0;
while ( p0<pEnd0 && *p0++ != '\n' )
@@ -473,14 +473,14 @@ void GnuDiff::find_identical_ends (struct file_data filevec[])
if (alloc_lines1 < buffered_prefix
|| (lin)(PTRDIFF_MAX / sizeof *linbuf1) <= alloc_lines1)
xalloc_die ();
- linbuf1 = (const QChar**)xmalloc (alloc_lines1 * sizeof(*linbuf1));
+ linbuf1 = (const TQChar**)xmalloc (alloc_lines1 * sizeof(*linbuf1));
lin i;
if (buffered_prefix != lines)
{
/* Rotate prefix lines to proper location. */
for (i = 0; i < buffered_prefix; i++)
- linbuf1[i] = linbuf0[(lines - context + i) & prefix_mask];
+ linbuf1[i] = linbuf0[(lines - context + i) & prefix_tqmask];
for (i = 0; i < buffered_prefix; i++)
linbuf0[i] = linbuf1[i];
}