format and comment only
This commit is contained in:
parent
52e9c039c5
commit
6fe7fee127
2 changed files with 38 additions and 30 deletions
24
toml.c
24
toml.c
|
@ -2216,6 +2216,7 @@ int toml_rtos(toml_raw_t src, char **ret) {
|
||||||
if (!src)
|
if (!src)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
// for strings, first char must be a s-quote or d-quote
|
||||||
int qchar = src[0];
|
int qchar = src[0];
|
||||||
int srclen = strlen(src);
|
int srclen = strlen(src);
|
||||||
if (!(qchar == '\'' || qchar == '"')) {
|
if (!(qchar == '\'' || qchar == '"')) {
|
||||||
|
@ -2224,12 +2225,14 @@ int toml_rtos(toml_raw_t src, char **ret) {
|
||||||
|
|
||||||
// triple quotes?
|
// triple quotes?
|
||||||
if (qchar == src[1] && qchar == src[2]) {
|
if (qchar == src[1] && qchar == src[2]) {
|
||||||
multiline = 1;
|
multiline = 1; // triple-quote implies multiline
|
||||||
sp = src + 3;
|
sp = src + 3; // first char after quote
|
||||||
sq = src + srclen - 3;
|
sq = src + srclen - 3; // first char of ending quote
|
||||||
/* last 3 chars in src must be qchar */
|
|
||||||
if (!(sp <= sq && sq[0] == qchar && sq[1] == qchar && sq[2] == qchar))
|
if (!(sp <= sq && sq[0] == qchar && sq[1] == qchar && sq[2] == qchar)) {
|
||||||
|
// last 3 chars in src must be qchar
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* skip new line immediate after qchar */
|
/* skip new line immediate after qchar */
|
||||||
if (sp[0] == '\n')
|
if (sp[0] == '\n')
|
||||||
|
@ -2238,13 +2241,18 @@ int toml_rtos(toml_raw_t src, char **ret) {
|
||||||
sp += 2;
|
sp += 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sp = src + 1;
|
sp = src + 1; // first char after quote
|
||||||
sq = src + srclen - 1;
|
sq = src + srclen - 1; // ending quote
|
||||||
|
if (!(sp <= sq && *sq == qchar)) {
|
||||||
/* last char in src must be qchar */
|
/* last char in src must be qchar */
|
||||||
if (!(sp <= sq && *sq == qchar))
|
|
||||||
return -1;
|
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 == '\'') {
|
if (qchar == '\'') {
|
||||||
*ret = norm_lit_str(sp, sq - sp, multiline, 0, 0);
|
*ret = norm_lit_str(sp, sq - sp, multiline, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue