You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by mc...@apache.org on 2004/06/15 19:24:56 UTC

cvs commit: logging-log4cxx/src stringhelper.cpp

mcatan      2004/06/15 10:24:56

  Modified:    src      stringhelper.cpp
  Log:
  fixed endsWith bug
  
  Revision  Changes    Path
  1.3       +10 -1     logging-log4cxx/src/stringhelper.cpp
  
  Index: stringhelper.cpp
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/src/stringhelper.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- stringhelper.cpp	22 Apr 2004 21:21:34 -0000	1.2
  +++ stringhelper.cpp	15 Jun 2004 17:24:56 -0000	1.3
  @@ -56,7 +56,16 @@
   
   bool StringHelper::endsWith(const String& s, const String& suffix)
   {
  -	return (s.length() - s.rfind(suffix)) == suffix.length();
  +	/*If suffix is not in s, false must be returned */ 
  +    int place = s.rfind(suffix);
  +    if (place == -1)
  +	{
  +        return false;
  +    }
  +    else
  +	{
  +        return (s.length() - place) == suffix.length();
  +    }
   }
   
   String StringHelper::format(const String& pattern, va_list argList)