Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nonstandard string function #33456

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@
# include "platform_win.h"
#endif

//--------------------------------------------------------------------------------------------------
// HACK: mingw only issue as of 14/01/2015
// TODO: move elsewhere
//--------------------------------------------------------------------------------------------------
#if defined(__MINGW32__) || defined(__CYGWIN__)
size_t strnlen( const char *const start, const size_t maxlen )
{
const auto end = reinterpret_cast<const char *>( memchr( start, '\0', maxlen ) );
return ( end ) ? static_cast<size_t>( end - start ) : maxlen;
}
#endif

namespace
{

Expand Down Expand Up @@ -261,14 +249,14 @@ bool is_special_dir( const dirent &entry )
//--------------------------------------------------------------------------------------------------
bool name_contains( const dirent &entry, const std::string &match, const bool at_end )
{
const auto len_fname = strnlen( entry.d_name, sizeof_array( entry.d_name ) );
const auto len_match = match.length();
const size_t len_fname = strlen( entry.d_name );
const size_t len_match = match.length();

if( len_match > len_fname ) {
return false;
}

const auto offset = at_end ? ( len_fname - len_match ) : 0;
const size_t offset = at_end ? ( len_fname - len_match ) : 0;
return strstr( entry.d_name + offset, match.c_str() ) != nullptr;
}

Expand Down