commit 2f0f372565eb3f2ccac6a5260d3d8d71af53eb76
parent 1f9f258c380c9e58a3b914e440d2a35236186787
Author: Francesco Saccone <francesco@francescosaccone.com>
Date: Tue, 1 Apr 2025 10:41:47 +0200
docs: add explanation comments in if statement
Signed-off-by: Francesco Saccone <francesco@francescosaccone.com>
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/file.c b/file.c
@@ -29,8 +29,9 @@ get_normalised_path(char *path) {
j = 0;
for (i = 0; path[i] != '\0'; i++) {
if (path[i] != '/' ||
- i == 0 ||
- path[i - 1] != '/') {
+ /* In the following conditions, we have path[i] == '/'. */
+ i == 0 || /* Keep leading slash */
+ path[i - 1] != '/'/* No continous slashes */) {
normalised[j] = path[i];
j++;
}