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