From 5510bc295094794b4804bb97db4bb58ebba3c5b0 Mon Sep 17 00:00:00 2001 From: "John F. Fay" Date: Wed, 2 Dec 2009 03:56:05 +0000 Subject: [PATCH] See e-mail from Martin Payne dated 11/30/09 at 5:51 AM. These changes include changing "HAVE_ERRNO" to "HAVE_ERRNO_H" globally, modifying "configure.ac" to check for "errno.h", and modifying the "vcproj" files to suppress spurious warnings. git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@854 7f0cb862-5218-0410-a997-914c9d46530a --- VisualStudio2008/freeglut.vcproj | 5 ++-- VisualStudio2008Static/freeglut.vcproj | 4 +-- configure.ac | 2 +- src/freeglut_init.c | 47 ++------------------------------ src/freeglut_input_devices.c | 15 +--------- src/freeglut_joystick.c | 14 +++++----- src/freeglut_main.c | 4 +-- src/freeglut_spaceball.c | 3 ++ 8 files changed, 20 insertions(+), 74 deletions(-) diff --git a/VisualStudio2008/freeglut.vcproj b/VisualStudio2008/freeglut.vcproj index 31e904e..bfc3b89 100644 --- a/VisualStudio2008/freeglut.vcproj +++ b/VisualStudio2008/freeglut.vcproj @@ -41,10 +41,9 @@ /> ]) AC_CHECK_HEADERS([X11/extensions/XI.h X11/extensions/XInput.h]) diff --git a/src/freeglut_init.c b/src/freeglut_init.c index 7893f05..5161c03 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -680,14 +680,6 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) char* geometry = NULL; int i, j, argc = *pargc; - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) - size_t sLen; -#if HAVE_ERRNO - errno_t err; -#endif -#endif - if( fgState.Initialised ) fgError( "illegal glutInit() reinitialization attempt" ); @@ -707,15 +699,8 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) /* check if GLUT_FPS env var is set */ #ifndef _WIN32_WCE { - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - char* fps = NULL; - err = _dupenv_s( &fps, &sLen, "GLUT_FPS" ); - if (err) - fgError("Error getting GLUT_FPS environment variable"); -#else const char *fps = getenv( "GLUT_FPS" ); -#endif + if( fps ) { int interval; @@ -726,20 +711,9 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) else fgState.FPSInterval = interval; } - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - free ( fps ); fps = NULL; /* dupenv_s allocates a string that we must free */ -#endif } - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - err = _dupenv_s( &displayName, &sLen, "DISPLAY" ); - if (err) - fgError("Error getting DISPLAY environment variable"); -#else displayName = getenv( "DISPLAY" ); -#endif for( i = 1; i < argc; i++ ) { @@ -824,10 +798,6 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) * variable for opening the X display (see code above): */ fghInitialize( displayName ); - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - free ( displayName ); displayName = NULL; /* dupenv_s allocates a string that we must free */ -#endif /* * Geometry parsing deffered until here because we may need the screen @@ -936,21 +906,13 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode ) * delimited by blanks or tabs. */ char *token ; - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) - char *next_token = NULL; -#endif size_t len = strlen ( displayMode ); char *buffer = (char *)malloc ( (len+1) * sizeof(char) ); memcpy ( buffer, displayMode, len ); buffer[len] = '\0'; - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) - token = strtok_s ( buffer, " \t", &next_token ); -#else token = strtok ( buffer, " \t" ); -#endif + while ( token ) { /* Process this token */ @@ -1127,12 +1089,7 @@ void FGAPIENTRY glutInitDisplayString( const char* displayMode ) break ; } - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) - token = strtok_s ( NULL, " \t", &next_token ); -#else token = strtok ( NULL, " \t" ); -#endif } free ( buffer ); diff --git a/src/freeglut_input_devices.c b/src/freeglut_input_devices.c index 0e202fa..0dcb97f 100755 --- a/src/freeglut_input_devices.c +++ b/src/freeglut_input_devices.c @@ -36,7 +36,7 @@ #include "freeglut_internal.h" #if TARGET_HOST_POSIX_X11 -#if HAVE_ERRNO +#if HAVE_ERRNO_H #include #endif #include @@ -140,17 +140,8 @@ void fgInitialiseInputDevices ( void ) { if( !fgState.InputDevsInitialised ) { - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - char *dial_device=NULL; - size_t sLen; - errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" ); - if (err) - fgError("Error getting GLUT_DIALS_SERIAL environment variable"); -#else const char *dial_device=NULL; dial_device = getenv ( "GLUT_DIALS_SERIAL" ); -#endif #if TARGET_HOST_MS_WINDOWS if (!dial_device){ static char devname[256]; @@ -167,10 +158,6 @@ void fgInitialiseInputDevices ( void ) #endif if ( !dial_device ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; - /* will return true for VC8 (VC2005) and higher */ -#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO - free ( dial_device ); dial_device = NULL; /* dupenv_s allocates a string that we must free */ -#endif serial_putchar(dialbox_port,DIAL_INITIALIZE); glutTimerFunc ( 10, poll_dials, 0 ); fgState.InputDevsInitialised = GL_TRUE; diff --git a/src/freeglut_joystick.c b/src/freeglut_joystick.c index c009377..2a57e29 100644 --- a/src/freeglut_joystick.c +++ b/src/freeglut_joystick.c @@ -75,7 +75,7 @@ # if HAVE_FCNTL_H # include # endif -# if HAVE_ERRNO +# if HAVE_ERRNO_H # include # endif # if defined(__FreeBSD__) || defined(__NetBSD__) @@ -240,7 +240,7 @@ static int fghJoystickFindUSBdev(char *name, char *out, int outlen) if (cp) return 1; } -#if HAVE_ERRNO +#if HAVE_ERRNO_H else if (errno == EACCES) { if (!protection_warned) { fgWarning ( "Can't open %s for read!", buf ); @@ -265,7 +265,7 @@ static int fghJoystickInitializeHID(struct os_specific_s *os, if ( ( rd = hid_get_report_desc( os->fd ) ) == 0 ) { -#if HAVE_ERRNO +#if HAVE_ERRNO_H fgWarning ( "error: %s: %s", os->fname, strerror( errno ) ); #else fgWarning ( "error: %s", os->fname ); @@ -279,7 +279,7 @@ static int fghJoystickInitializeHID(struct os_specific_s *os, if( ioctl( os->fd, USB_GET_REPORT_ID, &report_id ) < 0) { /*** XXX {report_id} may not be the right variable? ***/ -#if HAVE_ERRNO +#if HAVE_ERRNO_H fgWarning ( "error: %s%d: %s", UHIDDEV, report_id, strerror( errno ) ); #else fgWarning ( "error: %s%d", UHIDDEV, report_id ); @@ -676,7 +676,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) } } } -#if HAVE_ERRNO +#if HAVE_ERRNO_H if ( len < 0 && errno != EAGAIN ) #else if ( len < 0 ) @@ -699,7 +699,7 @@ static void fghJoystickRawRead( SFG_Joystick* joy, int* buttons, float* axes ) if ( status != sizeof( struct js_event ) ) { -#if HAVE_ERRNO +#if HAVE_ERRNO_H if ( errno == EAGAIN ) { /* Use the old values */ @@ -1317,7 +1317,7 @@ static void fghJoystickOpen( SFG_Joystick* joy ) joy->os->fd = open( joy->os->fname, O_RDONLY | O_NONBLOCK); -#if HAVE_ERRNO +#if HAVE_ERRNO_H if( joy->os->fd < 0 && errno == EACCES ) fgWarning ( "%s exists but is not readable by you", joy->os->fname ); #endif diff --git a/src/freeglut_main.c b/src/freeglut_main.c index 0a45402..1c308df 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -27,7 +27,7 @@ #include #include "freeglut_internal.h" -#if HAVE_ERRNO +#if HAVE_ERRNO_H # include #endif #include @@ -473,7 +473,7 @@ static void fghSleepForEvents( void ) wait.tv_usec = (msec % 1000) * 1000; err = select( socket+1, &fdset, NULL, NULL, &wait ); -#if HAVE_ERRNO +#if HAVE_ERRNO_H if( ( -1 == err ) && ( errno != EINTR ) ) fgWarning ( "freeglut select() error: %d", errno ); #endif diff --git a/src/freeglut_spaceball.c b/src/freeglut_spaceball.c index a36008e..154e52d 100644 --- a/src/freeglut_spaceball.c +++ b/src/freeglut_spaceball.c @@ -215,7 +215,10 @@ OF SUCH DAMAGE. #include #include #include + +#if HAVE_ERRNO_H #include +#endif #include #include -- 1.7.10.4