#!/bin/sh

type=c  # default

# determine type
if test -n "$1"; then
    if echo $1 | grep -q '^-'; then
        # given by option
        type=`echo -n $1 | sed -e 's/^-//'`
        shift
    else
        # take from extension
        ext=`echo $1 | sed -e 's/.*\.//'`
        if test -n "$ext"; then
            type=$ext
        fi
    fi
fi

case $type in
    c)  re='^[[:space:]]*(//|.[[:space:]]*$|$)';;
    ga) re='^[[:space:]]*(--|.[[:space:]]*$|$)';;
    *)  echo "unknown type: $type"; exit 1;;
esac

egrep -v -- "$re" "$@" | wc -l
