| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright 2018 Free Software Foundation, Inc. |
| 4 |
# |
| 5 |
# Written by Bertrand Garrigues <[email protected]> |
| 6 |
# |
| 7 |
# This file is part of hdtbl. |
| 8 |
# |
| 9 |
# hdtbl is distributed with groff, the GNU roff typesetting system. |
| 10 |
# |
| 11 |
# groff is free software; you can redistribute it and/or modify it under |
| 12 |
# the terms of the GNU General Public License as published by the Free |
| 13 |
# Software Foundation, either version 3 of the License, or |
| 14 |
# (at your option) any later version. |
| 15 |
# |
| 16 |
# groff is distributed in the hope that it will be useful, but WITHOUT |
| 17 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 18 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 19 |
# for more details. |
| 20 |
# |
| 21 |
# You should have received a copy of the GNU General Public License |
| 22 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 |
|
| 24 |
# Use Ghostscript to count pages in generated files "font_n.ps" and |
| 25 |
# "font_x.ps". |
| 26 |
|
| 27 |
builddir="@abs_top_builddir@" |
| 28 |
gs_program="@GHOSTSCRIPT@" |
| 29 |
ret=0 |
| 30 |
|
| 31 |
if [ "$gs_program" = "missing" ] |
| 32 |
then |
| 33 |
echo "Ghostscript program missing; skipping" >&2 |
| 34 |
exit 77 # skip |
| 35 |
fi |
| 36 |
|
| 37 |
# $1 file, $2 expected number of pages |
| 38 |
check_number_pages() |
| 39 |
{ |
| 40 |
echo "checking $1 for $2 pages" >&2 |
| 41 |
|
| 42 |
if ! [ -r "$1" ] |
| 43 |
then |
| 44 |
echo "error: \"$1\" does not exist or is not readable" >&2 |
| 45 |
exit 99 |
| 46 |
fi |
| 47 |
|
| 48 |
res=$("$gs_program" -o /dev/null/ -sDEVICE=bbox "$1" 2>&1 \ |
| 49 |
| grep HiResBoundingBox | wc -l) |
| 50 |
# macOS `wc` prefixes the line count with spaces. Get rid of them. |
| 51 |
if ! res=$(( res + 0 )) |
| 52 |
then |
| 53 |
echo "error: cannot perform arithmetic on output of 'wc'" \ |
| 54 |
"command" >&2 |
| 55 |
exit 99 |
| 56 |
fi |
| 57 |
|
| 58 |
if [ "$res" != $2 ] |
| 59 |
then |
| 60 |
echo "...FAILED; found $res page(s), expected $2" >&2 |
| 61 |
ret=1 |
| 62 |
fi |
| 63 |
} |
| 64 |
|
| 65 |
check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_n.ps 46 |
| 66 |
check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_x.ps 46 |
| 67 |
|
| 68 |
exit $ret |
| 69 |
|
| 70 |
# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72: |