#! /bin/bash

CSP=codespell
IGN=doc/codespell_ignore.txt
CSO="-I $IGN $@"

function bdie {
  echo "Error: $1" >&2
  exit 1
}

if test ! -r "$IGN" ; then
  bdie "execute from toplevel source directory"
fi
if test ! -r src/sc.h ; then
  bdie "execute from toplevel source directory"
fi

if ! which "$CSP" > /dev/null ; then
  bdie "codespell not found"
fi

exec "$CSP" $CSO    \
  src/sc*{c,h}      \
  test/*.c          \
  example/**/*.c
