LCOV - code coverage report
Current view: top level - src - match_include_ignore.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 78.9 % 19 15
Test Date: 2026-03-31 13:51:38 Functions: 100.0 % 1 1
Branches: 78.6 % 14 11

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Apply the shared --include/--ignore decision logic to one relative path
       5                 :             :  *
       6                 :             :  * Checks --include first so explicitly included paths stay visible even when they
       7                 :             :  * also match --ignore. If a regexp evaluation fails, reports the error and
       8                 :             :  * returns FAILURE
       9                 :             :  *
      10                 :             :  * @param[in] relative_path Relative path to test
      11                 :             :  * @param[out] include True when the path matched --include. May be NULL when the caller
      12                 :             :  *             does not need to distinguish explicitly included paths from default-visible ones
      13                 :             :  * @param[out] ignore True when the path matched --ignore without being restored by --include
      14                 :             :  * @return SUCCESS on a valid decision, otherwise FAILURE
      15                 :             :  */
      16                 :       18394 : Return match_include_ignore(
      17                 :             :         const char *relative_path,
      18                 :             :         bool       *include,
      19                 :             :         bool       *ignore)
      20                 :             : {
      21                 :             :         // include is optional: callers that only need ignore-or-show pass NULL
      22         [ +  + ]:       18394 :         if(include != NULL)
      23                 :             :         {
      24                 :       18234 :                 *include = false;
      25                 :             :         }
      26                 :             : 
      27                 :       18394 :         *ignore = false;
      28                 :             : 
      29                 :       18394 :         Include match_include_response = match_include_pattern(relative_path);
      30                 :             : 
      31         [ +  + ]:       18394 :         if(DO_NOT_INCLUDE == match_include_response)
      32                 :             :         {
      33                 :       18316 :                 Ignore match_ignore_response = match_ignore_pattern(relative_path);
      34                 :             : 
      35         [ +  + ]:       18316 :                 if(IGNORE == match_ignore_response)
      36                 :             :                 {
      37                 :         330 :                         *ignore = true;
      38                 :             : 
      39         [ -  + ]:       17986 :                 } else if(FAIL_REGEXP_IGNORE == match_ignore_response){
      40                 :             : 
      41                 :           0 :                         slog(ERROR,"Fail ignore REGEXP for a string: %s\n",relative_path);
      42                 :           0 :                         provide(FAILURE);
      43                 :             :                 }
      44                 :             : 
      45         [ -  + ]:          78 :         } else if(FAIL_REGEXP_INCLUDE == match_include_response){
      46                 :             : 
      47                 :           0 :                 slog(ERROR,"Fail include REGEXP for a string: %s\n",relative_path);
      48                 :           0 :                 provide(FAILURE);
      49                 :             : 
      50         [ +  - ]:          78 :         } else if(INCLUDE == match_include_response){
      51                 :             : 
      52                 :             :                 // Skipped when caller passed NULL: the path stays visible, distinction is just not reported
      53         [ +  + ]:          78 :                 if(include != NULL)
      54                 :             :                 {
      55                 :          68 :                         *include = true;
      56                 :             :                 }
      57                 :             :         }
      58                 :             : 
      59                 :       18394 :         provide(SUCCESS);
      60                 :             : }
        

Generated by: LCOV version 2.0-1