projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added svn:eol-style=CRLF property to MSVC project/workspace files.
[freeglut]
/
progs
/
demos
/
Lorenz
/
lorenz.c
diff --git
a/progs/demos/Lorenz/lorenz.c
b/progs/demos/Lorenz/lorenz.c
index
be32c77
..
93ed843
100644
(file)
--- a/
progs/demos/Lorenz/lorenz.c
+++ b/
progs/demos/Lorenz/lorenz.c
@@
-31,7
+31,6
@@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include <time.h>
#include <GL/freeglut.h>
#ifdef WIN32
/* DUMP MEMORY LEAKS */
#include <GL/freeglut.h>
#ifdef WIN32
/* DUMP MEMORY LEAKS */
@@
-108,6
+107,16
@@
void advance_in_time ( double time_step, double position[3], double new_position
( deriv0[i] + 2.0 * ( deriv1[i] + deriv2[i] ) + deriv3[i] ) ;
}
( 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
/* GLUT callbacks */
#define INPUT_LINE_LENGTH 80
@@
-143,15
+152,15
@@
void key_cb ( unsigned char key, int x, int y )
case 'm' : case 'M' : /* Modify the Lorenz parameters */
printf ( "Please enter new value for <sigma> (default %f, currently %f): ", s0, sigma ) ;
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 ) ;
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 ) ;
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 ;
sscanf ( inputline, "%lf", &r ) ;
break ;