Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : *
5 : : * Decide whether or not to protect the relative
6 : : * path from checksum recalculation by comparing it
7 : : * with PCRE2 regular expressions passed as arguments
8 : : * with --lock-checksum=
9 : : *
10 : : */
11 : 2914 : LockChecksum match_checksum_lock_pattern(
12 : : const char *relative_path,
13 : : bool *lock_checksum_showed_once)
14 : : {
15 [ + + ]: 2914 : if(config->lock_checksum == NULL)
16 : : {
17 : : // Nothing to lock
18 : 2338 : return(DO_NOT_LOCK_CHECKSUM);
19 : : }
20 : :
21 [ + + ]: 1168 : for(int i = 0; config->lock_checksum[i] != NULL; ++i)
22 : : {
23 : 744 : REGEXP result = regexp_match(config->lock_checksum[i],relative_path,lock_checksum_showed_once);
24 : :
25 [ + + ]: 744 : if(MATCH == result)
26 : : {
27 : : // Lock that file checksum from recalculation
28 : 152 : return(LOCK_CHECKSUM);
29 : :
30 [ - + ]: 592 : } else if(REGEXP_ERROR == result){
31 : :
32 : 0 : return(FAIL_REGEXP_LOCK_CHECKSUM);
33 : :
34 : : }
35 : : }
36 : :
37 : : // No regexp matched
38 : 424 : return(DO_NOT_LOCK_CHECKSUM);
39 : : }
|