scanner: Refactor name parsing
First, merge the implementations of parsing both identifiers and
symbols, since they had more in common than they had differences.
Secondly, fix the logic for priority of --accept-unprefixed in
the presence of unprefixed includes. The current namespace should
win. An example of this is mutter which has unprefixed public
symbols, but also includes xlib, which has no prefix.
Third, for unprefixed namespaces, actually look at the contents
rather than just blindly returning them. This is a bit of a hack,
but better than the alternatives.