commit - 62ab48ecd9c2696e7929e41bc2a683facffdcfcb
commit + 00d5652be692793aa7c9285b490702d05a7ab8df
blob - ced7b7cda23b7557d6c4109730b7e7a41b0db237
blob + f562ecca72b0513ec935200ca938e058c6375248
--- diff/diff.c
+++ diff/diff.c
struct diff_result *result;
int rc;
const struct diff_config *cfg;
+ int diff_flags = 0;
cfg = do_patience ? &diff_config_patience : &diff_config;
f1 = openfile(file1, &str1, &st1);
f2 = openfile(file2, &str2, &st2);
+ if (ignore_whitespace)
+ diff_flags |= DIFF_FLAG_IGNORE_WHITESPACE;
+
result = diff_main(cfg, f1, str1, st1.st_size, f2, str2, st2.st_size,
- ignore_whitespace);
+ diff_flags);
#if 0
rc = diff_output_plain(stdout, &info, result);
#else
blob - 8f4d84bc1f35dc43c975210732bbfc5572d1970c
blob + 9479d3112b7ca78b893d54f7948605a4e532da35
--- include/diff/diff_main.h
+++ include/diff/diff_main.h
ARRAYLIST(struct diff_atom) atoms;
struct diff_data *root;
- bool ignore_whitespace;
+ int diff_flags;
};
+#define DIFF_FLAG_IGNORE_WHITESPACE 0x00000001
+
void diff_data_free(struct diff_data *diff_data);
struct diff_chunk;
FILE *left_f, const uint8_t *left_data,
off_t left_len,
FILE *right_f, const uint8_t *right_data,
- off_t right_len, bool ignore_whitespace);
+ off_t right_len, int diff_flags);
void diff_result_free(struct diff_result *result);
blob - c31b9e6e33142ba75f981720737dd4b978c52a07
blob + 72a7a3d9970ce9219dcadb1b60ce2c935437cb03
--- lib/diff_main.c
+++ lib/diff_main.c
const struct diff_atom *right)
{
off_t remain_left, remain_right;
- bool ignore_whitespace;
-
- ignore_whitespace = (left->d->root->ignore_whitespace ||
- right->d->root->ignore_whitespace);
+ int flags = (left->d->root->diff_flags | right->d->root->diff_flags);
+ bool ignore_whitespace = (flags & DIFF_FLAG_IGNORE_WHITESPACE);
if (!ignore_whitespace) {
if (!left->len && !right->len) {
void
diff_data_init_root(struct diff_data *d, FILE *f, const uint8_t *data,
- unsigned long long len, bool ignore_whitespace)
+ unsigned long long len, int diff_flags)
{
*d = (struct diff_data){
.f = f,
.data = data,
.len = len,
.root = d,
- .ignore_whitespace = ignore_whitespace,
+ .diff_flags = diff_flags,
};
}
diff_main(const struct diff_config *config,
FILE *left_f, const uint8_t *left_data, off_t left_len,
FILE *right_f, const uint8_t *right_data, off_t right_len,
- bool ignore_whitespace)
+ int diff_flags)
{
struct diff_result *result = malloc(sizeof(struct diff_result));
if (!result)
*result = (struct diff_result){};
diff_data_init_root(&result->left, left_f, left_data, left_len,
- ignore_whitespace);
+ diff_flags);
diff_data_init_root(&result->right, right_f, right_data, right_len,
- ignore_whitespace);
+ diff_flags);
if (!config->atomize_func) {
result->rc = EINVAL;