1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006-2007, 2011 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "svn_pools.h"
25 * \ingroup TortoiseMerge
26 * Handles diffs of single lines. Used for inline diffs.
34 bool Diff(svn_diff_t
** diff
, LPCWSTR line1
, apr_size_t len1
, LPCWSTR line2
, apr_size_t len2
, bool bWordDiff
);
35 /** Checks if we really should show inline diffs.
36 * Inline diffs are only useful if the two lines are not
37 * completely different but at least a little bit similar.
39 static bool ShowInlineDiff(svn_diff_t
* diff
);
41 std::vector
<std::wstring
> m_line1tokens
;
42 std::vector
<std::wstring
> m_line2tokens
;
46 apr_pool_t
* m_subpool
;
48 apr_size_t m_line1length
;
50 apr_size_t m_line2length
;
51 apr_size_t m_line1pos
;
52 apr_size_t m_line2pos
;
56 static svn_error_t
* datasources_open(void *baton
, apr_off_t
*prefix_lines
, apr_off_t
*suffix_lines
, const svn_diff_datasource_e
*datasources
, apr_size_t datasource_len
);
57 static svn_error_t
* datasource_close(void *baton
, svn_diff_datasource_e datasource
);
58 static svn_error_t
* next_token(apr_uint32_t
* hash
, void ** token
, void * baton
, svn_diff_datasource_e datasource
);
59 static svn_error_t
* compare_token(void * baton
, void * token1
, void * token2
, int * compare
);
60 static void discard_token(void * baton
, void * token
);
61 static void discard_all_token(void *baton
);
62 static bool IsCharWhiteSpace(wchar_t c
);
64 static apr_uint32_t
Adler32(apr_uint32_t checksum
, const WCHAR
*data
, apr_size_t len
);
65 static void ParseLineWords(
66 LPCWSTR line
, apr_size_t lineLength
, std::vector
<std::wstring
>& tokens
);
67 static void ParseLineChars(
68 LPCWSTR line
, apr_size_t lineLength
, std::vector
<std::wstring
>& tokens
);
69 static void NextTokenWords(
70 apr_uint32_t
* hash
, void** token
, apr_size_t
& linePos
, const std::vector
<std::wstring
>& tokens
);
71 static void NextTokenChars(
72 apr_uint32_t
* hash
, void** token
, apr_size_t
& linePos
, LPCWSTR line
, apr_size_t lineLength
);
73 static const svn_diff_fns2_t SVNLineDiff_vtable
;