Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/kyua-cli kyua-cli: convert auto_ptr to unique_ptr



details:   https://anonhg.NetBSD.org/src/rev/02b0856e6a77
branches:  trunk
changeset: 973484:02b0856e6a77
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jul 02 14:04:00 2020 +0000

description:
kyua-cli: convert auto_ptr to unique_ptr

Update kyua-cli to C++11 and use unique_ptr instead of auto_ptr,
(with std::move() where appropriate), to avoid deprecated warning by g++ 8.

(I didn't change some of the code that could arguably be refactored
to use unique_ptr or shared_ptr instead of raw pointers
and therefore remove the special case destructor handling).

diffstat:

 external/bsd/kyua-cli/Makefile.inc                           |   5 +-
 external/bsd/kyua-cli/dist/cli/cmd_report.hpp                |   2 +-
 external/bsd/kyua-cli/dist/cli/common.hpp                    |   2 +-
 external/bsd/kyua-cli/dist/cli/main.cpp                      |   4 +-
 external/bsd/kyua-cli/dist/engine/config.cpp                 |   2 +-
 external/bsd/kyua-cli/dist/engine/metadata.cpp               |   8 +-
 external/bsd/kyua-cli/dist/engine/metadata.hpp               |   2 +-
 external/bsd/kyua-cli/dist/engine/testers.cpp                |   4 +-
 external/bsd/kyua-cli/dist/utils/cmdline/commands_map.hpp    |   2 +-
 external/bsd/kyua-cli/dist/utils/config/lua_module_test.cpp  |   2 +-
 external/bsd/kyua-cli/dist/utils/config/nodes.cpp            |  12 ++--
 external/bsd/kyua-cli/dist/utils/config/parser.hpp           |   2 +-
 external/bsd/kyua-cli/dist/utils/config/tree_test.cpp        |   2 +-
 external/bsd/kyua-cli/dist/utils/format/formatter.cpp        |   2 +-
 external/bsd/kyua-cli/dist/utils/logging/operations.cpp      |   2 +-
 external/bsd/kyua-cli/dist/utils/process/child.cpp           |  26 ++++----
 external/bsd/kyua-cli/dist/utils/process/child.hpp           |  14 ++--
 external/bsd/kyua-cli/dist/utils/process/child.ipp           |   8 +-
 external/bsd/kyua-cli/dist/utils/process/child_test.cpp      |  36 ++++++------
 external/bsd/kyua-cli/dist/utils/process/fdstream.hpp        |   2 +-
 external/bsd/kyua-cli/dist/utils/process/systembuf.hpp       |   2 +-
 external/bsd/kyua-cli/dist/utils/signals/interrupts.cpp      |  18 +++---
 external/bsd/kyua-cli/dist/utils/signals/interrupts_test.cpp |   4 +-
 external/bsd/kyua-cli/dist/utils/signals/misc_test.cpp       |   2 +-
 external/bsd/kyua-cli/dist/utils/signals/programmer.hpp      |   2 +-
 25 files changed, 82 insertions(+), 85 deletions(-)

diffs (truncated from 723 to 300 lines):

diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/Makefile.inc
--- a/external/bsd/kyua-cli/Makefile.inc        Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/Makefile.inc        Thu Jul 02 14:04:00 2020 +0000
@@ -1,13 +1,10 @@
-# $NetBSD: Makefile.inc,v 1.5 2020/06/21 14:26:16 lukem Exp $
+# $NetBSD: Makefile.inc,v 1.6 2020/07/02 14:04:00 lukem Exp $
 
 .include <bsd.own.mk>
 
 TOPDIR=                ${NETBSDSRCDIR}/external/bsd/kyua-cli
 SRCDIR=                ${TOPDIR}/dist
 
-# Kyua uses auto_ptr; g++ 8 complains about it
-CXXFLAGS+=     -Wno-deprecated-declarations
-
 # Name of the private libraries (without their lib prefix) to depend on.
 KYUA_LIBS?=
 
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/cli/cmd_report.hpp
--- a/external/bsd/kyua-cli/dist/cli/cmd_report.hpp     Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/cli/cmd_report.hpp     Thu Jul 02 14:04:00 2020 +0000
@@ -63,7 +63,7 @@
     const utils::fs::path _output_path;
 
     /// The output file, if not stdout nor stderr.
-    std::auto_ptr< std::ofstream > _output_file;
+    std::unique_ptr< std::ofstream > _output_file;
 
     /// Constant that represents the path to stdout.
     static const utils::fs::path _stdout_path;
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/cli/common.hpp
--- a/external/bsd/kyua-cli/dist/cli/common.hpp Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/cli/common.hpp Thu Jul 02 14:04:00 2020 +0000
@@ -76,7 +76,7 @@
 
 
 /// Scoped, strictly owned pointer to a cli_command.
-typedef std::auto_ptr< cli_command > cli_command_ptr;
+typedef std::unique_ptr< cli_command > cli_command_ptr;
 
 
 /// Collection of result types.
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/cli/main.cpp
--- a/external/bsd/kyua-cli/dist/cli/main.cpp   Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/cli/main.cpp   Thu Jul 02 14:04:00 2020 +0000
@@ -171,7 +171,7 @@
     commands.insert(new cli::cmd_report_html(), "Reporting");
 
     if (mock_command.get() != NULL)
