Mercurial > hg > easyhg-kdiff3
comparison kdiff3/src/gnudiff_io.cpp @ 53:32d5cbf9db71
Corrections for 0.9.81:
- Fix for configure --enable-final
- Bugfixes
- First steps towards internationalisation
author | joachim99 |
---|---|
date | Tue, 20 Jan 2004 20:19:59 +0000 |
parents | ba22ec30aa4e |
children | efe33e938730 |
comparison
equal
deleted
inserted
replaced
52:ba22ec30aa4e | 53:32d5cbf9db71 |
---|---|
1 /* File I/O for GNU DIFF. | 1 /* File I/O for GNU DIFF. |
2 | 2 |
3 Modified for KDiff3 by Joachim Eibl 2003. | 3 Modified for KDiff3 by Joachim Eibl 2003. |
4 The original file was part of GNU DIFF. | |
4 | 5 |
5 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002 | 6 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1998, 2001, 2002 |
6 Free Software Foundation, Inc. | 7 Free Software Foundation, Inc. |
7 | |
8 This file is part of GNU DIFF. | |
9 | 8 |
10 GNU DIFF is free software; you can redistribute it and/or modify | 9 GNU DIFF is free software; you can redistribute it and/or modify |
11 it under the terms of the GNU General Public License as published by | 10 it under the terms of the GNU General Public License as published by |
12 the Free Software Foundation; either version 2, or (at your option) | 11 the Free Software Foundation; either version 2, or (at your option) |
13 any later version. | 12 any later version. |
22 If not, write to the Free Software Foundation, | 21 If not, write to the Free Software Foundation, |
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 22 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
24 | 23 |
25 #include "gnudiff_diff.h" | 24 #include "gnudiff_diff.h" |
26 #include <stdlib.h> | 25 #include <stdlib.h> |
27 #include "gnudiff_xalloc.h" | |
28 | |
29 namespace GnuDiff | |
30 { | |
31 | 26 |
32 /* Rotate an unsigned value to the left. */ | 27 /* Rotate an unsigned value to the left. */ |
33 #define ROL(v, n) ((v) << (n) | (v) >> (sizeof (v) * CHAR_BIT - (n))) | 28 #define ROL(v, n) ((v) << (n) | (v) >> (sizeof (v) * CHAR_BIT - (n))) |
34 | 29 |
35 /* Given a hash value and a new character, return a new hash value. */ | 30 /* Given a hash value and a new character, return a new hash value. */ |
79 | 74 |
80 | 75 |
81 /* Split the file into lines, simultaneously computing the equivalence | 76 /* Split the file into lines, simultaneously computing the equivalence |
82 class for each line. */ | 77 class for each line. */ |
83 | 78 |
84 static void | 79 void GnuDiff::find_and_hash_each_line (struct file_data *current) |
85 find_and_hash_each_line (struct file_data *current) | |
86 { | 80 { |
87 hash_value h; | 81 hash_value h; |
88 unsigned char const *p = (unsigned char const *) current->prefix_end; | 82 unsigned char const *p = (unsigned char const *) current->prefix_end; |
89 unsigned char c; | 83 unsigned char c; |
90 lin i, *bucket; | 84 lin i, *bucket; |
377 /* Prepare the text. Make sure the text end is initialized. | 371 /* Prepare the text. Make sure the text end is initialized. |
378 Make sure text ends in a newline, | 372 Make sure text ends in a newline, |
379 but remember that we had to add one. | 373 but remember that we had to add one. |
380 Strip trailing CRs, if that was requested. */ | 374 Strip trailing CRs, if that was requested. */ |
381 | 375 |
382 static void | 376 void GnuDiff::prepare_text (struct file_data *current) |
383 prepare_text (struct file_data *current) | |
384 { | 377 { |
385 size_t buffered = current->buffered; | 378 size_t buffered = current->buffered; |
386 char *p = FILE_BUFFER (current); | 379 char *p = FILE_BUFFER (current); |
387 char *dst; | 380 char *dst; |
388 | 381 |
428 } | 421 } |
429 | 422 |
430 /* Given a vector of two file_data objects, find the identical | 423 /* Given a vector of two file_data objects, find the identical |
431 prefixes and suffixes of each object. */ | 424 prefixes and suffixes of each object. */ |
432 | 425 |
433 static void | 426 void GnuDiff::find_identical_ends (struct file_data filevec[]) |
434 find_identical_ends (struct file_data filevec[]) | |
435 { | 427 { |
436 word *w0, *w1; | 428 word *w0, *w1; |
437 char *p0, *p1, *buffer0, *buffer1; | 429 char *p0, *p1, *buffer0, *buffer1; |
438 char const *end0, *beg0; | 430 char const *end0, *beg0; |
439 char const **linbuf0, **linbuf1; | 431 char const **linbuf0, **linbuf1; |
655 with each one, and build the table of equivalence classes. | 647 with each one, and build the table of equivalence classes. |
656 Return nonzero if either file appears to be a binary file. | 648 Return nonzero if either file appears to be a binary file. |
657 If PRETEND_BINARY is nonzero, pretend they are binary regardless. */ | 649 If PRETEND_BINARY is nonzero, pretend they are binary regardless. */ |
658 | 650 |
659 bool | 651 bool |
660 read_files (struct file_data filevec[], bool /*pretend_binary*/) | 652 GnuDiff::read_files (struct file_data filevec[], bool /*pretend_binary*/) |
661 { | 653 { |
662 int i; | 654 int i; |
663 | 655 |
664 find_identical_ends (filevec); | 656 find_identical_ends (filevec); |
665 | 657 |
690 free (equivs); | 682 free (equivs); |
691 free (buckets - 1); | 683 free (buckets - 1); |
692 | 684 |
693 return 0; | 685 return 0; |
694 } | 686 } |
695 | |
696 } // namespace GnuDiff |