diff --git a/libobs/util/cf-lexer.c b/libobs/util/cf-lexer.c index 98ed53b0b..a524a3bf5 100644 --- a/libobs/util/cf-lexer.c +++ b/libobs/util/cf-lexer.c @@ -335,7 +335,7 @@ static bool cf_lexer_nexttoken(struct cf_lexer *lex, struct cf_token *out_token) base_token_clear(&start_token); cf_token_clear(out_token); - while (lexer_getbasetoken(&lex->base_lexer, &token, false)) { + while (lexer_getbasetoken(&lex->base_lexer, &token, PARSE_WHITESPACE)) { /* reclassify underscore as alpha for alnum tokens */ if (*token.text.array == '_') token.type = BASETOKEN_ALPHA; diff --git a/libobs/util/config-file.c b/libobs/util/config-file.c index fb05425e4..ecf88640a 100644 --- a/libobs/util/config-file.c +++ b/libobs/util/config-file.c @@ -101,7 +101,7 @@ static bool config_parse_string(struct lexer *lex, struct strref *ref, struct base_token token; base_token_clear(&token); - while (lexer_getbasetoken(lex, &token, false)) { + while (lexer_getbasetoken(lex, &token, PARSE_WHITESPACE)) { if (end) { if (*token.text.array == end) { success = true; @@ -138,11 +138,11 @@ static void config_parse_section(struct config_section *section, { struct base_token token; - while (lexer_getbasetoken(lex, &token, false)) { + while (lexer_getbasetoken(lex, &token, PARSE_WHITESPACE)) { struct strref name, value; while (token.type == BASETOKEN_WHITESPACE) { - if (!lexer_getbasetoken(lex, &token, false)) + if (!lexer_getbasetoken(lex, &token, PARSE_WHITESPACE)) return; } @@ -150,7 +150,7 @@ static void config_parse_section(struct config_section *section, if (*token.text.array == '#') { do { if (!lexer_getbasetoken(lex, &token, - false)) + PARSE_WHITESPACE)) return; } while (!is_newline(*token.text.array)); @@ -198,17 +198,18 @@ static int config_parse(struct darray *sections, const char *file, base_token_clear(&token); - while (lexer_getbasetoken(&lex, &token, false)) { + while (lexer_getbasetoken(&lex, &token, PARSE_WHITESPACE)) { struct config_section *section; while (token.type == BASETOKEN_WHITESPACE) { - if (!lexer_getbasetoken(&lex, &token, false)) + if (!lexer_getbasetoken(&lex, &token, PARSE_WHITESPACE)) goto complete; } if (*token.text.array != '[') { while (!is_newline(*token.text.array)) { - if (!lexer_getbasetoken(&lex, &token, false)) + if (!lexer_getbasetoken(&lex, &token, + PARSE_WHITESPACE)) goto complete; } diff --git a/libobs/util/lexer.c b/libobs/util/lexer.c index 1f18014d2..f0a41c664 100644 --- a/libobs/util/lexer.c +++ b/libobs/util/lexer.c @@ -250,11 +250,12 @@ static inline enum base_token_type get_char_token_type(const char ch) } bool lexer_getbasetoken(struct lexer *lex, struct base_token *token, - bool ignore_whitespace) + enum ignore_whitespace iws) { const char *offset = lex->offset; const char *token_start = NULL; enum base_token_type type = BASETOKEN_NONE; + bool ignore_whitespace = (iws == IGNORE_WHITESPACE); if (!offset) return false; diff --git a/libobs/util/lexer.h b/libobs/util/lexer.h index 174518646..ce11e2dee 100644 --- a/libobs/util/lexer.h +++ b/libobs/util/lexer.h @@ -280,8 +280,13 @@ static inline void lexer_reset(struct lexer *lex) lex->offset = lex->text; } +enum ignore_whitespace { + PARSE_WHITESPACE, + IGNORE_WHITESPACE +}; + EXPORT bool lexer_getbasetoken(struct lexer *lex, struct base_token *t, - bool ignore_whitespace); + enum ignore_whitespace iws); EXPORT void lexer_getstroffset(const struct lexer *lex, const char *str, uint32_t *row, uint32_t *col); diff --git a/libobs/util/text-lookup.c b/libobs/util/text-lookup.c index 17650cf25..620fe303a 100644 --- a/libobs/util/text-lookup.c +++ b/libobs/util/text-lookup.c @@ -216,7 +216,7 @@ static bool lookup_gettoken(struct lexer *lex, struct strref *str) base_token_clear(&temp); strref_clear(str); - while (lexer_getbasetoken(lex, &temp, false)) { + while (lexer_getbasetoken(lex, &temp, PARSE_WHITESPACE)) { char ch = *temp.text.array; if (!str->array) {