diff --git a/src/command/backup/common.c b/src/command/backup/common.c index 0f7916ff9..38d32c1eb 100644 --- a/src/command/backup/common.c +++ b/src/command/backup/common.c @@ -26,6 +26,7 @@ backupRegExp(BackupRegExpParam param) FUNCTION_LOG_PARAM(BOOL, param.full); FUNCTION_LOG_PARAM(BOOL, param.differential); FUNCTION_LOG_PARAM(BOOL, param.incremental); + FUNCTION_LOG_PARAM(BOOL, param.noAnchorEnd); FUNCTION_LOG_END(); ASSERT(param.full || param.differential || param.incremental); @@ -76,7 +77,8 @@ backupRegExp(BackupRegExpParam param) } // Append the end anchor - strCat(result, "$"); + if (!param.noAnchorEnd) + strCat(result, "$"); FUNCTION_LOG_RETURN(STRING, result); } diff --git a/src/command/backup/common.h b/src/command/backup/common.h index eef3d2459..77776a109 100644 --- a/src/command/backup/common.h +++ b/src/command/backup/common.h @@ -33,6 +33,7 @@ typedef struct BackupRegExpParam bool full; bool differential; bool incremental; + bool noAnchorEnd; } BackupRegExpParam; #define backupRegExpP(...) \ diff --git a/test/src/module/command/backupCommonTest.c b/test/src/module/command/backupCommonTest.c index e6ee9edb9..d0884d8dd 100644 --- a/test/src/module/command/backupCommonTest.c +++ b/test/src/module/command/backupCommonTest.c @@ -90,17 +90,14 @@ testRun(void) TEST_RESULT_BOOL(regExpMatchOne(filter, full), true, " match full"); // ------------------------------------------------------------------------------------------------------------------------- - filter = backupRegExpP(.incremental = true, .differential = true); + filter = backupRegExpP(.incremental = true, .differential = true, .noAnchorEnd = true); TEST_RESULT_STR( strPtr(filter), - "^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)$", "diff and incr backup regex with anchors"); + "^[0-9]{8}\\-[0-9]{6}F\\_[0-9]{8}\\-[0-9]{6}(D|I)", "diff and incr backup regex with anchors"); TEST_RESULT_BOOL(regExpMatchOne(filter, incr), true, " match incr"); TEST_RESULT_BOOL(regExpMatchOne(filter, diff), true, " match diff"); TEST_RESULT_BOOL(regExpMatchOne(filter, full), false, " does not match full"); - TEST_RESULT_BOOL( - regExpMatchOne( - filter, strNew("12341234-123123F_12341234-123123DG")), false, " does not match with trailing character"); TEST_RESULT_BOOL( regExpMatchOne( filter, strNew("A12341234-123123F_12341234-123123I")), false, " does not match with leading character");