From: Erwin Janssen Date: Fri, 2 Jun 2017 21:47:13 +0000 (+0200) Subject: Replace _sys_stat with HAVE_SYS_STAT_H X-Git-Tag: 2.42.0~161^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=caff50c49218720c62939d5cadf2c3dc060867f5;p=graphviz Replace _sys_stat with HAVE_SYS_STAT_H The check for is already included in configure.ac, so this could be used instead of the check in features/sfio. --- diff --git a/lib/sfio/features/sfio b/lib/sfio/features/sfio index 7b1339ca2..8ff2dca73 100644 --- a/lib/sfio/features/sfio +++ b/lib/sfio/features/sfio @@ -26,20 +26,6 @@ exit cleanup note{ stuck with standard _cleanup }end execute{ main() { printf("cleanup\n"); exit(1); } }end -sys stat note{ stat() in default lib(s) }end link{ - #if _STD_ - #include - #else - #include - #endif - #include - #include - main() - { struct stat st; - fstat(0,&st); - } -}end - hdr stat note{ stat() in default lib(s) }end link{ #if _STD_ #include diff --git a/lib/sfio/sfhdr.h b/lib/sfio/sfhdr.h index a48c380db..9d47edf98 100644 --- a/lib/sfio/sfhdr.h +++ b/lib/sfio/sfhdr.h @@ -50,7 +50,7 @@ extern "C" { are not needed and they may get in the way so we remove them here. */ #if defined(_SFBINARY_H) -#undef _sys_stat +#undef HAVE_SYS_ST #undef _hdr_stat #undef _lib_poll #undef _stream_peek @@ -66,19 +66,19 @@ extern "C" { #include #include -#if _sys_stat +#if HAVE_SYS_STAT_H #include #else #if _hdr_stat #include -#ifndef _sys_stat -#define _sys_stat 1 +#ifndef HAVE_SYS_STAT_H +#define HAVE_SYS_STAT_H 1 #endif #endif -#endif /*_sys_stat*/ +#endif /*HAVE_SYS_STAT_H*/ -#ifndef _sys_stat -#define _sys_stat 0 +#ifndef HAVE_SYS_STAT_H +#define HAVE_SYS_STAT_H 0 #endif #include @@ -153,7 +153,7 @@ extern "C" { #endif /* 64-bit vs 32-bit file stuff */ -#if _sys_stat +#if HAVE_SYS_STAT_H #ifdef _LARGEFILE64_SOURCE typedef struct stat64 Stat_t; #define lseek lseek64 @@ -823,7 +823,7 @@ extern "C" { typedef int (*Onexit_f)(void); extern Onexit_f onexit(Onexit_f); -#if _sys_stat +#if HAVE_SYS_STAT_H extern int fstat(int, Stat_t *); #endif diff --git a/lib/sfio/sfsetbuf.c b/lib/sfio/sfsetbuf.c index 255be54e8..f706df248 100644 --- a/lib/sfio/sfsetbuf.c +++ b/lib/sfio/sfsetbuf.c @@ -41,13 +41,13 @@ extern "C" { ** ** Written by Kiem-Phong Vo. */ -#if !_sys_stat +#if !HAVE_SYS_STAT_H struct stat { int st_mode; int st_size; }; #define fstat(fd,st) (-1) -#endif /*_sys_stat*/ +#endif /*HAVE_SYS_STAT_H*/ /** * @param f stream to be buffered @@ -138,7 +138,7 @@ void *sfsetbuf(reg Sfio_t * f, reg void * buf, reg size_t size) st.st_mode = 0; /* if has discipline, set size by discipline if possible */ - if (!_sys_stat || disc) { + if (!HAVE_SYS_STAT_H || disc) { if ((f->here = SFSK(f, (Sfoff_t) 0, SEEK_CUR, disc)) < 0) goto unseekable; else { @@ -154,7 +154,7 @@ void *sfsetbuf(reg Sfio_t * f, reg void * buf, reg size_t size) if (fstat((int) f->file, &st) < 0) f->here = -1; else { -#if _sys_stat && _stat_blksize /* preferred io block size */ +#if HAVE_SYS_STAT_H && _stat_blksize /* preferred io block size */ if ((blksize = (ssize_t) st.st_blksize) > 0) while ((blksize + (ssize_t) st.st_blksize) <= SF_PAGE) blksize += (ssize_t) st.st_blksize; @@ -185,7 +185,7 @@ void *sfsetbuf(reg Sfio_t * f, reg void * buf, reg size_t size) /* set line mode for terminals */ if (!(f->flags & SF_LINE) && isatty(f->file)) f->flags |= SF_LINE; -#if _sys_stat +#if HAVE_SYS_STAT_H else { /* special case /dev/null */ reg int dev, ino; dev = (int) st.st_dev; diff --git a/lib/sfio/sfsize.c b/lib/sfio/sfsize.c index a516d0759..4fdacc44a 100644 --- a/lib/sfio/sfsize.c +++ b/lib/sfio/sfsize.c @@ -43,14 +43,14 @@ Sfoff_t sfsize(reg Sfio_t * f) for (disc = f->disc; disc; disc = disc->disc) if (disc->seekf) break; - if (!_sys_stat || disc) { + if (!HAVE_SYS_STAT_H || disc) { Sfoff_t e; if ((e = SFSK(f, 0, SEEK_END, disc)) >= 0) f->extent = e; if (SFSK(f, f->here, SEEK_SET, disc) != f->here) f->here = SFSK(f, (Sfoff_t) 0, SEEK_CUR, disc); } -#if _sys_stat +#if HAVE_SYS_STAT_H else { Stat_t st; if (fstat(f->file, &st) < 0) diff --git a/windows/include/FEATURE/sfio b/windows/include/FEATURE/sfio index 3cd7b3670..738269918 100644 --- a/windows/include/FEATURE/sfio +++ b/windows/include/FEATURE/sfio @@ -4,7 +4,6 @@ #define _sys_types 1 /* #include ok */ //#define _hdr_unistd 1 /* #include ok */ #define _typ_off64_t 1 /* off64_t is a type */ -#define _sys_stat 1 /* stat() in default lib(s) */ #define _lib_remove 1 /* remove() in default lib(s) */ #define _lib_getpagesize 0 /* getpagesize() in default lib(s) */ #define _tmp_rmfail 1 /* file not removable if still opened */