From 9c2ec3862beb8a38a545849a6d68eb77749f5fd2 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 17 Jan 2012 04:12:15 +0000 Subject: [PATCH] Fixes for MSVC warnings C4273 and C4996 C4273 - (inconsistent dll linkage) generated by multiple declarations of isatty C4996 - deprecated POSIX function names need to be prefixed with "_" --- ext/f2c_libs/err.c | 8 ++++---- ext/f2c_libs/fio.h | 9 ++++++++- ext/f2c_libs/inquire.c | 2 +- ext/f2c_libs/lread.c | 2 +- ext/f2c_libs/open.c | 4 ++-- ext/f2c_libs/rsne.c | 2 +- ext/f2c_libs/s_paus.c | 11 ++++++++--- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ext/f2c_libs/err.c b/ext/f2c_libs/err.c index 18de588d2..4960c282b 100644 --- a/ext/f2c_libs/err.c +++ b/ext/f2c_libs/err.c @@ -98,11 +98,11 @@ f__canseek(FILE *f) /*SYSDEP*/ #endif { #ifdef NON_UNIX_STDIO - return !isatty(fileno(f)); + return !ISATTY(FILENO(f)); #else struct STAT_ST x; - if (FSTAT(fileno(f),&x) < 0) + if (FSTAT(FILENO(f),&x) < 0) return(0); #ifdef S_IFMT switch(x.st_mode & S_IFMT) { @@ -113,7 +113,7 @@ f__canseek(FILE *f) /*SYSDEP*/ else return(0); case S_IFCHR: - if(isatty(fileno(f))) + if(ISATTY(FILENO(f))) return(0); return(1); #ifdef S_IFBLK @@ -131,7 +131,7 @@ f__canseek(FILE *f) /*SYSDEP*/ return(0); } if (S_ISCHR(x.st_mode)) { - if(isatty(fileno(f))) + if(ISATTY(FILENO(f))) return(0); return(1); } diff --git a/ext/f2c_libs/fio.h b/ext/f2c_libs/fio.h index 4c3043e9c..4595187af 100644 --- a/ext/f2c_libs/fio.h +++ b/ext/f2c_libs/fio.h @@ -108,8 +108,15 @@ extern void f_init(void); extern int (*f__donewrec)(void), t_putc(int), x_wSL(void); extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*); extern int c_sfe(cilist*), z_rnew(void); -#ifndef WIN32 +#ifdef _MSC_VER +#define ISATTY _isatty +#define FILENO _fileno +#define ACCESS _access +#else extern int isatty(int); +#define ISATTY isatty +#define FILENO fileno +#define ACCESS access #endif extern int err__fl(int,int,char*); extern int xrd_SL(void); diff --git a/ext/f2c_libs/inquire.c b/ext/f2c_libs/inquire.c index 96db855eb..bbb3cc872 100644 --- a/ext/f2c_libs/inquire.c +++ b/ext/f2c_libs/inquire.c @@ -32,7 +32,7 @@ integer f_inqu(inlist *a) { byfile=1; g_char(a->infile,a->infilen,buf); #ifdef NON_UNIX_STDIO - x = access(buf,0) ? -1 : 0; + x = ACCESS(buf,0) ? -1 : 0; for(i=0,p=NULL;ioerr,errno,"open") fclose(tf); #else - if (access(buf,0)) + if (ACCESS(buf,0)) opnerr(a->oerr,errno,"open") #endif break; @@ -232,7 +232,7 @@ integer f_open(olist *a) opnerr(a->oerr,128,"open") } #else - if (!access(buf,0)) + if (!ACCESS(buf,0)) opnerr(a->oerr,128,"open") #endif /* no break */ diff --git a/ext/f2c_libs/rsne.c b/ext/f2c_libs/rsne.c index 4f6b57a60..190f6c461 100644 --- a/ext/f2c_libs/rsne.c +++ b/ext/f2c_libs/rsne.c @@ -66,7 +66,7 @@ un_getc(int x, FILE *f__cf) { return ungetc(x,f__cf); } #else #define un_getc ungetc -#ifndef WIN32 +#ifndef _MSC_VER extern int ungetc(int, FILE*); /* for systems with a buggy stdio.h */ #endif #endif diff --git a/ext/f2c_libs/s_paus.c b/ext/f2c_libs/s_paus.c index c5977174c..426b2c62a 100644 --- a/ext/f2c_libs/s_paus.c +++ b/ext/f2c_libs/s_paus.c @@ -20,8 +20,13 @@ extern "C" { extern "C" { #endif extern int getpid(void); -#ifndef WIN32 -extern int isatty(int); +#ifdef _MSC_VER +#define ISATTY _isatty +#define FILENO _fileno +#else +extern int isatty(int); +#define ISATTY isatty +#define FILENO fileno #endif extern int pause(void); #endif @@ -66,7 +71,7 @@ s_paus(char *s, ftnlen n) if(n > 0) fprintf(stderr, " %.*s", (int)n, s); fprintf(stderr, " statement executed\n"); - if( isatty(fileno(stdin)) ) + if( ISATTY(FILENO(stdin)) ) s_1paus(stdin); else { #ifdef MSDOS