summaryrefslogtreecommitdiff
path: root/subversion/libsvn_diff/deprecated.c
blob: 891ad5fa8fc07cb66e111d97c89db7f812e25a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
 * deprecated.c:  holding file for all deprecated APIs.
 *                "we can't lose 'em, but we can shun 'em!"
 *
 * ====================================================================
 *    Licensed to the Apache Software Foundation (ASF) under one
 *    or more contributor license agreements.  See the NOTICE file
 *    distributed with this work for additional information
 *    regarding copyright ownership.  The ASF licenses this file
 *    to you under the Apache License, Version 2.0 (the
 *    "License"); you may not use this file except in compliance
 *    with the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing,
 *    software distributed under the License is distributed on an
 *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *    KIND, either express or implied.  See the License for the
 *    specific language governing permissions and limitations
 *    under the License.
 * ====================================================================
 */

/* ==================================================================== */



/*** Includes. ***/

/* We define this here to remove any further warnings about the usage of
   deprecated functions in this file. */
#define SVN_DEPRECATED

#include "svn_diff.h"
#include "svn_utf.h"

#include "svn_private_config.h"




/*** Code. ***/
struct fns_wrapper_baton
{
  /* We put the old baton in front of this one, so that we can still use
     this baton in place of the old.  This prevents us from having to
     implement simple wrappers around each member of diff_fns_t. */
  void *old_baton;
  const svn_diff_fns_t *vtable;
};

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)
{
  struct fns_wrapper_baton *fwb = baton;
  apr_size_t i;

  /* Just iterate over the datasources, using the old singular version. */
  for (i = 0; i < datasource_len; i++)
    {
      SVN_ERR(fwb->vtable->datasource_open(fwb->old_baton, datasources[i]));
    }

  /* Don't claim any prefix or suffix matches. */
  *prefix_lines = 0;
  *suffix_lines = 0;

  return SVN_NO_ERROR;
}

static svn_error_t *
datasource_close(void *baton,
                 svn_diff_datasource_e datasource)
{
  struct fns_wrapper_baton *fwb = baton;
  return fwb->vtable->datasource_close(fwb->old_baton, datasource);
}

static svn_error_t *
datasource_get_next_token(apr_uint32_t *hash,
                          void **token,
                          void *baton,
                          svn_diff_datasource_e datasource)
{
  struct fns_wrapper_baton *fwb = baton;
  return fwb->vtable->datasource_get_next_token(hash, token, fwb->old_baton,
                                                datasource);
}

static svn_error_t *
token_compare(void *baton,
              void *ltoken,
              void *rtoken,
              int *compare)
{
  struct fns_wrapper_baton *fwb = baton;
  return fwb->vtable->token_compare(fwb->old_baton, ltoken, rtoken, compare);
}

static void
token_discard(void *baton,
              void *token)
{
  struct fns_wrapper_baton *fwb = baton;
  fwb->vtable->token_discard(fwb->old_baton, token);
}

static void
token_discard_all(void *baton)
{
  struct fns_wrapper_baton *fwb = baton;
  fwb->vtable->token_discard_all(fwb->old_baton);
}


static void
wrap_diff_fns(svn_diff_fns2_t **diff_fns2,
              struct fns_wrapper_baton **baton2,
              const svn_diff_fns_t *diff_fns,
              void *baton,
              apr_pool_t *result_pool)
{
  /* Initialize the return vtable. */
  *diff_fns2 = apr_palloc(result_pool, sizeof(**diff_fns2));

  (*diff_fns2)->datasources_open = datasources_open;
  (*diff_fns2)->datasource_close = datasource_close;
  (*diff_fns2)->datasource_get_next_token = datasource_get_next_token;
  (*diff_fns2)->token_compare = token_compare;
  (*diff_fns2)->token_discard = token_discard;
  (*diff_fns2)->token_discard_all = token_discard_all;

  /* Initialize the wrapper baton. */
  *baton2 = apr_palloc(result_pool, sizeof (**baton2));
  (*baton2)->old_baton = baton;
  (*baton2)->vtable = diff_fns;
}


