format and comment only

This commit is contained in:
CK Tan 2023-09-18 20:28:16 -07:00
parent 52e9c039c5
commit 6fe7fee127
2 changed files with 38 additions and 30 deletions

24
toml.c
View File

@ -2216,6 +2216,7 @@ int toml_rtos(toml_raw_t src, char **ret) {
if (!src)
return -1;
// for strings, first char must be a s-quote or d-quote
int qchar = src[0];
int srclen = strlen(src);
if (!(qchar == '\'' || qchar == '"')) {
@ -2224,12 +2225,14 @@ int toml_rtos(toml_raw_t src, char **ret) {
// triple quotes?
if (qchar == src[1] && qchar == src[2]) {
multiline = 1;
sp = src + 3;
sq = src + srclen - 3;
/* last 3 chars in src must be qchar */
if (!(sp <= sq && sq[0] == qchar && sq[1] == qchar && sq[2] == qchar))
multiline = 1; // triple-quote implies multiline
sp = src + 3; // first char after quote
sq = src + srclen - 3; // first char of ending quote
if (!(sp <= sq && sq[0] == qchar && sq[1] == qchar && sq[2] == qchar)) {
// last 3 chars in src must be qchar
return -1;
}
/* skip new line immediate after qchar */
if (sp[0] == '\n')
@ -2238,13 +2241,18 @@ int toml_rtos(toml_raw_t src, char **ret) {
sp += 2;
} else {
sp = src + 1;
sq = src + srclen - 1;
sp = src + 1; // first char after quote
sq = src + srclen - 1; // ending quote
if (!(sp <= sq && *sq == qchar)) {
/* last char in src must be qchar */
if (!(sp <= sq && *sq == qchar))
return -1;
}
}
// at this point:
// sp points to first valid char after quote.
// sq points to one char beyond last valid char.
// string len is (sq - sp).
if (qchar == '\'') {
*ret = norm_lit_str(sp, sq - sp, multiline, 0, 0);
} else {