Commit c7c3c510 authored by Robert Ricci's avatar Robert Ricci

Make the parser a bit more robust - in particular, accept double

spaces.
parent fde2c709
......@@ -12,6 +12,11 @@
#include "parser.h"
#ifdef DEBUG_PARSER
#define DEBUG(x) x
#else
#define DEBUG(x)
#endif
string_vector split_line(crope line,char split_char)
{
......@@ -19,12 +24,21 @@ string_vector split_line(crope line,char split_char)
crope::const_iterator next_space,prev_space;
prev_space = line.begin();
DEBUG(cerr << "Parsing line " << line << endl;)
while ((next_space = find(prev_space,line.end(),' ')) != line.end()) {
parsed.push_back(line.substr(prev_space,next_space));
if (next_space != prev_space) { // Skip multiple spaces
parsed.push_back(line.substr(prev_space,next_space));
DEBUG(cerr << "Pushing string: " << line.substr(prev_space,next_space) <<
endl;)
}
prev_space = ++next_space;
}
if (prev_space != next_space)
if (prev_space != next_space) {
parsed.push_back(line.substr(prev_space,next_space));
DEBUG(cerr << "Pushing string: " << line.substr(prev_space,next_space) <<
endl;)
}
return parsed;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment