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
|
/* See LICENSE file for copyright and license details. */
#include "libpatch.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define IS_LINE(T) ((T) >= LIBPATCH_PATCH_CONTEXT && (T) <= LIBPATCH_PATCH_POSTCHANGE)
struct printer_internals {
void (*put)(struct libpatch_diff2_printer *this, const char *text, size_t len);
union {
FILE *stream;
int fd;
} f;
};
void libpatch_plain_diff2_printer__(struct libpatch_diff2_printer *printer);
struct libpatch_diff2_printer *libpatch_stream_diff2_printer__(FILE *output);
struct libpatch_diff2_printer *libpatch_fd_diff2_printer__(int output);
size_t libpatch_next_line__(const char **text, size_t *textlen, size_t lastlen);
int libpatch_reverse_hunks__(struct libpatch_patch *patch, size_t patchlen,
const size_t *hunks, size_t nhunks,
struct libpatch_patch **patchcopy, size_t *patchcopysize);
size_t libpatch_get_zu__(const char *text, size_t len, size_t *out);
int libpatch_append_to_patch__(struct libpatch_patch **patch, size_t *patchlen, size_t *size,
size_t stroff, size_t strlen, int type);
#define APPEND_STRING(OFF, TYPE)\
do {\
if (libpatch_append_to_patch__(patch, patchlen, &size,\
(size_t)(&text[OFF] - patchtext),\
len - (size_t)(OFF), (TYPE)))\
goto fail;\
} while (0)
#define APPEND_OPTSTRING(OFF, TYPE)\
APPEND_STRING((OFF) + ((OFF) < len && text[OFF] == ' '), (TYPE))
#define APPEND_NO_TEXT(TYPE)\
APPEND_STRING(len, TYPE)
|