]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / locale / cons / 5.cc
index 9cc54614dca2eb684116cdc59a18fd5950c1ab30..cb13b8eeeecb9115103134ef2d3ab10cf45a7e90 100644 (file)
@@ -1,13 +1,17 @@
-// { dg-require-namedlocale "" }
+// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_PH" }
+// { dg-require-namedlocale "es_MX" }
+// { dg-require-namedlocale "fr_FR" }
+// { dg-require-namedlocale "it_IT" }
 
 // 2000-09-13 Benjamin Kosnik <bkoz@redhat.com>
 
-// Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation
+// Copyright (C) 2000-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 // terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
+// Free Software Foundation; either version 3, or (at your option)
 // any later version.
 
 // This library is distributed in the hope that it will be useful,
 // GNU General Public License for more details.
 
 // You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
 
 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
 
 #include <cwchar> // for mbstate_t
+#include <cstring>
+#include <cstdlib>
 #include <locale>
 #include <stdexcept>
 #include <testsuite_hooks.h>
 // More tests for locale("") == POSIX locale::name. 
 void test04()
 {
-  bool test __attribute__((unused)) = true;
   using namespace std;
 
 #ifdef _GLIBCXX_HAVE_SETENV
 
-  const char* LANG_orig = getenv("LANG") ? strdup(getenv("LANG")) : "";
-  const char* LC_ALL_orig = getenv("LC_ALL") ? strdup(getenv("LC_ALL")) : "";
-  const char* LC_CTYPE_orig = 
-    getenv("LC_CTYPE") ? strdup(getenv("LC_CTYPE")) : "";
-  const char* LC_NUMERIC_orig = 
-    getenv("LC_NUMERIC") ? strdup(getenv("LC_NUMERIC")) : "";
-  const char* LC_TIME_orig = 
-    getenv("LC_TIME") ? strdup(getenv("LC_TIME")) : "";
-  const char* LC_COLLATE_orig =
-    getenv("LC_COLLATE") ? strdup(getenv("LC_COLLATE")) : "";
-  const char* LC_MONETARY_orig = 
-    getenv("LC_MONETARY") ? strdup(getenv("LC_MONETARY")) : "";
-  const char* LC_MESSAGES_orig = 
-    getenv("LC_MESSAGES") ? strdup(getenv("LC_MESSAGES")) : "";
-#if _GLIBCXX_NUM_CATEGORIES
-  const char* LC_PAPER_orig = 
-    getenv("LC_PAPER") ? strdup(getenv("LC_PAPER")) : "";
-  const char* LC_NAME_orig = 
-    getenv("LC_NAME") ? strdup(getenv("LC_NAME")) : "";
-  const char* LC_ADDRESS_orig = 
-    getenv("LC_ADDRESS") ? strdup(getenv("LC_ADDRESS")) : "";
-  const char* LC_TELEPHONE_orig = 
-    getenv("LC_TELEPHONE") ? strdup(getenv("LC_TELEPHONE")) : "";
-  const char* LC_MEASUREMENT_orig = 
-    getenv("LC_MEASUREMENT") ? strdup(getenv("LC_MEASUREMENT")) : "";
-  const char* LC_IDENTIFICATION_orig =
-    getenv("LC_IDENTIFICATION") ? strdup(getenv("LC_IDENTIFICATION")) : "";
-#endif
+  char* LANG_orig = strdup(getenv("LANG") ? getenv("LANG") : "");
 
   // Check that a "POSIX" LC_ALL is equivalent to "C".
   if (!setenv("LC_ALL", "POSIX", 1))
@@ -89,12 +66,11 @@ void test04()
          VERIFY( loc.name() == "en_PH" );
        }
       setenv("LC_ALL", "", 1);
-      setenv("LANG", LANG_orig ? LANG_orig : "", 1);
-      setenv("LC_COLLATE", LC_COLLATE_orig ? LC_COLLATE_orig : "", 1);
+      setenv("LANG", LANG_orig, 1);
     }
 
   // NB: LANG checks all LC_* macro settings. As such, all LC_* macros
-  // must be cleared for these tests, and then restored.
+  // must be cleared for these tests.
   setenv("LC_ALL", "", 1);
   setenv("LC_CTYPE", "", 1);
   setenv("LC_NUMERIC", "", 1);
@@ -171,26 +147,9 @@ void test04()
     }
 #endif
 
-  // Restore the environment.
-  setenv("LANG", LANG_orig ? LANG_orig : "", 1);
-  setenv("LC_ALL", LC_ALL_orig ? LC_ALL_orig : "", 1);
-  setenv("LC_CTYPE", LC_CTYPE_orig ? LC_CTYPE_orig : "", 1);
-  setenv("LC_NUMERIC", LC_NUMERIC_orig ? LC_NUMERIC_orig : "", 1);
-  setenv("LC_TIME", LC_TIME_orig ? LC_TIME_orig : "", 1);
-  setenv("LC_COLLATE", LC_COLLATE_orig ? LC_COLLATE_orig : "", 1);
-  setenv("LC_MONETARY", LC_MONETARY_orig ? LC_MONETARY_orig : "", 1);
-  setenv("LC_MESSAGES", LC_MESSAGES_orig ? LC_MESSAGES_orig : "", 1);
-#if _GLIBCXX_NUM_CATEGORIES
-  setenv("LC_PAPER", LC_PAPER_orig ? LC_PAPER_orig : "", 1);
-  setenv("LC_NAME", LC_NAME_orig ? LC_NAME_orig : "", 1);
-  setenv("LC_ADDRESS", LC_ADDRESS_orig ? LC_ADDRESS_orig : "", 1);
-  setenv("LC_TELEPHONE", LC_TELEPHONE_orig ? LC_TELEPHONE_orig : "", 1);
-  setenv("LC_MEASUREMENT", LC_MEASUREMENT_orig ? LC_MEASUREMENT_orig : "", 1);
-  setenv("LC_IDENTIFICATION", 
-         LC_IDENTIFICATION_orig ? LC_IDENTIFICATION_orig : "", 1);
-#endif
+  free(LANG_orig);
 
-#endif
+#endif // _GLIBCXX_HAVE_SETENV
 }
 
 int main()