Skip to content

Commit af6af4d

Browse files
committed
Tex: Fix TEX_NAME_FLAG_OPTIONAL for the last macro parameter
When the last parameter is optional and not present, the token is already read by parseWithStrategy() but this token is not reported to the caller as unprocessed which may cause missed tag for the following macro.
1 parent aa63a3e commit af6af4d

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
boxed input.tex /^\\newenvironment{boxed}$/;" e
22
boxedA input.tex /^\\renewenvironment{boxedA}$/;" e
33
theorem input.tex /^\\newtheorem{theorem}{Theorem}$/;" t
4+
theoremA input.tex /^\\newtheorem{theoremA}{Theorem A}$/;" t

Units/parser-tex.r/newenvironment.d/input.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\documentclass{article}
2+
\newtheorem{theoremA}{Theorem A}
23
\newenvironment{boxed}
34
{\begin{center}
45
\begin{tabular}{|p{0.9\textwidth}|}

parsers/tex.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ static bool parseWithStrategy (tokenInfo *token,
693693
}
694694
}
695695

696+
/* The last token is optional and not present - let the caller know */
697+
if (!next_token)
698+
*tokenUnprocessed = true;
699+
696700
if (name)
697701
deleteToken (name);
698702

@@ -991,7 +995,7 @@ static bool parseNewTheorem (tokenInfo *const token, bool *tokenUnprocessed)
991995
static bool parseNewcounter (tokenInfo *const token, bool *tokenUnprocessed)
992996
{
993997
bool eof = false;
994-
/* \newccounter {counter}[parentCounter] */
998+
/* \newcounter {counter}[parentCounter] */
995999
struct TexParseStrategy strategy [] = {
9961000
{
9971001
.type = '{',
@@ -1003,7 +1007,7 @@ static bool parseNewcounter (tokenInfo *const token, bool *tokenUnprocessed)
10031007
},
10041008
{
10051009
.type = '[',
1006-
.flags = 0,
1010+
.flags = TEX_NAME_FLAG_OPTIONAL,
10071011
.kindIndex = KIND_GHOST_INDEX,
10081012
.name = NULL,
10091013
},

0 commit comments

Comments
 (0)