]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.C
fix a couple of hard crashes, constify local variables, whitespace changes, some...
[lyx.git] / src / support / lstrings.C
index 689a54be761ecb06a63ebaeec3406e0daaf3d9be..5592d825b38b7e6f557bc9d0543ca1c7becc3517 100644 (file)
@@ -26,9 +26,7 @@
 
 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
@@ -88,7 +86,7 @@ bool isStrInt(string const & str)
        if (tmpstr.empty()) return false;
        
        string::const_iterator cit = tmpstr.begin();
-       if ( (*cit) == '-') ++cit;
+       if ((*cit) == '-') ++cit;
        string::const_iterator end = tmpstr.end();
        for (; cit != end; ++cit) {
                if (!isdigit((*cit))) return false;
@@ -121,7 +119,7 @@ bool isStrDbl(string const & str)
 
        string::const_iterator cit = tmpstr.begin();
        bool found_dot(false);
-       if ( (*cit) == '-') ++cit;
+       if ((*cit) == '-') ++cit;
        string::const_iterator end = tmpstr.end();
        for (; cit != end; ++cit) {
                if (!isdigit((*cit))
@@ -155,13 +153,13 @@ double strToDbl(string const & str)
 
 char lowercase(char c) 
 { 
-       return tolower(c); 
+       return char( tolower(c) ); 
 }
 
 
 char uppercase(char c) 
 { 
-       return toupper(c); 
+       return char( toupper(c) ); 
 }
 
 
@@ -205,7 +203,7 @@ bool prefixIs(string const & a, char const * pre)
 {
        Assert(pre);
        
-       unsigned int const l = strlen(pre);
+       size_t const l = strlen(pre);
        string::size_type const alen = a.length();
        
        if (l > alen || a.empty())
@@ -253,7 +251,7 @@ bool suffixIs(string const & a, char const * suf)
 {
        Assert(suf);
        
-       unsigned int const suflen = strlen(suf);
+       size_t const suflen = strlen(suf);
        if (suflen > a.length())
                return false;
        else {
@@ -353,7 +351,7 @@ bool containsOnly(char const * s, string const & cset)
 }
 
 
-unsigned int countChar(string const & a, char c)
+string::size_type countChar(string const & a, char c)
 {
 #ifdef HAVE_STD_COUNT
        return count(a.begin(), a.end(), c);
@@ -427,7 +425,7 @@ string const subst(string const & a, char oldchar, char newchar)
        string tmp(a);
        string::iterator lit = tmp.begin();
        string::iterator end = tmp.end();
-       for(; lit != end; ++lit)
+       for (; lit != end; ++lit)
                if ((*lit) == oldchar)
                        (*lit) = newchar;
        return tmp;
@@ -441,7 +439,7 @@ string const subst(string const & a,
        
        string lstr(a);
        string::size_type i = 0;
-       int olen = strlen(oldstr);
+       string::size_type olen = strlen(oldstr);
        while((i = lstr.find(oldstr, i)) != string::npos) {
                lstr.replace(i, olen, newstr);
                i += newstr.length(); // We need to be sure that we dont