LCOV - code coverage report
Current view: top level - src - remove_trailing_slash.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 6 6
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 87.5 % 8 7

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Removes trailing slashes from a given path.
       5                 :             :  *
       6                 :             :  * Modifies the input string in-place by removing any trailing '/' characters.
       7                 :             :  * If the path consists only of slashes, it reduces it to a single '/'.
       8                 :             :  *
       9                 :             :  * @param path The string representing the path to be modified.
      10                 :             :  */
      11                 :        1538 : void remove_trailing_slash(char *path)
      12                 :             : {
      13   [ +  -  +  + ]:        1538 :         if(path == NULL || *path == '\0')
      14                 :             :         {
      15                 :           1 :                 return;
      16                 :             :         }
      17                 :             : 
      18                 :        1537 :         size_t len = strlen(path);
      19                 :             : 
      20                 :             :         // Avoid modifying "/" (root path)
      21   [ +  +  +  + ]:        1572 :         while(len > 1 && path[len - 1] == '/')
      22                 :             :         {
      23                 :          35 :                 path[--len] = '\0';
      24                 :             :         }
      25                 :             : }
        

Generated by: LCOV version 2.0-1