Hi!
I had some problems building lyx 1.1.6 on SunOS5.7 using gcc, which is
strange since that should be pretty common. After some hacking I found
the problem in the function strip in src/support/lstrings.C
This function is defined as:
string const strip(string const & a, char c)
{
if (a.empty()) return a;
string tmp(a);
string::size_type i = tmp.find_last_not_of(c);
if (i == a.length() - 1) return tmp; // no c's at end of a
if (i != string::npos)
tmp.erase(i + 1, string::npos);
else
tmp.erase(); // only c in the whole string
return tmp;
}
But the npos that find_last_not_of(c) returns when there is no c's is
NOT equal to a.length() - 1. The code below seems to work (not being
a c++ programmer it's best to not be to sure ;-) as intended:
string const strip(string const & a, char c)
{
if (a.empty()) return a;
string tmp(a);
string::size_type i = tmp.find_last_not_of(c);
if (i != string::npos)
tmp.erase(i + 1, string::npos);
else {
string::size_type k = tmp.find_first_of(c);
if (k == 0)
tmp.erase(); // only c in the whole string
else
return tmp; // no c's at end of a
}
return tmp;
}
/Roland Jonsson