diff options
Diffstat (limited to 'src/token822.c')
-rw-r--r-- | src/token822.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/token822.c b/src/token822.c index e1048c6..34d8c24 100644 --- a/src/token822.c +++ b/src/token822.c @@ -21,12 +21,12 @@ void token822_reverse(token822_alloc *ta) } } -GEN_ALLOC_ready(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_ready) - GEN_ALLOC_readyplus(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus) - GEN_ALLOC_append( - token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus, token822_append) +GEN_ALLOC_ready(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_ready); +GEN_ALLOC_readyplus(token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus); +GEN_ALLOC_append( + token822_alloc, struct token822, t, len, a, i, n, x, 30, token822_readyplus, token822_append); - static int needspace(int t1, int t2) +static int needspace(int t1, int t2) { if (!t1) return 0; if (t1 == TOKEN822_COLON) return 1; @@ -118,8 +118,8 @@ int token822_unparse(stralloc *sa, token822_alloc *ta, unsigned int linelen) case TOKEN822_LITERAL: case TOKEN822_COMMENT: if (t->type != TOKEN822_ATOM) len += 2; - for (j = 0; j < t->slen; ++j) switch (ch = t->s[j]) - { + for (j = 0; j < t->slen; ++j) { + switch (ch = t->s[j]) { case '"': case '[': case ']': @@ -130,6 +130,7 @@ int token822_unparse(stralloc *sa, token822_alloc *ta, unsigned int linelen) case '\n': ++len; default: ++len; } + } break; } } @@ -180,8 +181,8 @@ int token822_unparse(stralloc *sa, token822_alloc *ta, unsigned int linelen) if (t->type == TOKEN822_LITERAL) *s++ = '['; if (t->type == TOKEN822_COMMENT) *s++ = '('; - for (j = 0; j < t->slen; ++j) switch (ch = t->s[j]) - { + for (j = 0; j < t->slen; ++j) { + switch (ch = t->s[j]) { case '"': case '[': case ']': @@ -192,6 +193,7 @@ int token822_unparse(stralloc *sa, token822_alloc *ta, unsigned int linelen) case '\n': *s++ = '\\'; default: *s++ = ch; } + } if (t->type == TOKEN822_QUOTE) *s++ = '"'; if (t->type == TOKEN822_LITERAL) *s++ = ']'; if (t->type == TOKEN822_COMMENT) *s++ = ')'; @@ -272,8 +274,8 @@ int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf) numchars = 0; numtoks = 0; - for (i = 0; i < salen; ++i) switch (sa->s[i]) - { + for (i = 0; i < salen; ++i) { + switch (sa->s[i]) { case '.': case ',': case '@': @@ -339,6 +341,7 @@ int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf) --i; ++numtoks; } + } if (!token822_ready(ta, numtoks)) return -1; if (!stralloc_ready(buf, numchars)) return -1; @@ -347,8 +350,8 @@ int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf) t = ta->t; - for (i = 0; i < salen; ++i) switch (sa->s[i]) - { + for (i = 0; i < salen; ++i) { + switch (sa->s[i]) { case '.': t->type = TOKEN822_DOT; ++t; @@ -442,6 +445,7 @@ int token822_parse(token822_alloc *ta, stralloc *sa, stralloc *buf) --i; ++t; } + } return 1; } |