#!/bin/bash
set -euo pipefail
shopt -s globstar

replacements() {
  clang-format --output-replacements-xml "$@" | grep -c '</replacement>'
}

if [[ $(replacements --style=file -i **/*.c **/*.h) != 0 ]]; then
  printf 'ERROR: There are formatting errors, please run `make format-c`.\n' 1>&2
  exit 1
fi
