Browse Source

Fixed bug #21958 (workaround for unusual realpath() on AIX & Tru64).

PEAR_1_4DEV
Ilia Alshanetsky 23 years ago
parent
commit
63fcd301e9
  1. 27
      TSRM/tsrm_virtual_cwd.h

27
TSRM/tsrm_virtual_cwd.h

@ -41,6 +41,10 @@
#include <unistd.h>
#endif
#if defined(__osf__) || defined(_AIX)
#include <errno.h>
#endif
#ifdef TSRM_WIN32
#include "readdir.h"
#include <sys/utime.h>
@ -167,6 +171,25 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC);
#endif
#endif
/* On AIX & Tru64 when a file does not exist realpath() returns
* NULL, and sets errno to ENOENT. Unlike in other libc implementations
* the destination is not filled and remains undefined. Therefor, we
* must populate it manually using strcpy as done on systems with no
* realpath() function.
*/
#if defined(__osf__) || defined(_AIX)
static char *php_realpath_hack(char *src, char *dest)
{
char *ret;
if ((ret = realpath(src, dest)) == NULL && errno == ENOENT) {
return strcpy(dest, src);
} else {
return ret;
}
}
#endif
#if HAVE_UTIME
CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC);
#endif
@ -248,7 +271,11 @@ typedef struct _virtual_cwd_globals {
#endif
#ifdef HAVE_REALPATH
#if defined(__osf__) || defined(_AIX)
#define VCWD_REALPATH(path, real_path) php_realpath_hack(path, real_path)
#else
#define VCWD_REALPATH(path, real_path) realpath(path, real_path)
#endif
#else
#define VCWD_REALPATH(path, real_path) strcpy(real_path, path)
#endif

Loading…
Cancel
Save