--- At Fri, 19 Apr 2002 10:37:29 +0900, FUKUDA Fumiki wrote:
>--- "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.
Thank you for explaining. Bad implementations of stdlib are a real pain.
This is a reasonable work around for this poor implementation.
...Duane
--
"If tyranny and oppression come to this land, it will be in the
guise of fighting a foreign enemy." - James Madison
|