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-01-12 05:34:38 Functions: 100.0 % 1 1

            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          905 : void remove_trailing_slash(char *path)
      12              : {
      13          905 :         if(path == NULL || *path == '\0')
      14              :         {
      15            1 :                 return;
      16              :         }
      17              : 
      18          904 :         size_t len = strlen(path);
      19              : 
      20              :         // Avoid modifying "/" (root path)
      21          937 :         while(len > 1 && path[len - 1] == '/')
      22              :         {
      23           33 :                 path[--len] = '\0';
      24              :         }
      25              : }
        

Generated by: LCOV version 2.0-1