From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 09c7547d; for ; Sun, 1 Mar 2015 11:58:09 -0500 (EST) Date: Sun, 1 Mar 2015 11:58:09 -0500 (EST) Message-Id: <8910750180204903241.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: texi2mdoc: Minor bug-fixes: empty macros still have brackets parsed, X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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