diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-25 04:53:43 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-25 04:53:43 +0000 |
commit | 83c049b6c7eb05aabbfc008f46541c9d83b2be01 (patch) | |
tree | 778b1ca4f6a97b39712455bff4700a87fe9c5d38 /externals/grill/pool/source | |
parent | 53bf2216c3d76fdba0c98e6b41267d6b09dab1c6 (diff) |
update for flext build system
added saving/loading of spaces and other special characters (escaping)
svn path=/trunk/; revision=2644
Diffstat (limited to 'externals/grill/pool/source')
-rw-r--r-- | externals/grill/pool/source/main.cpp | 2 | ||||
-rw-r--r-- | externals/grill/pool/source/pool.cpp | 47 |
2 files changed, 33 insertions, 16 deletions
diff --git a/externals/grill/pool/source/main.cpp b/externals/grill/pool/source/main.cpp index 8dfa06e8..21dbb0ce 100644 --- a/externals/grill/pool/source/main.cpp +++ b/externals/grill/pool/source/main.cpp @@ -232,7 +232,7 @@ pooldata *pool::head,*pool::tail; V pool::setup(t_classid c) { post(""); - post("pool %s - hierarchical storage object, (C)2002-2004 Thomas Grill",POOL_VERSION); + post("pool %s - hierarchical storage object, (C)2002-2005 Thomas Grill",POOL_VERSION); post(""); head = tail = NULL; diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp index 35dfa2fe..7032707d 100644 --- a/externals/grill/pool/source/pool.cpp +++ b/externals/grill/pool/source/pool.cpp @@ -467,24 +467,39 @@ BL pooldir::Copy(pooldir *p,I depth,BL cut) } -static C *ReadAtom(C *c,A *a) +static char *ReadAtom(char *c,A *a) { - // skip whitespace + // skip leading whitespace while(*c && isspace(*c)) ++c; if(!*c) return NULL; - const C *m = c; // remember position - + char tmp[1024]; + char *m = tmp; // write position + // go to next whitespace - // \todo recognize symbol escapes - for(; *c && !isspace(*c); ++c) {} + for(bool escaped = false;; ++c) + if(*c == '\\') { + if(escaped) { + *m++ = *c; + escaped = false; + } + else + escaped = true; + } + else if(!*c || (isspace(*c) && !escaped)) { + *m = 0; + break; + } + else { + *m++ = *c; + escaped = false; + } // save character and set delimiter - char t = *c; *c = 0; float fres; // first try float - if(sscanf(m,"%f",&fres) == 1) { + if(sscanf(tmp,"%f",&fres) == 1) { if(a) { int ires = (int)fres; // try a cast if(fres == ires) @@ -495,11 +510,9 @@ static C *ReadAtom(C *c,A *a) } // no, it's a symbol else { - if(a) flext::SetString(*a,m); + if(a) flext::SetString(*a,tmp); } - // set back the saved character - *c = t; return c; } @@ -542,18 +555,22 @@ static V WriteAtom(ostream &os,const A &a) os << a.a_w.w_long; break; #endif - case A_SYMBOL: - os << flext::GetString(flext::GetSymbol(a)); + case A_SYMBOL: { + const char *c = flext::GetString(flext::GetSymbol(a)); + for(; *c; ++c) { + if(isspace(*c) || *c == '\\' || *c == ',') + os << '\\'; + os << *c; + } break; } + } } static V WriteAtoms(ostream &os,const flext::AtomList &l) { for(I i = 0; i < l.Count(); ++i) { -// if(IsSymbol(l[i]) os << "\""; WriteAtom(os,l[i]); -// if(IsSymbol(l[i]) os << "\""; if(i < l.Count()-1) os << ' '; } } |