-        commands.insert(mock_command);
+        commands.insert(std::move(mock_command));
 
     const cmdline::parsed_cmdline cmdline = cmdline::parse(argc, argv, options);
 
@@ -249,7 +249,7 @@
           cli_command_ptr mock_command)
 {
     try {
-        const int exit_code = safe_main(ui, argc, argv, mock_command);
+        const int exit_code = safe_main(ui, argc, argv, std::move(mock_command));
 
         // Codes above 1 are reserved to report conditions captured as
         // exceptions below.
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/engine/config.cpp
--- a/external/bsd/kyua-cli/dist/engine/config.cpp      Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/engine/config.cpp      Thu Jul 02 14:04:00 2020 +0000
@@ -125,7 +125,7 @@
 config::detail::base_node*
 engine::user_node::deep_copy(void) const
 {
-    std::auto_ptr< user_node > new_node(new user_node());
+    std::unique_ptr< user_node > new_node(new user_node());
     new_node->_value = _value;
     return new_node.release();
 }
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/engine/metadata.cpp
--- a/external/bsd/kyua-cli/dist/engine/metadata.cpp    Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/engine/metadata.cpp    Thu Jul 02 14:04:00 2020 +0000
@@ -72,7 +72,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< bytes_node > new_node(new bytes_node());
+        std::unique_ptr< bytes_node > new_node(new bytes_node());
         new_node->_value = _value;
         return new_node.release();
     }
@@ -108,7 +108,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< delta_node > new_node(new delta_node());
+        std::unique_ptr< delta_node > new_node(new delta_node());
         new_node->_value = _value;
         return new_node.release();
     }
@@ -174,7 +174,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< user_node > new_node(new user_node());
+        std::unique_ptr< user_node > new_node(new user_node());
         new_node->_value = _value;
         return new_node.release();
     }
@@ -205,7 +205,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< paths_set_node > new_node(new paths_set_node());
+        std::unique_ptr< paths_set_node > new_node(new paths_set_node());
         new_node->_value = _value;
         return new_node.release();
     }
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/engine/metadata.hpp
--- a/external/bsd/kyua-cli/dist/engine/metadata.hpp    Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/engine/metadata.hpp    Thu Jul 02 14:04:00 2020 +0000
@@ -107,7 +107,7 @@
     struct impl;
 
     /// Pointer to the shared internal implementation.
-    std::auto_ptr< impl > _pimpl;
+    std::unique_ptr< impl > _pimpl;
 
 public:
     metadata_builder(void);
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/engine/testers.cpp
--- a/external/bsd/kyua-cli/dist/engine/testers.cpp     Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/engine/testers.cpp     Thu Jul 02 14:04:00 2020 +0000
@@ -247,7 +247,7 @@
     args.push_back(program.str());
 
     const fs::path tester_path = engine::tester_path(_interface);
