Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK)) by mollari.NetBSD.org (Postfix) with ESMTPS id 2F25B7A16A for ; Sun, 12 Feb 2017 18:56:56 +0000 (UTC) Received: by mail.netbsd.org (Postfix, from userid 605) id 8FEF0855DE; Sun, 12 Feb 2017 18:56:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 1EF8B855DB for ; Sun, 12 Feb 2017 18:56:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id mScg8S23cr7H for ; Sun, 12 Feb 2017 18:56:54 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 47339855D4 for ; Sun, 12 Feb 2017 18:56:54 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 42632FBE3; Sun, 12 Feb 2017 18:56:54 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1486925814177160" MIME-Version: 1.0 Date: Sun, 12 Feb 2017 18:56:54 +0000 From: "Thomas Klausner" Subject: CVS commit: pkgsrc/textproc/verify-synopsis To: pkgsrc-changes@NetBSD.org Reply-To: wiz@netbsd.org X-Mailer: log_accum Message-Id: <20170212185654.42632FBE3@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk This is a multi-part message in MIME format. --_----------=_1486925814177160 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: wiz Date: Sun Feb 12 18:56:54 UTC 2017 Added Files: pkgsrc/textproc/verify-synopsis: DESCR Makefile PLIST pkgsrc/textproc/verify-synopsis/files: dmpsynopsis.awk verify-synopsis verify-synopsis.1 Log Message: Import verify-synopsis-1.0 as textproc/verify-synopsis. This package contains a tool to verify that the functions in the SYNOPSIS of a man page match the actual implementation. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 pkgsrc/textproc/verify-synopsis/DESCR \ pkgsrc/textproc/verify-synopsis/Makefile \ pkgsrc/textproc/verify-synopsis/PLIST cvs rdiff -u -r0 -r1.1 pkgsrc/textproc/verify-synopsis/files/dmpsynopsis.awk \ pkgsrc/textproc/verify-synopsis/files/verify-synopsis \ pkgsrc/textproc/verify-synopsis/files/verify-synopsis.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_1486925814177160 Content-Disposition: inline Content-Length: 10157 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Added files: Index: pkgsrc/textproc/verify-synopsis/DESCR diff -u /dev/null pkgsrc/textproc/verify-synopsis/DESCR:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/DESCR Sun Feb 12 18:56:54 2017 @@ -0,0 +1,2 @@ +This package contains a tool to verify that the functions in the +SYNOPSIS of a man page match the actual implementation. Index: pkgsrc/textproc/verify-synopsis/Makefile diff -u /dev/null pkgsrc/textproc/verify-synopsis/Makefile:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/Makefile Sun Feb 12 18:56:54 2017 @@ -0,0 +1,40 @@ +# $NetBSD: Makefile,v 1.1 2017/02/12 18:56:54 wiz Exp $ + +DISTNAME= verify-synopsis-1.0 +CATEGORIES= textproc +MASTER_SITES= # none +DISTFILES= # none + +OWNER= wiz@NetBSD.org +#HOMEPAGE= # +COMMENT= Tool for verifying man pages' SYNOPSIS +LICENSE= modified-bsd + +INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 libexec + +WRKSRC= ${WRKDIR} +NO_BUILD= yes +USE_LANGUAGES= # none + +.include "../../mk/bsd.prefs.mk" + +.if ${OPSYS} != "NetBSD" +DEPENDS+= mdocml-[0-9]*:../../textproc/mdocml +.endif + +SUBST_CLASSES+= prefix +SUBST_STAGE.prefix= post-extract +SUBST_VARS.prefix= PREFIX +SUBST_FILES.prefix= verify-synopsis +SUBST_MESSAGE.prefix= Fixing prefix. + +do-extract: + cd ${FILESDIR} && cp d* v* ${WRKSRC}/ + +do-install: + ${INSTALL_SCRIPT} ${WRKSRC}/verify-synopsis ${DESTDIR}${PREFIX}/bin + ${INSTALL_DATA} ${WRKSRC}/dmpsynopsis.awk ${DESTDIR}${PREFIX}/libexec + ${INSTALL_MAN} ${FILESDIR}/verify-synopsis.1 \ + ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1 + +.include "../../mk/bsd.pkg.mk" Index: pkgsrc/textproc/verify-synopsis/PLIST diff -u /dev/null pkgsrc/textproc/verify-synopsis/PLIST:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/PLIST Sun Feb 12 18:56:54 2017 @@ -0,0 +1,4 @@ +@comment $NetBSD: PLIST,v 1.1 2017/02/12 18:56:54 wiz Exp $ +bin/verify-synopsis +libexec/dmpsynopsis.awk +man/man1/verify-synopsis.1 Index: pkgsrc/textproc/verify-synopsis/files/dmpsynopsis.awk diff -u /dev/null pkgsrc/textproc/verify-synopsis/files/dmpsynopsis.awk:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/files/dmpsynopsis.awk Sun Feb 12 18:56:54 2017 @@ -0,0 +1,164 @@ +# +# Copyright (c) 2016 The DragonFly Project. All rights reserved. +# +# This code is derived from software contributed to The DragonFly Project +# by Sascha Wildner +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name of The DragonFly Project nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific, prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +# +# Converts the output of mandoc -Ttree (run over a manual page +# with prototypes) into a small C program that can be used to +# check it. +# + +($1 == "SYNOPSIS" && $2 == "(text)") { + getline; + if ($1 == "Sh" && ($2 == "(block-body)" || $2 == "(body)")) { + getline; + while ($1 != "Sh") { + if ($2 == "(elem)") { + if (elem == "Fn" || + (elem == "Fa" && $1 != "Fa")) { + printf ");\n" + if (justtypedef == 0) { + printf "#ifndef %s\n", + function_name; + printf "man_%s test_%s = %s;\n", + function_name, + function_name, + function_name; + printf "#endif"; + } + printf "\n"; + justtypedef = 0; + function_type = ""; + } + elem = $1; # elem is now from the current line + funcnamenext = 0; + if (elem == "In") + printf "#include "; + else if (elem == "Fn") + funcnamenext = 1; + else if (elem == "Ft") + firsttypenext = 1; + } else if ($2 == "(block)" && elem == "In" && + $1 != "Fo") { + elem = ""; + } else if (match($0, "(text)") != 0) { + if (elem == "In") { + printf "<%s>\n", $1; + } else if (elem == "Ft") { # function type + if ($1 == "typedef") { + justtypedef = 1; + firsttypenext = 0; + } + gsub("^[ ]*", ""); + gsub(" [(]text[)].*", ""); + gsub("\\\\", ""); + if (justtypedef == 1) { + printf "\n"; + } + if (firsttypenext == 1) { + firsttypenext = 0; + printf "\ntypedef "; + } + function_type = $0; + printf "%s ", function_type; + } else if (elem == "Fn") { # function name + if (funcnamenext == 1) { + function_name = $1; + if (justtypedef == 1) { + printf "%s(", + function_name; + } else { + if (function_type == "") + printf "\ntypedef void *****"; + printf "(*man_%s)(", + function_name; + } + funcnamenext = 0; + firstargnext = 1; + } else { # function arguments + gsub("^[ ]*", "") + gsub(" [(]text[)].*", ""); + gsub("\\\\\\\\[*][(]lp", "("); + gsub("\\\\\\\\[*][(]rp", ")"); + if (firstargnext == 1) + firstargnext = 0; + else + printf ", "; + if (justtypedef == 0) { + printf("\n#ifdef %s\n", function_name); + if (index($0, " ") == 0 && $0 != "void") + printf("int\n"); + printf("#endif\n"); + } + printf "%s", $0; + } + } else if (elem == "Fa") { + gsub("^[ ]*", "") + gsub(" [(]text[)].*", ""); + gsub("\\\\:", ""); # \: (see groff(7)) + if (firstargnext == 1) + firstargnext = 0; + else + printf ", "; + if (justtypedef == 0) { + printf("\n#ifdef %s\n", function_name); + if (index($0, " ") == 0 && $0 != "void") + printf("int\n"); + printf("#endif\n"); + } + printf "%s", $0; + } + } else if ($1 == "Fo") { + getline; getline; + function_name = $1; + if (function_type == "") + printf "\ntypedef void *****"; + printf "(*man_%s)(", function_name; + getline; + firstargnext = 1; + } + getline; + } + if (elem == "Fn" || elem == "Fa") { + printf ");\n"; + if (justtypedef == 0) { + printf "#ifndef %s\n", function_name; + printf "man_%s test_%s = %s;\n", + function_name, + function_name, + function_name; + printf "#endif\n"; + } + } + } +} Index: pkgsrc/textproc/verify-synopsis/files/verify-synopsis diff -u /dev/null pkgsrc/textproc/verify-synopsis/files/verify-synopsis:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/files/verify-synopsis Sun Feb 12 18:56:54 2017 @@ -0,0 +1,4 @@ +#!/bin/sh +TMPFILE=/tmp/verify-synopsis.$$.c +mandoc -Ttree "$@" | awk -f @PREFIX@/libexec/dmpsynopsis.awk > "$TMPFILE" && gcc -c -o /dev/null -Wall "$TMPFILE" 2>&1 +rm -f "$TMPFILE" Index: pkgsrc/textproc/verify-synopsis/files/verify-synopsis.1 diff -u /dev/null pkgsrc/textproc/verify-synopsis/files/verify-synopsis.1:1.1 --- /dev/null Sun Feb 12 18:56:54 2017 +++ pkgsrc/textproc/verify-synopsis/files/verify-synopsis.1 Sun Feb 12 18:56:54 2017 @@ -0,0 +1,51 @@ +.\" $NetBSD: verify-synopsis.1,v 1.1 2017/02/12 18:56:54 wiz Exp $ +.\" +.\" Copyright (c) 2017 Thomas Klausner +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR, THOMAS KLAUSNER, +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd February 12, 2017 +.Dt VERIFY-SYNOPSIS 1 +.Os +.Sh NAME +.Nm verify-synopsis +.Nd man page verification of SYNOPSIS section +.Sh SYNOPSIS +.Nm +.Op Ar manpage +.Sh DESCRIPTION +.Nm +verifies the SYNOPSIS section of a man page by extracting it into +a C code snipped and compiling this. +The compiler warnings will indiciate missing headers or incorrect +prototypes. +.Sh EXAMPLES +.Dl verify-synopsis foo.3 +.Sh SEE ALSO +.Xr mandoc 1 , +.Xr mdoclint 1 +.Sh AUTHORS +.An Sascha Wildner +.Aq Mt swildner@dragonflybsd.org +.Sh BUGS +Macros are not handled very well. --_----------=_1486925814177160--