summaryrefslogtreecommitdiff
path: root/src/token822.c
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 19:03:11 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 19:03:11 +0200
commit20b85c03e751b4876fa3c92040464e483172b746 (patch)
tree734fadbfdbc143ec4465093857f4c239448715e0 /src/token822.c
parenta6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (diff)
manual format adjustment
Diffstat (limited to 'src/token822.c')
-rw-r--r--src/token822.c30
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;
}