diff liboctave/file-ops.cc @ 2934:dddc1b5c324e

[project @ 1997-05-05 22:56:37 by jwe]
author jwe
date Mon, 05 May 1997 22:59:00 +0000
parents 66ef74ee5d9f
children 9d26524e2869
line wrap: on
line diff
--- a/liboctave/file-ops.cc
+++ b/liboctave/file-ops.cc
@@ -39,13 +39,10 @@
 #include <unistd.h>
 #endif
 
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-
 #include "file-ops.h"
 #include "lo-error.h"
 #include "oct-env.h"
+#include "oct-passwd.h"
 #include "statdefs.h"
 #include "str-vec.h"
 
@@ -181,8 +178,6 @@
 {
   string expansion = name;
 
-#if defined (HAVE_PWD_H)
-
   // If no leading tilde, do nothing.
 
   size_t beg = name.find_first_not_of (" \t");
@@ -218,12 +213,11 @@
 
 	  string user = name.substr (beg+1, len);
 
-	  struct passwd *p
-	    = static_cast<struct passwd *> (::getpwnam (user.c_str ()));
+	  octave_passwd pw = octave_passwd::getpwnam (user);
 
 	  // If no such user, just use `.'.
 
-	  string home = p ? p->pw_dir : ".";
+	  string home = pw.empty () ? : string (".") : pw.dir ();
       
 	  expansion = string (" ", beg) + home;
 
@@ -232,8 +226,6 @@
 	}
     }
 
-#endif
-
   return expansion;
 }