I'm pretty sure the logic checks out. I've just run it on the command line to check again. found_group increments whenever the group is in any of the databases. If it's in _none_ of the databases (ie you've !found the group) then found_all is permanently set to 1 so that an error will be returned, and it moves onto searching for the next group. If a group is found then found_all isn't touched, and it moves onto searching for the next group.
You're right, my bad. I forgot there's three for loops there. The diff cuts hid the middle one On that note, maybe the variable names could be clearer: rename 'found_group' to 'found_in_db' and 'found_all' to just 'found' (we use found everywhere else in pacman and libalpm). Two more concerns: - You need to keep with the established coding style: https://www.archlinux.org/pacman/HACKING.html Don't put a space after the if. - Don't top post please.