From eb23514478d261879266f32c2378f76f12d9539a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 26 Feb 2010 09:33:48 +0000 Subject: [PATCH] From Sukender, "I tried a tiny change in is83() function and had no crash (under Windows). "osgconv cow.osg cow.3ds" exports a black cow and "osgconv lz.osg lz.3ds" exports tree(s) at (0,0,0)... I guess there are still things to do about non-zero-index textures and multiple instanciation of a node, but at least it doesn't crash." --- src/osgPlugins/3ds/WriterNodeVisitor.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/3ds/WriterNodeVisitor.cpp b/src/osgPlugins/3ds/WriterNodeVisitor.cpp index 9ee3564a6..7059387a4 100644 --- a/src/osgPlugins/3ds/WriterNodeVisitor.cpp +++ b/src/osgPlugins/3ds/WriterNodeVisitor.cpp @@ -96,10 +96,14 @@ bool is3DSpath(const std::string & s, bool extendedFilePaths) { if (len >= 64 || len == 0) return false; if (extendedFilePaths) return true; // Extended paths are simply those that fits the 64 bytes buffer! - unsigned int tokenBegin = 0; - for (unsigned int tokenEnd=0; tokenEnd != std::string::npos; tokenBegin = tokenEnd+1) { + // For each subdirectory + unsigned int tokenLen; + for (unsigned int tokenBegin=0, tokenEnd=0; tokenEnd == std::string::npos; tokenBegin = tokenEnd+1) + { tokenEnd = s.find_first_of("/\\", tokenBegin); - if ( !is83(s.substr(tokenBegin, tokenEnd-tokenBegin-1)) ) return false; + if (tokenEnd != std::string::npos) tokenLen = tokenEnd-tokenBegin-1; // -1 to avoid reading the separator + else tokenLen = len-tokenBegin; + if ( tokenLen>0 && !is83(s.substr(tokenBegin, tokenLen)) ) return false; } return true; }