diff options
author | Mike Buland <eichlan@xagasoft.com> | 2008-04-14 22:36:34 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2008-04-14 22:36:34 +0000 |
commit | d416848a9c212bf0503ec5b9de4cd23449ecd73c (patch) | |
tree | 60766f975beff8bdf99bb8b1fcbce044d060c02c /src | |
parent | 37f43e6004b979a48aa99609264d12511023a956 (diff) | |
download | libbu++-d416848a9c212bf0503ec5b9de4cd23449ecd73c.tar.gz libbu++-d416848a9c212bf0503ec5b9de4cd23449ecd73c.tar.bz2 libbu++-d416848a9c212bf0503ec5b9de4cd23449ecd73c.tar.xz libbu++-d416848a9c212bf0503ec5b9de4cd23449ecd73c.zip |
The Bu::TafReader parser now knows about \\, \t, and \n escape sequences. The
writer also knows about \\, but will not insert \t or \n for now. It just uses
a tab and newline for those.
Diffstat (limited to 'src')
-rw-r--r-- | src/tafreader.cpp | 6 | ||||
-rw-r--r-- | src/tafwriter.cpp | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/tafreader.cpp b/src/tafreader.cpp index 7b5e65d..db2e9f5 100644 --- a/src/tafreader.cpp +++ b/src/tafreader.cpp | |||
@@ -146,6 +146,12 @@ Bu::FString Bu::TafReader::readStr() | |||
146 | } | 146 | } |
147 | else if( c == '"' ) | 147 | else if( c == '"' ) |
148 | c = '"'; | 148 | c = '"'; |
149 | else if( c == '\\' ) | ||
150 | c = '\\'; | ||
151 | else if( c == 'n' ) | ||
152 | c = '\n'; | ||
153 | else if( c == 't' ) | ||
154 | c = '\t'; | ||
149 | else | 155 | else |
150 | throw TafException("Invalid escape sequence at %d:%d.", iLine, iCol ); | 156 | throw TafException("Invalid escape sequence at %d:%d.", iLine, iCol ); |
151 | } | 157 | } |
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp index 8dcde86..c30bc67 100644 --- a/src/tafwriter.cpp +++ b/src/tafwriter.cpp | |||
@@ -97,6 +97,8 @@ void Bu::TafWriter::writeString( const Bu::FString &str ) | |||
97 | { | 97 | { |
98 | if( *s == '\"' ) | 98 | if( *s == '\"' ) |
99 | sOut.write("\\\"", 2 ); | 99 | sOut.write("\\\"", 2 ); |
100 | else if( *s == '\\' ) | ||
101 | sOut.write("\\\\", 2 ); | ||
100 | else | 102 | else |
101 | sOut.write( s, 1 ); | 103 | sOut.write( s, 1 ); |
102 | } | 104 | } |