#!/bin/sh # # Copyright 2018 Free Software Foundation, Inc. # # Written by Bertrand Garrigues # # This file is part of hdtbl. # # hdtbl is distributed with groff, the GNU roff typesetting system. # # groff 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 of the License, or # (at your option) any later version. # # groff 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 . # Use Ghostscript to count pages in generated files "font_n.ps" and # "font_x.ps". builddir="@abs_top_builddir@" gs_program="@GHOSTSCRIPT@" ret=0 if [ "$gs_program" = "missing" ] then echo "Ghostscript program missing; skipping" >&2 exit 77 # skip fi # $1 file, $2 expected number of pages check_number_pages() { echo "checking $1 for $2 pages" >&2 if ! [ -r "$1" ] then echo "error: \"$1\" does not exist or is not readable" >&2 exit 99 fi res=$("$gs_program" -o /dev/null/ -sDEVICE=bbox "$1" 2>&1 \ | grep HiResBoundingBox | wc -l) # macOS `wc` prefixes the line count with spaces. Get rid of them. if ! res=$(( res + 0 )) then echo "error: cannot perform arithmetic on output of 'wc'" \ "command" >&2 exit 99 fi if [ "$res" != $2 ] then echo "...FAILED; found $res page(s), expected $2" >&2 ret=1 fi } check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_n.ps 46 check_number_pages "$builddir"/contrib/hdtbl/examples/fonts_x.ps 46 exit $ret # vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72: