Update of /cvsroot/pure-data/externals/grill/delsplit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13853
Modified Files: main.cpp Added Files: help-delsplit.pd package.txt Removed Files: delsplit.dsp delsplit.mpw delsplit.vcproj.vspscc Log Message: resurrected delsplit external changed delimiter specification more fixes
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/delsplit/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.cpp 25 Jan 2003 04:40:36 -0000 1.5 --- main.cpp 7 Apr 2005 15:00:29 -0000 1.6 *************** *** 3,7 **** delsplit - split a delimited list-in-a-symbol
! Copyright (c) 2002-2003 Thomas Grill (xovo@gmx.net) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. --- 3,7 ---- delsplit - split a delimited list-in-a-symbol
! Copyright (c) 2002-2005 Thomas Grill (gr@grrrr.org) For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "license.txt," in this distribution. *************** *** 9,16 **** */
#include <flext.h>
! #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401) ! #error You need at least flext version 0.4.1 #endif
--- 9,18 ---- */
+ #define FLEXT_ATTRIBUTES 1 + #include <flext.h>
! #if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500) ! #error You need at least flext version 0.5.0 #endif
*************** *** 20,32 **** #include <ctype.h>
- #define I int - #define L long - #define F float - #define D double - #define V void - #define C char - #define BL bool
! #define VERSION "0.1.2"
#ifdef __MWERKS__ --- 22,27 ---- #include <ctype.h>
! #define VERSION "0.1.4"
#ifdef __MWERKS__ *************** *** 43,62 ****
public: ! delsplit(I argc,const t_atom *argv);
protected: ! V m_list(const t_symbol *s); ! V m_del(const t_symbol *s); const t_symbol *delim; ! virtual void m_help(); ! ! static V SetAtom(t_atom &l,const C *s); private: ! static V Setup(t_classid c);
FLEXT_CALLBACK_S(m_list) ! FLEXT_CALLBACK_S(m_del) };
--- 38,58 ----
public: ! delsplit(int argc,const t_atom *argv);
protected: ! void m_list(const t_symbol *s); ! void m_del(const t_symbol *s,int argc,const t_atom *argv); const t_symbol *delim; ! static void SetAtom(t_atom &l,const char *s); private: ! static void Setup(t_classid c);
+ static const t_symbol *sym__space; + FLEXT_CALLBACK_S(m_list) ! FLEXT_CALLBACK_A(m_del) ! FLEXT_ATTRVAR_S(delim) };
*************** *** 64,92 ****
! V delsplit::Setup(t_classid c) { FLEXT_CADDMETHOD(c,0,m_list); FLEXT_CADDMETHOD(c,1,m_del); }
! delsplit::delsplit(I argc,const t_atom *argv): ! delim(NULL) { AddInAnything("Symbol in, representing the delimited list"); ! AddInSymbol("Set the Delimiter"); AddOutList("The split list");
! if(argc && IsSymbol(argv[0])) delim = GetSymbol(argv[0]); }
- V delsplit::m_help() - { - post("%s version " VERSION " (using flext " FLEXT_VERSTR "), (C) 2002 Thomas Grill",thisName()); - }
/** \brief check whether string represents a number \ret 0..integer, 1..float, -1..no number */ ! static I chknum(const C *s) { int num = 0,pts = 0; --- 60,89 ----
! const t_symbol *delsplit::sym__space = NULL; ! ! void delsplit::Setup(t_classid c) { + sym__space = MakeSymbol(" "); + FLEXT_CADDMETHOD(c,0,m_list); FLEXT_CADDMETHOD(c,1,m_del); + FLEXT_CADDATTR_VAR1(c,"del",delim); }
! delsplit::delsplit(int argc,const t_atom *argv): ! delim(sym__) { AddInAnything("Symbol in, representing the delimited list"); ! AddInAnything("Set the Delimiter"); AddOutList("The split list");
! m_del(sym_list,argc,argv); }
/** \brief check whether string represents a number \ret 0..integer, 1..float, -1..no number */ ! static int chknum(const char *s) { int num = 0,pts = 0; *************** *** 99,105 **** }
! V delsplit::SetAtom(t_atom &l,const C *s) { ! I n = chknum(s);
if(n < 0) --- 96,122 ---- }
! void delsplit::m_del(const t_symbol *s,int argc,const t_atom *argv) ! { ! delim = NULL; ! if(s == sym_symbol) { ! FLEXT_ASSERT(argc == 1 && IsSymbol(argv[0])); ! delim = GetSymbol(argv[0]); ! } ! else if(s == sym_list) { ! if(argc == 0) ! delim = sym__space; ! else if(argc >= 1 && IsSymbol(argv[0])) ! delim = GetSymbol(argv[0]); ! } ! ! if(!delim) { ! post("%s - Argument must be a symbol, list or int/float/bang",thisName()); ! delim = sym__space; ! } ! } ! ! void delsplit::SetAtom(t_atom &l,const char *s) { ! int n = chknum(s);
if(n < 0) *************** *** 108,146 **** SetInt(l,atoi(s)); else ! SetFloat(l,(F)atof(s)); }
! V delsplit::m_list(const t_symbol *sym) { ! 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); } ! else ! post("%s - No delimiter defined",thisName()); ! } ! ! V delsplit::m_del(const t_symbol *s) ! { ! delim = s; } - --- 125,155 ---- SetInt(l,atoi(s)); else ! SetFloat(l,(float)atof(s)); }
! void delsplit::m_list(const t_symbol *sym) { ! FLEXT_ASSERT(delim); ! ! t_atom lst[256]; ! int cnt = 0; ! const char *sdel = GetString(delim); ! int ldel = strlen(sdel); ! char str[1024]; ! strcpy(str,GetString(sym)); ! ! for(const char *s = str; *s; ) { ! char *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); }
--- delsplit.vcproj.vspscc DELETED ---
--- NEW FILE: help-delsplit.pd --- #N canvas 300 90 458 286 12; #X msg 264 133 symbol -; #X msg 232 57 list; #X msg 242 84 list +; #X obj 105 229 print; #X obj 43 69 tosymbol; #X msg 42 42 ask+asd-ssds; #X symbolatom 251 111 10 0 0 0 - - -; #X obj 105 203 delsplit; #X text 273 54 space; #X connect 0 0 7 1; #X connect 1 0 7 1; #X connect 2 0 7 1; #X connect 4 0 7 0; #X connect 5 0 4 0; #X connect 6 0 7 1; #X connect 7 0 3 0;
--- delsplit.mpw DELETED ---
--- delsplit.dsp DELETED ---
--- NEW FILE: package.txt --- NAME=delsplit SRCS=main.cpp