-    std::auto_ptr< process::child > child = process::child::spawn_capture(
+    std::unique_ptr< process::child > child = process::child::spawn_capture(
         tester_path, args);
 
     const std::string output = utils::read_stream(child->output());
@@ -288,7 +288,7 @@
     args.push_back(result_file.str());
 
     const fs::path tester_path = engine::tester_path(_interface);
-    std::auto_ptr< process::child > child = process::child::spawn_files(
+    std::unique_ptr< process::child > child = process::child::spawn_files(
         tester_path, args, stdout_file, stderr_file);
     const process::status status = child->wait();
 
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/cmdline/commands_map.hpp
--- a/external/bsd/kyua-cli/dist/utils/cmdline/commands_map.hpp Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/cmdline/commands_map.hpp Thu Jul 02 14:04:00 2020 +0000
@@ -70,7 +70,7 @@
     ~commands_map(void);
 
     /// Scoped, strictly-owned pointer to a command from this map.
-    typedef typename std::auto_ptr< BaseCommand > command_ptr;
+    typedef typename std::unique_ptr< BaseCommand > command_ptr;
     void insert(command_ptr, const std::string& = "");
     void insert(BaseCommand*, const std::string& = "");
 
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/config/lua_module_test.cpp
--- a/external/bsd/kyua-cli/dist/utils/config/lua_module_test.cpp       Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/config/lua_module_test.cpp       Thu Jul 02 14:04:00 2020 +0000
@@ -67,7 +67,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< custom_node > new_node(new custom_node());
+        std::unique_ptr< custom_node > new_node(new custom_node());
         new_node->_value = _value;
         return new_node.release();
     }
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/config/nodes.cpp
--- a/external/bsd/kyua-cli/dist/utils/config/nodes.cpp Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/config/nodes.cpp Thu Jul 02 14:04:00 2020 +0000
@@ -223,7 +223,7 @@
 config::detail::base_node*
 config::detail::static_inner_node::deep_copy(void) const
 {
-    std::auto_ptr< inner_node > new_node(new static_inner_node());
+    std::unique_ptr< inner_node > new_node(new static_inner_node());
     copy_into(new_node.get());
     return new_node.release();
 }
@@ -286,7 +286,7 @@
 config::detail::base_node*
 config::detail::dynamic_inner_node::deep_copy(void) const
 {
-    std::auto_ptr< inner_node > new_node(new dynamic_inner_node());
+    std::unique_ptr< inner_node > new_node(new dynamic_inner_node());
     copy_into(new_node.get());
     return new_node.release();
 }
@@ -304,7 +304,7 @@
 config::detail::base_node*
 config::bool_node::deep_copy(void) const
 {
-    std::auto_ptr< bool_node > new_node(new bool_node());
+    std::unique_ptr< bool_node > new_node(new bool_node());
     new_node->_value = _value;
     return new_node.release();
 }
@@ -343,7 +343,7 @@
 config::detail::base_node*
 config::int_node::deep_copy(void) const
 {
-    std::auto_ptr< int_node > new_node(new int_node());
+    std::unique_ptr< int_node > new_node(new int_node());
     new_node->_value = _value;
     return new_node.release();
 }
@@ -382,7 +382,7 @@
 config::detail::base_node*
 config::string_node::deep_copy(void) const
 {
-    std::auto_ptr< string_node > new_node(new string_node());
+    std::unique_ptr< string_node > new_node(new string_node());
     new_node->_value = _value;
     return new_node.release();
 }
@@ -421,7 +421,7 @@
 config::detail::base_node*
 config::strings_set_node::deep_copy(void) const
 {
-    std::auto_ptr< strings_set_node > new_node(new strings_set_node());
+    std::unique_ptr< strings_set_node > new_node(new strings_set_node());
     new_node->_value = _value;
     return new_node.release();
 }
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/config/parser.hpp
--- a/external/bsd/kyua-cli/dist/utils/config/parser.hpp        Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/config/parser.hpp        Thu Jul 02 14:04:00 2020 +0000
@@ -66,7 +66,7 @@
 
 private:
     /// Pointer to the internal implementation.
-    std::auto_ptr< impl > _pimpl;
+    std::unique_ptr< impl > _pimpl;
 
     /// Hook to initialize the tree keys before reading the file.
     ///
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/config/tree_test.cpp
--- a/external/bsd/kyua-cli/dist/utils/config/tree_test.cpp     Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/config/tree_test.cpp     Thu Jul 02 14:04:00 2020 +0000
@@ -76,7 +76,7 @@
     virtual base_node*
     deep_copy(void) const
     {
-        std::auto_ptr< wrapped_int_node > new_node(new wrapped_int_node());
+        std::unique_ptr< wrapped_int_node > new_node(new wrapped_int_node());
         new_node->_value = _value;
         return new_node.release();
     }
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/format/formatter.cpp
--- a/external/bsd/kyua-cli/dist/utils/format/formatter.cpp     Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/format/formatter.cpp     Thu Jul 02 14:04:00 2020 +0000
@@ -118,7 +118,7 @@
 static std::ostringstream*
 new_ostringstream(const std::string& format)
 {
-    std::auto_ptr< std::ostringstream > output(new std::ostringstream());
+    std::unique_ptr< std::ostringstream > output(new std::ostringstream());
 
     if (format.length() <= 2) {
         // If the format is empty, we create a new stream so that we don't have
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/logging/operations.cpp
--- a/external/bsd/kyua-cli/dist/utils/logging/operations.cpp   Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/logging/operations.cpp   Thu Jul 02 14:04:00 2020 +0000
@@ -96,7 +96,7 @@
 
 
 /// Stream to the currently open log file.
-static std::auto_ptr< std::ofstream > logfile;
+static std::unique_ptr< std::ofstream > logfile;
 
 
 /// Constant string to strftime to format timestamps.
diff -r 7db3e2d81701 -r 02b0856e6a77 external/bsd/kyua-cli/dist/utils/process/child.cpp
--- a/external/bsd/kyua-cli/dist/utils/process/child.cpp        Thu Jul 02 14:02:04 2020 +0000
+++ b/external/bsd/kyua-cli/dist/utils/process/child.cpp        Thu Jul 02 14:04:00 2020 +0000
@@ -65,7 +65,7 @@
     pid_t _pid;
 
     /// The input stream for the process' stdout and stderr.  May be NULL.
-    std::auto_ptr< process::ifdstream > _output;
+    std::unique_ptr< process::ifdstream > _output;
 
     /// Initializes private implementation data.
     ///
@@ -252,7 +252,7 @@
 /// noncopyable.  In the case of the child, a NULL pointer.
 ///
 /// \throw process::system_error If the calls to pipe(2) or fork(2) fail.
-std::auto_ptr< process::child >
+std::unique_ptr< process::child >
 process::child::fork_capture_aux(void)
 {
     std::cout.flush();
@@ -262,7 +262,7 @@
     if (detail::syscall_pipe(fds) == -1)
         throw process::system_error("pipe(2) failed", errno);



Home | Main Index | Thread Index | Old Index