/*** From diff_file.c ***/
svn_error_t *
svn_diff_file_output_unified2(svn_stream_t *output_stream,
                              svn_diff_t *diff,
                              const char *original_path,
                              const char *modified_path,
                              const char *original_header,
                              const char *modified_header,
                              const char *header_encoding,
                              apr_pool_t *pool)
{
  return svn_diff_file_output_unified3(output_stream, diff,
                                       original_path, modified_path,
                                       original_header, modified_header,
                                       header_encoding, NULL, FALSE, pool);
}

svn_error_t *
svn_diff_file_output_unified(svn_stream_t *output_stream,
                             svn_diff_t *diff,
                             const char *original_path,
                             const char *modified_path,
                             const char *original_header,
                             const char *modified_header,
                             apr_pool_t *pool)
{
  return svn_diff_file_output_unified2(output_stream, diff,
                                       original_path, modified_path,
                                       original_header, modified_header,
                                       SVN_APR_LOCALE_CHARSET, pool);
}

svn_error_t *
svn_diff_file_diff(svn_diff_t **diff,
                   const char *original,
                   const char *modified,
                   apr_pool_t *pool)
{
  return svn_diff_file_diff_2(diff, original, modified,
                              svn_diff_file_options_create(pool), pool);
}

svn_error_t *
svn_diff_file_diff3(svn_diff_t **diff,
                    const char *original,
                    const char *modified,
                    const char *latest,
                    apr_pool_t *pool)
{
  return svn_diff_file_diff3_2(diff, original, modified, latest,
                               svn_diff_file_options_create(pool), pool);
}

svn_error_t *
svn_diff_file_diff4(svn_diff_t **diff,
                    const char *original,
                    const char *modified,
                    const char *latest,
                    const char *ancestor,
                    apr_pool_t *pool)
{
  return svn_diff_file_diff4_2(diff, original, modified, latest, ancestor,
                               svn_diff_file_options_create(pool), pool);
}

svn_error_t *
svn_diff_file_output_merge(svn_stream_t *output_stream,
                           svn_diff_t *diff,
                           const char *original_path,
                           const char *modified_path,
                           const char *latest_path,
                           const char *conflict_original,
                           const char *conflict_modified,
                           const char *conflict_latest,
                           const char *conflict_separator,
                           svn_boolean_t display_original_in_conflict,
                           svn_boolean_t display_resolved_conflicts,
                           apr_pool_t *pool)
{
  svn_diff_conflict_display_style_t style =
    svn_diff_conflict_display_modified_latest;

  if (display_resolved_conflicts)
    style = svn_diff_conflict_display_resolved_modified_latest;

  if (display_original_in_conflict)
    style = svn_diff_conflict_display_modified_original_latest;

  return svn_diff_file_output_merge2(output_stream,
                                     diff,
                                     original_path,
                                     modified_path,
                                     latest_path,
                                     conflict_original,
                                     conflict_modified,
                                     conflict_latest,
                                     conflict_separator,
                                     style,
                                     pool);
}


/*** From diff.c ***/
svn_error_t *
svn_diff_diff(svn_diff_t **diff,
              void *diff_baton,
              const svn_diff_fns_t *vtable,
              apr_pool_t *pool)
{
  svn_diff_fns2_t *diff_fns2;
  struct fns_wrapper_baton *fwb;

  wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
  return svn_diff_diff_2(diff, fwb, diff_fns2, pool);
}


/*** From diff3.c ***/
svn_error_t *
svn_diff_diff3(svn_diff_t **diff,
               void *diff_baton,
               const svn_diff_fns_t *vtable,
               apr_pool_t *pool)
{
  svn_diff_fns2_t *diff_fns2;
  struct fns_wrapper_baton *fwb;

  wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
  return svn_diff_diff3_2(diff, fwb, diff_fns2, pool);
}


/*** From diff4.c ***/
svn_error_t *
svn_diff_diff4(svn_diff_t **diff,
               void *diff_baton,
               const svn_diff_fns_t *vtable,
               apr_pool_t *pool)
{
  svn_diff_fns2_t *diff_fns2;
  struct fns_wrapper_baton *fwb;

  wrap_diff_fns(&diff_fns2, &fwb, vtable, diff_baton, pool);
  return svn_diff_diff4_2(diff, fwb, diff_fns2, pool);
}