[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recent checkins to lib/xgetcwd.c breaks Windows

From: Jim Hyslop
Subject: Recent checkins to lib/xgetcwd.c breaks Windows
Date: Sat, 05 Mar 2005 23:37:36 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217

The recent checkin to lib/xgetcwd.c changes the implementation of xgetwd() from:

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;


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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]