From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ey0-f177.google.com (mail-ey0-f177.google.com [209.85.215.177]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p97LEbSt008235 for ; Fri, 7 Oct 2011 17:14:38 -0400 (EDT) Received: by eya28 with SMTP id 28so1559241eya.36 for ; Fri, 07 Oct 2011 14:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=x-authentication-warning:date:from:to:subject:message-id :mime-version:content-type:content-disposition:user-agent; bh=oA7wKwqwC8a5ge/J8kVTbJXU+v9uWDuHeSq5gS/cjIw=; b=flJQalIkQcnYIc6SH5iyjjA2RJaGwyMWUkPAUCtR9RRob2YfGZvjx/IgNU5drsgip0 ghKuhX4FS3pPQPP8NAGcBTpwTCkPKBWdfMsnzp/4tvUpxpgn8H3XJWQjPaavhnBzLCQm Snzt7Ys4TWdjKtlBCUHA1hHgyESUK2wo73mQM= Received: by 10.223.16.82 with SMTP id n18mr13188214faa.2.1318022071749; Fri, 07 Oct 2011 14:14:31 -0700 (PDT) Received: from procyon.xvoid.org ([213.132.76.142]) by mx.google.com with ESMTPS id g19sm14643650fai.8.2011.10.07.14.14.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Oct 2011 14:14:30 -0700 (PDT) Received: from procyon.xvoid.org (yuri@procyon.xvoid.org [IPv6:::1]) by procyon.xvoid.org (8.14.5/8.14.5) with ESMTP id p97LESpr062632 for ; Sat, 8 Oct 2011 01:14:28 +0400 (MSD) (envelope-from yuri.pankov@gmail.com) Received: (from yuri@localhost) by procyon.xvoid.org (8.14.5/8.14.5/Submit) id p97LESW4062631 for discuss@mdocml.bsd.lv; Sat, 8 Oct 2011 01:14:28 +0400 (MSD) (envelope-from yuri.pankov@gmail.com) X-Authentication-Warning: procyon.xvoid.org: yuri set sender to yuri.pankov@gmail.com using -f Date: Sat, 8 Oct 2011 01:14:28 +0400 From: Yuri Pankov To: discuss@mdocml.bsd.lv Subject: Use OSNAME/uname and msec.in for man(7) input Message-ID: <20111007211428.GG1294@procyon.xvoid.org> X-Mailinglist: mdocml-discuss Reply-To: discuss@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6c2NcOVqGQ03X4Wi" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) --6c2NcOVqGQ03X4Wi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I want to propose the following change to man_validate.c - if we are missing SOURCE and VOL in TH, do the same as for the mdoc manpages - use OSNAME, if it's not defined, use uname output and get the VOL from msec.in if VOL isn't defined in manpage. I've attached the diff that seems to work for me (mostly just copy/paste from mdoc_validate.c), hope the idea sounds ok.. Yuri --6c2NcOVqGQ03X4Wi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mandoc.diff" diff -r e29e4165c957 usr/src/cmd/mandoc/libmdoc.h --- a/usr/src/cmd/mandoc/libmdoc.h Fri Oct 07 21:40:20 2011 +0400 +++ b/usr/src/cmd/mandoc/libmdoc.h Sat Oct 08 01:01:42 2011 +0400 @@ -124,7 +124,6 @@ const char *mdoc_a2st(const char *); const char *mdoc_a2arch(const char *); const char *mdoc_a2vol(const char *); -const char *mdoc_a2msec(const char *); int mdoc_valid_pre(struct mdoc *, struct mdoc_node *); int mdoc_valid_post(struct mdoc *); enum margverr mdoc_argv(struct mdoc *, int, enum mdoct, diff -r e29e4165c957 usr/src/cmd/mandoc/man_validate.c --- a/usr/src/cmd/mandoc/man_validate.c Fri Oct 07 21:40:20 2011 +0400 +++ b/usr/src/cmd/mandoc/man_validate.c Sat Oct 08 01:01:42 2011 +0400 @@ -19,6 +19,10 @@ #include "config.h" #endif +#ifndef OSNAME +#include +#endif + #include #include @@ -357,8 +361,12 @@ static int post_TH(CHKARGS) { - const char *p; + char buf[BUFSIZ]; + const char *cp, *p; int line, pos; +#ifndef OSNAME + struct utsname utsname; +#endif if (m->meta.title) free(m->meta.title); @@ -412,13 +420,47 @@ /* TITLE MSEC DATE ->SOURCE<- VOL */ - if (n && (n = n->next)) + if (n && (n = n->next)) { m->meta.source = mandoc_strdup(n->string); + } else { +#ifdef OSNAME + if (strlcpy(buf, OSNAME, BUFSIZ) >= BUFSIZ) { + man_nmsg(m, n, MANDOCERR_MEM); + return(0); + } +#else /*!OSNAME */ + if (-1 == uname(&utsname)) { + man_nmsg(m, n, MANDOCERR_UNAME); + m->meta.source = mandoc_strdup("UNKNOWN"); + return(0); + } + + if (strlcpy(buf, utsname.sysname, BUFSIZ) >= BUFSIZ) { + man_nmsg(m, n, MANDOCERR_MEM); + return(0); + } + if (strlcat(buf, " ", BUFSIZ) >= BUFSIZ) { + man_nmsg(m, n, MANDOCERR_MEM); + return(0); + } + if (strlcat(buf, utsname.release, BUFSIZ) >= BUFSIZ) { + man_nmsg(m, n, MANDOCERR_MEM); + return(0); + } +#endif /*!OSNAME*/ + m->meta.source = mandoc_strdup(buf); + } /* TITLE MSEC DATE SOURCE ->VOL<- */ - if (n && (n = n->next)) + if (n && (n = n->next)) { m->meta.vol = mandoc_strdup(n->string); + } else { + if (NULL != (cp = mandoc_a2msec(m->meta.msec))) + m->meta.vol = mandoc_strdup(cp); + else + m->meta.vol = mandoc_strdup("UNKNOWN"); + } /* * Remove the `TH' node after we've processed it for our diff -r e29e4165c957 usr/src/cmd/mandoc/mandoc.h --- a/usr/src/cmd/mandoc/mandoc.h Fri Oct 07 21:40:20 2011 +0400 +++ b/usr/src/cmd/mandoc/mandoc.h Sat Oct 08 01:01:42 2011 +0400 @@ -409,6 +409,8 @@ const char *mparse_strerror(enum mandocerr); const char *mparse_strlevel(enum mandoclevel); +const char *mandoc_a2msec(const char *); + void *mandoc_calloc(size_t, size_t); void *mandoc_malloc(size_t); void *mandoc_realloc(void *, size_t); diff -r e29e4165c957 usr/src/cmd/mandoc/mdoc_validate.c --- a/usr/src/cmd/mandoc/mdoc_validate.c Fri Oct 07 21:40:20 2011 +0400 +++ b/usr/src/cmd/mandoc/mdoc_validate.c Sat Oct 08 01:01:42 2011 +0400 @@ -2077,7 +2077,7 @@ * arch = NULL */ - cp = mdoc_a2msec(nn->string); + cp = mandoc_a2msec(nn->string); if (cp) { mdoc->meta.vol = mandoc_strdup(cp); mdoc->meta.msec = mandoc_strdup(nn->string); diff -r e29e4165c957 usr/src/cmd/mandoc/msec.c --- a/usr/src/cmd/mandoc/msec.c Fri Oct 07 21:40:20 2011 +0400 +++ b/usr/src/cmd/mandoc/msec.c Sat Oct 08 01:01:42 2011 +0400 @@ -29,7 +29,7 @@ if (0 == strcmp(p, x)) return(y); const char * -mdoc_a2msec(const char *p) +mandoc_a2msec(const char *p) { #include "msec.in" --6c2NcOVqGQ03X4Wi-- -- To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv