[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 2be5478 27/28: Preserve NUL characters in fs:
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 2be5478 27/28: Preserve NUL characters in fs::path::string() |
Date: |
Wed, 12 May 2021 18:14:47 -0400 (EDT) |
branch: master
commit 2be5478c88b07c3eb5d41c26660595dc3965e7a5
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Preserve NUL characters in fs::path::string()
Even though NULs are forbidden in the file paths, std::filesystem::path
doesn't discard them and returns them as part of std::[u8]strings that
it returns, so do likewise rather than truncating the string at the
first NUL appearing in it.
Note that this doesn't affect test_path_validation() since the changes
of the previous commit, but would have broken it for C++20 compilers
with char8_t support without them (previously the test was broken only
for the compilers without char8_t support).
---
path.hpp | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/path.hpp b/path.hpp
index 71f334d..38177f2 100644
--- a/path.hpp
+++ b/path.hpp
@@ -355,11 +355,7 @@ class path
// of char pointers that can be used to iterate over any buffer and
// that u8string contents can always be stored in string (unlike vice
// versa).
- //
- // Also note that the input string can't contain embedded NULs here, as
- // they're not allowed in file paths, hence there is no need to use
- // size.
- return reinterpret_cast<char const*>(s8.c_str());
+ return std::string{reinterpret_cast<char const*>(s8.c_str()),
s8.size()};
}
#endif // defined __cpp_char8_t
- [lmi-commits] [lmi] master d09dfce 17/28: Merge lmi directories creation step with the system setup one, (continued)
- [lmi-commits] [lmi] master d09dfce 17/28: Merge lmi directories creation step with the system setup one, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 95c9f72 08/28: Use Debian Wine version in CI job, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 4a1c735 19/28: Rename CI job and build names for brevity and consistency, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master e46db7c 21/28: Work around std::allocator::size_type problem in clang 11 libc++, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 4a09a23 09/28: Work around JRE installation problem in Debian slim container, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 21706da 25/28: Fix expression_template_0_test compilation with clang 12, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master c4a85fc 06/28: Install the required packages before checkout in the CI job, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 5d5054f 18/28: Use correct permissions for the Git checkout, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 3a89381 24/28: Create /tmp/.X11-unix directory before running Xvfb, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 5c2b93a 23/28: Install x11-xserver-utils package to get xset, Greg Chicares, 2021/05/12
- [lmi-commits] [lmi] master 2be5478 27/28: Preserve NUL characters in fs::path::string(),
Greg Chicares <=