@@ -140,7 +140,7 @@ void Element::dump() {
140140 std::cout << " dumping " << this << " : " << *this << " .\n " ;
141141}
142142
143- SExpressionParser::SExpressionParser (char * input) : input(input) {
143+ SExpressionParser::SExpressionParser (char const * input) : input(input) {
144144 root = nullptr ;
145145 line = 1 ;
146146 lineStart = input;
@@ -190,23 +190,23 @@ Element* SExpressionParser::parse() {
190190
191191void SExpressionParser::parseDebugLocation () {
192192 // Extracting debug location (if valid)
193- char * debugLoc = input + 3 ; // skipping ";;@"
193+ char const * debugLoc = input + 3 ; // skipping ";;@"
194194 while (debugLoc[0 ] && debugLoc[0 ] == ' ' ) {
195195 debugLoc++;
196196 }
197- char * debugLocEnd = debugLoc;
197+ char const * debugLocEnd = debugLoc;
198198 while (debugLocEnd[0 ] && debugLocEnd[0 ] != ' \n ' ) {
199199 debugLocEnd++;
200200 }
201- char * pos = debugLoc;
201+ char const * pos = debugLoc;
202202 while (pos < debugLocEnd && pos[0 ] != ' :' ) {
203203 pos++;
204204 }
205205 if (pos >= debugLocEnd) {
206206 return ; // no line number
207207 }
208208 std::string name (debugLoc, pos);
209- char * lineStart = ++pos;
209+ char const * lineStart = ++pos;
210210 while (pos < debugLocEnd && pos[0 ] != ' :' ) {
211211 pos++;
212212 }
@@ -279,7 +279,7 @@ Element* SExpressionParser::parseString() {
279279 input++;
280280 dollared = true ;
281281 }
282- char * start = input;
282+ char const * start = input;
283283 if (input[0 ] == ' "' ) {
284284 // parse escaping \", but leave code escaped - we'll handle escaping in
285285 // memory segments specifically
@@ -317,12 +317,14 @@ Element* SExpressionParser::parseString() {
317317 if (start == input) {
318318 throw ParseException (" expected string" , line, input - lineStart);
319319 }
320- char temp = input[0 ];
321- input[0 ] = 0 ;
320+
321+ std::string temp;
322+ temp.assign (start, input - start);
323+
322324 auto ret = allocator.alloc <Element>()
323- ->setString (IString (start , false ), dollared, false )
325+ ->setString (IString (temp. c_str () , false ), dollared, false )
324326 ->setMetadata (line, start - lineStart, loc);
325- input[ 0 ] = temp;
327+
326328 return ret;
327329}
328330
0 commit comments