summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPhilipp Hofer <philipp.hofer@protonmail.com>2020-11-12 13:23:10 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-11-18 12:04:58 +0100
commit1582d9a2c5ef9f28bc97a74e25c3948a7611fac1 (patch)
tree854893c78571f69672be4e695c3069b3cab2f1b0 /tools
parentf5e3b2e83ab463064f100a9cd93f09cadaae2292 (diff)
tdf#123936 Formatting files in module tools with clang-format
Change-Id: I0f66d02e67388cc4d21c5e96bf84b6848e8de63a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105721 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qa/cppunit/test_date.cxx72
-rw-r--r--tools/qa/cppunit/test_pathutils.cxx25
-rw-r--r--tools/qa/cppunit/test_rectangle.cxx9
-rw-r--r--tools/source/generic/svborder.cxx14
-rw-r--r--tools/source/misc/cpuid.cxx31
-rw-r--r--tools/source/misc/extendapplicationenvironment.cxx24
-rw-r--r--tools/source/ref/ref.cxx6
7 files changed, 89 insertions, 92 deletions
diff --git a/tools/qa/cppunit/test_date.cxx b/tools/qa/cppunit/test_date.cxx
index ca6c39d84109..9a243cce504c 100644
--- a/tools/qa/cppunit/test_date.cxx
+++ b/tools/qa/cppunit/test_date.cxx
@@ -14,7 +14,6 @@
namespace tools
{
-
class DateTest : public CppUnit::TestFixture
{
public:
@@ -43,45 +42,45 @@ public:
void DateTest::testDate()
{
- const Date aCE(1,1,1); // first day CE
- const Date aBCE(31,12,-1); // last day BCE
- const Date aMin(1,1,-32768); // minimum date
- const Date aMax(31,12,32767); // maximum date
+ const Date aCE(1, 1, 1); // first day CE
+ const Date aBCE(31, 12, -1); // last day BCE
+ const Date aMin(1, 1, -32768); // minimum date
+ const Date aMax(31, 12, 32767); // maximum date
Date aDate(Date::EMPTY);
const sal_Int32 kMinDays = -11968265;
- const sal_Int32 kMaxDays = 11967900;
+ const sal_Int32 kMaxDays = 11967900;
// Last day BCE to first day CE is 1 day difference.
- CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(1), aCE - aBCE);
- CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(-1), aBCE - aCE);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aCE - aBCE);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aBCE - aCE);
aDate = aBCE;
aDate.AddDays(1);
- CPPUNIT_ASSERT_EQUAL( aCE.GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(aCE.GetDate(), aDate.GetDate());
aDate = aCE;
aDate.AddDays(-1);
- CPPUNIT_ASSERT_EQUAL( aBCE.GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(aBCE.GetDate(), aDate.GetDate());
// The entire BCE and CE ranges cover that many days. Day 0 is -0001-12-31
- CPPUNIT_ASSERT_EQUAL( kMaxDays, aMax - aBCE);
- CPPUNIT_ASSERT_EQUAL( kMinDays, aMin - aBCE);
+ CPPUNIT_ASSERT_EQUAL(kMaxDays, aMax - aBCE);
+ CPPUNIT_ASSERT_EQUAL(kMinDays, aMin - aBCE);
// Truncate at limits, not under-/overflow or wrap.
aDate = aMin;
aDate.AddDays(-1);
- CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(aMin.GetDate(), aDate.GetDate());
aDate = aMax;
aDate.AddDays(1);
- CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(aMax.GetDate(), aDate.GetDate());
aDate = aBCE;
- aDate.AddDays(kMinDays-10);
- CPPUNIT_ASSERT_EQUAL( aMin.GetDate(), aDate.GetDate());
+ aDate.AddDays(kMinDays - 10);
+ CPPUNIT_ASSERT_EQUAL(aMin.GetDate(), aDate.GetDate());
aDate = aBCE;
- aDate.AddDays(kMaxDays+10);
- CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
+ aDate.AddDays(kMaxDays + 10);
+ CPPUNIT_ASSERT_EQUAL(aMax.GetDate(), aDate.GetDate());
aDate = aMax;
aDate.SetDay(32);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( aMax.GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(aMax.GetDate(), aDate.GetDate());
CPPUNIT_ASSERT(!aDate.IsEmpty());
// 0001-00-x normalized to -0001-12-x
@@ -89,7 +88,7 @@ void DateTest::testDate()
aDate.SetMonth(0);
aDate.SetDay(22);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(22,12,-1).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(22, 12, -1).GetDate(), aDate.GetDate());
sal_uInt32 nExpected = 11222;
CPPUNIT_ASSERT_EQUAL(nExpected, aDate.GetDateUnsigned());
@@ -98,21 +97,21 @@ void DateTest::testDate()
aDate.SetMonth(2);
aDate.SetDay(32);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(4,3,1999).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(4, 3, 1999).GetDate(), aDate.GetDate());
// Empty date is not normalized and stays empty date.
- aDate = Date( Date::EMPTY );
+ aDate = Date(Date::EMPTY);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(Date::EMPTY).GetDate(), aDate.GetDate());
- CPPUNIT_ASSERT( !aDate.IsValidDate()); // GetDate() also shall have no normalizing side effect
+ CPPUNIT_ASSERT_EQUAL(Date(Date::EMPTY).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT(!aDate.IsValidDate()); // GetDate() also shall have no normalizing side effect
// 0000-01-00 normalized to -0001-12-31
// SetYear(0) asserts, use empty date to force.
- aDate = Date( Date::EMPTY );
+ aDate = Date(Date::EMPTY);
aDate.SetMonth(1);
aDate.SetDay(0);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(31,12,-1).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(31, 12, -1).GetDate(), aDate.GetDate());
// 1999-00-00 normalized to 1998-12-31 (not 1998-11-30, or otherwise
// also 0001-00-00 should be -0001-11-30 which it should not, should it?)
@@ -120,14 +119,14 @@ void DateTest::testDate()
aDate.SetMonth(0);
aDate.SetDay(0);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(31,12,1998).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(31, 12, 1998).GetDate(), aDate.GetDate());
// 0001-00-00 normalized to -0001-12-31
aDate.SetYear(1);
aDate.SetMonth(0);
aDate.SetDay(0);
aDate.Normalize();
- CPPUNIT_ASSERT_EQUAL( Date(31,12,-1).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(31, 12, -1).GetDate(), aDate.GetDate());
}
void DateTest::testLeapYear()
@@ -159,32 +158,32 @@ void DateTest::testLeapYear()
{
// Year -1 is a leap year.
- Date aDate (28,2,-1);
+ Date aDate(28, 2, -1);
aDate.AddDays(1);
CPPUNIT_ASSERT(aDate.IsLeapYear());
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(29, 2, -1).GetDate(), aDate.GetDate());
}
{
- Date aDate(1,3,-1);
+ Date aDate(1, 3, -1);
aDate.AddDays(-1);
CPPUNIT_ASSERT(aDate.IsLeapYear());
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-1).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(29, 2, -1).GetDate(), aDate.GetDate());
}
{
// Year -5 is a leap year.
- Date aDate(28,2,-5);
+ Date aDate(28, 2, -5);
aDate.AddDays(1);
CPPUNIT_ASSERT(aDate.IsLeapYear());
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(29, 2, -5).GetDate(), aDate.GetDate());
}
{
- Date aDate(1,3,-5);
+ Date aDate(1, 3, -5);
aDate.AddDays(-1);
CPPUNIT_ASSERT(aDate.IsLeapYear());
- CPPUNIT_ASSERT_EQUAL( Date(29,2,-5).GetDate(), aDate.GetDate());
+ CPPUNIT_ASSERT_EQUAL(Date(29, 2, -5).GetDate(), aDate.GetDate());
}
}
@@ -535,7 +534,6 @@ void DateTest::testIsBetween()
}
CPPUNIT_TEST_SUITE_REGISTRATION(DateTest);
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/tools/qa/cppunit/test_pathutils.cxx b/tools/qa/cppunit/test_pathutils.cxx
index c0a1ea5078d0..7ad75f1e8db2 100644
--- a/tools/qa/cppunit/test_pathutils.cxx
+++ b/tools/qa/cppunit/test_pathutils.cxx
@@ -24,25 +24,24 @@
#include <cppunit/extensions/HelperMacros.h>
#include <tools/pathutils.hxx>
-namespace {
-
-void buildPath(
- wchar_t const * front, wchar_t const * back, wchar_t const * path)
+namespace
+{
+void buildPath(wchar_t const* front, wchar_t const* back, wchar_t const* path)
{
#if defined(_WIN32)
wchar_t p[MAX_PATH];
- wchar_t * e = tools::buildPath(
- p, front, front + std::wcslen(front), back, std::wcslen(back));
- CPPUNIT_ASSERT_EQUAL(static_cast<void *>(p + std::wcslen(path)), static_cast<void *>(e));
+ wchar_t* e = tools::buildPath(p, front, front + std::wcslen(front), back, std::wcslen(back));
+ CPPUNIT_ASSERT_EQUAL(static_cast<void*>(p + std::wcslen(path)), static_cast<void*>(e));
CPPUNIT_ASSERT_EQUAL(0, std::wcscmp(path, p));
#else
- (void) front;
- (void) back;
- (void) path;
+ (void)front;
+ (void)back;
+ (void)path;
#endif
}
-class Test: public CppUnit::TestFixture {
+class Test : public CppUnit::TestFixture
+{
public:
void testBuildPath();
@@ -51,7 +50,8 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-void Test::testBuildPath() {
+void Test::testBuildPath()
+{
buildPath(L"a:\\b\\", L"..", L"a:\\");
buildPath(L"a:\\b\\", L"..\\", L"a:\\");
buildPath(L"a:\\b\\c\\", L"..\\..\\..\\d", L"a:\\..\\d");
@@ -61,7 +61,6 @@ void Test::testBuildPath() {
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx
index 76ab1827f622..00970e47c792 100644
--- a/tools/qa/cppunit/test_rectangle.cxx
+++ b/tools/qa/cppunit/test_rectangle.cxx
@@ -14,8 +14,7 @@
namespace
{
-
-class Test: public CppUnit::TestFixture
+class Test : public CppUnit::TestFixture
{
public:
void test_rectangle();
@@ -28,7 +27,7 @@ public:
void Test::test_rectangle()
{
{
- tools::Rectangle aRect(1,1,1,1);
+ tools::Rectangle aRect(1, 1, 1, 1);
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth());
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight());
@@ -38,7 +37,7 @@ void Test::test_rectangle()
}
{
- tools::Rectangle aRect(Point(), Size(1,1));
+ tools::Rectangle aRect(Point(), Size(1, 1));
CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Left());
CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Top());
@@ -55,9 +54,7 @@ void Test::test_rectangle()
}
}
-
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/generic/svborder.cxx b/tools/source/generic/svborder.cxx
index 78238b480508..a61c79b0e437 100644
--- a/tools/source/generic/svborder.cxx
+++ b/tools/source/generic/svborder.cxx
@@ -19,16 +19,16 @@
#include <tools/svborder.hxx>
#include <tools/gen.hxx>
-tools::Rectangle & operator += ( tools::Rectangle & rRect, const SvBorder & rBorder )
+tools::Rectangle& operator+=(tools::Rectangle& rRect, const SvBorder& rBorder)
{
// call GetSize first due to Empty-Rect
- Size aS( rRect.GetSize() );
- aS.AdjustWidth(rBorder.Left() + rBorder.Right() );
- aS.AdjustHeight(rBorder.Top() + rBorder.Bottom() );
+ Size aS(rRect.GetSize());
+ aS.AdjustWidth(rBorder.Left() + rBorder.Right());
+ aS.AdjustHeight(rBorder.Top() + rBorder.Bottom());
- rRect.AdjustLeft( -(rBorder.Left()) );
- rRect.AdjustTop( -(rBorder.Top()) );
- rRect.SetSize( aS );
+ rRect.AdjustLeft(-(rBorder.Left()));
+ rRect.AdjustTop(-(rBorder.Top()));
+ rRect.SetSize(aS);
return rRect;
}
diff --git a/tools/source/misc/cpuid.cxx b/tools/source/misc/cpuid.cxx
index e2a8e20a762a..0395d0e0f001 100644
--- a/tools/source/misc/cpuid.cxx
+++ b/tools/source/misc/cpuid.cxx
@@ -11,10 +11,10 @@
#include <tools/cpuid.hxx>
#include <cstdint>
-namespace cpuid {
-
-namespace {
-
+namespace cpuid
+{
+namespace
+{
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
#include <intrin.h>
void getCpuId(uint32_t array[4], uint32_t nInfoType)
@@ -30,7 +30,7 @@ void getCpuId(uint32_t array[4], uint32_t nInfoType)
#else
void getCpuId(uint32_t array[4], uint32_t /*nInfoType*/)
{
- array[0] = array[1] = array[2] = array[3] = 0;
+ array[0] = array[1] = array[2] = array[3] = 0;
}
#endif
@@ -41,7 +41,7 @@ bool checkAVXSupportInOS()
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
xcr0 = uint32_t(_xgetbv(0));
#elif (defined(__i386__) || defined(__x86_64__))
- __asm__("xgetbv" : "=a" (xcr0) : "c" (0) : "%edx");
+ __asm__("xgetbv" : "=a"(xcr0) : "c"(0) : "%edx");
#endif
return ((xcr0 & 6) == 6); /* checking if xmm and ymm state are enabled in XCR0 */
}
@@ -49,25 +49,25 @@ bool checkAVXSupportInOS()
} // end anonymous namespace
#define HYPER_bit (1 << 28)
-#define SSE2_bit (1 << 26)
-#define SSSE3_bit (1 << 9)
+#define SSE2_bit (1 << 26)
+#define SSSE3_bit (1 << 9)
#define SSE41_bit (1 << 19)
#define SSE42_bit (1 << 20)
#define XSAVE_bit (1 << 27)
-#define AVX_bit (1 << 28)
-#define AVX2_bit (1 << 5)
+#define AVX_bit (1 << 28)
+#define AVX2_bit (1 << 5)
InstructionSetFlags getCpuInstructionSetFlags()
{
InstructionSetFlags eInstructions = InstructionSetFlags::NONE;
- uint32_t info[] = {0, 0, 0, 0};
+ uint32_t info[] = { 0, 0, 0, 0 };
getCpuId(info, 0);
int nLevel = info[0];
if (nLevel >= 1)
{
- uint32_t aCpuInfoArray[] = {0, 0, 0, 0};
+ uint32_t aCpuInfoArray[] = { 0, 0, 0, 0 };
getCpuId(aCpuInfoArray, 1);
if ((aCpuInfoArray[3] & HYPER_bit) != 0)
@@ -79,14 +79,13 @@ InstructionSetFlags getCpuInstructionSetFlags()
if ((aCpuInfoArray[2] & SSSE3_bit) != 0)
eInstructions |= InstructionSetFlags::SSSE3;
- if ((aCpuInfoArray[2] & SSE41_bit ) != 0)
+ if ((aCpuInfoArray[2] & SSE41_bit) != 0)
eInstructions |= InstructionSetFlags::SSE41;
if ((aCpuInfoArray[2] & SSE42_bit) != 0)
eInstructions |= InstructionSetFlags::SSE42;
- if (((aCpuInfoArray[2] & AVX_bit) != 0) &&
- ((aCpuInfoArray[2] & XSAVE_bit) != 0))
+ if (((aCpuInfoArray[2] & AVX_bit) != 0) && ((aCpuInfoArray[2] & XSAVE_bit) != 0))
{
if (checkAVXSupportInOS())
{
@@ -94,7 +93,7 @@ InstructionSetFlags getCpuInstructionSetFlags()
if (nLevel >= 7)
{
- uint32_t aExtendedInfo[] = {0, 0, 0, 0};
+ uint32_t aExtendedInfo[] = { 0, 0, 0, 0 };
getCpuId(aExtendedInfo, 7);
if ((aExtendedInfo[1] & AVX2_bit) != 0)
diff --git a/tools/source/misc/extendapplicationenvironment.cxx b/tools/source/misc/extendapplicationenvironment.cxx
index 13171d8e70ff..ce2237a88c70 100644
--- a/tools/source/misc/extendapplicationenvironment.cxx
+++ b/tools/source/misc/extendapplicationenvironment.cxx
@@ -34,13 +34,15 @@
#include <sal/types.h>
#include <tools/extendapplicationenvironment.hxx>
-namespace tools {
-
-void extendApplicationEnvironment() {
+namespace tools
+{
+void extendApplicationEnvironment()
+{
#if defined UNX
// Try to set RLIMIT_NOFILE as large as possible (failure is harmless):
rlimit lim;
- if (getrlimit(RLIMIT_NOFILE, &lim) == 0) {
+ if (getrlimit(RLIMIT_NOFILE, &lim) == 0)
+ {
lim.rlim_cur = lim.rlim_max;
setrlimit(RLIMIT_NOFILE, &lim);
}
@@ -57,12 +59,16 @@ void extendApplicationEnvironment() {
uri = rtl::Bootstrap::encode(uri);
}
env.append(uri);
- } else {
- if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) {
+ }
+ else
+ {
+ if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None)
+ {
abort();
}
sal_Int32 lastDirSeparatorPos = uri.lastIndexOf('/');
- if (lastDirSeparatorPos >= 0) {
+ if (lastDirSeparatorPos >= 0)
+ {
uri = uri.copy(0, lastDirSeparatorPos + 1);
}
env.append(rtl::Bootstrap::encode(uri));
@@ -72,11 +78,11 @@ void extendApplicationEnvironment() {
env.append(SAL_CONFIGFILE("fundamental"));
}
OUString envValue(env.makeStringAndClear());
- if (osl_setEnvironment(envVar.pData, envValue.pData) != osl_Process_E_None) {
+ if (osl_setEnvironment(envVar.pData, envValue.pData) != osl_Process_E_None)
+ {
abort();
}
}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/ref/ref.cxx b/tools/source/ref/ref.cxx
index dbb2122529e1..a84ae45e69a7 100644
--- a/tools/source/ref/ref.cxx
+++ b/tools/source/ref/ref.cxx
@@ -20,13 +20,11 @@
#include <tools/ref.hxx>
#include <tools/weakbase.hxx>
-SvRefBase::~SvRefBase() COVERITY_NOEXCEPT_FALSE
-{
-}
+SvRefBase::~SvRefBase() COVERITY_NOEXCEPT_FALSE {}
tools::WeakBase::~WeakBase()
{
- if( mpWeakConnection.is() )
+ if (mpWeakConnection.is())
mpWeakConnection->mpReference = nullptr;
}