vtools_genesis 1 #include "system.h"
vtools_genesis 2 #include <stdio.h>
vtools_genesis 3 #include <string.h>
vtools_genesis 4 #include <sys/stat.h>
vtools_genesis 5
vtools_genesis 6
vtools_genesis 7 enum changes {
vtools_genesis 8
vtools_genesis 9 UNCHANGED,
vtools_genesis 10
vtools_genesis 11
vtools_genesis 12 OLD,
vtools_genesis 13
vtools_genesis 14
vtools_genesis 15 NEW,
vtools_genesis 16
vtools_genesis 17
vtools_genesis 18 CHANGED
vtools_genesis 19 };
vtools_genesis 20
vtools_genesis 21
vtools_genesis 22
vtools_genesis 23 #ifndef GDIFF_MAIN
vtools_genesis 24 # define XTERN extern
vtools_genesis 25 #else
vtools_genesis 26 # define XTERN
vtools_genesis 27 #endif
vtools_genesis 28
vtools_genesis 29
vtools_genesis 30 zero when context is not to be shown. */
vtools_genesis 31 XTERN lin context;
vtools_genesis 32
vtools_genesis 33
vtools_genesis 34 0177 as implying a "binary file". */
vtools_genesis 35 XTERN bool text;
vtools_genesis 36
vtools_genesis 37
vtools_genesis 38 XTERN lin horizon_lines;
vtools_genesis 39
vtools_genesis 40
vtools_genesis 41 depends on various options. */
vtools_genesis 42 XTERN bool files_can_be_treated_as_binary;
vtools_genesis 43
vtools_genesis 44
vtools_genesis 45 XTERN char *file_label[2];
vtools_genesis 46
vtools_genesis 47
vtools_genesis 48 XTERN bool brief;
vtools_genesis 49
vtools_genesis 50
vtools_genesis 51 XTERN bool suppress_blank_empty;
vtools_genesis 52
vtools_genesis 53
vtools_genesis 54 is used for resuming an aborted comparison. All file names less
vtools_genesis 55 than this name are ignored. */
vtools_genesis 56 XTERN char const *starting_file;
vtools_genesis 57
vtools_genesis 58
vtools_genesis 59 spaces between and at the beginning but none at the end. If there
vtools_genesis 60 were no options given, this string is empty. */
vtools_genesis 61 XTERN char *switch_string;
vtools_genesis 62
vtools_genesis 63
vtools_genesis 64 density of changes. */
vtools_genesis 65 XTERN bool speed_large_files;
vtools_genesis 66
vtools_genesis 67
vtools_genesis 68 slower) but will find a guaranteed minimal set of changes. */
vtools_genesis 69 XTERN bool minimal;
vtools_genesis 70
vtools_genesis 71
vtools_genesis 72 change|. Each |struct change| represents one place where some
vtools_genesis 73 lines are deleted and some are inserted.
vtools_genesis 74
vtools_genesis 75 |line0| and |line1| are the first affected lines in the two files
vtools_genesis 76 (origin 0). |deleted| is the number of lines deleted here from file
vtools_genesis 77 0. |inserted| is the number of lines inserted here in file 1.
vtools_genesis 78
vtools_genesis 79 If |deleted| is 0 then |line0| is the number of the line before
vtools_genesis 80 which the insertion was done; vice versa for |inserted| and
vtools_genesis 81 |line1|. */
vtools_genesis 82
vtools_genesis 83 struct change {
vtools_genesis 84 struct change *link;
vtools_genesis 85 lin inserted;
vtools_genesis 86 lin deleted;
vtools_genesis 87 lin line0;
vtools_genesis 88 lin line1;
vtools_genesis 89 bool ignore;
vtools_genesis 90 };
vtools_genesis 91
vtools_genesis 92
vtools_genesis 93
vtools_genesis 94
vtools_genesis 95
vtools_genesis 96 struct file_data {
vtools_genesis 97 int desc;
vtools_genesis 98 char const *name;
vtools_genesis 99 struct stat stat;
vtools_genesis 100
vtools_genesis 101
vtools_genesis 102 word *buffer;
vtools_genesis 103
vtools_genesis 104
vtools_genesis 105 sizeof |*buffer|. */
vtools_genesis 106 size_t bufsize;
vtools_genesis 107
vtools_genesis 108
vtools_genesis 109 size_t buffered;
vtools_genesis 110
vtools_genesis 111
vtools_genesis 112 char const **linbuf;
vtools_genesis 113
vtools_genesis 114
vtools_genesis 115 |linebuf[linbuf_base ... buffered_lines - 1]| are possibly differing.
vtools_genesis 116 |linebuf[linbuf_base ... valid_lines - 1]| contain valid data.
vtools_genesis 117 |linebuf[linbuf_base ... alloc_lines - 1]| are allocated. */
vtools_genesis 118 lin linbuf_base, buffered_lines, valid_lines, alloc_lines;
vtools_genesis 119
vtools_genesis 120
vtools_genesis 121 char const *prefix_end;
vtools_genesis 122
vtools_genesis 123
vtools_genesis 124 file before |linbuf[0]|. */
vtools_genesis 125 lin prefix_lines;
vtools_genesis 126
vtools_genesis 127
vtools_genesis 128 char const *suffix_begin;
vtools_genesis 129
vtools_genesis 130
vtools_genesis 131 for each line. It is this vector that is actually compared
vtools_genesis 132 with that of another file to generate differences. */
vtools_genesis 133 lin *equivs;
vtools_genesis 134
vtools_genesis 135
vtools_genesis 136 discarded lines have been squeezed out. */
vtools_genesis 137 lin *undiscarded;
vtools_genesis 138
vtools_genesis 139
vtools_genesis 140 lines) to real ones (counting those lines). Both are
vtools_genesis 141 $origin-0$. */
vtools_genesis 142 lin *realindexes;
vtools_genesis 143
vtools_genesis 144
vtools_genesis 145 lin nondiscarded_lines;
vtools_genesis 146
vtools_genesis 147
vtools_genesis 148 for a line that is an insertion or a deletion. The results of
vtools_genesis 149 comparison are stored here. */
vtools_genesis 150 char *changed;
vtools_genesis 151
vtools_genesis 152
vtools_genesis 153 bool missing_newline;
vtools_genesis 154
vtools_genesis 155
vtools_genesis 156 bool eof;
vtools_genesis 157
vtools_genesis 158
vtools_genesis 159 sibling file. */
vtools_genesis 160 lin equiv_max;
vtools_genesis 161 };
vtools_genesis 162
vtools_genesis 163
vtools_genesis 164 array of words. */
vtools_genesis 165 #define FILE_BUFFER(f) ((char *) (f)->buffer)
vtools_genesis 166
vtools_genesis 167
vtools_genesis 168
vtools_genesis 169 struct comparison {
vtools_genesis 170 struct file_data file[2];
vtools_genesis 171 struct comparison const *parent;
vtools_genesis 172 };
vtools_genesis 173
vtools_genesis 174
vtools_genesis 175
vtools_genesis 176 XTERN struct file_data files[2];
vtools_genesis 177
vtools_genesis 178
vtools_genesis 179
vtools_genesis 180 XTERN FILE *outfile;
vtools_genesis 181
vtools_genesis 182
vtools_genesis 183
vtools_genesis 184
vtools_genesis 185 extern int diff_2_files(struct comparison *);
vtools_genesis 186
vtools_genesis 187
vtools_genesis 188 extern void print_context_header(struct file_data[], char const *const *);
vtools_genesis 189
vtools_genesis 190 extern void print_context_script(struct change *);
vtools_genesis 191
vtools_genesis 192
vtools_genesis 193 extern int diff_dirs(struct comparison const *,
vtools_genesis 194 int (*)(struct comparison const *,
vtools_genesis 195 char const *, char const *));
vtools_genesis 196
vtools_genesis 197 extern char *find_dir_file_pathname(char const *, char const *);
vtools_genesis 198
vtools_genesis 199
vtools_genesis 200 extern struct change *find_hunk(struct change *);
vtools_genesis 201
vtools_genesis 202 extern void pr_unidiff_hunk(struct change *);
vtools_genesis 203
vtools_genesis 204
vtools_genesis 205 extern void file_block_read(struct file_data *, size_t);
vtools_genesis 206
vtools_genesis 207 extern bool read_files(struct file_data[], bool);
vtools_genesis 208
vtools_genesis 209
vtools_genesis 210
vtools_genesis 211 extern bool lines_differ(char const *, char const *);
vtools_genesis 212
vtools_genesis 213 extern lin translate_line_number(struct file_data const *, lin);
vtools_genesis 214
vtools_genesis 215 extern struct change *find_change(struct change *);
vtools_genesis 216
vtools_genesis 217 extern void *zalloc(size_t);
vtools_genesis 218
vtools_genesis 219 extern enum changes analyze_hunk(struct change *, lin *, lin *, lin *, lin *);
vtools_genesis 220
vtools_genesis 221 extern void begin_output(void);
vtools_genesis 222
vtools_genesis 223 extern void debug_script(struct change *);
vtools_genesis 224
vtools_genesis 225 extern void fatal(char const *) __attribute__((noreturn));
vtools_genesis 226
vtools_genesis 227 extern void finish_output(void);
vtools_genesis 228
vtools_genesis 229 extern void message(char const *, char const *, char const *);
vtools_genesis 230
vtools_genesis 231 extern void message5(char const *, char const *, char const *,
vtools_genesis 232 char const *, char const *);
vtools_genesis 233
vtools_genesis 234 extern void output_1_line(char const *, char const *);
vtools_genesis 235
vtools_genesis 236 extern void perror_with_name(char const *);
vtools_genesis 237
vtools_genesis 238 extern void pfatal_with_name(char const *) __attribute__((noreturn));
vtools_genesis 239
vtools_genesis 240 extern void print_1_line(char const *, char const *const *);
vtools_genesis 241
vtools_genesis 242 extern void print_1_line_nl(char const *, char const *const *, bool);
vtools_genesis 243
vtools_genesis 244 extern void print_script(struct change *);
vtools_genesis 245
vtools_genesis 246 extern void setup_output(char const *, char const *, bool);
vtools_genesis 247
vtools_genesis 248 extern void translate_range(struct file_data const *, lin, lin,
vtools_genesis 249 printint *, printint *);