Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / tests / libsvn_delta / delta-window-test.h
blob0ad0532f0223e2e731954bfca8a0f51de1fdb1da
1 /* delta-window-test.h -- utilities for delta window output
3 * ====================================================================
4 * Copyright (c) 2000-2004 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_DELTA_WINDOW_TEST_H
19 #define SVN_DELTA_WINDOW_TEST_H
21 #define APR_WANT_STDIO
22 #define APR_WANT_STRFUNC
23 #include <apr_want.h>
24 #include <apr_lib.h>
26 #include "svn_delta.h"
28 static apr_off_t
29 delta_window_size_estimate(const svn_txdelta_window_t *window)
31 apr_off_t len;
32 int i;
34 if (!window)
35 return 0;
37 /* Try to estimate the size of the delta. */
38 for (i = 0, len = 0; i < window->num_ops; ++i)
40 apr_size_t const offset = window->ops[i].offset;
41 apr_size_t const length = window->ops[i].length;
42 if (window->ops[i].action_code == svn_txdelta_new)
44 len += 1; /* opcode */
45 len += (length > 255 ? 2 : 1);
46 len += length;
48 else
50 len += 1; /* opcode */
51 len += (offset > 255 ? 2 : 1);
52 len += (length > 255 ? 2 : 1);
56 return len;
60 static apr_off_t
61 delta_window_print(const svn_txdelta_window_t *window,
62 const char *tag, FILE *stream)
64 const apr_off_t len = delta_window_size_estimate(window);
65 apr_off_t op_offset = 0;
66 int i;
68 if (!window)
69 return 0;
71 fprintf(stream, "%s: (WINDOW %" APR_OFF_T_FMT, tag, len);
72 fprintf(stream,
73 " (%" SVN_FILESIZE_T_FMT
74 " %" APR_SIZE_T_FMT " %" APR_SIZE_T_FMT ")",
75 window->sview_offset, window->sview_len, window->tview_len);
76 for (i = 0; i < window->num_ops; ++i)
78 apr_size_t const offset = window->ops[i].offset;
79 apr_size_t const length = window->ops[i].length;
80 apr_size_t tmp;
81 switch (window->ops[i].action_code)
83 case svn_txdelta_source:
84 fprintf(stream, "\n%s: (%" APR_OFF_T_FMT " SRC %" APR_SIZE_T_FMT
85 " %" APR_SIZE_T_FMT ")", tag, op_offset, offset, length);
86 break;
87 case svn_txdelta_target:
88 fprintf(stream, "\n%s: (%" APR_OFF_T_FMT " TGT %" APR_SIZE_T_FMT
89 " %" APR_SIZE_T_FMT ")", tag, op_offset, offset, length);
90 break;
91 case svn_txdelta_new:
92 fprintf(stream, "\n%s: (%" APR_OFF_T_FMT " NEW %"
93 APR_SIZE_T_FMT " \"", tag, op_offset, length);
94 for (tmp = offset; tmp < offset + length; ++tmp)
96 int const dat = window->new_data->data[tmp];
97 if (apr_iscntrl(dat) || !apr_isascii(dat))
98 fprintf(stream, "\\%3.3o", dat & 0xff);
99 else if (dat == '\\')
100 fputs("\\\\", stream);
101 else
102 putc(dat, stream);
104 fputs("\")", stream);
105 break;
106 default:
107 fprintf(stream, "\n%s: (BAD-OP)", tag);
110 op_offset += length;
112 fputs(")\n", stream);
113 return len;
117 #endif /* SVN_DELTA_WINDOW_TEST_H */