From 562dcc336797951b2a8707413aa44177484c9f2a Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Sat, 28 Dec 2002 04:37:42 +0000 Subject: "" svn path=/trunk/; revision=309 --- externals/grill/delsplit/main.cpp | 61 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'externals/grill/delsplit/main.cpp') diff --git a/externals/grill/delsplit/main.cpp b/externals/grill/delsplit/main.cpp index 17e30bc3..a7369dc7 100755 --- a/externals/grill/delsplit/main.cpp +++ b/externals/grill/delsplit/main.cpp @@ -10,8 +10,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include -#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) -#error You need at least flext version 0.4.0 +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) +#error You need at least flext version 0.4.1 #endif #include @@ -27,7 +27,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define C char #define BL bool -#define VERSION "0.1.1" +#define VERSION "0.1.2" #ifdef __MWERKS__ #define STD std @@ -39,7 +39,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. class delsplit: public flext_base { - FLEXT_HEADER(delsplit,flext_base) + FLEXT_HEADER_S(delsplit,flext_base,Setup) public: delsplit(I argc,const t_atom *argv); @@ -55,6 +55,8 @@ protected: static V SetAtom(t_atom &l,const C *s); private: + static V Setup(t_class *c); + FLEXT_CALLBACK_S(m_list) FLEXT_CALLBACK_S(m_del) }; @@ -62,6 +64,12 @@ private: FLEXT_NEW_V("delsplit",delsplit) +V delsplit::Setup(t_class *c) +{ + FLEXT_CADDMETHOD(c,0,m_list); + FLEXT_CADDMETHOD(c,1,m_del); +} + delsplit::delsplit(I argc,const t_atom *argv): delim(NULL) { @@ -69,9 +77,6 @@ delsplit::delsplit(I argc,const t_atom *argv): AddInSymbol(); AddOutList(); - FLEXT_ADDMETHOD(0,m_list); - FLEXT_ADDMETHOD(1,m_del); - if(argc && IsSymbol(argv[0])) delim = GetSymbol(argv[0]); } @@ -128,27 +133,31 @@ V delsplit::SetAtom(t_atom &l,const C *s) V delsplit::m_list(const t_symbol *sym) { - t_atom lst[256]; - int cnt = 0; - const C *sdel = GetString(delim); - I ldel = strlen(sdel); - C str[1024]; - strcpy(str,GetString(sym)); - - for(const char *s = str; *s; ) { - C *e = strstr(s,sdel); - if(!e) { - SetAtom(lst[cnt++],s); - break; - } - else { - *e = 0; - SetAtom(lst[cnt++],s); - s = e+ldel; + if(delim) { + t_atom lst[256]; + int cnt = 0; + const C *sdel = GetString(delim); + I ldel = strlen(sdel); + C str[1024]; + strcpy(str,GetString(sym)); + + for(const char *s = str; *s; ) { + C *e = strstr(s,sdel); + if(!e) { + SetAtom(lst[cnt++],s); + break; + } + else { + *e = 0; + SetAtom(lst[cnt++],s); + s = e+ldel; + } } + + ToOutList(0,cnt,lst); } - - ToOutList(0,cnt,lst); + else + post("%s - No delimiter defined",thisName()); } V delsplit::m_del(const t_symbol *s) -- cgit v1.2.1