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 : : }
|