Adjust the script to iterate over arguments using a for loop instead of
repeatedly checkind $# and shifting. More significantly, avoid calling
expr on each filename where a case pattern can do the job.
Additionally, add a new test case to verify the basic sanity of this
script and its corresponding Autoconf macro.