From: Matthias Maennich Date: Fri, 5 Jul 2019 09:10:37 +0000 (+0100) Subject: Drop requirement to compile with GNU extensions X-Git-Tag: upstream/1.7~69 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42cd02a9be1bfd871557be5edd40b637a70a0e11;p=platform%2Fupstream%2Flibabigail.git Drop requirement to compile with GNU extensions __gnu_cxx::stdio_filebuf is a GNU extension only available in certain std libraries. It is not e.g. in libc++. In order to be able to compile with using libc++, replace the usage of __gnu_cxx::stdio_filebuf with standard C++ methods. In this case, reopen the temporary file with a std::fstream and expose that stream rather than the previously exposed std::iostream. * include/abg-tools-utils.h (get_stream): Change return type to std::fstream * src/abg-corpus.cc: remove unused #include of ext/stdio_filebuf.h * src/abg-tools-utils (temp_file::priv): remove filebuf_ member, and replace iostream_ by fstream_ with changing the shared_ptr type accordingly (temp_file::priv::priv): initialize fstream_ based on temporary file name (temp_file::priv::~priv): adjust destruction accordingly (temp_file::is_good): test the fstream rather than the fd (temp_file::get_stream): adjust return type to std::fstream and adjust implementation based on the changes in temp_file::priv * src/Makefile.am: remove gnu extension from c++ standard flag * tests/Makefile.am: likewise Signed-off-by: Matthias Maennich Signed-off-by: Dodji Seketeli --- diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index 3eb71cb7..a014e85a 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -129,7 +129,7 @@ typedef shared_ptr temp_file_sptr; /// This is a helper file around the mkstemp API. /// /// Once the temporary file is created, users can interact with it -/// using an iostream. They can also get the path to the newly +/// using an fstream. They can also get the path to the newly /// created temporary file. /// /// When the instance of @ref temp_file is destroyed, the underlying @@ -152,7 +152,7 @@ public: const char* get_path() const; - std::iostream& + std::fstream& get_stream(); static temp_file_sptr diff --git a/src/Makefile.am b/src/Makefile.am index 9fd74e21..7c02d538 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,7 @@ if ENABLE_CXX11 CXX11_SOURCES = abg-viz-common.cc \ abg-viz-dot.cc \ abg-viz-svg.cc -AM_CXXFLAGS += "-std=gnu++11" +AM_CXXFLAGS += "-std=c++11" else CXX11_SOURCES = endif diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 7d164bdc..0b1ebf6e 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 1605245e..87a79c08 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -42,7 +42,6 @@ #include #include #include -#include // For __gnu_cxx::stdio_filebuf // If fts.h is included before config.h, its indirect inclusions may // not give us the right LFS aliases of these functions, so map them // manually. @@ -1071,10 +1070,9 @@ convert_char_stars_to_char_star_stars(const vector &char_stars, /// The private data of the @ref temp_file type. struct temp_file::priv { - char* path_template_; - int fd_; - shared_ptr<__gnu_cxx::stdio_filebuf > filebuf_; - shared_ptr iostream_; + char* path_template_; + int fd_; + shared_ptr fstream_; priv() { @@ -1088,18 +1086,17 @@ struct temp_file::priv if (fd_ == -1) return; - using __gnu_cxx::stdio_filebuf; - filebuf_.reset(new stdio_filebuf(fd_, - std::ios::in | std::ios::out)); - iostream_.reset(new std::iostream(filebuf_.get())); + fstream_.reset(new std::fstream(path_template_, + std::ios::trunc + | std::ios::in + | std::ios::out)); } ~priv() { if (fd_ && fd_ != -1) { - iostream_.reset(); - filebuf_.reset(); + fstream_.reset(); close(fd_); remove(path_template_); } @@ -1120,7 +1117,7 @@ temp_file::temp_file() /// useable. bool temp_file::is_good() const -{return (priv_->fd_ && priv_->fd_ != -1);} +{return priv_->fstream_->good();} /// Return the path to the temporary file. /// @@ -1135,19 +1132,19 @@ temp_file::get_path() const return 0; } -/// Get the iostream to the temporary file. +/// Get the fstream to the temporary file. /// /// Note that the current process is aborted if this member function /// is invoked on an instance of @ref temp_file that is not usable. /// So please test that the instance is usable by invoking the /// temp_file::is_good() member function on it first. /// -/// @return the iostream to the temporary file. -std::iostream& +/// @return the fstream to the temporary file. +std::fstream& temp_file::get_stream() { ABG_ASSERT(is_good()); - return *priv_->iostream_; + return *priv_->fstream_; } /// Create the temporary file and return it if it's usable. diff --git a/tests/Makefile.am b/tests/Makefile.am index 544aa193..2104300a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,7 +13,7 @@ AM_CXXFLAGS = $(VISIBILITY_FLAGS) CXX11_TESTS = if ENABLE_CXX11 CXX11_TESTS += runtestsvg -AM_CXXFLAGS += "-std=gnu++11" +AM_CXXFLAGS += "-std=c++11" endif FEDABIPKGDIFF_TEST =