Relax VRML2 naming rules (perhaps temporarily) to accept the '-' character in DEF names

This commit is contained in:
Cirilo Bernardo 2016-01-03 09:18:16 +11:00
parent 76bf525d12
commit 8939955f2f
3 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,7 @@
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/v2 )
#add_definitions( -DDEBUG_VRML2=3 )
add_library( s3d_plugin_vrml MODULE
vrml.cpp
v2/wrlproc.cpp

View File

@ -235,7 +235,10 @@ bool WRL2NODE::SetName( const std::string& aName )
return false;
}
#define BAD_CHARS1 "\"\'#+,-.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
// XXX: NOTE: in VRML2 the '-' is invalid; however there are some bad models which contain '-' in
// a name and many VRML parsers seem to accept them. In VRML1 the '-' is allowed.
// #define BAD_CHARS1 "\"\'#+,-.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
#define BAD_CHARS1 "\"\'#+,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
#define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
if( std::string::npos != aName.find_first_of( BAD_CHARS1 )

View File

@ -111,7 +111,11 @@ bool WRLPROC::Open( const std::string& aFileName )
// square brackets []
// curly braces {}
// backslash
m_badchars = "'\"#,.+-[]\\{}";
// XXX: NOTE: badchars should include '-' but due to my bad model naming scheme
// in the VRML model generator, I have allowed '-'. Other VRML parsers seem to
// accept '-'.
//m_badchars = "'\"#,.+-[]\\{}";
m_badchars = "'\"#,.+[]\\{}";
return true;
}
@ -332,6 +336,18 @@ bool WRLPROC::ReadName( std::string& aName )
return false;
}
if( aName.empty() && m_buf[m_linepos] >= '0' && m_buf[m_linepos] <= '9' )
{
std::ostringstream ostr;
ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
ostr << " * [INFO] failed on file '" << m_filename << "'\n";
ostr << " * [INFO] line " << m_fileline << ", column " << m_linepos;
ostr << " -- name must not start with a digit";
m_error = ostr.str();
return false;
}
aName.append( 1, m_buf[m_linepos++] );
}