aboutsummaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
Diffstat (limited to 'externals')
-rw-r--r--externals/grill/pool/data.cpp3
-rw-r--r--externals/grill/pool/main.cpp18
-rw-r--r--externals/grill/pool/pool-0.2.dtd (renamed from externals/grill/pool/pool.dtd)0
-rw-r--r--externals/grill/pool/pool.cpp138
-rw-r--r--externals/grill/pool/pool.pd70
-rw-r--r--externals/grill/pool/pool.vcproj3
-rw-r--r--externals/grill/pool/readme.txt4
7 files changed, 156 insertions, 80 deletions
diff --git a/externals/grill/pool/data.cpp b/externals/grill/pool/data.cpp
index 26b5464b..9eda196b 100644
--- a/externals/grill/pool/data.cpp
+++ b/externals/grill/pool/data.cpp
@@ -279,8 +279,7 @@ BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir)
if(absdir) tmp = d;
if(fl.good()) {
fl << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" << endl;
-// fl << "<!DOCTYPE pool SYSTEM \"http://www.parasitaere-kapazitaeten.net/ext/pool/pool.dtd\">" << endl;
- fl << "<!DOCTYPE pool SYSTEM \"pool.dtd\">" << endl;
+ fl << "<!DOCTYPE pool SYSTEM \"http://www.parasitaere-kapazitaeten.net/ext/pool/pool-0.2.dtd\">" << endl;
fl << "<pool>" << endl;
BL ret = pd->SvDirXML(fl,depth,tmp);
fl << "</pool>" << endl;
diff --git a/externals/grill/pool/main.cpp b/externals/grill/pool/main.cpp
index f9b6993c..5f75f07d 100644
--- a/externals/grill/pool/main.cpp
+++ b/externals/grill/pool/main.cpp
@@ -43,12 +43,14 @@ protected:
// handle directories
V m_getdir();
- V m_mkdir(I argc,const A *argv,BL abs = true); // make and change to dir
+ V m_mkdir(I argc,const A *argv,BL abs = true,BL chg = false); // make (and change) to dir
+ V m_mkchdir(I argc,const A *argv) { m_mkdir(argc,argv,true,true); } // make and change to dir
V m_chdir(I argc,const A *argv,BL abs = true); // change to dir
V m_rmdir(I argc,const A *argv,BL abs = true); // remove dir
V m_updir(I argc,const A *argv); // one or more levels up
V m_mksub(I argc,const A *argv) { m_mkdir(argc,argv,false); }
+ V m_mkchsub(I argc,const A *argv) { m_mkdir(argc,argv,false,true); }
V m_chsub(I argc,const A *argv) { m_chdir(argc,argv,false); }
V m_rmsub(I argc,const A *argv) { m_rmdir(argc,argv,false); }
@@ -162,10 +164,12 @@ private:
FLEXT_CALLBACK(m_getdir)
FLEXT_CALLBACK_V(m_mkdir)
FLEXT_CALLBACK_V(m_chdir)
+ FLEXT_CALLBACK_V(m_mkchdir)
FLEXT_CALLBACK_V(m_updir)
FLEXT_CALLBACK_V(m_rmdir)
FLEXT_CALLBACK_V(m_mksub)
FLEXT_CALLBACK_V(m_chsub)
+ FLEXT_CALLBACK_V(m_mkchsub)
FLEXT_CALLBACK_V(m_rmsub)
FLEXT_CALLBACK_V(m_set)
@@ -240,10 +244,12 @@ V pool::setup(t_classid c)
FLEXT_CADDMETHOD_(c,0,"getdir",m_getdir);
FLEXT_CADDMETHOD_(c,0,"mkdir",m_mkdir);
FLEXT_CADDMETHOD_(c,0,"chdir",m_chdir);
+ FLEXT_CADDMETHOD_(c,0,"mkchdir",m_mkchdir);
FLEXT_CADDMETHOD_(c,0,"rmdir",m_rmdir);
FLEXT_CADDMETHOD_(c,0,"updir",m_updir);
FLEXT_CADDMETHOD_(c,0,"mksub",m_mksub);
FLEXT_CADDMETHOD_(c,0,"chsub",m_chsub);
+ FLEXT_CADDMETHOD_(c,0,"mkchsub",m_mkchsub);
FLEXT_CADDMETHOD_(c,0,"rmsub",m_rmsub);
FLEXT_CADDMETHOD_(c,0,"set",m_set);
@@ -380,17 +386,21 @@ V pool::getdir(const S *tag)
V pool::m_getdir() { getdir(MakeSymbol("getdir")); }
-V pool::m_mkdir(I argc,const A *argv,BL abs)
+V pool::m_mkdir(I argc,const A *argv,BL abs,BL chg)
{
+ const char *nm = chg?"mkchdir":"mkdir";
if(!ValChk(argc,argv))
- post("%s - mkdir: invalid directory name",thisName());
+ post("%s - %s: invalid directory name",thisName(),nm);
else {
AtomList ndir;
if(abs) ndir(argc,argv);
else (ndir = curdir).Append(argc,argv);
if(!pl->MkDir(ndir,vcnt,dcnt)) {
- post("%s - mkdir: directory couldn't be created",thisName());
+ post("%s - %s: directory couldn't be created",thisName(),nm);
}
+ else if(chg)
+ // change to newly created directory
+ curdir = ndir;
}
echodir();
diff --git a/externals/grill/pool/pool.dtd b/externals/grill/pool/pool-0.2.dtd
index 57a48498..57a48498 100644
--- a/externals/grill/pool/pool.dtd
+++ b/externals/grill/pool/pool-0.2.dtd
diff --git a/externals/grill/pool/pool.cpp b/externals/grill/pool/pool.cpp
index 1be84ec2..76a61cc0 100644
--- a/externals/grill/pool/pool.cpp
+++ b/externals/grill/pool/pool.cpp
@@ -537,9 +537,10 @@ BL pooldir::LdDir(istream &is,I depth,BL mkdir)
{
for(I i = 1; !is.eof(); ++i) {
AtomList d,k,*v = new AtomList;
- BL r = ReadAtoms(is,d,',');
- r = r && ReadAtoms(is,k,',') && k.Count() == 1;
- r = r && ReadAtoms(is,*v,'\n') && v->Count();
+ BL r =
+ ReadAtoms(is,d,',') &&
+ ReadAtoms(is,k,',') && k.Count() == 1 &&
+ ReadAtoms(is,*v,'\n');
if(r) {
if(depth < 0 || d.Count() <= depth) {
@@ -593,40 +594,86 @@ public:
enum { t_start,t_end,t_empty } type;
};
-static bool gettag(istream &is,xmltag &t)
+static bool gettag(istream &is,xmltag &tag)
{
- while(isspace(is.peek())) is.get();
- if(is.peek() == '<') {
- is.get();
- char tmp[256];
- is.getline(tmp,sizeof tmp,'>');
- char *tb = tmp,*te = tmp+strlen(tmp)-1,*tf;
+ static const char *commstt = "<!--",*commend = "-->";
- for(; isspace(*tb); ++tb);
- if(*tb == '/') {
- t.type = xmltag::t_end;
- for(++tb; isspace(*tb); ++tb);
+ for(;;) {
+ // eat whitespace
+ while(isspace(is.peek())) is.get();
+
+ // no tag begin -> break
+ if(is.peek() != '<') break;
+ is.get(); // swallow <
+
+ char tmp[1024],*t = tmp;
+
+ // parse for comment start
+ const char *c = commstt;
+ while(*++c) {
+ if(*c != is.peek()) break;
+ *(t++) = is.get();
}
- else {
- for(; isspace(*te); --te);
- if(*te == '/') {
- for(--te; isspace(*te); --te);
- t.type = xmltag::t_empty;
+
+ if(!*c) { // is comment
+ char cmp[2] = {0,0};
+ for(int ic = 0; ; ic = (++ic)%2) {
+ char c = is.get();
+ if(c == '>') {
+ for(int i = 0; i < 2 && cmp[(ic+i)%2] == commend[i]; ++i);
+ if(i == 2) break; // comment end!
+ }
+ else
+ cmp[ic] = c;
}
- else
- t.type = xmltag::t_start;
}
+ else {
+ // parse until > with consideration of "s
+ bool intx = false;
+ for(;;) {
+ *t = is.get();
+ if(*t == '"') intx = !intx;
+ else if(*t == '>' && !intx) {
+ *t = 0;
+ break;
+ }
+ t++;
+ }
- for(tf = tb; tf <= te && *tf && !isspace(*tf); ++tf);
- t.tag.assign(tb,tf-tb);
- while(isspace(*tf)) ++tf;
- t.attr.assign(tf,te-tf+1);
- return true;
- }
- else {
- t.Clear();
- return false;
+ // look for tag slashes
+
+ char *tb = tmp,*te = t-1,*tf;
+
+ for(; isspace(*tb); ++tb);
+ if(*tb == '/') {
+ // slash at the beginning -> end tag
+ tag.type = xmltag::t_end;
+ for(++tb; isspace(*tb); ++tb);
+ }
+ else {
+ for(; isspace(*te); --te);
+ if(*te == '/') {
+ // slash at the end -> empty tag
+ for(--te; isspace(*te); --te);
+ tag.type = xmltag::t_empty;
+ }
+ else
+ // no slash -> begin tag
+ tag.type = xmltag::t_start;
+ }
+
+ // copy tag text without slashes
+ for(tf = tb; tf <= te && *tf && !isspace(*tf); ++tf);
+ tag.tag.assign(tb,tf-tb);
+ while(isspace(*tf)) ++tf;
+ tag.attr.assign(tf,te-tf+1);
+
+ return true;
+ }
}
+
+ tag.Clear();
+ return false;
}
static void getvalue(istream &is,string &s)
@@ -647,6 +694,8 @@ BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
{
AtomList d,k,v;
bool inpool = false,inval = false,inkey = false,indata = false;
+ const t_symbol *empty = MakeSymbol("");
+
while(!is.eof()) {
xmltag tag;
gettag(is,tag);
@@ -697,8 +746,12 @@ BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
else if(inpool) {
if(tag == "dir") {
if(tag.type == xmltag::t_start) {
+ // warn if last directory key was not given
+ if(d.Count() && GetSymbol(d[d.Count()-1]) == empty)
+ post("pool - XML load: dir key must be given prior to subdirs, ignoring items");
+
// initialize dir key as empty
- t_atom at; SetString(at,"");
+ t_atom at; SetSymbol(at,empty);
d.Append(at);
}
else if(tag.type == xmltag::t_end) {
@@ -716,14 +769,23 @@ BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
else if(tag.type == xmltag::t_end) {
if(depth < 0 || d.Count() <= depth) {
// NOW set value
- const char *ds = d.Count()?GetString(d[d.Count()-1]):NULL;
- if(!ds || !*ds)
- post("pool - XML load: dir key must be given prior to dir values");
+
+ int fnd;
+ for(fnd = d.Count()-1; fnd >= 0; --fnd)
+ if(GetSymbol(d[fnd]) == empty) break;
+
+ // look if last dir key has been given
+ if(fnd >= 0) {
+ if(fnd == d.Count()-1)
+ post("pool - XML load: dir key must be given prior to values");
+
+ // else: one directoy level has been left unintialized, ignore items
+ }
else {
- pooldir *nd = mkdir?AddDir(d):GetDir(d);
- if(nd) {
- // only use first word of key
- if(k.Count() == 1)
+ // only use first word of key
+ if(k.Count() == 1) {
+ pooldir *nd = mkdir?AddDir(d):GetDir(d);
+ if(nd)
nd->SetVal(k[0],new AtomList(v));
else
post("pool - XML load: value key must be exactly one word, value not stored");
diff --git a/externals/grill/pool/pool.pd b/externals/grill/pool/pool.pd
index 2c1c75d5..8af2223e 100644
--- a/externals/grill/pool/pool.pd
+++ b/externals/grill/pool/pool.pd
@@ -1,4 +1,4 @@
-#N canvas 12 3 946 702 12;
+#N canvas 12 3 948 704 12;
#X msg 296 105 set 1 2 3;
#X obj 308 619 print K;
#X msg 607 211 getall;
@@ -54,34 +54,38 @@
#X text 677 364 ... and subdirs;
#X text 673 378 (depth may be given);
#X text 295 258 set but don't replace;
-#N canvas 0 0 520 546 dirs 0;
-#X msg 109 27 mkdir fld1;
-#X msg 111 122 chdir;
-#X msg 110 217 updir;
-#X msg 111 354 getsub -1;
-#X text 110 7 make absolute dir;
-#X text 109 51 make relative dir;
-#X msg 110 72 mksub fld2;
-#X text 109 104 change to absolute dir;
-#X msg 110 165 chsub fld2;
-#X text 108 146 change to relative dir;
-#X text 106 198 change to upper dir;
-#X text 107 250 remove absolute dir;
-#X msg 108 269 rmdir fld1;
-#X msg 110 308 rmsub fld2;
-#X text 109 289 remove relative dir;
-#X text 109 336 get subdirs;
-#X text 251 380 -1 ... infinite;
-#X text 167 213 depth may be given;
-#X text 168 229 default=1;
-#X text 209 349 depth may be given;
-#X text 207 365 default=1;
-#X text 108 377 count subdirs;
-#X msg 111 398 cntsub -1;
-#X msg 111 458 getdir;
-#X text 110 438 get current dir;
-#X text 176 458 always absolute;
-#X obj 11 239 s \$0-pool;
+#N canvas 472 45 416 627 dirs 0;
+#X msg 111 40 mkdir fld1;
+#X msg 113 135 chdir;
+#X msg 109 331 updir;
+#X msg 110 468 getsub -1;
+#X text 112 20 make absolute dir;
+#X text 111 64 make relative dir;
+#X msg 112 85 mksub fld2;
+#X text 111 117 change to absolute dir;
+#X msg 112 178 chsub fld2;
+#X text 110 159 change to relative dir;
+#X text 105 312 change to upper dir;
+#X text 106 364 remove absolute dir;
+#X msg 107 383 rmdir fld1;
+#X msg 109 422 rmsub fld2;
+#X text 108 403 remove relative dir;
+#X text 108 450 get subdirs;
+#X text 250 494 -1 ... infinite;
+#X text 166 327 depth may be given;
+#X text 167 343 default=1;
+#X text 208 463 depth may be given;
+#X text 206 479 default=1;
+#X text 107 491 count subdirs;
+#X msg 110 512 cntsub -1;
+#X msg 110 572 getdir;
+#X text 109 552 get current dir;
+#X text 175 572 always absolute;
+#X obj 13 252 s \$0-pool;
+#X msg 111 231 mkchdir fld1;
+#X text 112 211 make and change to absolute dir;
+#X msg 109 276 mkchsub fld2;
+#X text 110 256 make and change to relative dir;
#X connect 0 0 26 0;
#X connect 1 0 26 0;
#X connect 2 0 26 0;
@@ -92,6 +96,8 @@
#X connect 13 0 26 0;
#X connect 22 0 26 0;
#X connect 23 0 26 0;
+#X connect 27 0 26 0;
+#X connect 29 0 26 0;
#X restore 716 496 pd dirs;
#X text 713 470 directory operations;
#N canvas 0 0 829 461 file 0;
@@ -187,8 +193,8 @@ the folder containing the current patcher will be used.;
#X obj 298 389 r \$0-pool;
#X text 174 517 data is shared among pool objects with the same name
;
-#X obj 26 10 cnv 15 850 40 empty empty pool 10 22 0 24 -260818 -1 0
-;
+#X obj 26 10 cnv 15 850 40 empty empty empty 10 22 0 24 -260818 -1
+0;
#X text 272 33 http://www.parasitaere-kapazitaeten.net;
#X obj 456 541 print A;
#X text 521 541 attributes;
@@ -207,7 +213,7 @@ Grill;
#X msg 41 518 getmethods;
#X text 328 466 (see attributes in properties dialog);
#X text 715 638 console printout;
-#N canvas 0 0 553 284 print 0;
+#N canvas 0 0 559 290 print 0;
#X obj 21 231 s \$0-pool;
#X msg 109 80 printall;
#X msg 109 132 printrec;
diff --git a/externals/grill/pool/pool.vcproj b/externals/grill/pool/pool.vcproj
index 6370595d..7e0e6999 100644
--- a/externals/grill/pool/pool.vcproj
+++ b/externals/grill/pool/pool.vcproj
@@ -395,9 +395,6 @@
</FileConfiguration>
</File>
<File
- RelativePath="pool.dtd">
- </File>
- <File
RelativePath="pool.h">
</File>
<File
diff --git a/externals/grill/pool/readme.txt b/externals/grill/pool/readme.txt
index 98671bdf..62a14e0c 100644
--- a/externals/grill/pool/readme.txt
+++ b/externals/grill/pool/readme.txt
@@ -65,6 +65,7 @@ Version history:
- fixed bug with stored numbers starting with - or +
- relative file names will be based on the folder of the current patcher
- added printall, printrec, printroot messages for console printout
+- added mkchdir, mkchsub to create and change to directories at once
0.1.0:
- first public release
@@ -72,10 +73,11 @@ Version history:
---------------------------------------------------------------------------
BUGS:
-- pool does not handle symbols with spaces or all digits
+- pool does not handle symbols with spaces, colons or all digits
TODO list:
+- check for invalid symbols (spaces, colons)
general:
- what is output as value if it is key only? (Max->nothing!)