Make decl_names_equal more accurate

This utility function compares qualified names component-wise with
special handling of components that are anonymous names.

The code is incorrect for some cases when there are different numbers
of components on each side. Also, the control flow in the loop body is
more complex than it needs to be.

This commit simplifies the control flow, fixes the comparison bugs and
adds some extra tests to cover these cases.

	* src/abg-tools-utils.cc (decl_names_equal): Move {l,r}_pos2
	declarations into the loop and make {l,r}_length const. Avoid
	chance of arithmetic on string::npos values. Rework
	logic so there is a single test for "names compare equal" and
	a single test for different numbers of name components.
	* tests/test-tools-utils.cc (main): Add nine more tests.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2 files changed