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 3db4aa51; for ; Sat, 7 Mar 2015 06:50:02 -0500 (EST) Date: Sat, 7 Mar 2015 06:50:02 -0500 (EST) Message-Id: <10538101184207899635.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: Be more careful when we emit newlines before tables. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Be more careful when we emit newlines before tables. Also adds an ifdef'd initial @menu implementation, which still requires some careful thought. Modified Files: -------------- texi2mdoc: main.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v retrieving revision 1.63 retrieving revision 1.64 diff -Lmain.c -Lmain.c -u -p -r1.63 -r1.64 --- main.c +++ main.c @@ -61,6 +61,9 @@ static void doitemize(struct texi *, enu static void dolink(struct texi *, enum texicmd, size_t *); static void domacro(struct texi *, enum texicmd, size_t *); static void domath(struct texi *, enum texicmd, size_t *); +#if 0 +static void domenu(struct texi *, enum texicmd, size_t *); +#endif static void domultitable(struct texi *, enum texicmd, size_t *); static void doquotation(struct texi *, enum texicmd, size_t *); static void dotable(struct texi *, enum texicmd, size_t *); @@ -1451,6 +1454,117 @@ doquotation(struct texi *p, enum texicmd teximacro(p, "Qc"); } +#if 0 +static void +domenu(struct texi *p, enum texicmd cmd, size_t *pos) +{ + size_t start; + + if (NULL != p->chapters) { + doignblock(p, cmd, pos); + return; + } + + advanceeoln(p, pos, 1); + + teximacro(p, "Bl -tag -width Ds"); + while (*pos < BUFSZ(p)) { + /* Read to next menu item. */ + while (*pos < BUFSZ(p) && ismspace(BUF(p)[*pos])) + advance(p, pos); + if ('*' != BUF(p)[*pos]) + break; + + assert('*' == BUF(p)[*pos]); + advance(p, pos); + while (*pos < BUFSZ(p) && ismspace(BUF(p)[*pos])) + advance(p, pos); + start = *pos; + while (*pos < BUFSZ(p) && ':' != BUF(p)[*pos]) + advance(p, pos); + if (*pos == BUFSZ(p) || *pos == start) { + texiwarn(p, "empty menu name"); + break; + } + teximacroopen(p, "It"); + teximacroopen(p, "Sx"); + for ( ; start < *pos; start++) + texiputchar(p, BUF(p)[start]); + teximacroclose(p); + teximacroclose(p); + + advance(p, pos); + if (*pos == BUFSZ(p)) { + texiwarn(p, "bad menu syntax"); + break; + } else if (':' != BUF(p)[*pos]) { + while (*pos < BUFSZ(p) && isws(BUF(p)[*pos])) + advance(p, pos); + start = *pos; + while (*pos < BUFSZ(p)) { + switch (BUF(p)[*pos]) { + case ('\t'): + case ('\n'): + case (','): + break; + case ('.'): + if (*pos + 1 == BUFSZ(p)) { + advance(p, pos); + continue; + } + if (' ' == BUF(p)[*pos + 1]) { + advance(p, pos); + break; + } + /* FALLTHROUGH */ + default: + advance(p, pos); + continue; + } + advance(p, pos); + break; + } + } else + advance(p, pos); + + while (*pos < BUFSZ(p) && isws(BUF(p)[*pos])) + advance(p, pos); + + if (*pos == BUFSZ(p)) { + texiwarn(p, "bad menu syntax"); + break; + } + + while (*pos < BUFSZ(p)) { + if ('*' == BUF(p)[*pos]) + break; + if ('\n' != BUF(p)[*pos]) { + texiputchar(p, BUF(p)[*pos]); + advance(p, pos); + continue; + } + advance(p, pos); + while (*pos == BUFSZ(p)) { + texiwarn(p, "bad menu syntax"); + break; + } + if ('\n' == BUF(p)[*pos]) { + advance(p, pos); + break; + } else if ('*' == BUF(p)[*pos]) { + continue; + } else if ('@' == BUF(p)[*pos]) + break; + texiputchar(p, ' '); + } + } + + teximacro(p, "El"); + + doignblock(p, cmd, pos); +} +#endif + static void domath(struct texi *p, enum texicmd cmd, size_t *pos) { @@ -1705,7 +1819,8 @@ doitem(struct texi *p, enum texicmd cmd, /* Multitable is using raw tbl(7). */ if (TEXILIST_TABLE == p->list) { - texiputchar(p, '\n'); + if (p->outcol > 0) + texiputchar(p, '\n'); return; } @@ -1740,7 +1855,7 @@ dotab(struct texi *p, enum texicmd cmd, { /* This command is only useful in @multitable. */ - if (TEXILIST_TABLE == p->list) + if (TEXILIST_TABLE == p->list && p->outcol) texiputchar(p, '\t'); } @@ -1752,6 +1867,7 @@ domultitable(struct texi *p, enum texicm enum texicmd type; size_t i, end, columns; + texivspace(p); p->list = TEXILIST_TABLE; /* * TS/TE blocks aren't "in mdoc(7)", so we can disregard the @@ -1805,7 +1921,9 @@ domultitable(struct texi *p, enum texicm texiputchar(p, ' '); texiputchar(p, 'l'); } - texiputchars(p, ".\n"); + + texiputchar(p, '.'); + texiputchar(p, '\n'); p->outmacro++; parseto(p, pos, texitoks[cmd].tok); p->outmacro--; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv