Commit cb91e095 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Coding policy fixes and comment out debugging output.

parent 5f70ec63
......@@ -28,65 +28,63 @@
#include "vrml_aux.h"
char SkipGetChar ( FILE* File )
char SkipGetChar( FILE* File )
{
char c;
bool re_parse;
char c;
bool re_parse;
if( (c = fgetc( File )) == EOF )
if( ( c = fgetc( File ) ) == EOF )
{
//DBG( printf( "EOF\n" ) );
// DBG( printf( "EOF\n" ) );
return EOF;
}
//DBG( printf( "c %c 0x%02X\n", c, c ) );
// DBG( printf( "c %c 0x%02X\n", c, c ) );
do
{
re_parse = false;
if ((c == ' ') || (c == '\t') || (c == '{') || (c == '['))
if( (c == ' ') || (c == '\t') || (c == '{') || (c == '[') )
{
//DBG( printf( "Skipping space \\t or { or [\n" ) );
// DBG( printf( "Skipping space \\t or { or [\n" ) );
do
{
if( (c = fgetc( File )) == EOF )
if( ( c = fgetc( File ) ) == EOF )
{
//DBG( printf( "EOF\n" ) );
// DBG( printf( "EOF\n" ) );
return EOF;
}
}
while((c == ' ') || (c == '\t') || (c == '{') || (c == '['));
} while( (c == ' ') || (c == '\t') || (c == '{') || (c == '[') );
}
if ((c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ','))
if( (c == '#') || (c == '\n') || (c == '\r') || (c == 0) || (c == ',') )
{
if (c == '#')
if( c == '#' )
{
//DBG( printf( "Skipping # \\n or \\r or 0, 0x%02X\n", c ) );
// DBG( printf( "Skipping # \\n or \\r or 0, 0x%02X\n", c ) );
do
{
if( (c = fgetc( File )) == EOF )
if( ( c = fgetc( File ) ) == EOF )
{
//DBG( printf( "EOF\n" ) );
// DBG( printf( "EOF\n" ) );
return EOF;
}
}
while((c != '\n') && (c != '\r') && (c != 0) && (c != ','));
} while( (c != '\n') && (c != '\r') && (c != 0) && (c != ',') );
}
else
{
if( (c = fgetc( File )) == EOF )
if( ( c = fgetc( File ) ) == EOF )
{
//DBG( printf( "EOF\n" ) );
// DBG( printf( "EOF\n" ) );
return EOF;
}
}
re_parse = true;
}
}while(re_parse == true);
} while( re_parse == true );
return c;
}
......@@ -94,35 +92,38 @@ char SkipGetChar ( FILE* File )
char* GetNextTag( FILE* File, char* tag )
{
char c = SkipGetChar( File );
if (c == EOF)
if( c == EOF )
{
return NULL;
}
tag[0] = c;
tag[1] = 0;
//DBG( printf( "tag[0] %c\n", tag[0] ) );
tag[0] = c;
tag[1] = 0;
// DBG( printf( "tag[0] %c\n", tag[0] ) );
if( (c != '}') && (c != ']') )
{
char *dst = &tag[1];
while( fscanf( File, "%c", dst) )
char* dst = &tag[1];
while( fscanf( File, "%c", dst ) )
{
if( (*dst == ' ') || (*dst == '[') || (*dst == '{') ||
(*dst == '\t') || (*dst == '\n')|| (*dst == '\r') )
if( (*dst == ' ') || (*dst == '[') || (*dst == '{')
|| (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') )
{
*dst = 0;
break;
}
dst++;
}
//DBG( printf( "tag %s\n", tag ) );
// DBG( printf( "tag %s\n", tag ) );
c = SkipGetChar( File );
if (c != EOF)
if( c != EOF )
{
// Puts again the read char in the buffer
ungetc( c, File );
......@@ -133,40 +134,44 @@ char* GetNextTag( FILE* File, char* tag )
}
int read_NotImplemented( FILE* File, char closeChar)
int read_NotImplemented( FILE* File, char closeChar )
{
char c;
//DBG( printf( "look for %c\n", closeChar) );
while( (c = fgetc( File )) != EOF )
// DBG( printf( "look for %c\n", closeChar) );
while( ( c = fgetc( File ) ) != EOF )
{
if( c == '{' )
{
//DBG( printf( "{\n") );
// DBG( printf( "{\n") );
read_NotImplemented( File, '}' );
} else if( c == '[' )
}
else if( c == '[' )
{
//DBG( printf( "[\n") );
// DBG( printf( "[\n") );
read_NotImplemented( File, ']' );
} else if( c == closeChar )
}
else if( c == closeChar )
{
//DBG( printf( "%c\n", closeChar) );
// DBG( printf( "%c\n", closeChar) );
return 0;
}
}
DBG( printf( " NotImplemented failed\n" ) );
// DBG( printf( " NotImplemented failed\n" ) );
return -1;
}
int parseVertexList( FILE* File, std::vector< glm::vec3 > &dst_vector)
int parseVertexList( FILE* File, std::vector<glm::vec3>& dst_vector )
{
//DBG( printf( " parseVertexList\n" ) );
// DBG( printf( " parseVertexList\n" ) );
dst_vector.clear();
glm::vec3 vertex;
while( parseVertex ( File, vertex ) == 3 )
while( parseVertex( File, vertex ) == 3 )
{
dst_vector.push_back( vertex );
}
......@@ -175,32 +180,34 @@ int parseVertexList( FILE* File, std::vector< glm::vec3 > &dst_vector)
}
int parseVertex( FILE* File, glm::vec3 &dst_vertex )
int parseVertex( FILE* File, glm::vec3& dst_vertex )
{
float a,b,c;
int ret = fscanf( File, "%e %e %e", &a, &b, &c );
float a, b, c;
int ret = fscanf( File, "%e %e %e", &a, &b, &c );
dst_vertex.x = a;
dst_vertex.y = b;
dst_vertex.z = c;
dst_vertex.x = a;
dst_vertex.y = b;
dst_vertex.z = c;
char s = SkipGetChar( File );
if (s != EOF)
if( s != EOF )
{
// Puts again the read char in the buffer
ungetc( s, File );
}
//DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) );
// DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) );
return ret;
}
int parseFloat( FILE* File, float *dst_float )
int parseFloat( FILE* File, float* dst_float )
{
float value;
int ret = fscanf( File, "%e", &value );
float value;
int ret = fscanf( File, "%e", &value );
*dst_float = value;
return ret;
......
This diff is collapsed.
This diff is collapsed.
......@@ -76,20 +76,21 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )
if( fgets( line, 11, file ) == NULL )
{
fclose( file );
return;
}
fclose( file );
if( stricmp( line, "#VRML V2.0" ) == 0)
if( stricmp( line, "#VRML V2.0" ) == 0 )
{
//DBG( printf( "About to parser a #VRML V2.0 file\n" ) );
vrml2_parser->Load( aFilename );
return;
}
else if( stricmp( line, "#VRML V1.0" ) == 0)
else if( stricmp( line, "#VRML V1.0" ) == 0 )
{
//DBG( printf( "About to parser a #VRML V1.0 file\n" ) );
vrml1_parser->Load( aFilename );
......@@ -97,5 +98,5 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )
return;
}
DBG( printf( "Unknown VRML file format: %s\n", line ) );
// DBG( printf( "Unknown VRML file format: %s\n", line ) );
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment