Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : * @brief Apply the shared --include and --ignore decision logic to one path
5 : : *
6 : : * Applies --include first, then --ignore, so explicitly included paths stay visible
7 : : *
8 : : * @param[in] relative_path Relative path descriptor to test
9 : : * @param[out] include True when the path matched --include. May be NULL when the caller
10 : : * only needs the final visibility decision
11 : : * @param[out] ignore True when the path matched --ignore without being restored by --include
12 : : * @return SUCCESS on a valid decision, otherwise FAILURE
13 : : */
14 : 24236 : Return match_include_ignore(
15 : : const memory *relative_path,
16 : : bool *include,
17 : : bool *ignore)
18 : : {
19 : 24236 : const char *runtime_relative_path = m_text(relative_path);
20 : :
21 : : // Callers may omit include when only the final visibility decision is needed
22 [ + + ]: 24236 : if(include != NULL)
23 : : {
24 : 23602 : *include = false;
25 : : }
26 : :
27 : 24236 : *ignore = false;
28 : :
29 : 24236 : Include match_include_response = match_include_pattern(relative_path);
30 : :
31 [ + + ]: 24236 : if(DO_NOT_INCLUDE == match_include_response)
32 : : {
33 : 24130 : Ignore match_ignore_response = match_ignore_pattern(relative_path);
34 : :
35 [ + + ]: 24130 : if(IGNORE == match_ignore_response)
36 : : {
37 : 582 : *ignore = true;
38 : :
39 [ - + ]: 23548 : } else if(FAIL_REGEXP_IGNORE == match_ignore_response){
40 : :
41 : 0 : slog(ERROR,"Fail ignore REGEXP for a string: %s\n",runtime_relative_path);
42 : 0 : provide(FAILURE);
43 : : }
44 : :
45 [ - + ]: 106 : } else if(FAIL_REGEXP_INCLUDE == match_include_response){
46 : :
47 : 0 : slog(ERROR,"Fail include REGEXP for a string: %s\n",runtime_relative_path);
48 : 0 : provide(FAILURE);
49 : :
50 [ + - ]: 106 : } else if(INCLUDE == match_include_response){
51 : :
52 : : // Keep the path visible even when the include flag is not requested
53 [ + + ]: 106 : if(include != NULL)
54 : : {
55 : 72 : *include = true;
56 : : }
57 : : }
58 : :
59 : 24236 : provide(SUCCESS);
60 : : }
|