diff liboctave/file-ops.cc @ 2947:cf676ff8b702

[project @ 1997-05-09 13:32:46 by jwe]
author jwe
date Fri, 09 May 1997 13:32:52 +0000
parents 9d26524e2869
children 443851377f3f
line wrap: on
line diff
--- a/liboctave/file-ops.cc
+++ b/liboctave/file-ops.cc
@@ -213,7 +213,8 @@
 
   if (beg != NPOS && name[beg] == '~')
     {
-      // If `~' or `~/', use $HOME if it exists, or `.' if it doesn't.
+      // If `~' or `~/', use the user's home directory.  If that is
+      // empty, just use ".".
 
       // If `~user' or `~user/', look up user in the passwd database.
 
@@ -237,21 +238,24 @@
 
 	  size_t len = end;
 
-	  if (len != NPOS)
+	  if (end != NPOS)
 	    len -= beg + 1;
 
 	  string user = name.substr (beg+1, len);
 
 	  octave_passwd pw = octave_passwd::getpwnam (user);
 
-	  // If no such user, just use `.'.
+	  // If no such user, just return the original string.
+
+	  if (pw)
+	    {
+	      expansion = string (" ", beg) + pw.dir ();
 
-	  string home = pw ? string (".") : pw.dir ();
-      
-	  expansion = string (" ", beg) + home;
-
-	  if (end != NPOS)
-	    expansion.append (name.substr (end));
+	      if (end != NPOS)
+		expansion.append (name.substr (end));
+	    }
+	  else
+	    expansion = name;
 	}
     }