]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.C
Add a bunch of c_str() for string stream uses; remove lyxfunc symbol-insert.
[lyx.git] / src / support / lstrings.C
index fae7df7bfa225bf3da0a89f9f05b6879ce538def..547d0790aa234b5876a600fffa0b6cde410fc414 100644 (file)
@@ -59,7 +59,6 @@ int compare_no_case(string const & s, string const & s2)
 
 int compare_no_case(string const & s, string const & s2, unsigned int len)
 {
-//#warning verify this func please
        string::const_iterator p = s.begin();
        string::const_iterator p2 = s2.begin();
        unsigned int i = 0;
@@ -89,7 +88,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;
@@ -122,7 +121,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))
@@ -156,29 +155,30 @@ 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) ); 
 }
 
 
 string const lowercase(string const & a)
 {
        string tmp(a);
-//#ifdef __GLIBCPP__
+#if 1
        string::iterator result = tmp.begin();
        string::iterator end = tmp.end();
        for (string::iterator first = tmp.begin();
             first != end; ++first, ++result) {
                *result = lowercase(*first);
        }
-//#else
-//     transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
-//#endif
+#else
+       // We want to use this one. (Lgb)
+       transform(tmp.begin(), tmp.end(), tmp.begin(), tolower);
+#endif
        return tmp;
 }
 
@@ -186,16 +186,17 @@ string const lowercase(string const & a)
 string const uppercase(string const & a)
 {
        string tmp(a);
-//#ifdef __GLIBCPP__
+#if 1
        string::iterator result = tmp.begin();
        string::iterator end = tmp.end();
        for (string::iterator first = tmp.begin();
             first != end; ++first, ++result) {
                *result = uppercase(*first);
        }
-//#else
-//     transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
-//#endif
+#else
+       // We want to use this one. (Lgb)
+       transform(tmp.begin(), tmp.end(), tmp.begin(), toupper);
+#endif
        return tmp;
 }
 
@@ -204,7 +205,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())
@@ -252,7 +253,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 {
@@ -283,7 +284,7 @@ bool suffixIs(string const & a, string const & suf)
                string tmp(a, alen - suflen);
                return ::strncmp(tmp.c_str(), suf.c_str(), suflen) == 0;
 #else
-               return a.compare(alen - suflen, suflen, suf);
+               return a.compare(alen - suflen, suflen, suf) == 0;
 #endif
        }
 }
@@ -352,7 +353,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);
@@ -426,7 +427,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;
@@ -440,7 +441,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