#include "perl.h"
#include "XSUB.h"
+#ifdef I_UNISTD
+# include <unistd.h>
+#endif
+
/* The realpath() implementation from OpenBSD 2.9 (realpath.c 1.4)
* Renamed here to bsd_realpath() to avoid library conflicts.
* --jhi 2000-06-20 */
#endif
/* It's okay if the close fails, what's an fd more or less? */
+#ifdef HAS_FCHDIR
(void)close(fd);
+#endif
return (resolved);
err1: serrno = errno;
+#ifdef HAS_FCHDIR
(void)fchdir(fd);
-err2: (void)close(fd);
+#else
+ (void)chdir(wd);
+#endif
+
+err2:
+#ifdef HAS_FCHDIR
+ (void)close(fd);
+#endif
errno = serrno;
return (NULL);
#endif
PPCODE:
{
dXSTARG;
- sv_getcwd(TARG);
+ getcwd_sv(TARG);
XSprePUSH; PUSHTARG;
}
dXSTARG;
char *path;
STRLEN len;
- char *buf;
-
- New(0, buf, MAXPATHLEN, char);
- if (buf) {
- buf[MAXPATHLEN] = 0;
- if (pathsv)
- path = SvPV(pathsv, len);
- else {
- path = ".";
- len = 1;
- }
+ char buf[MAXPATHLEN];
- if (bsd_realpath(path, buf)) {
- sv_setpvn(TARG, buf, strlen(buf));
- SvPOK_only(TARG);
- }
- else
- sv_setsv(TARG, &PL_sv_undef);
+ if (pathsv)
+ path = SvPV(pathsv, len);
+ else {
+ path = ".";
+ len = 1;
+ }
- Safefree(buf);
+ if (bsd_realpath(path, buf)) {
+ sv_setpvn(TARG, buf, strlen(buf));
+ SvPOK_only(TARG);
}
else
- sv_setsv(TARG, &PL_sv_undef);
+ sv_setsv(TARG, &PL_sv_undef);
XSprePUSH; PUSHTARG;
}