* texi2mdoc: Have @math mode properly interpret commands and match
@ 2015-02-28 8:42 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-02-28 8:42 UTC (permalink / raw)
To: source
Log Message:
-----------
Have @math mode properly interpret commands and match squiggly brackets.
Modified Files:
--------------
texi2mdoc:
extern.h
main.c
util.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -Lmain.c -Lmain.c -u -p -r1.52 -r1.53
--- main.c
+++ main.c
@@ -690,13 +690,13 @@ doinline(struct texi *p, enum texicmd cm
}
if (NULL == macro || p->literal || TEXILIST_TABLE == p->list) {
- parsebracket(p, pos);
+ parsebracket(p, pos, 0);
return;
}
teximacroopen(p, macro);
p->seenws = 0;
- parsebracket(p, pos);
+ parsebracket(p, pos, 0);
texipunctuate(p, pos);
teximacroclose(p);
}
@@ -900,7 +900,7 @@ static void
dobracket(struct texi *p, enum texicmd cmd, size_t *pos)
{
- parsebracket(p, pos);
+ parsebracket(p, pos, 0);
}
static void
@@ -1328,35 +1328,8 @@ doquotation(struct texi *p, enum texicmd
static void
domath(struct texi *p, enum texicmd cmd, size_t *pos)
{
- size_t nest, start;
- /*
- * Math handling is different from everything else.
- * We don't allow any subcomponents, and we ignore the rules in
- * terms of @-commands.
- * This departs from GNU's rules, but whatever.
- */
- while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
- advance(p, pos);
- if (*pos == BUFSZ(p) || '{' != BUF(p)[*pos])
- return;
- advance(p, pos);
- if (p->seenws && p->outcol && 0 == p->literal)
- texiputchar(p, ' ');
- p->seenws = 0;
- for (nest = 1, start = *pos; *pos < BUFSZ(p) && nest > 0; ) {
- if ('{' == BUF(p)[*pos])
- nest++;
- else if ('}' == BUF(p)[*pos])
- if (0 == --nest)
- continue;
- advance(p, pos);
- }
- if (*pos == BUFSZ(p))
- return;
- assert('}' == BUF(p)[*pos]);
- texiputbuf(p, start, *pos);
- advance(p, pos);
+ parsebracket(p, pos, 1);
}
static void
@@ -1809,7 +1782,7 @@ doignbracket(struct texi *p, enum texicm
{
p->ign++;
- parsebracket(p, pos);
+ parsebracket(p, pos, 0);
p->ign--;
}
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -Lextern.h -Lextern.h -u -p -r1.18 -r1.19
--- extern.h
+++ extern.h
@@ -417,7 +417,7 @@ void advanceto(struct texi *, size_t *,
char **argparse(struct texi *, size_t *, size_t *, size_t);
int parsearg(struct texi *, size_t *, size_t);
-void parsebracket(struct texi *, size_t *);
+void parsebracket(struct texi *, size_t *, int);
void parsestdin(struct texi *);
void parsefile(struct texi *, const char *, int);
int parselinearg(struct texi *, size_t *);
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -Lutil.c -Lutil.c -u -p -r1.17 -r1.18
--- util.c
+++ util.c
@@ -719,9 +719,9 @@ parsearg(struct texi *p, size_t *pos, si
* This will stop in the event of EOF or if we're not at a bracket.
*/
void
-parsebracket(struct texi *p, size_t *pos)
+parsebracket(struct texi *p, size_t *pos, int dostack)
{
- size_t end, sv;
+ size_t end, sv, stack;
enum texicmd cmd;
struct teximacro *macro;
@@ -732,12 +732,25 @@ parsebracket(struct texi *p, size_t *pos
return;
advance(p, pos);
+ stack = 0;
while ((*pos = advancenext(p, pos)) < BUFSZ(p)) {
switch (BUF(p)[*pos]) {
case ('}'):
+ if (stack > 0) {
+ stack--;
+ advance(p, pos);
+ texiputchar(p, '}');
+ continue;
+ }
advance(p, pos);
return;
case ('{'):
+ if (dostack) {
+ stack++;
+ advance(p, pos);
+ texiputchar(p, '{');
+ continue;
+ }
if (0 == p->ign)
texiwarn(p, "unexpected \"{\"");
advance(p, pos);
@@ -874,7 +887,7 @@ parselinearg(struct texi *p, size_t *pos
}
if (*pos < BUFSZ(p) && '{' == BUF(p)[*pos])
- parsebracket(p, pos);
+ parsebracket(p, pos, 0);
else if (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos])
parsesingle(p, pos);
else
--
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-28 8:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-28 8:42 texi2mdoc: Have @math mode properly interpret commands and match 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).