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 cf493b4f; for ; Sat, 28 Feb 2015 08:17:14 -0500 (EST) Date: Sat, 28 Feb 2015 08:17:14 -0500 (EST) Message-Id: <14943697991492359906.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: When using @def style commands, indent the "explanation" X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- When using @def style commands, indent the "explanation" block as it's supposed to be, where subsequent @defx commands aren't indented. 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.53 retrieving revision 1.54 diff -Lmain.c -Lmain.c -u -p -r1.53 -r1.54 --- main.c +++ main.c @@ -498,9 +498,45 @@ dodefn(struct texi *p, enum texicmd cmd, abort(); } - texivspace(p); - if (NULL != blk) - parseto(p, pos, blk); + if (NULL == blk) + return; + + /* + * All "block" definitions have their block bodies indented + * unless they have the "x" form of the command following. + * E.g., + * @deffn some function + * @deffnx another + * An explanation. + * @end deffn + * With this loop, we delay opening the indented block until we + * skipped past conformant macros. + */ + for (;;) { + switch (peekcmd(p, *pos)) { + case (TEXICMD_DEFFNX): + case (TEXICMD_DEFMACX): + case (TEXICMD_DEFTPX): + case (TEXICMD_DEFTYPEFNX): + case (TEXICMD_DEFTYPEFUNX): + case (TEXICMD_DEFTYPEMETHODX): + case (TEXICMD_DEFTYPEVARX): + case (TEXICMD_DEFTYPEVRX): + case (TEXICMD_DEFUNX): + case (TEXICMD_DEFVARX): + case (TEXICMD_DEFVRX): + texivspace(p); + parseeoln(p, pos); + continue; + default: + break; + } + break; + } + teximacro(p, "Bd -filled -offset indent"); + p->seenvs = 1; + parseto(p, pos, blk); + teximacro(p, "Ed"); } static void Index: extern.h =================================================================== RCS file: /home/cvs/mdocml/texi2mdoc/extern.h,v retrieving revision 1.19 retrieving revision 1.20 diff -Lextern.h -Lextern.h -u -p -r1.19 -r1.20 --- extern.h +++ extern.h @@ -427,7 +427,9 @@ void parseto(struct texi *, size_t *, co void texiabort(struct texi *, const char *) __attribute__((noreturn)); enum texicmd - texicmd(struct texi *, size_t, size_t *, struct teximacro **); + texicmd(const struct texi *, size_t, size_t *, struct teximacro **); +enum texicmd + peekcmd(const struct texi *, size_t); void texierr(struct texi *, const char *, ...) __attribute__((format(printf, 2, 3))) __attribute__((noreturn)); Index: util.c =================================================================== RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v retrieving revision 1.18 retrieving revision 1.19 diff -Lutil.c -Lutil.c -u -p -r1.18 -r1.19 --- util.c +++ util.c @@ -591,7 +591,7 @@ parseword(struct texi *p, size_t *pos, c * index after the command name. */ enum texicmd -texicmd(struct texi *p, size_t pos, size_t *end, struct teximacro **macro) +texicmd(const struct texi *p, size_t pos, size_t *end, struct teximacro **macro) { size_t i, len, toksz; @@ -824,6 +824,23 @@ parseeoln(struct texi *p, size_t *pos) if (*pos < BUFSZ(p) && '\n' == BUF(p)[*pos]) advance(p, pos); +} + +/* + * Peek to see if there's a command after subsequent whitespace. + * If so, return the macro identifier. + * This DOES NOT work with user-defined macros. + */ +enum texicmd +peekcmd(const struct texi *p, size_t pos) +{ + size_t end; + + while (pos < BUFSZ(p) && ismspace(BUF(p)[pos])) + pos++; + if (pos == BUFSZ(p) || '@' != BUF(p)[pos]) + return(TEXICMD__MAX); + return(texicmd(p, pos, &end, NULL)); } /* -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv