James - > >> Then this appears to be a difference (bug?) in your libc. This is not > >> the case with glibc 2.7 or 2.8 (the two systems I can currently test > >> on). Those error with ENOENT (as specified by SUS[0]). > > > > I'm on FreeBSD. I used this test program: > > > > #include <stdio.h> > > #include <sys/param.h> > > #include <stdlib.h> > > #include <errno.h> > > > > main() > > { > > char buf[PATH_MAX]; > > char *s; > > errno = 0; > > buf[0] = 0; > > s = realpath("", buf); > > printf("errno = %d; s = %s; buf = %s\n", errno, s, buf); > > } > > > > Result (when pwd is /tmp): > > > > errno = 0; s = /tmp; buf = /tmp > > errno = 2; s = (null); buf = > > > The definition of realpath() doesn't say what happens for an empty > > string. It might handle it as "." or give an error. > > SUS does specify what should happen. It's an error. FWIW, I've filed a > bug[0] against FreeBSD's behavior so we'll see what they think about it.
OK. It's good to have uniform behavior. Unspecified behavior is annoying. > > Did you test my proposed solution on Linux? I think it should work > > everywhere. > > Yes, I did. It works fine. Well, in that case I'll use this not-that-nice-but-works-everywhere solution. Thanks for testing. - Bram -- hundred-and-one symptoms of being an internet addict: 270. You are subscribed to a mailing list for every piece of software you use. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]