using std::count;
using std::transform;
-#ifndef __GLIBCPP__
-// The new glibstdc++-v3 has not worked out all the quirks regarding cctype
-// yet. So currently it failes if the to using lines below are stated.
+#ifndef CXX_GLOBAL_CSTD
using std::tolower;
using std::toupper;
#endif
int compare_no_case(string const & s, string const & s2)
{
- // ANSI C
string::const_iterator p = s.begin();
string::const_iterator p2 = s2.begin();
++p;
++p2;
}
-
+
if (s.size() == s2.size())
return 0;
if (s.size() < s2.size())
++p;
++p2;
}
- if (s.size() == s2.size())
+
+ if (s.size() >= len && s2.size() >= len)
return 0;
if (s.size() < s2.size())
return -1;
}
+bool isStrUnsignedInt(string const & str)
+{
+ if (str.empty()) return false;
+
+ // Remove leading and trailing white space chars.
+ string const tmpstr = frontStrip(strip(str, ' '), ' ');
+ if (tmpstr.empty()) return false;
+
+ string::const_iterator cit = tmpstr.begin();
+ string::const_iterator end = tmpstr.end();
+ for (; cit != end; ++cit) {
+ if (!isdigit((*cit))) return false;
+ }
+ return true;
+}
+
+
int strToInt(string const & str)
{
if (isStrInt(str)) {
}
+unsigned int strToUnsignedInt(string const & str)
+{
+ if (isStrUnsignedInt(str)) {
+ // Remove leading and trailing white space chars.
+ string const tmpstr = frontStrip(strip(str, ' '), ' ');
+ // Do the conversion proper.
+ return lyx::atoi(tmpstr);
+ } else {
+ return 0;
+ }
+}
+
+
bool isStrDbl(string const & str)
{
if (str.empty()) return false;
}
#else
// We want to use this one. (Lgb)
- transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
+ transform(tmp.begin(), tmp.end(), tmp.begin(), lowercase);
#endif
return tmp;
}
}
#else
// We want to use this one. (Lgb)
- transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
+ transform(tmp.begin(), tmp.end(), tmp.begin(), uppercase);
#endif
return tmp;
}
string::size_type const prelen = pre.length();
string::size_type const alen = a.length();
- if (prelen < alen || a.empty())
+ if (prelen > alen || a.empty())
return false;
else {
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
Assert(suf);
size_t const suflen = strlen(suf);
- if (suflen > a.length())
+ string::size_type const alen = a.length();
+
+ if (suflen > alen)
return false;
else {
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
// Delete this code when the compilers get a bit better.
- string tmp(a, a.length() - suflen);
+ string tmp(a, alen - suflen);
return ::strncmp(tmp.c_str(), suf, suflen) == 0;
#else
// This is the code that we really want to use
// but until gcc ships with a basic_string that
// implements std::string correctly we have to
// use the code above.
- return a.compare(a.length() - suflen, suflen, suf) == 0;
+ return a.compare(alen - suflen, suflen, suf) == 0;
#endif
}
}