#!/bin/sh topdir="`dirname "$0"`"; topdir="`cd "$topdir/.."; pwd`" "$topdir/doclib/dot-munge.pl" "$1" case "$2" in -Tpng:gd) first="$1"; shift; shift set -- "$first" "-Tpng" "$@" ;; *) esac set -e dot "$@" case "$4" in *.png) if [ -r "$4" ]; then size="`pngtopnm "$4" | sed -n -e '2p'`" width_a="${size% *}" height_a="${size#* }" if [ $width_a -gt 800 ]; then for file in "${1%.dot}".*; do cp "$file" "$file.a" done sed -e 's/rankdir=LR/rankdir=TB/' -e t -e 's/rankdir=TB/rankdir=LR/' "$1.a" > "$1" dot "$@" size="`pngtopnm "$4" | sed -n -e '2p'`" width_b="${size% *}" height_b="${size#* }" if [ $width_a -lt $width_b ]; then for file in "${1%.dot}".*.a; do mv "$file" "${file%.a}" done else rm "${1%.dot}".*.a fi fi fi ;; *) ;; esac