pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/verify-synopsis Import verify-synopsis-1.0 as...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/075e7f305a53
branches:  trunk
changeset: 358428:075e7f305a53
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Sun Feb 12 18:56:54 2017 +0000

description:
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.

diffstat:

 textproc/verify-synopsis/DESCR                   |    2 +
 textproc/verify-synopsis/Makefile                |   40 +++++
 textproc/verify-synopsis/PLIST                   |    4 +
 textproc/verify-synopsis/files/dmpsynopsis.awk   |  164 +++++++++++++++++++++++
 textproc/verify-synopsis/files/verify-synopsis   |    4 +
 textproc/verify-synopsis/files/verify-synopsis.1 |   51 +++++++
 6 files changed, 265 insertions(+), 0 deletions(-)

diffs (289 lines):

diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/DESCR    Sun Feb 12 18:56:54 2017 +0000
@@ -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.
diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/Makefile Sun Feb 12 18:56:54 2017 +0000
@@ -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@localhost
+#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"
diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/PLIST    Sun Feb 12 18:56:54 2017 +0000
@@ -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
diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/files/dmpsynopsis.awk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/files/dmpsynopsis.awk    Sun Feb 12 18:56:54 2017 +0000
@@ -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 <swildner%dragonflybsd.org@localhost>
+#
+# 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";
+                       }
+               }
+       }
+}
diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/files/verify-synopsis
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/files/verify-synopsis    Sun Feb 12 18:56:54 2017 +0000
@@ -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"
diff -r 9b16d2f7df84 -r 075e7f305a53 textproc/verify-synopsis/files/verify-synopsis.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/textproc/verify-synopsis/files/verify-synopsis.1  Sun Feb 12 18:56:54 2017 +0000
@@ -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@localhost
+.Sh BUGS
+Macros are not handled very well.



Home | Main Index | Thread Index | Old Index