]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.cpp
tiger support on mac snow leopard, include Qt4 frameworks, smart build script with...
[lyx.git] / src / support / lstrings.cpp
index 402b2c31190781e1ff746b16c7c8faef0441002d..7039fe127f8811b26ee73eedf61901177dcd9437 100644 (file)
@@ -315,6 +315,23 @@ bool isStrDbl(string const & str)
 }
 
 
+bool hasDigit(docstring const & str)
+{
+       if (str.empty())
+               return false;
+
+       docstring::const_iterator cit = str.begin();
+       docstring::const_iterator const end = str.end();
+       for (; cit != end; ++cit) {
+               if (*cit == ' ')
+                       continue;
+               if (isdigit((*cit)))
+                       return true;
+       }
+       return false;
+}
+
+
 static bool isHexChar(char_type c)
 {
        return c == '0' ||
@@ -958,7 +975,7 @@ vector<docstring> wrapToVec(docstring const & str, int ind,
        vector<docstring> retval;
        while (s.size() > width) {
                // find the last space within the first 'width' chars
-               size_t i = s.find_last_of(' ', width - 1);
+               size_t const i = s.find_last_of(' ', width - 1);
                if (i == docstring::npos || i <= size_t(ind)) {
                        // no space found
                        s = s.substr(0, width - 3) + "...";
@@ -993,11 +1010,11 @@ docstring wrapParas(docstring const & str, int const indent,
        if (str.empty())
                return docstring();
 
-       vector<docstring> pars = getVectorFromString(str, from_ascii("\n"), true);
+       vector<docstring> const pars = getVectorFromString(str, from_ascii("\n"), true);
        vector<docstring> retval;
 
-       vector<docstring>::iterator it = pars.begin();
-       vector<docstring>::iterator en = pars.end();
+       vector<docstring>::const_iterator it = pars.begin();
+       vector<docstring>::const_iterator const en = pars.end();
        for (; it != en; ++it) {
                vector<docstring> tmp = wrapToVec(*it, indent, width);
                size_t const nlines = tmp.size();
@@ -1170,6 +1187,17 @@ docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
 }
 
 
+template<>
+docstring bformat(docstring const & fmt, docstring arg1, int arg2)
+{
+       LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
+       LASSERT(contains(fmt, from_ascii("%2$d")), /**/);
+       docstring str = subst(fmt, from_ascii("%1$s"), arg1);
+       str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
+       return subst(str, from_ascii("%%"), from_ascii("%"));
+}
+
+
 template<>
 docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
 {