gcc-git: Fix filesystem patch. (#4915)

Signed-off-by: Liu Hao <lh_mouse@126.com>
This commit is contained in:
LH_Mouse
2019-01-29 12:47:05 +08:00
committed by Алексей
parent 87f2a3b372
commit d82844dd33
5 changed files with 75 additions and 116 deletions

View File

@@ -4,7 +4,7 @@ _realname=crt
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-svn")
pkgver=7.0.0.5285.7b2baaf8
pkgver=7.0.0.5297.692b0487
pkgrel=1
pkgdesc='MinGW-w64 CRT for Windows'
arch=('any')

View File

@@ -1,6 +1,6 @@
From 953d61a7250a144603df548e1d80651ea9190f12 Mon Sep 17 00:00:00 2001
From 8e4be0e087603f2a9aa24d9dbbc7aa2c0fdf838a Mon Sep 17 00:00:00 2001
From: Liu Hao <lh_mouse@126.com>
Date: Sat, 23 Jun 2018 17:02:02 +0800
Date: Sat, 26 Jan 2019 15:14:38 +0800
Subject: [PATCH] Backport patches for std::filesystem from master.
This is done by running the following commands on `gcc-8-branch`:
@@ -21,7 +21,7 @@ Signed-off-by: Liu Hao <lh_mouse@126.com>
libstdc++-v3/configure.ac | 2 +
libstdc++-v3/crossconfig.m4 | 1 +
libstdc++-v3/include/bits/fs_dir.h | 5 +-
libstdc++-v3/include/bits/fs_path.h | 251 +++++++++--------
libstdc++-v3/include/bits/fs_path.h | 250 +++++++++--------
libstdc++-v3/include/bits/fstream.tcc | 36 +++
.../include/experimental/bits/fs_path.h | 74 ++---
libstdc++-v3/include/std/fstream | 119 ++++++++
@@ -32,8 +32,8 @@ Signed-off-by: Liu Hao <lh_mouse@126.com>
libstdc++-v3/src/filesystem/path.cc | 24 +-
libstdc++-v3/src/filesystem/std-dir.cc | 5 +-
libstdc++-v3/src/filesystem/std-ops.cc | 260 ++++++++++++------
libstdc++-v3/src/filesystem/std-path.cc | 122 +++++---
19 files changed, 933 insertions(+), 371 deletions(-)
libstdc++-v3/src/filesystem/std-path.cc | 114 +++++---
19 files changed, 926 insertions(+), 369 deletions(-)
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 765cedc6edf..3fb685ce9aa 100644
@@ -248,7 +248,7 @@ index c8c1e5e5bef..6b332e171cf 100644
}
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 51af2891647..e3938d06d59 100644
index fb85d489fd8..e3938d06d59 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -37,11 +37,11 @@
@@ -277,7 +277,17 @@ index 51af2891647..e3938d06d59 100644
template<typename _Iter,
typename _Iter_traits = std::iterator_traits<_Iter>>
@@ -144,7 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -106,8 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _Tp1, typename _Tp2 = void>
using _Path = typename
- std::enable_if<__and_<__not_<is_same<remove_cv_t<_Tp1>, path>>,
- __not_<is_void<_Tp1>>,
+ std::enable_if<__and_<__not_<is_same<_Tp1, path>>,
__constructible_from<_Tp1, _Tp2>>::value,
path>::type;
@@ -145,7 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())),
typename _Val = typename std::iterator_traits<_Iter>::value_type>
using __value_type_is_char
@@ -286,7 +296,7 @@ index 51af2891647..e3938d06d59 100644
public:
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
@@ -230,37 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -231,37 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
// appends
@@ -325,7 +335,7 @@ index 51af2891647..e3938d06d59 100644
template <class _Source>
_Path<_Source>&
@@ -376,7 +348,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -377,7 +348,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
bool has_filename() const;
bool has_stem() const;
bool has_extension() const;
@@ -334,7 +344,7 @@ index 51af2891647..e3938d06d59 100644
bool is_relative() const { return !is_absolute(); }
// generation
@@ -391,6 +363,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -392,6 +363,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
iterator begin() const;
iterator end() const;
@@ -375,7 +385,7 @@ index 51af2891647..e3938d06d59 100644
private:
enum class _Type : unsigned char {
_Multi, _Root_name, _Root_dir, _Filename
@@ -403,19 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -404,19 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
enum class _Split { _Stem, _Extension };
@@ -396,7 +406,7 @@ index 51af2891647..e3938d06d59 100644
pair<const string_type*, size_t> _M_find_extension() const;
@@ -443,11 +437,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -444,11 +437,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
static string_type
_S_convert(_InputIterator __src, __null_terminated)
{
@@ -410,7 +420,7 @@ index 51af2891647..e3938d06d59 100644
}
static string_type
@@ -467,10 +458,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -468,10 +458,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_S_convert_loc(_InputIterator __src, __null_terminated,
const std::locale& __loc)
{
@@ -423,12 +433,8 @@ index 51af2891647..e3938d06d59 100644
}
template<typename _CharT, typename _Traits, typename _Allocator>
@@ -497,28 +486,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
struct _Cmpt;
using _List = _GLIBCXX_STD_C::vector<_Cmpt>;
_List _M_cmpts; // empty unless _M_type == _Type::_Multi
- _Type _M_type = _Type::_Multi;
+ _Type _M_type = _Type::_Filename;
@@ -501,25 +489,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_Type _M_type = _Type::_Filename;
};
- template<>
@@ -453,7 +459,7 @@ index 51af2891647..e3938d06d59 100644
inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
size_t hash_value(const path& __p) noexcept;
@@ -555,58 +525,50 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -556,58 +525,50 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return __result;
}
@@ -544,7 +550,7 @@ index 51af2891647..e3938d06d59 100644
#endif
}
@@ -915,11 +877,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -916,11 +877,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
path::string(const _Allocator& __a) const
{
if constexpr (is_same_v<_CharT, value_type>)
@@ -563,7 +569,7 @@ index 51af2891647..e3938d06d59 100644
else
return _S_str_convert<_CharT, _Traits>(_M_pathname, __a);
}
@@ -1071,12 +1038,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -1072,6 +1038,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return ext.first && ext.second != string_type::npos;
}
@@ -580,14 +586,7 @@ index 51af2891647..e3938d06d59 100644
inline path::iterator
path::begin() const
{
if (_M_type == _Type::_Multi)
return iterator(this, _M_cmpts.begin());
- return iterator(this, false);
+ return iterator(this, empty());
}
inline path::iterator
@@ -1087,6 +1064,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -1088,6 +1064,38 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return iterator(this, true);
}
@@ -674,7 +673,7 @@ index f23ff7af4eb..d9eff00823a 100644
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>::
diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h
index ada7c1791aa..653b4a3fe85 100644
index 088d62f8f43..340cc59d541 100644
--- a/libstdc++-v3/include/experimental/bits/fs_path.h
+++ b/libstdc++-v3/include/experimental/bits/fs_path.h
@@ -79,8 +79,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -691,7 +690,7 @@ index ada7c1791aa..653b4a3fe85 100644
template<typename _Iter,
typename _Iter_traits = std::iterator_traits<_Iter>>
@@ -161,8 +164,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -163,8 +166,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _Tp,
typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())),
typename _Val = typename std::iterator_traits<_Iter>::value_type>
@@ -703,7 +702,7 @@ index ada7c1791aa..653b4a3fe85 100644
public:
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
@@ -368,7 +372,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -370,7 +374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
bool has_filename() const;
bool has_stem() const;
bool has_extension() const;
@@ -712,7 +711,7 @@ index ada7c1791aa..653b4a3fe85 100644
bool is_relative() const { return !is_absolute(); }
// iterators
@@ -378,6 +382,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -380,6 +384,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
iterator begin() const;
iterator end() const;
@@ -733,7 +732,7 @@ index ada7c1791aa..653b4a3fe85 100644
private:
enum class _Type : unsigned char {
_Multi, _Root_name, _Root_dir, _Filename
@@ -427,11 +445,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -429,11 +447,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
static string_type
_S_convert(_InputIterator __src, __null_terminated)
{
@@ -747,7 +746,7 @@ index ada7c1791aa..653b4a3fe85 100644
}
static string_type
@@ -451,10 +466,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -453,10 +468,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_S_convert_loc(_InputIterator __src, __null_terminated,
const std::locale& __loc)
{
@@ -760,7 +759,7 @@ index ada7c1791aa..653b4a3fe85 100644
}
bool _S_is_dir_sep(value_type __ch)
@@ -524,7 +537,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -526,7 +539,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
auto __tmp = __p.string<_CharT, _Traits>();
using __quoted_string
= std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>;
@@ -769,7 +768,7 @@ index ada7c1791aa..653b4a3fe85 100644
return __os;
}
@@ -536,7 +549,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -538,7 +551,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
basic_string<_CharT, _Traits> __tmp;
using __quoted_string
= std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>;
@@ -778,7 +777,7 @@ index ada7c1791aa..653b4a3fe85 100644
__p = std::move(__tmp);
return __is;
}
@@ -594,25 +607,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -596,25 +609,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
std::string _M_what = _M_gen_what();
};
@@ -804,7 +803,7 @@ index ada7c1791aa..653b4a3fe85 100644
struct path::_Cmpt : path
{
_Cmpt(string_type __s, _Type __t, size_t __pos)
@@ -999,6 +993,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -1001,6 +995,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
return ext.first && ext.second != string_type::npos;
}
@@ -2397,7 +2396,7 @@ index 74868cd48e6..e266fa6d3f8 100644
if (ec)
result.clear();
diff --git a/libstdc++-v3/src/filesystem/std-path.cc b/libstdc++-v3/src/filesystem/std-path.cc
index d5016e06138..f6c0b8bb0f6 100644
index b4ab921ff21..f6c0b8bb0f6 100644
--- a/libstdc++-v3/src/filesystem/std-path.cc
+++ b/libstdc++-v3/src/filesystem/std-path.cc
@@ -38,6 +38,66 @@ fs::filesystem_error::~filesystem_error() = default;
@@ -2467,16 +2466,7 @@ index d5016e06138..f6c0b8bb0f6 100644
path&
path::remove_filename()
{
@@ -63,8 +123,6 @@ path::remove_filename()
}
else if (_M_type == _Type::_Filename)
clear();
- if (!empty() && _M_pathname.back() != '/')
- throw 1;
return *this;
}
@@ -76,6 +134,12 @@ path::replace_filename(const path& replacement)
@@ -74,6 +134,12 @@ path::replace_filename(const path& replacement)
return *this;
}
@@ -2489,7 +2479,7 @@ index d5016e06138..f6c0b8bb0f6 100644
path&
path::replace_extension(const path& replacement)
{
@@ -96,8 +160,8 @@ path::replace_extension(const path& replacement)
@@ -94,8 +160,8 @@ path::replace_extension(const path& replacement)
}
// If replacement is not empty and does not begin with a dot character,
// a dot character is appended
@@ -2500,25 +2490,7 @@ index d5016e06138..f6c0b8bb0f6 100644
operator+=(replacement);
return *this;
}
@@ -292,7 +356,7 @@ path::has_root_path() const
bool
path::has_relative_path() const
{
- if (_M_type == _Type::_Filename)
+ if (_M_type == _Type::_Filename && !_M_pathname.empty())
return true;
if (!_M_cmpts.empty())
{
@@ -301,7 +365,7 @@ path::has_relative_path() const
++__it;
if (__it != _M_cmpts.end() && __it->_M_type == _Type::_Root_dir)
++__it;
- if (__it != _M_cmpts.end())
+ if (__it != _M_cmpts.end() && !__it->_M_pathname.empty())
return true;
}
return false;
@@ -334,11 +398,7 @@ path::has_filename() const
@@ -332,11 +398,7 @@ path::has_filename() const
namespace
{
@@ -2531,7 +2503,7 @@ index d5016e06138..f6c0b8bb0f6 100644
inline bool is_dot(const fs::path& path)
{
@@ -378,7 +438,7 @@ path::lexically_normal() const
@@ -376,7 +438,7 @@ path::lexically_normal() const
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
// Replace each slash character in the root-name
@@ -2540,7 +2512,7 @@ index d5016e06138..f6c0b8bb0f6 100644
{
string_type s = p.native();
std::replace(s.begin(), s.end(), L'/', L'\\');
@@ -398,8 +458,7 @@ path::lexically_normal() const
@@ -396,8 +458,7 @@ path::lexically_normal() const
}
else if (!ret.has_relative_path())
{
@@ -2550,28 +2522,42 @@ index d5016e06138..f6c0b8bb0f6 100644
ret /= p;
}
else
@@ -412,18 +471,8 @@ path::lexically_normal() const
@@ -405,30 +466,15 @@ path::lexically_normal() const
// Got a path with a relative path (i.e. at least one non-root
// element) and no filename at the end (i.e. empty last element),
// so must have a trailing slash. See what is before it.
- auto elem = ret._M_cmpts.end() - 2;
+ auto elem = std::prev(ret.end(), 2);
if (elem->has_filename() && !is_dotdot(*elem))
{
// Remove the filename before the trailing slash
// (equiv. to ret = ret.parent_path().remove_filename())
-
- if (elem == ret.begin())
- if (elem == ret._M_cmpts.begin())
- ret.clear();
- else
- {
- ret._M_pathname.erase(elem._M_cur->_M_pos);
- // Do we still have a trailing slash?
- ret._M_pathname.erase(elem->_M_pos);
- // Remove empty filename at the end:
- ret._M_cmpts.pop_back();
- // If we still have a trailing non-root dir separator
- // then leave an empty filename at the end:
- if (std::prev(elem)->_M_type == _Type::_Filename)
- ret._M_cmpts.erase(elem._M_cur);
- else
- ret._M_cmpts.erase(elem._M_cur, ret._M_cmpts.end());
- elem->clear();
- else // remove the component completely:
- ret._M_cmpts.pop_back();
- }
+ ret._M_pathname.erase(elem._M_cur->_M_pos);
+ ret._M_cmpts.erase(elem._M_cur, ret._M_cmpts.end());
}
else // ???
- else
- // Append the ".." to something ending in "../" which happens
- // when normalising paths like ".././.." and "../a/../.."
+ else // ???
ret /= p;
@@ -498,7 +547,7 @@ path::lexically_proximate(const path& base) const
}
}
@@ -501,7 +547,7 @@ path::lexically_proximate(const path& base) const
std::pair<const path::string_type*, std::size_t>
path::_M_find_extension() const
{
@@ -2580,7 +2566,7 @@ index d5016e06138..f6c0b8bb0f6 100644
if (_M_type == _Type::_Filename)
s = &_M_pathname;
@@ -513,9 +562,9 @@ path::_M_find_extension() const
@@ -516,9 +562,9 @@ path::_M_find_extension() const
{
if (auto sz = s->size())
{
@@ -2592,34 +2578,7 @@ index d5016e06138..f6c0b8bb0f6 100644
return { s, pos ? pos : string_type::npos };
}
}
@@ -525,11 +574,13 @@ path::_M_find_extension() const
void
path::_M_split_cmpts()
{
- _M_type = _Type::_Multi;
_M_cmpts.clear();
-
if (_M_pathname.empty())
- return;
+ {
+ _M_type = _Type::_Filename;
+ return;
+ }
+ _M_type = _Type::_Multi;
size_t pos = 0;
const size_t len = _M_pathname.size();
@@ -604,8 +655,7 @@ path::_M_split_cmpts()
// An empty element, if trailing non-root directory-separator present.
if (_M_cmpts.back()._M_type == _Type::_Filename)
{
- const auto& last = _M_cmpts.back();
- pos = last._M_pos + last._M_pathname.size();
+ pos = _M_pathname.size();
_M_cmpts.emplace_back(string_type(), _Type::_Filename, pos);
}
}
@@ -715,8 +765,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
@@ -719,8 +765,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
std::string filesystem_error::_M_gen_what()
{
@@ -2631,5 +2590,5 @@ index d5016e06138..f6c0b8bb0f6 100644
_GLIBCXX_END_NAMESPACE_CXX11
--
2.18.0
2.20.1

View File

@@ -70,7 +70,7 @@ sha256sums=('SKIP'
'c1e271c166de0062092cb61d50977c0e61d75b0ae6fb086cb8bb4da2b3fd18d7'
'b1c3c20bf501cebbcb02b4a50f117a4f90eb4fb79eac7aa99c85e2c54c106790'
'33392651e17b81609718873ff32606deee5f3fc5176c197bb96eedc3dada8912'
'b3a02a35e5e9fce937bf7a617fe56b16d36cfe2184becb481a87f511ce292e85')
'd03aef0d25cc922dd388e31424a88f92ac1b83ad05d92a700e3b9f7220da17c2')
_threads="posix"

View File

@@ -5,7 +5,7 @@ pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-svn")
pkgdesc="MinGW-w64 headers for Windows"
pkgver=7.0.0.5285.7b2baaf8
pkgver=7.0.0.5297.692b0487
pkgrel=1
arch=('any')
url="https://mingw-w64.sourceforge.io/"

View File

@@ -4,7 +4,7 @@ _realname=mcfgthread
pkgbase=mingw-w64-${_realname}-git
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-${_realname}"-libs)
pkgver=r250.9aa34c3
pkgver=r521.9570e5c
pkgrel=1
pkgdesc="An efficient Gthread implementation for GCC MinGW-w64 targets on Windows, providing both C11 and C++11 thread support"
arch=('any')