char * xgetwd () { char *cwd; char *ret; unsigned path_max;
errno = 0; path_max = (unsigned) PATH_MAX; path_max += 2; /* The getcwd docs say to do this. */
cwd = xmalloc (path_max);
errno = 0; while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) { path_max += PATH_INCR; cwd = xrealloc (cwd, path_max); errno = 0; }
if (ret == NULL) { int save_errno = errno; free (cwd); errno = save_errno; return NULL; } return cwd; }
to:
char * xgetcwd (void) { char *cwd = getcwd (NULL, 0); if (! cwd && errno == ENOMEM) xalloc_die (); return cwd; }
While the new version is shorter, it doesn't work on Windows (Cygwin). It appears that Cygwin expects the parameter to getcwd() to be non-NULL. At least, 'getcwd()' always returns in the latest version of the file (trunk). Can we revert xgetcwd.c to its previous version? Why was it changed?
-- Jim
_______________________________________________ Bug-cvs mailing list Bug-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/bug-cvs