aboutsummaryrefslogtreecommitdiff
path: root/src/parse.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2016-05-16 11:59:26 +0100
committerIan C <ianc@noddybox.co.uk>2016-05-16 11:59:26 +0100
commitb6b86b40135b448c91177984a8d25518a66d7cdc (patch)
tree65a56c0dc9a8ff12fb87401b333a6beb5a2e9107 /src/parse.c
parent5e6a1c3434b96ea16485b160c25732df3b00b2b8 (diff)
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.
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c29
1 files changed, 28 insertions, 1 deletions
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 == ';')