Skip to content

Commit

Permalink
iniconf: some more adjustments for parsing TOML
Browse files Browse the repository at this point in the history
This patch:

- improve parsing of TOML [[arrays_of_tables]]
- adds support for 'single quoted keys' = true and
  "double quoted keys" = true

See universal-ctags/ctags#4099
  • Loading branch information
techee committed Nov 7, 2024
1 parent 5d0c388 commit 94cd13e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ctags/parsers/iniconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@
#include "subparser.h"
#include "vstring.h"

#define TOML_QUOTED_KEY_CHAR(c) ( (c) == '"' || (c) == '\'' )

static bool isIdentifier (int c)
{
/* allow whitespace within keys and sections */
return (bool)(isalnum (c) || isspace (c) || c == '_' || c == '-' || c == '.');
/* allow whitespace within keys and sections */
return (bool)(isalnum (c) || isspace (c) || c == '_' || c == '-' || c == '.'
|| TOML_QUOTED_KEY_CHAR(c));
}

static bool isValue (int c)
Expand Down Expand Up @@ -130,7 +133,8 @@ static void findIniconfTags (void)
if (*cp == '[')
{
++cp;
while (*cp != '\0' && *cp != ']')
/* look for the final ] to support TOML [[arrays.of.tables]] */
while (*cp != '\0' && (*cp != ']' || *(cp+1) == ']'))
{
vStringPut (name, *cp);
++cp;
Expand Down

0 comments on commit 94cd13e

Please sign in to comment.