diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-07-20 07:00:05 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-07-20 07:00:05 +0000 |
commit | 89755f7344de571c4b1b7c68e90de39363a4d1ff (patch) | |
tree | d735587f7030f0536272048df7a4b53cefc133a4 /Build/source/texk/kpathsea/xgetcwd.c | |
parent | 713aef9b071ca2b5dd68d014e99897f0e5e2036c (diff) |
libs/t1lib + texk/ps2pkm: bug fix and update
git-svn-id: svn://tug.org/texlive/trunk@23187 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/xgetcwd.c')
-rw-r--r-- | Build/source/texk/kpathsea/xgetcwd.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/Build/source/texk/kpathsea/xgetcwd.c b/Build/source/texk/kpathsea/xgetcwd.c index 905775d0fa1..bde9102d845 100644 --- a/Build/source/texk/kpathsea/xgetcwd.c +++ b/Build/source/texk/kpathsea/xgetcwd.c @@ -1,6 +1,6 @@ /* xgetcwd.c: a from-scratch version of getwd. Ideas from tcsh 5.20 source. - Copyright 1992, 1994, 1996, 2008 Karl Berry. + Copyright 1992, 1994, 1996, 2008, 2011 Karl Berry. Copyright 2005 Olaf Weber. This library is free software; you can redistribute it and/or @@ -18,9 +18,9 @@ #include <kpathsea/config.h> -#if defined (HAVE_GETCWD) || defined (HAVE_GETWD) +#if (defined (HAVE_GETCWD) && !defined (GETCWD_FORKS)) || defined (HAVE_GETWD) #include <kpathsea/c-pathmx.h> -#else /* not HAVE_GETCWD && not HAVE_GETWD*/ +#else /* (not HAVE_GETCWD || GETCWD_FORKS) && not HAVE_GETWD */ #include <kpathsea/c-dir.h> #include <kpathsea/xopendir.h> #include <kpathsea/xstat.h> @@ -33,7 +33,7 @@ xchdir (string dirname) _PERROR(dirname); } -#endif /* not HAVE_GETCWD && not HAVE_GETWD */ +#endif /* (not HAVE_GETCWD || GETCWD_FORKS) && not HAVE_GETWD */ /* Return the pathname of the current directory, or give a fatal error. */ @@ -48,24 +48,22 @@ xgetcwd (void) is not detected by configure, let me know. -- Olaf Weber <infovore@xs4all.nl */ #if defined (HAVE_GETCWD) && !defined (GETCWD_FORKS) - string path = (string)xmalloc(PATH_MAX + 1); + char path[PATH_MAX + 1]; - if (getcwd (path, PATH_MAX + 1) == 0) { - fprintf(stderr, "getcwd: %s", path); - exit(EXIT_FAILURE); + if (getcwd (path, PATH_MAX + 1) == NULL) { + FATAL_PERROR ("getcwd"); } - return path; + return xstrdup (path); #elif defined (HAVE_GETWD) - string path = (string)xmalloc(PATH_MAX + 1); + char path[PATH_MAX + 1]; - if (getwd (path) == 0) { - fprintf(stderr, "getwd: %s", path); - exit(EXIT_FAILURE); + if (getwd (path) == NULL) { + FATAL_PERROR ("getwd"); } - return path; -#else /* not HAVE_GETCWD && not HAVE_GETWD */ + return xstrdup (path); +#else /* (not HAVE_GETCWD || GETCWD_FORKS) && not HAVE_GETWD */ struct stat root_stat, cwd_stat; string cwd_path = (string)xmalloc(2); /* In case we assign "/" below. */ @@ -143,5 +141,5 @@ xgetcwd (void) #endif return cwd_path; -#endif /* not HAVE_GETCWD && not HAVE_GETWD */ +#endif /* (not HAVE_GETCWD || GETCWD_FORKS) && not HAVE_GETWD */ } |