Enhancement - caseless string compare, find

- Switched the sense of the Boolean parameter to match a more natural
  name in the .taskrc file.
This commit is contained in:
Paul Beckingham 2010-01-27 09:33:26 -05:00
parent 3e5ea8cb6c
commit 2dfe144236
3 changed files with 27 additions and 27 deletions

View file

@ -466,10 +466,10 @@ bool isWordEnd (const std::string& input, std::string::size_type pos)
bool compare (
const std::string& left,
const std::string& right,
bool caseless /*= false*/)
bool sensitive /*= true*/)
{
// Use strcasecmp if required.
if (caseless)
if (!sensitive)
return strcasecmp (left.c_str (), right.c_str ()) == 0 ? true : false;
// Otherwise, just use std::string::operator==.
@ -480,11 +480,11 @@ bool compare (
std::string::size_type find (
const std::string& text,
const std::string& pattern,
bool caseless /*= false*/)
bool sensitive /*= true*/)
{
// Implement a caseless find, which is really just a loop withing a loop,
// Implement a sensitive find, which is really just a loop withing a loop,
// comparing lower-case versions of each character in turn.
if (caseless)
if (!sensitive)
{
// Handle empty pattern.
const char* p = pattern.c_str ();