Extract correct man section from files in man_MANS.
authorPeter Breitenlohner <peb@mppmu.mpg.de>
Sat, 7 Mar 2009 00:06:18 +0000 (01:06 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 7 Mar 2009 00:07:09 +0000 (01:07 +0100)
* lib/am/mans.am: Extract correct man section in the presence of
multiple dots in the file base name and/or directory components.
* tests/man5.test: New test case.
* tests/Makefile.am: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
lib/am/mans.am
tests/Makefile.am
tests/Makefile.in
tests/man5.test [new file with mode: 0755]

index 49c2543..5aff609 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-03-07  Peter Breitenlohner  <peb@mppmu.mpg.de>
+           Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Extract correct man section from files in man_MANS.
+       * lib/am/mans.am: Extract correct man section in the presence of
+       multiple dots in the file base name and/or directory components.
+       * tests/man5.test: New test case.
+       * tests/Makefile.am: Update.
+
 2009-03-06  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * doc/automake.texi (maintainer-mode): Fix logic in
index 803a892..d389145 100644 (file)
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1998, 2001, 2003, 2004, 2006, 2008 Free Software
+## Copyright (C) 1998, 2001, 2003, 2004, 2006, 2008, 2009 Free Software
 ## Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
@@ -38,10 +38,9 @@ if %?NOTRANS_MANS%
        { for i in $$list; do echo "$$i"; done;  \
 ## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; for i in $$l2; do \
-## Accept files like `foo.1c'.
-?HAVE_NOTRANS?   case $$i in *.%SECTION%*) echo "$$i";; esac; \
-?HAVE_NOTRANS? done; \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
+## Accept for `man1' files like `foo.1c' but not `sub.1/foo.2' or `foo-2.1.4'.
+?HAVE_NOTRANS?   sed -n '/\.%SECTION%[a-z]*$$/p'; \
 ## Extract basename of manpage, change the extension if needed.
        } | while read p; do \
 ## Find the file.
@@ -71,10 +70,9 @@ if %?TRANS_MANS%
        { for i in $$list; do echo "$$i"; done; \
 ## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-?HAVE_TRANS?   l2='%TRANS_LIST%'; for i in $$l2; do \
-## Accept files like `foo.1c'.
-?HAVE_TRANS?     case $$i in *.%SECTION%*) echo "$$i";; esac; \
-?HAVE_TRANS?   done; \
+?HAVE_TRANS?   l2='%TRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
+## Accept for `man1' files like `foo.1c' but not `sub.1/foo.2' or `foo-2.1.4'.
+?HAVE_TRANS?     sed -n '/\.%SECTION%[a-z]*$$/p'; \
 ## Extract basename of manpage, change the extension if needed.
        } | while read p; do \
 ## Find the file.
@@ -116,10 +114,9 @@ if %?NOTRANS_MANS%
        files=`{ for i in $$list; do echo "$$i"; done; \
 ## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; for i in $$l2; do \
-## Accept files like `foo.1c'.
-?HAVE_NOTRANS?   case $$i in *.%SECTION%*) echo "$$i";; esac; \
-?HAVE_NOTRANS? done; \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
+## Accept for `man1' files like `foo.1c' but not `sub.1/foo.2' or `foo-2.1.4'.
+?HAVE_NOTRANS?   sed -n '/\.%SECTION%[a-z]*$$/p'; \
 ## Extract basename of manpage, change the extension if needed.
        } | sed 's,.*/,,;s,\.[^%SECTION%][0-9a-z]*$$,.%SECTION%,'`; \
        test -n "$$files" || exit 0; \
@@ -132,10 +129,9 @@ if %?TRANS_MANS%
        files=`{ for i in $$list; do echo "$$i"; done; \
 ## Extract all items from man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-?HAVE_TRANS?   l2='%TRANS_LIST%'; for i in $$l2; do \
-## Accept files like `foo.1c'.
-?HAVE_TRANS?     case $$i in *.%SECTION%*) echo "$$i";; esac; \
-?HAVE_TRANS?   done; \
+?HAVE_TRANS?   l2='%TRANS_LIST%'; for i in $$l2; do echo "$$i"; done | \
+## Accept for `man1' files like `foo.1c' but not `sub.1/foo.2' or `foo-2.1.4'.
+?HAVE_TRANS?     sed -n '/\.%SECTION%[a-z]*$$/p'; \
 ## Extract basename of manpage, run it through the program rename
 ## transform, and change the extension if needed.
        } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^%SECTION%][0-9a-z]*$$,%SECTION%,;x' \
index 2d8a974..d4687f4 100644 (file)
@@ -398,6 +398,7 @@ man.test \
 man2.test \
 man3.test \
 man4.test \
+man5.test \
 mclean.test \
 mdate.test \
 mdate2.test \
index 92434ab..dc0a339 100644 (file)
@@ -553,6 +553,7 @@ man.test \
 man2.test \
 man3.test \
 man4.test \
+man5.test \
 mclean.test \
 mdate.test \
 mdate2.test \
diff --git a/tests/man5.test b/tests/man5.test
new file mode 100755 (executable)
index 0000000..626602a
--- /dev/null
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure to extract the correct mansection from files in man_MANS.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am << 'END'
+man_MANS = foo-1.4.5/foo.2 foo-1.4.5/bar.3 baz-1.4.2
+notrans_man_MANS = foo-1.4.5/nfoo.2 foo-1.4.5/nbar.3 nbaz-1.4.2
+END
+
+mkdir foo-1.4.5
+
+: > foo-1.4.5/foo.2
+: > foo-1.4.5/nfoo.2
+: > foo-1.4.5/bar.3
+: > foo-1.4.5/nbar.3
+: > baz-1.4.2
+: > nbaz-1.4.2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Let's play with $DESTDIR too, it shouldn't hurt.
+./configure --mandir=/man
+DESTDIR="`pwd`/_inst" $MAKE -e install
+
+test -f ./_inst/man/man2/foo.2
+test -f ./_inst/man/man2/nfoo.2
+test -f ./_inst/man/man2/baz-1.4.2
+test -f ./_inst/man/man2/nbaz-1.4.2
+test -f ./_inst/man/man3/bar.3
+test -f ./_inst/man/man3/nbar.3
+
+test ! -d ./_inst/man/man1
+test ! -d ./_inst/man/man4
+test ! -d ./_inst/man/man5
+
+DESTDIR="`pwd`/_inst" $MAKE -e uninstall
+
+test ! -f ./_inst/man/man2/foo.2
+test ! -f ./_inst/man/man2/nfoo.2
+test ! -f ./_inst/man/man2/baz-1.4.2
+test ! -f ./_inst/man/man2/nbaz-1.4.2
+test ! -f ./_inst/man/man3/bar.3
+test ! -f ./_inst/man/man3/nbar.3
+
+: