From 27ee419355bab24eb6606434d638aec725dad4aa Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sun, 8 May 2011 00:17:16 +0000 Subject: [PATCH] # fix crashbug in rtrim(), hackpatch STEP::Object::GetClassName() for gcc git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@990 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/STEPFile.h | 8 +++++--- code/STEPFileReader.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/STEPFile.h b/code/STEPFile.h index e7e5a89d1..8418dfe27 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -463,9 +463,11 @@ namespace STEP { } std::string GetClassName() const { - // strictly speaking this relies on unspecified behaviour - we hijack the name() field of std::type_info - const char* s = typeid(*this).name(), *s2 = strstr(s,"IFC::"); - return std::string(s2?s2+5:s); + // XXX this relies on unspecified behaviour - we hijack the name() field of std::type_info + // known to work as intended for only msvc 8, with gcc 4.5 it produces reasonable, but + // not totally unmangled output - we definitely need a traits-based solution here. + const char* s = typeid(*this).name(), *s2 = strstr(s,"Ifc"); + return std::string(s2?s2:s); } void SetID(uint64_t newval) { diff --git a/code/STEPFileReader.cpp b/code/STEPFileReader.cpp index cf5049cac..56b1a07bb 100644 --- a/code/STEPFileReader.cpp +++ b/code/STEPFileReader.cpp @@ -63,7 +63,7 @@ static inline std::string <rim(std::string &s) { // trim from end static inline std::string &rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1( std::ptr_fun(Assimp::IsSpace))).base()); + s.erase(std::find_if(s.rbegin(), s.rend(), std::not1( std::ptr_fun(Assimp::IsSpace))).base(),s.end()); return s; } // trim from both ends