* texi2mdoc: Minor bug-fixes: empty macros still have brackets parsed,
@ 2015-03-01 16:58 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-03-01 16:58 UTC (permalink / raw)
To: source
Log Message:
-----------
Minor bug-fixes: empty macros still have brackets parsed, correctly
skipping '@NEWLINE' when advancing to the end of line, adding which
nodes are in the info navigation section.
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.56
retrieving revision 1.57
diff -Lmain.c -Lmain.c -u -p -r1.56 -r1.57
--- main.c
+++ main.c
@@ -942,6 +942,8 @@ static void
dodisplay(struct texi *p, enum texicmd cmd, size_t *pos)
{
+ advanceeoln(p, pos, 1);
+
switch (cmd) {
case (TEXICMD_FORMAT):
case (TEXICMD_SMALLFORMAT):
@@ -953,8 +955,6 @@ dodisplay(struct texi *p, enum texicmd c
}
p->seenvs = 1;
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
parseto(p, pos, texitoks[cmd].tok);
teximacro(p, "Ed");
}
@@ -963,9 +963,9 @@ static void
doexample(struct texi *p, enum texicmd cmd, size_t *pos)
{
- teximacro(p, "Bd -literal -offset indent");
- /* FIXME: ignore and parseeoln. */
advanceeoln(p, pos, 1);
+
+ teximacro(p, "Bd -literal -offset indent");
p->literal++;
parseto(p, pos, texitoks[cmd].tok);
p->literal--;
@@ -983,22 +983,27 @@ dobye(struct texi *p, enum texicmd cmd,
static void
dotitle(struct texi *p, enum texicmd cmd, size_t *pos)
{
- size_t start, end;
+ size_t start;
while (*pos < BUFSZ(p) && isws(BUF(p)[*pos]))
advance(p, pos);
- start = end = *pos;
- while (end < BUFSZ(p) && '\n' != BUF(p)[end])
- end++;
- if (end < BUFSZ(p))
- end++;
- advanceeoln(p, pos, 1);
+
+ /* We want to suck down the entire line, inclusive \n. */
+ start = *pos;
+ while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) {
+ if ('@' == BUF(p)[*pos])
+ advance(p, pos);
+ advance(p, pos);
+ }
+ if (*pos < BUFSZ(p))
+ advance(p, pos);
+
+ /* Copy this into a buffer. */
free(p->subtitle);
- p->subtitle = malloc(end - start + 1);
- if (NULL == p->subtitle)
+ if (NULL == (p->subtitle = malloc(*pos - start + 1)))
texiabort(p, NULL);
- memcpy(p->subtitle, &BUF(p)[start], end - start);
- p->subtitle[end - start] = '\0';
+ memcpy(p->subtitle, &BUF(p)[start], *pos - start);
+ p->subtitle[*pos - start] = '\0';
}
static void
@@ -1604,12 +1609,11 @@ static void
dosp(struct texi *p, enum texicmd cmd, size_t *pos)
{
+ advanceeoln(p, pos, 1);
if (p->literal)
texiputchar(p, '\n');
else
texivspace(p);
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
}
static void
@@ -1681,7 +1685,7 @@ domultitable(struct texi *p, enum texicm
/* Make sure we don't print anything when scanning. */
p->ign++;
- if ('@' == BUF(p)[*pos]) {
+ if (*pos < BUFSZ(p) && '@' == BUF(p)[*pos]) {
/*
* Look for @columnfractions.
* We ignore these, but we do use the number of
@@ -1733,10 +1737,10 @@ dotable(struct texi *p, enum texicmd cmd
{
enum texilist sv = p->list;
+ advanceeoln(p, pos, 1);
+
p->list = TEXILIST_ITEM;
teximacro(p, "Bl -tag -width Ds");
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
p->seenvs = 1;
parseto(p, pos, texitoks[cmd].tok);
teximacro(p, "El");
@@ -1764,12 +1768,12 @@ doenumerate(struct texi *p, enum texicmd
{
enum texilist sv = p->list;
+ advanceeoln(p, pos, 1);
+
p->list = TEXILIST_NOITEM;
teximacro(p, "Bl -enum");
p->seenvs = 1;
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
- parseto(p, pos, "enumerate");
+ parseto(p, pos, texitoks[cmd].tok);
teximacro(p, "El");
p->list = sv;
}
@@ -1779,12 +1783,12 @@ doitemize(struct texi *p, enum texicmd c
{
enum texilist sv = p->list;
+ advanceeoln(p, pos, 1);
+
p->list = TEXILIST_NOITEM;
teximacro(p, "Bl -bullet");
p->seenvs = 1;
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
- parseto(p, pos, "itemize");
+ parseto(p, pos, texitoks[cmd].tok);
teximacro(p, "El");
p->list = sv;
}
@@ -1802,8 +1806,7 @@ static void
doignline(struct texi *p, enum texicmd cmd, size_t *pos)
{
- /* FIXME: ignore and parseeoln. */
- advanceeoln(p, pos, 1);
+ advanceeoln(p, pos, 1);
}
/*
Index: extern.h
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -Lextern.h -Lextern.h -u -p -r1.22 -r1.23
--- extern.h
+++ extern.h
@@ -373,7 +373,7 @@ struct teximacro {
*/
struct texi {
const char *chapters; /* are we splitting chapters */
- size_t chapnum;
+ size_t chapnum; /* current chapter node */
char **dirs; /* texi directories */
size_t dirsz; /* number of texi directories */
FILE *outfile;
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lutil.c -Lutil.c -u -p -r1.21 -r1.22
--- util.c
+++ util.c
@@ -362,6 +362,7 @@ texipunctuate(struct texi *p, size_t *po
case ('.'):
case ('"'):
case (':'):
+ case (';'):
case ('!'):
case ('?'):
continue;
@@ -415,15 +416,18 @@ advancenext(struct texi *p, size_t *pos)
/*
* Advance to the EOLN in the input stream.
- * NOTE: THIS SHOULD NOT BE CALLED ON BLANK TEXT, as it will read up to
- * the @\n.
+ * This will skip over '@' markers in an effort to ignore escaped
+ * newlines.
*/
size_t
advanceeoln(struct texi *p, size_t *pos, int consumenl)
{
- while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos])
+ while (*pos < BUFSZ(p) && '\n' != BUF(p)[*pos]) {
+ if ('@' == BUF(p)[*pos])
+ advance(p, pos);
advance(p, pos);
+ }
if (*pos < BUFSZ(p) && consumenl)
advance(p, pos);
return(*pos);
@@ -452,8 +456,13 @@ texiexecmacro(struct texi *p, struct tex
const char *cp;
/* Disregard empty macros. */
- if (0 == (valsz = realsz = strlen(m->value)))
+ if (0 == (valsz = realsz = strlen(m->value))) {
+ args = argparse(p, pos, &asz, m->argsz);
+ for (i = 0; i < asz; i++)
+ free(args[i]);
+ free(args);
return;
+ }
/*
* This is important: it protect us from macros that invoke more
@@ -1369,26 +1378,32 @@ teximdocclose(struct texi *p, int last)
/* Print a reference to the "top" node. */
if (p->chapnum > 1) {
+ texiputchars(p, "Top node,");
snprintf(buf, sizeof(buf), "node1 7");
teximacroopen(p, "Xr ");
texiputchars(p, buf);
- texiputchars(p, " ,");
+ texiputchars(p, " ;");
teximacroclose(p);
}
/* Print a reference to the previous node. */
if (p->chapnum > 2) {
+ texiputchars(p, "previous node,");
snprintf(buf, sizeof(buf),
"node%zu 7", p->chapnum - 1);
teximacroopen(p, "Xr ");
texiputchars(p, buf);
if ( ! last)
- texiputchars(p, " ,");
+ texiputchars(p, " ;");
teximacroclose(p);
}
/* Print a reference to the next node. */
if ( ! last) {
+ if (1 == p->chapnum)
+ texiputchars(p, "Next node,");
+ else
+ texiputchars(p, "next node,");
snprintf(buf, sizeof(buf),
"node%zu 7", p->chapnum + 1);
teximacroopen(p, "Xr ");
--
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-03-01 16:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 16:58 texi2mdoc: Minor bug-fixes: empty macros still have brackets parsed, 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).