* texi2mdoc: Make @value{...} parse its own arguments.
@ 2015-02-21 21:49 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-02-21 21:49 UTC (permalink / raw)
To: source
Log Message:
-----------
Make @value{...} parse its own arguments.
So add the necessary protection against infinite recursion.
Also protect against texivspace() in tables.
Modified Files:
--------------
texi2mdoc:
extern.h
main.c
texi2mdoc.1
util.c
Revision Data
-------------
Index: texi2mdoc.1
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/texi2mdoc.1,v
retrieving revision 1.5
retrieving revision 1.6
diff -Ltexi2mdoc.1 -Ltexi2mdoc.1 -u -p -r1.5 -r1.6
--- texi2mdoc.1
+++ texi2mdoc.1
@@ -86,8 +86,8 @@ utility was written by
.Sh CAVEATS
Amongst others, the
.Li @macro
-and macro-related commands,
-.Li @defcodeindex ,
+and macro-related commands,
+.Li @verb ,
and
.Li @footnote
are not supported.
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lutil.c -Lutil.c -u -p -r1.4 -r1.5
--- util.c
+++ util.c
@@ -252,7 +252,7 @@ void
texivspace(struct texi *p)
{
- if (p->seenvs)
+ if (p->seenvs || TEXILIST_TABLE == p->list)
return;
teximacro(p, "Pp");
p->seenvs = 1;
@@ -777,7 +777,8 @@ parsefile(struct texi *p, const char *fn
struct stat st;
size_t i;
- assert(p->filepos < 64);
+ if (64 == p->filepos)
+ texiabort(p, "too many open files");
f = &p->files[p->filepos];
memset(f, 0, sizeof(struct texifile));
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lmain.c -Lmain.c -u -p -r1.27 -r1.28
--- main.c
+++ main.c
@@ -135,12 +135,14 @@ static const struct texitok __texitoks[T
{ doignline, "dircategory", 11 }, /* TEXICMD_DIRCATEGORY */
{ doignblock, "direntry", 8 }, /* TEXICMD_DIRENTRY */
{ dodisplay, "display", 7 }, /* TEXICMD_DISPLAY */
+ { doignbracket, "dmn", 3 }, /* TEXICMD_DMN */
{ dosymbol, "dots", 4 }, /* TEXICMD_DOTS */
{ dolink, "email", 5 }, /* TEXICMD_EMAIL */
{ doinline, "emph", 4 }, /* TEXICMD_EMPH */
{ NULL, "end", 3 }, /* TEXICMD_END */
{ doenumerate, "enumerate", 9 }, /* TEXICMD_ENUMERATE */
{ doinline, "env", 3 }, /* TEXICMD_ENV */
+ { dosymbol, "equiv", 5 }, /* TEXICMD_EQUIV */
{ dosymbol, "error", 5 }, /* TEXICMD_ERROR */
{ doexample, "example", 7 }, /* TEXICMD_EXAMPLE */
{ doignline, "exdent", 6 }, /* TEXICMD_EXDENT */
@@ -201,10 +203,12 @@ static const struct texitok __texitoks[T
{ doignline, "page", 4 }, /* TEXICMD_PAGE */
{ doignline, "paragraphindent", 15 }, /* TEXICMD_PARINDENT */
{ dosymbol, ".", 1 }, /* TEXICMD_PERIOD */
+ { doignline, "pindex", 6 }, /* TEXICMD_PINDEX */
{ doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */
{ doinline, "r", 1 }, /* TEXICMD_R */
{ dosecoffs, "raisesections", 13 }, /* TEXICMD_RAISESECTIONS */
{ dobracket, "ref", 3 }, /* TEXICMD_REF */
+ { doignline, "refill", 6 }, /* TEXICMD_REFILL */
{ dosymbol, "result", 6 }, /* TEXICMD_RESULT */
{ doinline, "samp", 4 }, /* TEXICMD_SAMP */
{ doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */
@@ -228,6 +232,7 @@ static const struct texitok __texitoks[T
{ doinline, "strong", 6 }, /* TEXICMD_STRONG */
{ dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */
{ dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */
+ { dosubsubsection, "subsubheading", 13 }, /* TEXICMD_SUBSUBHEADING */
{ dosubsubsection, "subsubsection", 13 }, /* TEXICMD_SUBSUBSECTION */
{ doignline, "subtitle", 8 }, /* TEXICMD_SUBTITLE */
{ doignline, "summarycontents", 15 }, /* TEXICMD_SUMMARYCONTENTS */
@@ -870,6 +875,9 @@ dosymbol(struct texi *p, enum texicmd cm
case (TEXICMD_DOTS):
texiputchars(p, "...");
break;
+ case (TEXICMD_EQUIV):
+ texiputchars(p, "\\(==");
+ break;
case (TEXICMD_ERROR):
texiputchars(p, "error\\(->");
break;
@@ -961,7 +969,7 @@ static void
dovalue(struct texi *p, enum texicmd cmd,
const char *buf, size_t sz, size_t *pos)
{
- size_t start, end;
+ size_t start, end, i;
char *key, *val;
const char *cp;
@@ -1000,10 +1008,17 @@ dovalue(struct texi *p, enum texicmd cmd
if (p->seenws)
texiputchar(p, ' ');
p->seenws = 0;
- if (NULL == (cp = valueblookup(p, buf, sz, pos)))
+ if (NULL != (cp = valueblookup(p, buf, sz, pos))) {
+ for (i = 0; i < p->valstackpos; i++)
+ if (cp == p->valstack[i])
+ break;
+ if (i < p->valstackpos)
+ texierr(p, "recursive value");
+ p->valstack[p->valstackpos++] = cp;
+ parseeof(p, cp, strlen(cp));
+ p->valstackpos--;
+ } else
texiputchars(p, "{No value}");
- else
- texiputchars(p, cp);
} else if (TEXICMD_IFCLEAR == cmd) {
if (NULL != valuellookup(p, buf, sz, pos))
doignblock(p, cmd, buf, sz, pos);
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lextern.h -Lextern.h -u -p -r1.3 -r1.4
--- extern.h
+++ extern.h
@@ -81,12 +81,14 @@ enum texicmd {
TEXICMD_DIRCATEGORY,
TEXICMD_DIRENTRY,
TEXICMD_DISPLAY,
+ TEXICMD_DMN,
TEXICMD_DOTS,
TEXICMD_EMAIL,
TEXICMD_EMPH,
TEXICMD_END,
TEXICMD_ENUMERATE,
TEXICMD_ENV,
+ TEXICMD_EQUIV,
TEXICMD_ERROR,
TEXICMD_EXAMPLE,
TEXICMD_EXDENT,
@@ -147,10 +149,12 @@ enum texicmd {
TEXICMD_PAGE,
TEXICMD_PARINDENT,
TEXICMD_PERIOD,
+ TEXICMD_PINDEX,
TEXICMD_PRINTINDEX,
TEXICMD_R,
TEXICMD_RAISESECTIONS,
TEXICMD_REF,
+ TEXICMD_REFILL,
TEXICMD_RESULT,
TEXICMD_SAMP,
TEXICMD_SANSSERIF,
@@ -174,6 +178,7 @@ enum texicmd {
TEXICMD_STRONG,
TEXICMD_SUBHEADING,
TEXICMD_SUBSECTION,
+ TEXICMD_SUBSUBHEADING,
TEXICMD_SUBSUBSECTION,
TEXICMD_SUBTITLE,
TEXICMD_SUMMARYCONTENTS,
@@ -258,6 +263,8 @@ struct texivalue {
struct texi {
struct texifile files[64]; /* stack of open files */
size_t filepos; /* number of open files */
+ const char *valstack[64]; /* stack of opened values */
+ size_t valstackpos; /* position in valstack */
size_t outcol; /* column in output line */
char **dirs; /* texi directories */
size_t dirsz; /* number of texi directories */
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-02-21 21:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-21 21:49 texi2mdoc: Make @value{...} parse its own arguments kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).