#! /bin/bash
# Last edited on 2024-08-30 11:46:16 by stolfi

# Compares the lists of functions defined in "{m}.h" and in "{m}.c".
# Writes the differences to ".${m}.funcs.diff".

m="$1"; shift

tmp="/tmp/$$"

for ext in h c ; do 
  ff="${m}.${ext}";
  if [[ ! ( -s ${ff} ) ]]; then
    echo "** ${ff} does not exist" 1>&2 ; exit 1
  fi
  egrep -e '^[a-zA-Z]' ${ff} \
    | sed -e 's:;::g' \
    | sort > ${tmp}-${ff}.funcs;
done; 

prdiff -Bb ${tmp}-${m}.{h,c}.funcs \
  > .${m}.funcs.diff

rm ${tmp}-*
