From d4efa5f81caf87a3ac170c5a4a1aa1fe78520f4d Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 21 Dec 2013 16:58:02 -0700 Subject: [PATCH] KWSys 2013-12-21 (e81f2a9e) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ e81f2a9e | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 2426b57d..e81f2a9e Clinton Stimpson (1): e81f2a9e FStream: Fix opening non-existant file. Change-Id: I1f79e6671de7733d1b8e8a34ce627749c2f666b7 --- CMakeLists.txt | 5 +++++ FStream.hxx.in | 5 +++-- testFStream.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 testFStream.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b377df1..736e30afa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1133,6 +1133,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testEncoding ) ENDIF(KWSYS_STL_HAS_WSTRING) + IF(KWSYS_USE_FStream) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} + testFStream + ) + ENDIF(KWSYS_USE_FStream) IF(KWSYS_USE_SystemInformation) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) ENDIF(KWSYS_USE_SystemInformation) diff --git a/FStream.hxx.in b/FStream.hxx.in index c340c55a3..916a93eba 100644 --- a/FStream.hxx.in +++ b/FStream.hxx.in @@ -25,8 +25,9 @@ namespace @KWSYS_NAMESPACE@ typedef std::basic_filebuf my_base_type; basic_filebuf *open(char const *s,std::ios_base::openmode mode) { - my_base_type::open(Encoding::ToWide(s).c_str(), mode); - return this; + return static_cast( + my_base_type::open(Encoding::ToWide(s).c_str(), mode) + ); } }; diff --git a/testFStream.cxx b/testFStream.cxx new file mode 100644 index 000000000..89425490b --- /dev/null +++ b/testFStream.cxx @@ -0,0 +1,48 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "kwsysPrivate.h" + +#if defined(_MSC_VER) +# pragma warning (disable:4786) +#endif + +#include KWSYS_HEADER(FStream.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "FStream.hxx.in" +#endif + + +//---------------------------------------------------------------------------- +static int testNoFile() +{ + kwsys::ifstream in_file("NoSuchFile.txt"); + if(in_file) + { + return 1; + } + + return 0; +} + + +//---------------------------------------------------------------------------- +int testFStream(int, char*[]) +{ + int ret = 0; + + ret |= testNoFile(); + + return ret; +}