Various formatting fixes

This commit is contained in:
Sergey Poznyakoff
2024-06-07 00:05:00 +03:00
parent 1e6ce98e3a
commit 5f2cda027d
3 changed files with 46 additions and 38 deletions

View File

@@ -191,6 +191,7 @@ enum old_files
SKIP_OLD_FILES, /* --skip-old-files */
KEEP_NEWER_FILES /* --keep-newer-files */
};
#define MAX_OLD_FILES (KEEP_NEWER_FILES+1)
GLOBAL enum old_files old_files_option;
GLOBAL bool keep_directory_symlink_option;

View File

@@ -1351,6 +1351,19 @@ static void
set_old_files_option (int code, struct option_locus *loc)
{
struct option_locus *prev;
/* Option compatibility map. 0 means two options are incompatible. */
static bool compat_map[MAX_OLD_FILES][MAX_OLD_FILES] = {
[NO_OVERWRITE_DIR_OLD_FILES] = {
[KEEP_OLD_FILES] = 1,
[SKIP_OLD_FILES] = 1
},
[KEEP_OLD_FILES] = {
[NO_OVERWRITE_DIR_OLD_FILES] = 1
},
[SKIP_OLD_FILES] = {
[NO_OVERWRITE_DIR_OLD_FILES] = 1
}
};
static char const *const code_to_opt[] = {
"--overwrite-dir",
"--no-overwrite-dir",
@@ -1362,7 +1375,8 @@ set_old_files_option (int code, struct option_locus *loc)
};
prev = optloc_save (OC_OLD_FILES, loc);
if (prev && optloc_eq (loc, prev) && code != old_files_option)
if (prev && optloc_eq (loc, prev) && code != old_files_option &&
compat_map[code][old_files_option] == 0)
option_conflict_error (code_to_opt[code], code_to_opt[old_files_option]);
old_files_option = code;