list-all command stops listing results when encounters serious error in any package
Submitted by Tadeusz Szczyrba
Assigned to pkg..@..op.org
Created attachment 96614 Implement parser control logic in place of exit() when error occurs
pkg-config's parser control logic seems to be pretty simple - any serious error in parsed package description and pkg-config outputs descriptive error message and exits. The exit() calls are used internally in many places in parser.
Unfortunately such an approach causes --list-all command to stop outputting data as soon as any serious error in one of the listed packages is found. This is something rather unexpected - no one probably expects shortened packages listing where the only assumption if the package will be listed or not is if the package would be listed before or after erroneus package.
I would suggest two solutions:
first scan & parse all packages' .pc files and if any error occurs only print out error message with information which package caused error - if no error occured during parsing print out packages' description in format of '--list-all' command. The approach seems to be simpler to implement and could be clearer indication that something is wrong with .pc files in one or more of scanned directories.
scan and output info about all .pc files which doesn't cause problems to stdout and descriptive errors to stderr about the packages which are not linkable because of errors in their .pc files.
The approach has the advantage that all the working .pc files are listed in --list-all commands and the possible trashes don't cause the software to work. And --list-all command is possibly very useful for IDEs to get information which packages are available in the system to handle external dependiences (valama ide is one of such IDEs ).
I've implemented solution for the (2) - patch included for 0.28. The patch changes all exit() calls in parser to graceful returns with checks in callers if some problems occured to skip the package. 'make check' performed - all 25 tests successful.
The patch applies cleanly against 0.28 - with current git master it applies with 'offset 1 line'.
The remaining issue is exit status of pkg-config when error during parsing of one of the .pc files - before it was '1' and after the patch applied it is '0'.
Attachment 96614, "Implement parser control logic in place of exit() when error occurs":