diff options
author | Christian Kamm <mail@ckamm.de> | 2017-09-13 14:03:40 +0300 |
---|---|---|
committer | ckamm <mail@ckamm.de> | 2017-09-14 15:53:05 +0300 |
commit | 0b7ad2c804b86f8623fb6e53a185c0f54d7fe7d7 (patch) | |
tree | 26347a01666419a6a2e3dfcf79cb14b606747c04 | |
parent | 8392d6c13626f7a357018d38b37a28ccf95e40a8 (diff) |
Excludes: Allow escaping # #6012
Otherwise adding patterns that start with # are impossible to add, since
they get treated as comments. Also add this escaping for patterns added
in the ui.
-rw-r--r-- | src/csync/csync_exclude.cpp | 1 | ||||
-rw-r--r-- | src/gui/ignorelisteditor.cpp | 2 | ||||
-rw-r--r-- | sync-exclude.lst | 2 | ||||
-rw-r--r-- | test/csync/csync_tests/check_csync_exclude.cpp | 4 |
4 files changed, 7 insertions, 2 deletions
diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 7517ee218..7a177b840 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -84,6 +84,7 @@ static const char *csync_exclude_expand_escapes(const char * input) case '"': out[o++] = '"'; break; case '?': out[o++] = '?'; break; case '\\': out[o++] = '\\'; break; + case '#': out[o++] = '#'; break; case 'a': out[o++] = '\a'; break; case 'b': out[o++] = '\b'; break; case 'f': out[o++] = '\f'; break; diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp index 64c39c48f..3253b2b1e 100644 --- a/src/gui/ignorelisteditor.cpp +++ b/src/gui/ignorelisteditor.cpp @@ -107,6 +107,8 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList() QByteArray prepend; if (deletableItem->checkState() == Qt::Checked) { prepend = "]"; + } else if (patternItem->text().startsWith('#')) { + prepend = "\\"; } ignores.write(prepend + patternItem->text().toUtf8() + '\n'); } diff --git a/sync-exclude.lst b/sync-exclude.lst index bdf6c3441..fe5cbee10 100644 --- a/sync-exclude.lst +++ b/sync-exclude.lst @@ -1,3 +1,5 @@ +# This file contains fixed global exclude patterns + *~ ~$* .~lock.* diff --git a/test/csync/csync_tests/check_csync_exclude.cpp b/test/csync/csync_tests/check_csync_exclude.cpp index 99a771266..0525942ac 100644 --- a/test/csync/csync_tests/check_csync_exclude.cpp +++ b/test/csync/csync_tests/check_csync_exclude.cpp @@ -387,9 +387,9 @@ static void check_csync_exclude_expand_escapes(void **state) (void)state; const char *str = csync_exclude_expand_escapes( - "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z"); + "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#"); assert_true(0 == strcmp( - str, "keep ' \" ? \\ \a \b \f \n \r \t \v \\z")); + str, "keep ' \" ? \\ \a \b \f \n \r \t \v \\z #")); SAFE_FREE(str); str = csync_exclude_expand_escapes(""); |