]> git.lyx.org Git - lyx.git/blobdiff - src/support/lstrings.cpp
Added distribution of a missing file used by tests.
[lyx.git] / src / support / lstrings.cpp
index 9eb9e43d5fbe975367e8b527f313db11f4fdee7e..8ffab19c7ef14b9a8f2a4fe0b3cbd371ac68e3ff 100644 (file)
@@ -182,6 +182,18 @@ bool isASCII(char_type c)
 }
 
 
+bool isOpenPunctuation(char_type c)
+{
+       if (!is_utf16(c)) {
+               // assume that no non-utf16 character is an op
+               // c outside the UCS4 range is catched as well
+               return false;
+       }
+       QChar const qc = ucs4_to_qchar(c);
+       return qc.category() == QChar::Punctuation_Open;
+}
+
+
 namespace support {
 
 int compare_no_case(docstring const & s, docstring const & s2)
@@ -1168,7 +1180,8 @@ docstring const escape(docstring const & lab)
        for (size_t i = 0; i < lab.length(); ++i) {
                char_type c = lab[i];
                if (c >= 128 || c == '=' || c == '%' || c == '#' || c == '$'
-                   || c == '}' || c == '{' || c == ']' || c == '[' || c == '&') {
+                   || c == '}' || c == '{' || c == ']' || c == '[' || c == '&'
+                   || c == '\\') {
                        // Although char_type is a 32 bit type we know that
                        // UCS4 occupies only 21 bits, so we don't need to
                        // encode bigger values. Test for 2^24 because we
@@ -1190,6 +1203,16 @@ docstring const escape(docstring const & lab)
 }
 
 
+docstring const protectArgument(docstring & arg, char const l,
+                         char const r)
+{
+       if (contains(arg, l) || contains(arg, r))
+               // protect brackets
+               arg = '{' + arg + '}';
+       return arg;
+}
+
+
 bool truncateWithEllipsis(docstring & str, size_t const len)
 {
        if (str.size() <= len)
@@ -1408,7 +1431,6 @@ std::string formatFPNumber(double x)
 }
 
 
-template<>
 docstring bformat(docstring const & fmt, int arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1417,7 +1439,6 @@ docstring bformat(docstring const & fmt, int arg1)
 }
 
 
-template<>
 docstring bformat(docstring const & fmt, long arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1427,7 +1448,6 @@ docstring bformat(docstring const & fmt, long arg1)
 
 
 #ifdef LYX_USE_LONG_LONG
-template<>
 docstring bformat(docstring const & fmt, long long arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1437,7 +1457,6 @@ docstring bformat(docstring const & fmt, long long arg1)
 #endif
 
 
-template<>
 docstring bformat(docstring const & fmt, unsigned int arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1446,8 +1465,7 @@ docstring bformat(docstring const & fmt, unsigned int arg1)
 }
 
 
-template<>
-docstring bformat(docstring const & fmt, docstring arg1)
+docstring bformat(docstring const & fmt, docstring const & arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        docstring const str = subst(fmt, from_ascii("%1$s"), arg1);
@@ -1455,7 +1473,6 @@ docstring bformat(docstring const & fmt, docstring arg1)
 }
 
 
-template<>
 docstring bformat(docstring const & fmt, char * arg1)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
@@ -1464,8 +1481,7 @@ docstring bformat(docstring const & fmt, char * arg1)
 }
 
 
-template<>
-docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
+docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        LATTEST(contains(fmt, from_ascii("%2$s")));
@@ -1475,8 +1491,7 @@ docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
 }
 
 
-template<>
-docstring bformat(docstring const & fmt, docstring arg1, int arg2)
+docstring bformat(docstring const & fmt, docstring const & arg1, int arg2)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        LATTEST(contains(fmt, from_ascii("%2$d")));
@@ -1486,8 +1501,7 @@ docstring bformat(docstring const & fmt, docstring arg1, int arg2)
 }
 
 
-template<>
-docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
+docstring bformat(docstring const & fmt, char const * arg1, docstring const & arg2)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        LATTEST(contains(fmt, from_ascii("%2$s")));
@@ -1497,7 +1511,6 @@ docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
 }
 
 
-template<>
 docstring bformat(docstring const & fmt, int arg1, int arg2)
 {
        LATTEST(contains(fmt, from_ascii("%1$d")));
@@ -1508,8 +1521,7 @@ docstring bformat(docstring const & fmt, int arg1, int arg2)
 }
 
 
-template<>
-docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3)
+docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        LATTEST(contains(fmt, from_ascii("%2$s")));
@@ -1521,9 +1533,8 @@ docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstri
 }
 
 
-template<>
 docstring bformat(docstring const & fmt,
-              docstring arg1, docstring arg2, docstring arg3, docstring arg4)
+              docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4)
 {
        LATTEST(contains(fmt, from_ascii("%1$s")));
        LATTEST(contains(fmt, from_ascii("%2$s")));