From 13209c3183733cf1f9726ff16a019afd54dac289 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sat, 20 Jul 2019 13:10:53 +0000 Subject: [PATCH] Revert 09916ce6cb which broken jenkins build. This was SVN commit r22519. --- source/lib/scoped_locale.h | 43 -------------------------------- source/ps/tests/test_CStr.h | 5 ++-- source/ps/tests/test_cppformat.h | 5 ++-- 3 files changed, 6 insertions(+), 47 deletions(-) delete mode 100755 source/lib/scoped_locale.h diff --git a/source/lib/scoped_locale.h b/source/lib/scoped_locale.h deleted file mode 100755 index 1f1a0076f5..0000000000 --- a/source/lib/scoped_locale.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2019 Wildfire Games. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef INCLUDED_SCOPED_LOCALE -#define INCLUDED_SCOPED_LOCALE - -class ScopedLocale -{ -public: - ScopedLocale(int category, char* newLocale) : m_Category(category) - { - m_OldLocale = setlocale(category, nullptr); - TS_ASSERT(setlocale(m_Category, newLocale) != nullptr); - } - ~ScopedLocale() - { - TS_ASSERT(setlocale(m_Category, m_OldLocale)); - } -private: - int m_Category; - char* m_OldLocale; -}; - -#endif // #ifndef INCLUDED_SCOPED_LOCALE diff --git a/source/ps/tests/test_CStr.h b/source/ps/tests/test_CStr.h index d362371749..4e7562ec20 100644 --- a/source/ps/tests/test_CStr.h +++ b/source/ps/tests/test_CStr.h @@ -16,7 +16,6 @@ */ #include "lib/self_test.h" -#include "lib/scoped_locale.h" #include "ps/CStr.h" @@ -114,7 +113,7 @@ public: // because GTK+ can change the locale when we're running Atlas. // (If the host system doesn't have the locale we're using for this test // then it'll just stick with the default, which is fine) - ScopedLocale(LC_NUMERIC, "en_US.UTF-8"); + char* old = setlocale(LC_NUMERIC, "fr_FR.UTF-8"); CStr8 str1("1.234"); TS_ASSERT_DELTA(str1.ToFloat(), 1.234f, 0.0001f); @@ -139,5 +138,7 @@ public: TS_ASSERT_EQUALS(str3.ToUInt(), 3u); TS_ASSERT_EQUALS(str3.ToLong(), 3); TS_ASSERT_EQUALS(str3.ToULong(), 3u); + + setlocale(LC_NUMERIC, old); } }; diff --git a/source/ps/tests/test_cppformat.h b/source/ps/tests/test_cppformat.h index d799574aa2..df2e2f8380 100644 --- a/source/ps/tests/test_cppformat.h +++ b/source/ps/tests/test_cppformat.h @@ -16,7 +16,6 @@ */ #include "lib/self_test.h" -#include "lib/scoped_locale.h" #include "third_party/cppformat/format.h" @@ -26,7 +25,7 @@ public: void test_basic() { // Make test behave independent of current host locale - ScopedLocale(LC_ALL, "en_US.UTF-8"); + char* old = setlocale(LC_ALL, "en_US.UTF-8"); TS_ASSERT_EQUALS(fmt::sprintf("abc"), "abc"); @@ -58,5 +57,7 @@ public: TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)NULL), "T(null)T"); TS_ASSERT_EQUALS(fmt::sprintf("T%pT", (void*)0x1234), "T0x1234T"); + + setlocale(LC_ALL, old); } };