From: Richard Rauch Date: Sun, 26 Oct 2003 04:39:27 +0000 (+0000) Subject: Fixed the buglet about failing to report the program's name on error- X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;ds=sidebyside;h=e4aeaead5b7292e16223ed828b6ba4bc897e80c8;p=freeglut Fixed the buglet about failing to report the program's name on error- messages. Please test. (Modified glutInit(), the state structure, and the warn/err functions.) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@238 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/freeglut_init.c b/src/freeglut_init.c index 36b5b4b..9949138 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -379,6 +379,10 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) char* displayName = NULL; int i, j, argc = *pargc; + if (pargc && *pargc && argv && *argv && **argv) + fgState.ProgramName = strdup (*argv); + else + fgState.ProgramName = strdup (""); /* * Do not allow multiple initialization of the library */ diff --git a/src/freeglut_internal.h b/src/freeglut_internal.h index 91e29e4..eb8def5 100644 --- a/src/freeglut_internal.h +++ b/src/freeglut_internal.h @@ -244,9 +244,9 @@ struct tagSFG_State int GameModeDepth; /* The pixel depth for game mode */ int GameModeRefresh; /* The refresh rate for game mode */ - int ActionOnWindowClose ; /* Action when user clicks "x" on window header bar */ - - fgExecutionState ExecState ; /* Current state of the GLUT execution */ + int ActionOnWindowClose; /* Action when user clicks "x" on window header bar */ + fgExecutionState ExecState; /* Current state of the GLUT execution */ + char *ProgramName; }; /* diff --git a/src/freeglut_main.c b/src/freeglut_main.c index c28658f..ee20be9 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -396,7 +396,7 @@ void fgError( const char *fmt, ... ) va_start( ap, fmt ); - fprintf( stderr, "freeglut: "); + fprintf( stderr, "freeglut (%s): ", fgState.ProgramName || ""); vfprintf( stderr, fmt, ap ); fprintf( stderr, "\n" ); @@ -411,7 +411,7 @@ void fgWarning( const char *fmt, ... ) va_start( ap, fmt ); - fprintf( stderr, "freeglut: "); + fprintf( stderr, "freeglut (%s): ", fgState.ProgramName || ""); vfprintf( stderr, fmt, ap ); fprintf( stderr, "\n" );