Skip to content

Commit

Permalink
Merge branch 'upstream-KWSys' into update-kwsys-2021-02-10
Browse files Browse the repository at this point in the history
# By KWSys Upstream
* upstream-KWSys:
  KWSys 2021-02-10 (dda7a943)
  • Loading branch information
seanm committed Feb 10, 2021
2 parents faec364 + 84dc94c commit 8b21c33
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 98 deletions.
25 changes: 25 additions & 0 deletions Modules/ThirdParty/KWSys/src/KWSys/.gitattributes-e
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.git* export-ignore
# import off
.gitattributes -export-ignore
.hooks* export-ignore

# Custom attribute to mark sources as using the kwsys C code style.
[attr]kwsys-c-style whitespace=tab-in-indent format.clang-format

/GitSetup export-ignore
/*.sh export-ignore eol=lf
/*.bash export-ignore eol=lf
/.clang-format export-ignore
# import on

*.c kwsys-c-style
*.c.in kwsys-c-style
*.cxx kwsys-c-style
*.h kwsys-c-style
*.h.in kwsys-c-style
*.hxx kwsys-c-style
*.hxx.in kwsys-c-style

*.cmake whitespace=tab-in-indent
*.rst whitespace=tab-in-indent conflict-marker-size=79
*.txt whitespace=tab-in-indent
46 changes: 46 additions & 0 deletions Modules/ThirdParty/KWSys/src/KWSys/FStream.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,50 @@ protected:
FILE* file_;
};

template <typename CharType, typename Traits = std::char_traits<CharType> >
class basic_fstream
: public std::basic_iostream<CharType, Traits>
, public basic_efilebuf<CharType, Traits>
{
public:
typedef typename basic_efilebuf<CharType, Traits>::internal_buffer_type
internal_buffer_type;
typedef std::basic_iostream<CharType, Traits> internal_stream_type;

basic_fstream()
: internal_stream_type(new internal_buffer_type())
{
this->buf_ =
static_cast<internal_buffer_type*>(internal_stream_type::rdbuf());
}
explicit basic_fstream(char const* file_name,
std::ios_base::openmode mode = std::ios_base::in |
std::ios_base::out)
: internal_stream_type(new internal_buffer_type())
{
this->buf_ =
static_cast<internal_buffer_type*>(internal_stream_type::rdbuf());
open(file_name, mode);
}

void open(char const* file_name,
std::ios_base::openmode mode = std::ios_base::in |
std::ios_base::out)
{
this->_set_state(this->_open(file_name, mode), this, this);
}

bool is_open() { return this->_is_open(); }

void close() { this->_set_state(this->_close(), this, this); }

using basic_efilebuf<CharType, Traits>::_is_open;

internal_buffer_type* rdbuf() const { return this->buf_; }

~basic_fstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT { close(); }
};

template <typename CharType, typename Traits = std::char_traits<CharType> >
class basic_ifstream
: public std::basic_istream<CharType, Traits>
Expand Down Expand Up @@ -251,11 +295,13 @@ public:
~basic_ofstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT { close(); }
};

typedef basic_fstream<char> fstream;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;

# undef @KWSYS_NAMESPACE@_FStream_NOEXCEPT
#else
using std::fstream;
using std::ofstream;
using std::ifstream;
#endif
Expand Down
5 changes: 4 additions & 1 deletion Modules/ThirdParty/KWSys/src/KWSys/ProcessWin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,10 @@ void kwsysProcess_Execute(kwsysProcess* cp)
kwsysProcessCleanup(cp, GetLastError());
return;
}
SetCurrentDirectoryW(cp->WorkingDirectory);
if (!SetCurrentDirectoryW(cp->WorkingDirectory)) {
kwsysProcessCleanup(cp, GetLastError());
return;
}
}

/* Setup the stdin pipe for the first process. */
Expand Down
Loading

0 comments on commit 8b21c33

Please sign in to comment.