--- path_canon.c 2002/08/27 19:04:33 1.1
+++ path_canon.c 2003/02/16 11:38:11 1.2
@@ -33,7 +33,7 @@
#include "path.h"
-path_rc_t
+path_rc_t
path_canon(
char *res_buf, size_t res_len,
const char *src_buf, size_t src_len)
@@ -59,13 +59,13 @@
if (res_len == 0)
res_len = strlen(res_buf);
- /* perform processing
+ /* perform processing
(keep in mind that source and target can overlap) */
res_ptr = res_buf;
res_end = res_buf+res_len;
src_ptr = src_buf;
src_end = src_buf+src_len;
-
+
while (src_ptr < src_end && res_ptr < res_end) {
/* recognize path separator */
if (*src_ptr == '/') {
@@ -96,8 +96,8 @@
/* path element is parent directory (".."),
so skip over to next path element in source and
skip back last path element in result */
- if ( res_ptr == res_buf
- || ( res_ptr >= res_buf+3
+ if ( res_ptr == res_buf
+ || ( res_ptr >= res_buf+3
&& res_ptr[-1] == '/' && res_ptr[-2] == '.' && res_ptr[-3] == '.')) {
/* path is relative and empty or already explicit directing
to the parent directory, so keep explicit parent specification */
@@ -105,7 +105,7 @@
*res_ptr++ = *src_ptr++;
}
else {
- /* there is already a path element in the
+ /* there is already a path element in the
result which can be removed */
src_ptr += 2;
while (res_ptr > res_buf && res_ptr[-1] == '/')
@@ -119,7 +119,7 @@
}
}
else {
- /* path element something else, so copy
+ /* path element something else, so copy
it over from source to the result */
while (src_ptr < src_end && res_ptr < res_end && src_ptr[0] != '/')
*res_ptr++ = *src_ptr++;
|