Re: [Cppunit-devel] questionable code @ TypeInfoHelper.cpp
Brought to you by:
blep
From: FUKUDA F. <ff...@nt...> - 2002-04-19 01:38:03
|
--- "Re: [Cppunit-devel] questionable code @ TypeInfoHelper.cpp" / Duane Murphy / 2002/04/18 08:12:06 -0700 --- >>----- excerpt from src/cppunit/TypeInfoHelper.cpp ----- >>std::string >>TypeInfoHelper::getClassName( const std::type_info &info ) >>{ >> static std::string classPrefix( "class " ); >> std::string name( info.name() ); >> >> bool has_class_prefix = 0 == >>#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST >> name.compare( classPrefix, 0, classPrefix.length() ); >>#else >> name.compare( 0, classPrefix.length(), classPrefix ); >>#endif >> return has_class_prefix ? name.substr( classPrefix.length() ) : name; >>} >>------------------ >> >>if info.name().length() < classPrefix.length(), an exception should be >thrown. >>I think this method should return 'name' at this condition (as follows). > >This is incorrect. string.compare() will not throw an exception under >these conditions. The minimum of classPrefix.length() and >info.name().length() will be compared. The code is fine. thanks. yes, you're correct... some of stdlib impl. throws exception on this case.... I'm now trying to mekr 'makefile' for Borland C++ 5.5 free compiler, BC++5.5's stdlib throws... I think its stdlib was implemented based on old version of std-C++ spec. If CppUnit can add only-1-line in TypeInfoHelper.cpp, It make lot of BC++5.5 uses happy. please consider. -----:-----:-----:-----:-----:-----:-----:-----:-----:----- FUKUDA (episteme) Fumiki -- magical, but never a magic... |