diff --git a/src/ChangeLog b/src/ChangeLog index 8967d0a89..95c9ebf80 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2002-02-18 Pavel Roskin + * utilunix.c (canonicalize_pathname) [__QNX__]: Fix detection + of Qnet names. Disable support of Qnet names under QNX Netrino. + Reported by Maurizio Rossi + * global.h: Include unix.h under "classical" QNX. * subshell.c: Don't include unix.h. * utilunix.c: Likewise. diff --git a/src/utilunix.c b/src/utilunix.c index 3d870512b..e7ba75e15 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -575,86 +575,84 @@ char *canonicalize_pathname (char *path) i = 0; while (path[i]) { - while (path[i] && path[i] != PATH_SEP) + while (path[i] && path[i] != PATH_SEP) i++; - start = i++; + start = i++; - /* If we didn't find any slashes, then there is nothing left to do. */ - if (!path[start]) + /* If we didn't find any slashes, then there is nothing left to do. */ + if (!path[start]) break; -#if defined(__QNX__) - /* - ** QNX accesses the directories of nodes on its peer-to-peer - ** network by prefixing their directories with "//[nid]". - ** We don't want to collapse two '/'s if they're at the start - ** of the path, followed by digits, and ending with a '/'. - */ - if (start == 0 && i == 1) - { - char *p = path + 2; - char *q = strchr(p, PATH_SEP); +#if defined(__QNX__) && !defined(__QNXNTO__) + /* + ** QNX accesses the directories of nodes on its peer-to-peer + ** network (Qnet) by prefixing their directories with "//[nid]". + ** We don't want to collapse two '/'s if they're at the start + ** of the path, followed by digits, and ending with a '/'. + */ + if (start == 0 && path[1] == PATH_SEP) { + char *p = path + 2; + char *q = strchr (p, PATH_SEP); - if (q > p) - { - *q = 0; - if (!strcspn(p, "0123456789")) - { - start = q - path; - i = start + 1; - } - *q = PATH_SEP; - } + if (q > p) { + *q = 0; + if (!strcspn (p, "0123456789")) { + start = q - path; + i = start + 1; } + *q = PATH_SEP; + } + } #endif - /* Handle multiple `/'s in a row. */ - while (path[i] == PATH_SEP) + /* Handle multiple `/'s in a row. */ + while (path[i] == PATH_SEP) i++; - if ((start + 1) != i) { + if ((start + 1) != i) { strcpy (path + start + 1, path + i); i = start + 1; } - /* Check for trailing `/'. */ - if (start && !path[i]) { - zero_last: + /* Check for trailing `/'. */ + if (start && !path[i]) { + zero_last: path[--i] = '\0'; break; } - /* Check for `../', `./' or trailing `.' by itself. */ - if (path[i] == '.') { + /* Check for `../', `./' or trailing `.' by itself. */ + if (path[i] == '.') { /* Handle trailing `.' by itself. */ if (!path[i + 1]) - goto zero_last; + goto zero_last; /* Handle `./'. */ if (path[i + 1] == PATH_SEP) { - strcpy (path + i, path + i + 1); - i = start; - continue; + strcpy (path + i, path + i + 1); + i = start; + continue; } /* Handle `../' or trailing `..' by itself. Remove the previous ?/ part with the exception of ../, which we should leave intact. */ - if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) { - while (--start > -1 && path[start] != PATH_SEP); - if (!strncmp (path + start + 1, "../", 3)) - continue; - strcpy (path + start + 1, path + i + 2); - i = start; - continue; + if (path[i + 1] == '.' + && (path[i + 2] == PATH_SEP || !path[i + 2])) { + while (--start > -1 && path[start] != PATH_SEP); + if (!strncmp (path + start + 1, "../", 3)) + continue; + strcpy (path + start + 1, path + i + 2); + i = start; + continue; } } } if (!*path) { - *path = stub_char; - path[1] = '\0'; + *path = stub_char; + path[1] = '\0'; } return path; }