(303) Moved GLUT_INIT_STATE to <GL/freeglut_ext.h>, it is not part of the
original GLUT.
+
+**************************************************************************
+* Changes on August 05, 2006.
+**************************************************************************
+
+(304) Updated build requirements for SuSE 10.1.
+
+(305) Check fgets for return value to avoid warnings.
}
+static void
+checkedFGets ( char *s, int size, FILE *stream )
+{
+ if ( fgets ( s, size, stream ) == NULL ) {
+ fprintf ( stderr, "fgets failed\n");
+ exit ( EXIT_FAILURE );
+ }
+}
+
+
void readConfigFile ( char *fnme )
{
FILE *fptr = fopen ( fnme, "rt" ) ;
if ( fptr )
{
/* Read a header line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read the window title */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* We assume here that this line will not exceed 79 characters plus a
newline (window_title is 80 characters long). That'll cause a buffer
overflow. For a simple program like this, though, we're letting it
sscanf ( inputline, "%[a-zA-Z0-9!@#$%^&*()+=/\\_-\" ]", window_title ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read the number of affine transformations */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
sscanf ( inputline, "%d", &num_trans ) ;
affine = (AffineTrans *)malloc ( num_trans * sizeof(AffineTrans) ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
for ( i = 0; i < num_trans; i++ )
{
/* Read an affine transformation definition */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
sscanf ( inputline, "%lf %lf %lf %lf %lf %lf", &affine[i].a00, &affine[i].a01,
&affine[i].a10, &affine[i].a11, &affine[i].b0, &affine[i].b1 ) ;
}
}
+static void
+checkedFGets ( char *s, int size, FILE *stream )
+{
+ if ( fgets ( s, size, stream ) == NULL ) {
+ fprintf ( stderr, "fgets failed\n");
+ exit ( EXIT_FAILURE );
+ }
+}
+
+
void readConfigFile ( char *fnme )
{
FILE *fptr = fopen ( fnme, "rt" ) ;
if ( fptr )
{
/* Read a header line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read the window title */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* We assume here that this line will not exceed 79 characters plus a
newline (window_title is 80 characters long). That'll cause a buffer
overflow. For a simple program like this, though, we're letting it
sscanf ( inputline, "%[a-zA-Z0-9!@#$%^&*()+=/\\_-\" ]", window_title ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
/* Read the number of affine transformations */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
sscanf ( inputline, "%d", &num_trans ) ;
affine = (AffineTrans *)malloc ( num_trans * sizeof(AffineTrans) ) ;
/* Read a comment line */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
for ( i = 0; i < num_trans; i++ )
{
/* Read an affine transformation definition */
- fgets ( inputline, 256, fptr ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
sscanf ( inputline, "%lf %lf %lf %lf %lf %lf", &affine[i].a00, &affine[i].a01,
&affine[i].a10, &affine[i].a11, &affine[i].b0, &affine[i].b1 ) ;
}
( deriv0[i] + 2.0 * ( deriv1[i] + deriv2[i] ) + deriv3[i] ) ;
}
+static void
+checkedFGets ( char *s, int size, FILE *stream )
+{
+ if ( fgets ( s, size, stream ) == NULL ) {
+ fprintf ( stderr, "fgets failed\n");
+ exit ( EXIT_FAILURE );
+ }
+}
+
+
/* GLUT callbacks */
#define INPUT_LINE_LENGTH 80
case 'm' : case 'M' : /* Modify the Lorenz parameters */
printf ( "Please enter new value for <sigma> (default %f, currently %f): ", s0, sigma ) ;
- fgets ( inputline, INPUT_LINE_LENGTH-1, stdin ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), stdin ) ;
sscanf ( inputline, "%lf", &sigma ) ;
printf ( "Please enter new value for <b> (default %f, currently %f): ", b0, b ) ;
- fgets ( inputline, INPUT_LINE_LENGTH-1, stdin ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), stdin ) ;
sscanf ( inputline, "%lf", &b ) ;
printf ( "Please enter new value for <r> (default %f, currently %f): ", r0, r ) ;
- fgets ( inputline, INPUT_LINE_LENGTH-1, stdin ) ;
+ checkedFGets ( inputline, sizeof ( inputline ), stdin ) ;
sscanf ( inputline, "%lf", &r ) ;
break ;