diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-04-19 13:08:32 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-04-19 13:08:32 +0000 |
commit | 4868cd86e564ec1d61b1e10b4f3f993249974337 (patch) | |
tree | f8b52157ebc726e7645d5dad0959b11b9b14452c /externals/grill/pool/source | |
parent | 2980784b0084b1bfa265755530114f6d57abfccc (diff) |
added saving/loading of spaces and other special characters (escaping)
more symbol escaping
svn path=/trunk/; revision=2788
Diffstat (limited to 'externals/grill/pool/source')
-rw-r--r-- | externals/grill/pool/source/pool.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp index 7032707d..0ce81ed8 100644 --- a/externals/grill/pool/source/pool.cpp +++ b/externals/grill/pool/source/pool.cpp @@ -475,7 +475,15 @@ static char *ReadAtom(char *c,A *a) char tmp[1024]; char *m = tmp; // write position - + + bool issymbol; + if(*c == '"') { + issymbol = true; + ++c; + } + else + issymbol = false; + // go to next whitespace for(bool escaped = false;; ++c) if(*c == '\\') { @@ -486,9 +494,16 @@ static char *ReadAtom(char *c,A *a) else escaped = true; } + else if(*c == '"' && issymbol && !escaped) { + // end of string + ++c; + FLEXT_ASSERT(!*c || isspace(*c)); + *m = 0; + break; + } else if(!*c || (isspace(*c) && !escaped)) { - *m = 0; - break; + *m = 0; + break; } else { *m++ = *c; @@ -499,7 +514,7 @@ static char *ReadAtom(char *c,A *a) float fres; // first try float - if(sscanf(tmp,"%f",&fres) == 1) { + if(!issymbol && sscanf(tmp,"%f",&fres) == 1) { if(a) { int ires = (int)fres; // try a cast if(fres == ires) @@ -557,11 +572,13 @@ static V WriteAtom(ostream &os,const A &a) #endif case A_SYMBOL: { const char *c = flext::GetString(flext::GetSymbol(a)); + os << '"'; for(; *c; ++c) { if(isspace(*c) || *c == '\\' || *c == ',') os << '\\'; os << *c; } + os << '"'; break; } } |