summaryrefslogtreecommitdiffstats
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-06-19 11:33:24 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-06-19 13:26:09 +0200
commitcbe944e323edb20f958bb46ea644de659b75382e (patch)
treec51e99e46e447f139fbbc48ff0d9aa8885e70a82 /include/rtl
parentRevert "optimise SdrObjList::SetObjectOrdNum" (diff)
downloadcore-cbe944e323edb20f958bb46ea644de659b75382e.tar.gz
core-cbe944e323edb20f958bb46ea644de659b75382e.zip
Catch inadvertent uses of OUString(sal_Unicode) ctor
...with numeric values that are not meant to be characters. Inspired by <https://gerrit.libreoffice.org/#/c/16339/> "OUString: add constructor from single Unicode code point" and ecaf1cb3861c1b519a1495487fc796884cf37b92 "seems to be what was meant." Found e46e8d19458fd64ff20b1013e5eeabd07e62379c "Shall this produce a string representation of a number?" and f2a0e4032734d6be635f14ade3dea499c29ec6c2 "Don't truncate a UTF-32 code point to a UTF-16 code unit." (LIBO_INTERNAL_ONLY mostly because it uses a C++11 delegating ctor for simplicity, but also because it requires mild modifications to client code, see additional changes in this commit and some other recent commits.) Change-Id: I8a156f01d1b772c6052d7afaa088ae13ed234e2b
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/ustring.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 80d67e843677..2c56443e8219 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -172,6 +172,17 @@ public:
rtl_uString_newFromStr_WithLength( &pData, &value, 1 );
}
+#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
+ /// @cond INTERNAL
+ // Catch inadvertent conversions to the above ctor (but still allow
+ // construction from char literals):
+ OUString(int) = delete;
+ explicit OUString(char c):
+ OUString(sal_Unicode(static_cast<unsigned char>(c)))
+ {}
+ /// @endcond
+#endif
+
/**
New string from a Unicode character buffer array.