From 86425c2efc359c547f3c900efab99d913fcde2f5 Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Sat, 26 Oct 2024 19:11:14 -0700 Subject: [PATCH] fix extract_filepath_ext() --- src/core/chuck_compile.cpp | 4 ++-- src/core/util_string.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/chuck_compile.cpp b/src/core/chuck_compile.cpp index c86b56c6a..6eb7b125f 100644 --- a/src/core/chuck_compile.cpp +++ b/src/core/chuck_compile.cpp @@ -508,8 +508,8 @@ t_CKBOOL Chuck_Compiler::visit( ImportTargetNode * node, // this function updates 'filename' with the first match //----------------------------------------------------------------------------- static t_CKBOOL matchFilename( std::string & filename, - const std::string & ext, - const std::vector & extensions ) + const std::string & ext, + const std::vector & extensions ) { // test filename as is if( ck_fileexists( filename ) && !ck_isdir( filename ) ) return TRUE; diff --git a/src/core/util_string.cpp b/src/core/util_string.cpp index f04d241b6..cceecde8e 100644 --- a/src/core/util_string.cpp +++ b/src/core/util_string.cpp @@ -915,10 +915,10 @@ std::string extract_filepath_ext( const std::string & filepath ) // look for separator from the right size_t pathPos = normalize.rfind( path_separator ); // if path separator found after the rightmost ext separator - if( pathPos > extPos ) return ""; + if( (pathPos != std::string::npos) && (pathPos > extPos) ) return ""; // substring after the rightmost ext separator - return std::string( filepath, extPos ); + return std::string( normalize, extPos ); }