History

refactor extension matching

Ge Wang committed 3 years ago

Commit dcebc361 parent 5a68b864 files · +26 −33Browse files

Unified · Split

4 files
  1. src/core/chuck.cpp +5 −13
  2. src/core/chuck_compile.cpp +1 −16
  3. src/core/util_string.cpp +16 −0
  4. src/core/util_string.h +4 −4
src/core/chuck.cpp+5−13
@@ -740,12 +740,8 @@ void ChucK::probeChugins() · 739 unmodified lines
740740 // list of individually named chug-ins (added 1.3.0.0)
741741 std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_USER_CHUGINS );
742742
743− //---------------------------------------------------------------------
744− // set origin hint | 1.5.0.0 (ge) added
745− m_carrier->compiler->m_originHint = te_originChugin;
746− //---------------------------------------------------------------------
747743 // log
748− EM_log( CK_LOG_SYSTEM, "loading chugins..." );
744+ EM_log( CK_LOG_SYSTEM, "probing chugins..." );
749745 // push indent level
750746 EM_pushlog();
751747 // load external libs
@@ -759,18 +755,14 @@ void ChucK::probeChugins() · 7 unmodified lines
759755 // pop log
760756 EM_poplog();
761757
762− //---------------------------------------------------------------------
763− // set origin hint | 1.5.0.0 (ge) added
764− m_carrier->compiler->m_originHint = te_originImport;
765− //---------------------------------------------------------------------
766758 // log
767− EM_log( CK_LOG_SYSTEM, "pre-loading ChucK libs..." );
759+ EM_log( CK_LOG_SYSTEM, "probing pre-loading ChucK libs..." );
768760 EM_pushlog();
769761
770762 // iterate over list of ck files that the compiler found
771− for(std::list<std::string>::iterator j =
772− compiler()->m_cklibs_to_preload.begin();
773− j != compiler()->m_cklibs_to_preload.end(); j++)
763+ for( std::list<std::string>::iterator j =
764+ compiler()->m_cklibs_to_preload.begin();
765+ j != compiler()->m_cklibs_to_preload.end(); j++ )
774766 {
775767 // the filename
776768 std::string filename = *j;
src/core/chuck_compile.cpp+1−16
@@ -49,6 +49,7 @@ · 48 unmodified lines
4949 #include "ulib_machine.h"
5050 #include "ulib_math.h"
5151 #include "ulib_std.h"
52+#include "util_string.h"
5253
5354 #ifndef __DISABLE_NETWORK__
5455 #include "ulib_opsc.h"
@@ -786,22 +787,6 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler, · 731 unmodified lines
786787
787788
788789
789−//-----------------------------------------------------------------------------
790−// name: extension_matches()
791−// desc: ...
792−//-----------------------------------------------------------------------------
793−static t_CKBOOL extension_matches( const char * filename, const char * extension )
794−{
795− t_CKUINT extension_length = strlen(extension);
796− t_CKUINT filename_length = strlen(filename);
797−
798− return strncmp( extension, filename+(filename_length-extension_length),
799− extension_length) == 0;
800−}
801−
802−
803−
804−
805790 //-----------------------------------------------------------------------------
806791 // name: load_external_modules_in_directory()
807792 // desc: ...
src/core/util_string.cpp+16−0
@@ -723,3 +723,19 @@ t_CKBOOL is_absolute_path( const std::string & path ) · 722 unmodified lines
723723 return( path.length() != 0 && path[0] == '/' );
724724 #endif
725725 }
726+
727+
728+
729+
730+//-----------------------------------------------------------------------------
731+// name: extension_matches()
732+// desc: check whether a filename matches a particular extension
733+//-----------------------------------------------------------------------------
734+t_CKBOOL extension_matches( const char * filename, const char * extension )
735+{
736+ t_CKUINT extension_length = strlen( extension );
737+ t_CKUINT filename_length = strlen( filename );
738+
739+ return strncmp( extension, filename+(filename_length-extension_length),
740+ extension_length ) == 0;
741+}
src/core/util_string.h+4−4
@@ -83,12 +83,12 @@ t_CKBOOL str_endsin(const char *str, const char *end); · 82 unmodified lines
8383 // check if path is absolute on the underlying platform
8484 t_CKBOOL is_absolute_path( const std::string & path );
8585
86−//-----------------------------------------------------------------------------
87−// name: parse_path_list()
88−// desc: split "x:y:z"-style path list into {"x","y","z"}
89−//-----------------------------------------------------------------------------
86+// split "x:y:z"-style path list into {"x","y","z"}
9087 void parse_path_list( std::string & str, std::list<std::string> & lst );
9188
89+// check whether a filename matches a particular extension
90+t_CKBOOL extension_matches( const char * filename, const char * extension );
91+
9292
9393
9494

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t