[Dip] Fix for the bug in 0.82.1

Shahin Gelareh shahin.gelareh at gmail.com
Tue Sep 13 05:22:07 EDT 2011


Hi,

The current function "UtilStrToLower" in 0.82.1 crashes because my compiler
(VS2010 C++) does not see '\0' at the end of string.
Formerly it could be fixed by using :
// -------------------------------------------------------------------------
//
// returns a lower case version of the std::string in-place
inline std::string & UtilStrToLower(std::string & s) {
   // Purify did not like this version:
   //   transform (s.begin(), s.end(), s.begin(), myToLower());
   if(s.size() == 0)
      return s;
    std::transform(s.begin(), s.end(),
s.begin(),std::ptr_fun<int,int>(std::tolower));
   //int i;
   //for (i = 0; s[i] != '\0'; i++)
   //   s[i] = static_cast<char>(tolower(s[i]));
   return s;
}

instead.

Some changes seem to have been done from 0.82.0 to 0.82.1 which  have tried
to force C-type strings. With this change the above function does not
compile because "tolower" is not longer recognized to be in the scope of
STD.
The fix is now to use:

// -------------------------------------------------------------------------
//
// returns a lower case version of the std::string in-place
inline std::string & UtilStrToLower(std::string & s) {
   // Purify did not like this version:
   //   transform (s.begin(), s.end(), s.begin(), myToLower());
   if(s.size() == 0)
      return s;
    std::transform(s.begin(), s.end(),
s.begin(),std::ptr_fun<int,int>tolower));
   //int i;
   //for (i = 0; s[i] != '\0'; i++)
   //   s[i] = static_cast<char>(tolower(s[i]));
   return s;
}

This works fine.

regards,
Shahin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/dip/attachments/20110913/956d50a9/attachment.html>


More information about the Dip mailing list