Why does canonicalize call collapse after realpath?

Martin Buchholz martinrb at google.com
Wed Apr 30 23:33:52 UTC 2014


canonicalize_md.c does:

    /* First try realpath() on the entire path */
    if (realpath(original, resolved)) {
        /* That worked, so return it */
        collapse(resolved);
        return 0;
    }

And collapse promises to remove /./ and /../ BUT realpath should have
already done that:

http://pubs.opengroup.org/onlinepubs/009696899/functions/realpath.html
The *realpath*() function shall derive, from the pathname pointed to by
*file_name*, an absolute pathname that names the same file, whose
resolution does not involve '.', '..', or symbolic links.

(although it's true that collapse is not the expensive part of the
operation...)



More information about the core-libs-dev mailing list