History

refactor extension matching

Ge Wang committed 3 years ago

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

Showing the changes to src (4 of 4 files). Show all

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
740 // list of individually named chug-ins (added 1.3.0.0)740 // list of individually named chug-ins (added 1.3.0.0)
741 std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_USER_CHUGINS );741 std::list<std::string> named_dls = getParamStringList( CHUCK_PARAM_USER_CHUGINS );
742 742
743 //---------------------------------------------------------------------
744 // set origin hint | 1.5.0.0 (ge) added
745 m_carrier->compiler->m_originHint = te_originChugin;
746 //---------------------------------------------------------------------
747 // log743 // log
748 EM_log( CK_LOG_SYSTEM, "loading chugins..." );744 EM_log( CK_LOG_SYSTEM, "probing chugins..." );
749 // push indent level745 // push indent level
750 EM_pushlog();746 EM_pushlog();
751 // load external libs747 // load external libs
@@ -759,18 +755,14 @@ void ChucK::probeChugins() · 7 unmodified lines
759 // pop log755 // pop log
760 EM_poplog();756 EM_poplog();
761 757
762 //---------------------------------------------------------------------
763 // set origin hint | 1.5.0.0 (ge) added
764 m_carrier->compiler->m_originHint = te_originImport;
765 //---------------------------------------------------------------------
766 // log758 // log
767 EM_log( CK_LOG_SYSTEM, "pre-loading ChucK libs..." );759 EM_log( CK_LOG_SYSTEM, "probing pre-loading ChucK libs..." );
768 EM_pushlog();760 EM_pushlog();
769 761
770 // iterate over list of ck files that the compiler found762 // iterate over list of ck files that the compiler found
771 for(std::list<std::string>::iterator j =763 for( std::list<std::string>::iterator j =
772 compiler()->m_cklibs_to_preload.begin();764 compiler()->m_cklibs_to_preload.begin();
773 j != compiler()->m_cklibs_to_preload.end(); j++)765 j != compiler()->m_cklibs_to_preload.end(); j++ )
774 {766 {
775 // the filename767 // the filename
776 std::string filename = *j;768 std::string filename = *j;
src/core/chuck_compile.cpp+1−16
@@ -49,6 +49,7 @@ · 48 unmodified lines
49#include "ulib_machine.h"49#include "ulib_machine.h"
50#include "ulib_math.h"50#include "ulib_math.h"
51#include "ulib_std.h"51#include "ulib_std.h"
52#include "util_string.h"
52 53
53#ifndef __DISABLE_NETWORK__54#ifndef __DISABLE_NETWORK__
54#include "ulib_opsc.h"55#include "ulib_opsc.h"
@@ -786,22 +787,6 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler, · 731 unmodified lines
786 787
787 788
788 789
789//-----------------------------------------------------------------------------
790// name: extension_matches()
791// desc: ...
792//-----------------------------------------------------------------------------
793static 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
805//-----------------------------------------------------------------------------790//-----------------------------------------------------------------------------
806// name: load_external_modules_in_directory()791// name: load_external_modules_in_directory()
807// desc: ...792// desc: ...
src/core/util_string.cpp+16−0
@@ -723,3 +723,19 @@ t_CKBOOL is_absolute_path( const std::string & path ) · 722 unmodified lines
723 return( path.length() != 0 && path[0] == '/' );723 return( path.length() != 0 && path[0] == '/' );
724#endif724#endif
725}725}
726
727
728
729
730//-----------------------------------------------------------------------------
731// name: extension_matches()
732// desc: check whether a filename matches a particular extension
733//-----------------------------------------------------------------------------
734t_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
83// check if path is absolute on the underlying platform83// check if path is absolute on the underlying platform
84t_CKBOOL is_absolute_path( const std::string & path );84t_CKBOOL is_absolute_path( const std::string & path );
85 85
86//-----------------------------------------------------------------------------86// split "x:y:z"-style path list into {"x","y","z"}
87// name: parse_path_list()
88// desc: split "x:y:z"-style path list into {"x","y","z"}
89//-----------------------------------------------------------------------------
90void parse_path_list( std::string & str, std::list<std::string> & lst );87void parse_path_list( std::string & str, std::list<std::string> & lst );
91 88
89// check whether a filename matches a particular extension
90t_CKBOOL extension_matches( const char * filename, const char * extension );
91
92 92
93 93
94 94

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