Browse Source

Ticket #1911: use system realapth(3) function if available.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 15 years ago
parent
commit
d2b23924dd
3 changed files with 10 additions and 7 deletions
  1. 2 1
      configure.ac
  2. 5 1
      lib/util.h
  3. 3 5
      lib/utilunix.c

+ 2 - 1
configure.ac

@@ -161,7 +161,8 @@ AC_CHECK_FUNCS([\
 	memcpy memset \
 	setreuid statfs sysconf \
 	tcgetattr tcsetattr truncate \
-	strverscmp
+	strverscmp \
+	realpath
 ])
 
 dnl

+ 5 - 1
lib/util.h

@@ -188,7 +188,11 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix);
 #define MAXSYMLINKS 32
 #endif
 
-char *mc_realpath(const char *path, char resolved_path[]);
+#ifdef HAVE_REALPATH
+#define mc_realpath realpath
+#else
+char *mc_realpath (const char *path, char *resolved_path);
+#endif
 
 enum compression_type {
 	COMPRESSION_NONE,

+ 3 - 5
lib/utilunix.c

@@ -665,12 +665,10 @@ gettimeofday (struct timeval *tp, void *tzp)
 }
 #endif /* HAVE_GET_PROCESS_STATS */
 
+#ifndef HAVE_REALPATH
 char *
-mc_realpath (const char *path, char resolved_path[])
+mc_realpath (const char *path, char *resolved_path)
 {
-#ifdef	USE_SYSTEM_REALPATH
-    return realpath (path, resolved_path);
-#else
     char copy_path[PATH_MAX];
     char link_path[PATH_MAX];
     char got_path[PATH_MAX];
@@ -806,8 +804,8 @@ mc_realpath (const char *path, char resolved_path[])
     *new_path = '\0';
     strcpy (resolved_path, got_path);
     return resolved_path;
-#endif /* USE_SYSTEM_REALPATH */
 }
+#endif /* HAVE_REALPATH */
 
 /* Return the index of the permissions triplet */
 int