From b23509d7d8a809cb4c04b5b5223b311145632f32 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 4 Nov 2018 09:29:29 -0800 Subject: [PATCH] BULK: Fix size calculation and allow whitespace. --- doc/pwmd.html | 9 ++++++--- doc/pwmd.texi | 9 ++++++--- src/bulk.c | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/pwmd.html b/doc/pwmd.html index 130df5d4..0c2f32d6 100644 --- a/doc/pwmd.html +++ b/doc/pwmd.html @@ -1773,10 +1773,13 @@ follows:

Each token is prefixed with an unsigned integer that specifies the length of the token, followed by a colon ’:’, followed by the token itself. Pwmd -uses token pairs to create a name=value relationship. There is no whitespace -between the token pairs although one or more whitespace characters is required -between two token pairs. +uses token pairs to create a name=value relationship. Whitespace is +allowed between token pairs. For example, the following is valid:

+
+
( 2:id 7:FirstID 4:LIST0: 2:rc 1:0 (2:id6:Second 7:GETINFO7:version))
+
+

The id token begins a new command and requires an <id> token of length <I> to uniquely identify this command. The next token pair is the protocol command name <prot> of length <P> to run and without diff --git a/doc/pwmd.texi b/doc/pwmd.texi index b4aa308d..c487603f 100644 --- a/doc/pwmd.texi +++ b/doc/pwmd.texi @@ -665,9 +665,12 @@ follows: Each token is prefixed with an unsigned integer that specifies the length of the token, followed by a colon '@code{:}', followed by the token itself. Pwmd -uses token pairs to create a name=value relationship. There is no whitespace -between the token pairs although one or more whitespace characters is required -between two token pairs. +uses token pairs to create a @emph{name=value} relationship. Whitespace is +allowed between token pairs. For example, the following is valid: + +@example +( 2:id 7:FirstID 4:LIST0: 2:rc 1:0 (2:id6:Second 7:GETINFO7:version)) +@end example The @code{id} token begins a new command and requires an @var{} token of length @var{} to uniquely identify this command. The next token pair is diff --git a/src/bulk.c b/src/bulk.c index 8356b4ad..10de764f 100644 --- a/src/bulk.c +++ b/src/bulk.c @@ -47,7 +47,7 @@ bulk_free_list (struct sexp_s **list) #define SKIP_WS(s, size) do { \ while (s && isspace (*s)) \ - s++, *size--; \ + s++, (*size)--; \ } while (0) #define NUMBER(s, size, buf, len, rc) do { \ @@ -148,6 +148,7 @@ parse_sexp (struct sexp_s ***head, const char *str, size_t *size) p += taglen; *size -= taglen; + SKIP_WS (p, size); NUMBER (p, size, buf, datalen, rc); if (rc) { -- 2.11.4.GIT