Sync libsvn_diff from subversion r876937
[TortoiseGit.git] / src / TortoiseMerge / libsvn_diff / diff.h
blobdabfb8b73062ebd7809b47466fa10dd1946d229e
1 /*
2 * diff.h : private header file
4 * ====================================================================
5 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
19 #if !defined(DIFF_H)
20 #define DIFF_H
22 #include <apr.h>
23 #include <apr_pools.h>
24 #include <apr_general.h>
26 #include "svn_diff.h"
27 #include "svn_types.h"
29 #include "svn_pools.h"
31 #define SVN_DIFF__UNIFIED_CONTEXT_SIZE 3
33 typedef struct svn_diff__node_t svn_diff__node_t;
34 typedef struct svn_diff__tree_t svn_diff__tree_t;
35 typedef struct svn_diff__position_t svn_diff__position_t;
36 typedef struct svn_diff__lcs_t svn_diff__lcs_t;
38 typedef enum svn_diff__type_e
40 svn_diff__type_common,
41 svn_diff__type_diff_modified,
42 svn_diff__type_diff_latest,
43 svn_diff__type_diff_common,
44 svn_diff__type_conflict
45 } svn_diff__type_e;
47 struct svn_diff_t {
48 svn_diff_t *next;
49 svn_diff__type_e type;
50 apr_off_t original_start;
51 apr_off_t original_length;
52 apr_off_t modified_start;
53 apr_off_t modified_length;
54 apr_off_t latest_start;
55 apr_off_t latest_length;
56 svn_diff_t *resolved_diff;
59 struct svn_diff__position_t
61 svn_diff__position_t *next;
62 svn_diff__node_t *node;
63 apr_off_t offset;
66 struct svn_diff__lcs_t
68 svn_diff__lcs_t *next;
69 svn_diff__position_t *position[2];
70 apr_off_t length;
71 int refcount;
75 /* State used when normalizing whitespace and EOL styles. */
76 typedef enum svn_diff__normalize_state_t
78 /* Initial state; not in a sequence of whitespace. */
79 svn_diff__normalize_state_normal,
80 /* We're in a sequence of whitespace characters. Only entered if
81 we ignore whitespace. */
82 svn_diff__normalize_state_whitespace,
83 /* The previous character was CR. */
84 svn_diff__normalize_state_cr
85 } svn_diff__normalize_state_t;
88 svn_diff__lcs_t *
89 svn_diff__lcs(svn_diff__position_t *position_list1, /* pointer to tail (ring) */
90 svn_diff__position_t *position_list2, /* pointer to tail (ring) */
91 apr_pool_t *pool);
95 * Support functions to build a tree of token positions
97 void
98 svn_diff__tree_create(svn_diff__tree_t **tree, apr_pool_t *pool);
102 * Get all tokens from a datasource. Return the
103 * last item in the (circular) list.
105 svn_error_t *
106 svn_diff__get_tokens(svn_diff__position_t **position_list,
107 svn_diff__tree_t *tree,
108 void *diff_baton,
109 const svn_diff_fns_t *vtable,
110 svn_diff_datasource_e datasource,
111 apr_pool_t *pool);
114 /* Morph a svn_lcs_t into a svn_diff_t. */
115 svn_diff_t *
116 svn_diff__diff(svn_diff__lcs_t *lcs,
117 apr_off_t original_start, apr_off_t modified_start,
118 svn_boolean_t want_common,
119 apr_pool_t *pool);
121 void
122 svn_diff__resolve_conflict(svn_diff_t *hunk,
123 svn_diff__position_t **position_list1,
124 svn_diff__position_t **position_list2,
125 apr_pool_t *pool);
129 * Return an adler32 checksum based on CHECKSUM, updated with
130 * DATA of size LEN.
132 apr_uint32_t
133 svn_diff__adler32(apr_uint32_t checksum, const char *data, apr_off_t len);
136 /* Normalize the characters pointed to by the buffer BUF (of length *LENGTHP)
137 * according to the options *OPTS, starting in the state *STATEP.
139 * Adjust *LENGTHP and *STATEP to be the length of the normalized buffer and
140 * the final state, respectively.
141 * Normalized data is written to the memory at *TGT. BUF and TGT may point
142 * to the same memory area. The memory area pointed to by *TGT should be
143 * large enough to hold *LENGTHP bytes.
144 * When on return *TGT is not equal to the value passed in, it points somewhere
145 * into the memory region designated by BUF and *LENGTHP.
147 void
148 svn_diff__normalize_buffer(char **tgt,
149 apr_off_t *lengthp,
150 svn_diff__normalize_state_t *statep,
151 const char *buf,
152 const svn_diff_file_options_t *opts);
155 #endif /* DIFF_H */