#!/bin/sh
output="`qhelpgenerator "$@" 2>&1`"
errors="`echo "$output"|grep "Error in line .*: Opening and ending tag mismatch."`"
if echo "$1"|grep -q '\.qhp'; then
  file="$1"
elif echo "$2"|grep -q '\.qhp'; then
  file="$2"
elif echo "$3"|grep -q '\.qhp'; then
  file="$3"
fi
while test -n "$errors"; do
    for i in `echo "$errors"|tac|sed 's/^.* \([0-9]\+\):.*$/\1/'`; do
      sed -i "${i}d" "$file"
    done
    output="`qhelpgenerator "$@" 2>&1`"
    errors="`echo "$output"|grep "Error in line .*: Opening and ending tag mismatch."`"
done
echo "$output"
