Fixed the buglet about failing to report the program's name on error-
authorRichard Rauch <rkr@olib.org>
Sun, 26 Oct 2003 04:39:27 +0000 (04:39 +0000)
committerRichard Rauch <rkr@olib.org>
Sun, 26 Oct 2003 04:39:27 +0000 (04:39 +0000)
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

src/freeglut_init.c
src/freeglut_internal.h
src/freeglut_main.c

index 36b5b4b..9949138 100644 (file)
@@ -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
      */
index 91e29e4..eb8def5 100644 (file)
@@ -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;
 };
 
 /*
index c28658f..ee20be9 100644 (file)
@@ -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" );