From b6b86b40135b448c91177984a8d25518a66d7cdc Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 16 May 2016 11:59:26 +0100 Subject: SPC700 additions. * First completed version of SPC700. Very untested. * Fixed an oddity in the parser regarding quoted values not ending with a separator. These values now appear unquoted with the additional text included in the same argument. --- src/parse.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index fe9a989..8e83374 100644 --- a/src/parse.c +++ b/src/parse.c @@ -97,6 +97,17 @@ static void AddToken(const char *start, const char *end, Line *line, int quoted) } +static int IsClosure(const char *p, const char *sep) +{ + while(*p && isspace(*p)) + { + p++; + } + + return !*p || strchr(sep, *p); +} + + /* ---------------------------------------- INTERFACES */ @@ -210,9 +221,25 @@ int ParseLine(Line *line, const char *source) { if (quote) { + /* When we find a closing quote check if the following + character is a seperator or end-of-line. If not + this wasn't really a quoted string. + */ if (*p == quote) { - state = CONSUME_WS; + if (IsClosure(p + 1, sep_chars[stage])) + { + state = CONSUME_WS; + } + else + { + /* Wasn't a real closue, so add the quote as + a character onto the string. + */ + quote = 0; + open_quote = 0; + start--; + } } } else if (strchr(sep_chars[stage], *p) || *p == ';') -- cgit v1.2.3