Pārlūkot izejas kodu

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.
Christian Kamm 8 gadi atpakaļ
vecāks
revīzija
72131ff4ce

+ 1 - 0
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;

+ 2 - 0
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');
             }

+ 2 - 0
sync-exclude.lst

@@ -1,3 +1,5 @@
+# This file contains fixed global exclude patterns
+
 *~
 ~$*
 .~lock.*

+ 2 - 2
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("");