Re: [Boost-bugs] [Boost C++ Libraries] #10731: make_permissions is case-inconsistent and requires unnecessary conversions

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10731: make_permissions is case-inconsistent and requires unnecessary conversions
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-09-09 19:07:08


#10731: make_permissions is case-inconsistent and requires unnecessary conversions
--------------------------------+------------------------
  Reporter: daniel.kruegler@… | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.56.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------+------------------------

Comment (by Daniel Kruegler <daniel.kruegler@…>):

 Beman, I'm willing to provide a patch, but given the potential race
 conditions in regard to locales (see #6320), I'm now tending to suggest a
 less ambitious resolution: Instead of using boost::algorithm::iequals, as
 originally suggested, I now tend to keep the existing
 BOOST_FILESYSTEM_STRICMP, with the idea to just replace the function it
 points to:

 {{{
 // some distributions of mingw as early as GLIBCXX__ 20110325 have
 _wcsicmp, but the
 // offical 4.6.2 release with __GLIBCXX__ 20111026 doesn't. Play it safe
 for now, and
 // only use _wcsicmp if _MSC_VER is defined
 #if defined(_MSC_VER) // || (defined(__GLIBCXX__) && __GLIBCXX__ >=
 20110325)
 # define BOOST_FILESYSTEM_STRICMP _wcsicmp
 #else
 # define BOOST_FILESYSTEM_STRICMP wcscmp
 #endif
 }}}

 Given that we can replace make_permissions as follows:

 {{{
   perms make_permissions(const path& p, DWORD attr)
   {
     perms prms = fs::owner_read | fs::group_read | fs::others_read;
     if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
       prms |= fs::owner_write | fs::group_write | fs::others_write;
     if (BOOST_FILESYSTEM_STRICMP(p.extension().c_str(), L".exe") == 0
       || BOOST_FILESYSTEM_STRICMP(p.extension().c_str(), L".com") == 0
       || BOOST_FILESYSTEM_STRICMP(p.extension().c_str(), L".bat") == 0
       || BOOST_FILESYSTEM_STRICMP(p.extension().c_str(), L".cmd") == 0)
       prms |= fs::owner_exe | fs::group_exe | fs::others_exe;
     return prms;
   }
 }}}

 How would you feel about that alternative?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10731#comment:4>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC