aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2019-02-08 20:30:00 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2019-02-08 20:30:00 +0000
commitcba6449c786df4bf1df235a4420dcd8d964af98e (patch)
tree2861c9046f15f0279707f8d5810a126d7e65750c
parent4da5f970124d55511ab4db167ff9a14ed760a15e (diff)
Backport small improvement to filesystem::absolute
* src/c++17/fs_ops.cc (absolute(const path&, error_code&)): Do nothing if the path is already absolute. [!_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Pass error_code to current_path. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@268707 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog4
-rw-r--r--libstdc++-v3/src/filesystem/std-ops.cc10
2 files changed, 12 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 45f1c95d29d..0c7657029ac 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,9 @@
2019-02-08 Jonathan Wakely <jwakely@redhat.com>
+ * src/c++17/fs_ops.cc (absolute(const path&, error_code&)): Do nothing
+ if the path is already absolute.
+ [!_GLIBCXX_FILESYSTEM_IS_WINDOWS]: Pass error_code to current_path.
+
Backport from mainline
2019-01-11 Jonathan Wakely <jwakely@redhat.com>
diff --git a/libstdc++-v3/src/filesystem/std-ops.cc b/libstdc++-v3/src/filesystem/std-ops.cc
index a08380056b2..c0742d73b5c 100644
--- a/libstdc++-v3/src/filesystem/std-ops.cc
+++ b/libstdc++-v3/src/filesystem/std-ops.cc
@@ -90,11 +90,17 @@ fs::absolute(const path& p, error_code& ec)
ec = make_error_code(std::errc::no_such_file_or_directory);
return ret;
}
+ if (p.is_absolute())
+ {
+ ec.clear();
+ ret = p;
+ return ret;
+ }
+
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
ec = std::make_error_code(errc::not_supported);
#else
- ec.clear();
- ret = current_path();
+ ret = current_path(ec);
ret /= p;
#endif
return ret;