diff liboctave/lo-sysdep.cc @ 10250:2d47356a7a1a

use gnulib getcwd module
author John W. Eaton <jwe@octave.org>
date Wed, 03 Feb 2010 03:07:06 -0500
parents 0522a65bcd56
children 65b41bc71f09
line wrap: on
line diff
--- a/liboctave/lo-sysdep.cc	Tue Feb 02 17:47:23 2010 -0500
+++ b/liboctave/lo-sysdep.cc	Wed Feb 03 03:07:06 2010 -0500
@@ -55,20 +55,17 @@
 {
   std::string retval;
 
-  char buf[MAXPATHLEN];
-
-  char *tmp = 0;
+  // Using the gnulib getcwd module ensures that we have a getcwd that
+  // will allocate a buffer as large as necessary if buf and size are
+  // both 0.
 
-#if defined (__EMX__)
-  tmp = _getcwd2 (buf, MAXPATHLEN);
-#elif defined (HAVE_GETCWD)
-  tmp = getcwd (buf, MAXPATHLEN);
-#elif defined (HAVE_GETWD)
-  tmp = getwd (buf);
-#endif
+  char *tmp = getcwd (0, 0);
 
   if (tmp)
-    retval = tmp;
+    {
+      retval = tmp;
+      free (tmp);
+    }
   else
     (*current_liboctave_error_handler) ("unable to find current directory");