From 29e86cb09c6ffe497456341864551b504c9a6f4f Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sat, 31 Mar 2007 19:41:11 +0000 Subject: re PR libfortran/31335 (Calls lstat(), stat() and fstat() in libgfortran should be protected by autoconf HAVE_{L,,F}STAT macros) PR libfortran/31335 * intrinsics/stat.c: Only provide STAT and FSTAT library routines if stat() and fstat() library functions are available. When lstat() is not available, use stat() instead. * configure.ac: Add checks for stat, fstat and lstat. * configure: Regenerate. * config.h.in: Regenerate. From-SVN: r123388 --- libgfortran/intrinsics/stat.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'libgfortran/intrinsics/stat.c') diff --git a/libgfortran/intrinsics/stat.c b/libgfortran/intrinsics/stat.c index 150387d..ce65245 100644 --- a/libgfortran/intrinsics/stat.c +++ b/libgfortran/intrinsics/stat.c @@ -49,6 +49,9 @@ Boston, MA 02110-1301, USA. */ #include + +#ifdef HAVE_STAT + /* SUBROUTINE STAT(FILE, SARRAY, STATUS) CHARACTER(len=*), INTENT(IN) :: FILE INTEGER, INTENT(OUT), :: SARRAY(13) @@ -88,9 +91,12 @@ stat_i4_sub_0 (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status, memcpy (str, name, name_len); str[name_len] = '\0'; + /* On platforms that don't provide lstat(), we use stat() instead. */ +#ifdef HAVE_LSTAT if (is_lstat) val = lstat(str, &sb); else +#endif val = stat(str, &sb); if (val == 0) @@ -204,9 +210,12 @@ stat_i8_sub_0 (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status, memcpy (str, name, name_len); str[name_len] = '\0'; + /* On platforms that don't provide lstat(), we use stat() instead. */ +#ifdef HAVE_LSTAT if (is_lstat) val = lstat(str, &sb); else +#endif val = stat(str, &sb); if (val == 0) @@ -319,13 +328,13 @@ stat_i8 (char *name, gfc_array_i8 *sarray, gfc_charlen_type name_len) } -/* SUBROUTINE STAT(FILE, SARRAY, STATUS) +/* SUBROUTINE LSTAT(FILE, SARRAY, STATUS) CHARACTER(len=*), INTENT(IN) :: FILE INTEGER, INTENT(OUT), :: SARRAY(13) INTEGER, INTENT(OUT), OPTIONAL :: STATUS - FUNCTION STAT(FILE, SARRAY) - INTEGER STAT + FUNCTION LSTAT(FILE, SARRAY) + INTEGER LSTAT CHARACTER(len=*), INTENT(IN) :: FILE INTEGER, INTENT(OUT), :: SARRAY(13) */ @@ -351,7 +360,10 @@ lstat_i8 (char *name, gfc_array_i8 *sarray, gfc_charlen_type name_len) return val; } +#endif + +#ifdef HAVE_FSTAT /* SUBROUTINE FSTAT(UNIT, SARRAY, STATUS) INTEGER, INTENT(IN) :: UNIT @@ -546,3 +558,5 @@ fstat_i8 (GFC_INTEGER_8 *unit, gfc_array_i8 *sarray) fstat_i8_sub (unit, sarray, &val); return val; } + +#endif -- cgit v1.1