stat: use pathmax.h only if needed
[gnulib.git] / lib / stat.c
index ae86929..fe5b1ac 100644 (file)
@@ -44,9 +44,15 @@ orig_stat (const char *filename, struct stat *buf)
 #include <stdbool.h>
 #include <string.h>
 #include "dosname.h"
-#include "pathmax.h"
 #include "verify.h"
 
+#if REPLACE_FUNC_STAT_DIR
+# include "pathmax.h"
+# ifndef PATH_MAX
+#  error "Please port this replacement to your platform"
+# endif
+#endif
+
 /* Store information about NAME into ST.  Work around bugs with
    trailing slashes.  Mingw has other bugs (such as st_ino always
    being 0 on success) which this wrapper does not work around.  But
@@ -73,9 +79,6 @@ rpl_stat (char const *name, struct stat *st)
 #if REPLACE_FUNC_STAT_DIR
   /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
      have a constant PATH_MAX.  */
-# ifndef PATH_MAX
-#  error "Please port this replacement to your platform"
-# endif
 
   if (result == -1 && errno == ENOENT)
     {