From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-1.sys.kth.se (smtp-1.sys.kth.se [130.237.32.175]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p92JriuH000047 for ; Sun, 2 Oct 2011 15:53:44 -0400 (EDT) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-1.sys.kth.se (Postfix) with ESMTP id B8573155920 for ; Sun, 2 Oct 2011 21:53:38 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-1.sys.kth.se ([130.237.32.175]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id 0cX5FShigyNq for ; Sun, 2 Oct 2011 21:53:36 +0200 (CEST) X-KTH-Auth: kristaps [83.250.3.9] X-KTH-mail-from: kristaps@bsd.lv X-KTH-rcpt-to: tech@mdocml.bsd.lv Received: from macky.local (c83-250-3-9.bredband.comhem.se [83.250.3.9]) by smtp-1.sys.kth.se (Postfix) with ESMTP id 0C72E1551FC for ; Sun, 2 Oct 2011 21:53:35 +0200 (CEST) Message-ID: <4E88C13D.6090708@bsd.lv> Date: Sun, 02 Oct 2011 21:53:33 +0200 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Thunderbird/3.1.14 X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 To: tech@mdocml.bsd.lv Subject: Re: -Tman with -mman References: <4E887D72.9090605@bsd.lv> <20111002154058.GA14208@britannica.bec.de> In-Reply-To: <20111002154058.GA14208@britannica.bec.de> Content-Type: multipart/mixed; boundary="------------070109070402050502010102" This is a multi-part message in MIME format. --------------070109070402050502010102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 02/10/2011 17:40, Joerg Sonnenberger wrote: > On Sun, Oct 02, 2011 at 05:04:18PM +0200, Kristaps Dzonsons wrote: >> Hi, >> >> What sort of behaviour is most reasonable when providing a man >> manual to the new -Tman? I think this should be ironed out before >> the release. The mandoc manual says "-Tman only with mdoc" and, if >> man is provided to -Tman, outputs nothing (like -Tlint). >> >> It makes the most sense to me to output the original file (after >> preprocessing, I guess). All this requires is a duplicate buffer in >> read.c (conditional on -Tman being present to avoid overhead in >> normal usage). I don't like the idea of putting out an error (or >> nothing at all) because it special-cases modes for input. > > Agreed, just giving back the original input (maybe reformatted) sounds > like the best approach. Putting some code to the idea... (Sorry for the churn, I ordered the mandoc.h functions. They're the same except for the mandoc_keep() and mandoc_getkeep() additions). This isn't quite commit-ready, but a start. Basically, I ask for a keep buffer if OUTT_MAN is specified. This needed some machinery to expose the parser to the front-end. Thoughts? --------------070109070402050502010102 Content-Type: text/plain; name="patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch.txt" Index: main.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/main.h,v retrieving revision 1.14 diff -u -r1.14 main.h --- main.h 18 Sep 2011 14:14:15 -0000 1.14 +++ main.h 2 Oct 2011 19:50:23 -0000 @@ -42,6 +42,7 @@ void tree_man(void *, const struct man *); void man_mdoc(void *, const struct mdoc *); +void man_man(void *, const struct man *); void *locale_alloc(char *); void *utf8_alloc(char *); Index: man.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v retrieving revision 1.111 diff -u -r1.111 man.c --- man.c 28 Jul 2011 14:17:11 -0000 1.111 +++ man.c 2 Oct 2011 19:50:27 -0000 @@ -648,3 +648,10 @@ if (m && m->first == n) m->first = NULL; } + +const struct mparse * +man_mparse(const struct man *m) +{ + + return(m->parse); +} Index: man.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v retrieving revision 1.58 diff -u -r1.58 man.h --- man.h 23 Mar 2011 12:33:01 -0000 1.58 +++ man.h 2 Oct 2011 19:50:27 -0000 @@ -105,6 +105,7 @@ const struct man_node *man_node(const struct man *); const struct man_meta *man_meta(const struct man *); +const struct mparse *man_mparse(const struct man *); __END_DECLS Index: mandoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v retrieving revision 1.95 diff -u -r1.95 mandoc.h --- mandoc.h 23 Jul 2011 18:44:42 -0000 1.95 +++ mandoc.h 2 Oct 2011 19:50:29 -0000 @@ -400,30 +400,31 @@ __BEGIN_DECLS -void mparse_free(struct mparse *); -void mparse_reset(struct mparse *); -struct mparse *mparse_alloc(enum mparset, - enum mandoclevel, mandocmsg, void *); -enum mandoclevel mparse_readfd(struct mparse *, int, const char *); -void mparse_result(struct mparse *, struct mdoc **, struct man **); -const char *mparse_strerror(enum mandocerr); -const char *mparse_strlevel(enum mandoclevel); - void *mandoc_calloc(size_t, size_t); +enum mandoc_esc mandoc_escape(const char **, const char **, int *); void *mandoc_malloc(size_t); void *mandoc_realloc(void *, size_t); char *mandoc_strdup(const char *); char *mandoc_strndup(const char *, size_t); - -enum mandoc_esc mandoc_escape(const char **, const char **, int *); - struct mchars *mchars_alloc(void); +void mchars_free(struct mchars *); char mchars_num2char(const char *, size_t); int mchars_num2uc(const char *, size_t); -const char *mchars_spec2str(struct mchars *, const char *, size_t, size_t *); -int mchars_spec2cp(struct mchars *, const char *, size_t); -void mchars_free(struct mchars *); - +int mchars_spec2cp(struct mchars *, + const char *, size_t); +const char *mchars_spec2str(struct mchars *, + const char *, size_t, size_t *); +struct mparse *mparse_alloc(enum mparset, + enum mandoclevel, mandocmsg, void *); +void mparse_free(struct mparse *); +void mparse_keep(struct mparse *); +enum mandoclevel mparse_readfd(struct mparse *, int, const char *); +void mparse_reset(struct mparse *); +void mparse_result(struct mparse *, + struct mdoc **, struct man **); +const char *mparse_getkeep(const struct mparse *); +const char *mparse_strerror(enum mandocerr); +const char *mparse_strlevel(enum mandoclevel); __END_DECLS Index: mdoc_man.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v retrieving revision 1.3 diff -u -r1.3 mdoc_man.c --- mdoc_man.c 30 Sep 2011 00:13:28 -0000 1.3 +++ mdoc_man.c 2 Oct 2011 19:50:29 -0000 @@ -18,6 +18,7 @@ #include #include "mandoc.h" +#include "man.h" #include "mdoc.h" #include "main.h" @@ -216,6 +217,13 @@ break; } } +} + +void +man_man(void *arg, const struct man *man) +{ + + puts(mparse_getkeep(man_mparse(man))); } void Index: read.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/read.c,v retrieving revision 1.23 diff -u -r1.23 read.c --- read.c 23 Jul 2011 18:41:18 -0000 1.23 +++ read.c 2 Oct 2011 19:50:33 -0000 @@ -63,6 +63,7 @@ mandocmsg mmsg; /* warning/error message handler */ void *arg; /* argument to mmsg */ const char *file; + struct buf *secondary; }; static void resize_buf(struct buf *, size_t); @@ -411,6 +412,21 @@ of = 0; + if (curp->secondary) { + curp->secondary->buf = + mandoc_realloc + (curp->secondary->buf, + curp->secondary->sz + pos + 2); + memcpy(curp->secondary->buf + + curp->secondary->sz, + ln.buf, pos); + curp->secondary->sz += pos; + curp->secondary->buf + [curp->secondary->sz] = '\n'; + curp->secondary->sz++; + curp->secondary->buf + [curp->secondary->sz] = '\0'; + } rerun: rr = roff_parseln (curp->roff, curp->line, @@ -704,6 +720,8 @@ mdoc_reset(curp->mdoc); if (curp->man) man_reset(curp->man); + if (curp->secondary) + curp->secondary->sz = 0; curp->file_status = MANDOCLEVEL_OK; curp->mdoc = NULL; @@ -720,7 +738,10 @@ man_free(curp->pman); if (curp->roff) roff_free(curp->roff); + if (curp->secondary) + free(curp->secondary->buf); + free(curp->secondary); free(curp); } @@ -779,4 +800,19 @@ mparse_strlevel(enum mandoclevel lvl) { return(mandoclevels[lvl]); +} + +void +mparse_keep(struct mparse *p) +{ + + p->secondary = mandoc_calloc(1, sizeof(struct buf)); +} + +const char * +mparse_getkeep(const struct mparse *p) +{ + + assert(p->secondary); + return(p->secondary->sz ? p->secondary->buf : NULL); } --------------070109070402050502010102-- -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv