Fix getcwd for Rhapsody, fix was on tip RHAPSODY_NSPR_BRANCH
authormcafee
Thu, 07 May 1998 04:22:13 +0000
branchRHAPSODY_NSPR_BRANCH
changeset 95 c76cedb83a30687401992c6ef151dfee5d8cdae3
parent 89 ee61d81e87b483776ed7d309dec9d4693ebf6ff5
child 96 6d56e618462aacd0d107e1a2e4cb04251bd4bb76
push idunknown
push userunknown
push dateunknown
Fix getcwd for Rhapsody, fix was on tip
config/nsinstall.c
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -36,16 +36,24 @@
 #include "pathsub.h"
 
 #define HAVE_LCHOWN
 
 #if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(RHAPSODY)
 #undef HAVE_LCHOWN
 #endif
 
+/*
+ * Does getcwd() take NULL as the first argument and malloc
+ * the result buffer?
+ */
+#if !defined(RHAPSODY)
+#define GETCWD_CAN_MALLOC
+#endif
+
 #ifdef LINUX
 #include <getopt.h>
 #endif
 
 #if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC)
 #if !defined(S_ISLNK) && defined(S_IFLNK)
 #define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
 #endif
@@ -182,20 +190,31 @@ main(int argc, char **argv)
     todir = argv[argc-1];
     if ((stat(todir, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
 	mkdirs(todir, 0777) < 0) {
 	fail("cannot make directory %s", todir);
     }
     if (onlydir)
 	return 0;
 
-    if (!cwd)
+    if (!cwd) {
+#ifdef GETCWD_CAN_MALLOC
 	cwd = getcwd(0, PATH_MAX);
+#else
+	cwd = malloc(PATH_MAX + 1);
+	cwd = getcwd(cwd, PATH_MAX);
+#endif
+    }
     xchdir(todir);
+#ifdef GETCWD_CAN_MALLOC
     todir = getcwd(0, PATH_MAX);
+#else
+    todir = malloc(PATH_MAX + 1);
+    todir = getcwd(todir, PATH_MAX);
+#endif
     tdlen = strlen(todir);
     xchdir(cwd);
     tdlen = strlen(todir);
 
     uid = owner ? touid(owner) : -1;
     gid = group ? togid(group) : -1;
 
     while (--argc > 0) {