1
1

* utilunix.c (canonicalize_pathname) [__QNX__]: Fix detection

of Qnet names.  Disable support of Qnet names under QNX Netrino.
Reported by Maurizio Rossi <MRossi@system-group.it>
Этот коммит содержится в:
Pavel Roskin 2002-02-18 22:31:56 +00:00
родитель 2b7cf88d85
Коммит 6c67d1918c
2 изменённых файлов: 48 добавлений и 46 удалений

Просмотреть файл

@ -1,5 +1,9 @@
2002-02-18 Pavel Roskin <proski@gnu.org> 2002-02-18 Pavel Roskin <proski@gnu.org>
* utilunix.c (canonicalize_pathname) [__QNX__]: Fix detection
of Qnet names. Disable support of Qnet names under QNX Netrino.
Reported by Maurizio Rossi <MRossi@system-group.it>
* global.h: Include unix.h under "classical" QNX. * global.h: Include unix.h under "classical" QNX.
* subshell.c: Don't include unix.h. * subshell.c: Don't include unix.h.
* utilunix.c: Likewise. * utilunix.c: Likewise.

Просмотреть файл

@ -575,86 +575,84 @@ char *canonicalize_pathname (char *path)
i = 0; i = 0;
while (path[i]) { while (path[i]) {
while (path[i] && path[i] != PATH_SEP) while (path[i] && path[i] != PATH_SEP)
i++; i++;
start = i++; start = i++;
/* If we didn't find any slashes, then there is nothing left to do. */ /* If we didn't find any slashes, then there is nothing left to do. */
if (!path[start]) if (!path[start])
break; break;
#if defined(__QNX__) #if defined(__QNX__) && !defined(__QNXNTO__)
/* /*
** QNX accesses the directories of nodes on its peer-to-peer ** QNX accesses the directories of nodes on its peer-to-peer
** network by prefixing their directories with "//[nid]". ** network (Qnet) by prefixing their directories with "//[nid]".
** We don't want to collapse two '/'s if they're at the start ** We don't want to collapse two '/'s if they're at the start
** of the path, followed by digits, and ending with a '/'. ** of the path, followed by digits, and ending with a '/'.
*/ */
if (start == 0 && i == 1) if (start == 0 && path[1] == PATH_SEP) {
{ char *p = path + 2;
char *p = path + 2; char *q = strchr (p, PATH_SEP);
char *q = strchr(p, PATH_SEP);
if (q > p) if (q > p) {
{ *q = 0;
*q = 0; if (!strcspn (p, "0123456789")) {
if (!strcspn(p, "0123456789")) start = q - path;
{ i = start + 1;
start = q - path;
i = start + 1;
}
*q = PATH_SEP;
}
} }
*q = PATH_SEP;
}
}
#endif #endif
/* Handle multiple `/'s in a row. */ /* Handle multiple `/'s in a row. */
while (path[i] == PATH_SEP) while (path[i] == PATH_SEP)
i++; i++;
if ((start + 1) != i) { if ((start + 1) != i) {
strcpy (path + start + 1, path + i); strcpy (path + start + 1, path + i);
i = start + 1; i = start + 1;
} }
/* Check for trailing `/'. */ /* Check for trailing `/'. */
if (start && !path[i]) { if (start && !path[i]) {
zero_last: zero_last:
path[--i] = '\0'; path[--i] = '\0';
break; break;
} }
/* Check for `../', `./' or trailing `.' by itself. */ /* Check for `../', `./' or trailing `.' by itself. */
if (path[i] == '.') { if (path[i] == '.') {
/* Handle trailing `.' by itself. */ /* Handle trailing `.' by itself. */
if (!path[i + 1]) if (!path[i + 1])
goto zero_last; goto zero_last;
/* Handle `./'. */ /* Handle `./'. */
if (path[i + 1] == PATH_SEP) { if (path[i + 1] == PATH_SEP) {
strcpy (path + i, path + i + 1); strcpy (path + i, path + i + 1);
i = start; i = start;
continue; continue;
} }
/* Handle `../' or trailing `..' by itself. /* Handle `../' or trailing `..' by itself.
Remove the previous ?/ part with the exception of Remove the previous ?/ part with the exception of
../, which we should leave intact. */ ../, which we should leave intact. */
if (path[i + 1] == '.' && (path[i + 2] == PATH_SEP || !path[i + 2])) { if (path[i + 1] == '.'
while (--start > -1 && path[start] != PATH_SEP); && (path[i + 2] == PATH_SEP || !path[i + 2])) {
if (!strncmp (path + start + 1, "../", 3)) while (--start > -1 && path[start] != PATH_SEP);
continue; if (!strncmp (path + start + 1, "../", 3))
strcpy (path + start + 1, path + i + 2); continue;
i = start; strcpy (path + start + 1, path + i + 2);
continue; i = start;
continue;
} }
} }
} }
if (!*path) { if (!*path) {
*path = stub_char; *path = stub_char;
path[1] = '\0'; path[1] = '\0';
} }
return path; return path;
} }