Skip to content

Commit

Permalink
check for the existance of S_ISSOCK, S_ISCHR, and S_ISFIFO before try…
Browse files Browse the repository at this point in the history
…ing to use them in notspecial.c
  • Loading branch information
Orc committed Feb 27, 2018
1 parent 80e1ad5 commit 6fd1631
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,37 @@ AC_CHECK_BASENAME
AC_CHECK_ALLOCA

AC_CHECK_HEADERS sys/types.h pwd.h && AC_CHECK_FUNCS getpwuid
AC_CHECK_HEADERS sys/stat.h && AC_CHECK_FUNCS stat
if AC_CHECK_HEADERS sys/stat.h && AC_CHECK_FUNCS stat; then

# need to check some of the S_ISxxx stat macros, because they may not
# exist (for notspecial.c)

cat > ngc$$.c << EOF
#include <sys/stat.h>
issock(f)
char *f;
{
struct stat info;
if ( stat(f, &info) != 0 )
return 1;
return MACRO(info.st_mode);
}
EOF
LOGN "special file macros in sys/stat.h:"
_none="none"
for x in ISSOCK ISCHR ISFIFO; do
if $AC_CC -DMACRO=S_$x -c ngc$$.c; then
LOGN " S_${x}"
AC_DEFINE "HAS_${x}" '1'
unset _none
fi
done
LOG "${_none}."
rm -f ngc$$.c ngc$$.o
fi

if AC_CHECK_FUNCS srandom; then
AC_DEFINE 'INITRNG(x)' 'srandom((unsigned int)x)'
Expand Down
2 changes: 1 addition & 1 deletion notspecial.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "config.h"

#if HAVE_STAT
#if HAVE_STAT && HAS_ISCHR && HAS_ISSOCK && HAS_ISSOCK
#include <sys/stat.h>

int
Expand Down

0 comments on commit 6fd1631

Please sign in to comment.