Skip to content

Commit 23c6e36

Browse files
authored
Merge pull request #4248 from masatake/toml--disabling
TOML,Cargo: disable the parsers temporarily
2 parents 64829f4 + 5a450d0 commit 23c6e36

File tree

18 files changed

+57
-6
lines changed

18 files changed

+57
-6
lines changed

.github/workflows/building-with-pegof.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
- run: ./ctags --list-features | grep pegof
4646

4747
- run: |
48-
echo "Targets: $(./ctags --list-languages=_packcc | tr '\n' ',')"
49-
- run: make units LANGUAGES="$(./ctags --list-languages=_packcc | tr '\n' ',')"
48+
echo "Targets: $(./ctags --list-languages=_packcc | while read LANG REST; do echo "$LANG"; done | tr '\n' ',')"
49+
- run: make units LANGUAGES="$(./ctags --list-languages=_packcc | while read LANG REST; do echo "$LANG"; done | tr '\n' ',')"
5050
- run: make dist
5151
# See EXTRA_DIST in Makefile.am.
5252
# Currently we add .pego files.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
--languages=-TOML
2+
--languages=+Cargo
3+
24
--map-Cargo=.cargo
35
--sort=no
46
--fields=+lK
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
--languages=+TOML
2+
13
--extras=+g
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
--languages=+TOML
2+
13
--extras=+g
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--languages=+TOML
2+
13
--extras=+g
24
--sort=no
35
--fields=+lne
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--languages=+TOML
2+
13
--extras=+g
24
--sort=no
35
--fields=+lne
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Taken from https://github.com/BurntSushi/toml/raw/refs/heads/master/internal/toml-test/tests/invalid/encoding/bad-utf8-at-end.toml
2+
With this input, the TOML parser entered an infinite loop.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
x input.toml /^x = """"""�/;" K
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packcc
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# There is a 0xda at after the quotes, and no EOL at the end of the file.
2+
#
3+
# This is a bit of an edge case: This indicates there should be two bytes
4+
# (0b1101_1010) but there is no byte to follow because it's the end of the file.
5+
x = """"""Ú
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--languages=+TOML
2+
13
--sort=no
24
--fields=+ne
35
--extras=+g
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
--languages=+TOML
2+
13
--sort=no
24
--fields=+ne
35
--extras=+g
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
--languages=+TOML
2+
13
--sort=no
24
--fields=+K{nth}{end}{line}

docs/news/HEAD.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ Parser related changes
4040
New parsers
4141
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4242

43-
* TOML *peg/packcc*
44-
* Cargo *TOML based subparser*
4543
* SELinuxIntefae *M4 based subparser*
4644
* SELinuxTypeEnforcement *optlib*
4745
* PythonEntryPoints *subparser*
4846
* Scdoc *optlib*
4947

48+
.. note:: We added a TOML as a new parser in this version. However,
49+
after adding it, we learned its implementation didn't work
50+
entirely. So we deleted the TOML parser, and Cargo subparser
51+
runs on the TOML parser from this "New parsers" list.
52+
See `TOML: infinite loop <https://github.com/universal-ctags/ctags/issues/4096>`__
53+
about how it doesn't work.
54+
5055
Changes about parser specific kinds, roles, fields, and extras
5156
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5257

main/parse.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,22 @@ extern void enableLanguage (const langType language, const bool state)
18131813
{
18141814
Assert (0 <= language && language < (int) LanguageCount);
18151815
LanguageTable [language].def->enabled = state;
1816+
1817+
static bool warned_toml;
1818+
static bool warned_cargo;
1819+
1820+
/* See #4096 */
1821+
if (!warned_toml && strcmp (LanguageTable [language].def->name, "TOML") == 0)
1822+
{
1823+
warned_toml = true;
1824+
error (WARNING, "The current implementation of the TOML parser is broken.");
1825+
}
1826+
1827+
if (!warned_cargo && strcmp (LanguageTable [language].def->name, "Cargo") == 0)
1828+
{
1829+
warned_cargo = true;
1830+
error (WARNING, "Enabling Cargo subparser may enable TOML parser.");
1831+
}
18161832
}
18171833

18181834
#ifdef DO_TRACING

main/parse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ struct sParserDefinition {
126126
tagXpathTableTable *tagXpathTableTable;
127127
unsigned int tagXpathTableCount;
128128
bool invisible;
129+
bool enabled; /* currently enabled? */
129130
fieldDefinition *fieldTable;
130131
unsigned int fieldCount;
131132
xtagDefinition *xtagTable;
@@ -149,7 +150,6 @@ struct sParserDefinition {
149150

150151
/* used internally */
151152
langType id; /* id assigned to language */
152-
unsigned int enabled:1; /* currently enabled? */
153153
unsigned int traced:1;
154154
};
155155

parsers/cargo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,8 @@ extern parserDefinition* CargoParser (void)
136136
def->patterns = patterns;
137137
def->parser = findCargoTags;
138138
def->useCork = CORK_QUEUE;
139+
140+
def->enabled = false; /* The base parser, TOML parser doesn't work well. */
141+
139142
return def;
140143
}

peg/toml_post.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ extern parserDefinition* TomlParser (void)
243243
def->extensions = extensions;
244244
def->parser = findTomlTags;
245245
def->useCork = true;
246-
def->enabled = true;
247246
def->requestAutomaticFQTag = false;
247+
248+
def->enabled = false; /* This parser is broken. */
249+
248250
return def;
249251
}

0 commit comments

Comments
 (0)