pkg-config seems to get confused when variables in .pc files contain whitespace. Example: I generate a .pc file from configure where the value corresponds to a detected filename (such as build/temp.darwin-6.8-Power\ Macintosh-2.2). I tried quoting ("") as well as escaping ('\') without success. The documentation is silent on the matter. Is there a workaround ?
Created attachment 2917 [details] Xorg log file patch 1/2 to make pkgconfig pass quoted whitespace through
Created attachment 2918 [details] Testcase for the bug, sorry, that I've just pasted it in the report at first. patch 2/2 to make pkgconfig pass quoted whitespace through
Huh, it appears the attachments don't carry enough information to be useful. The first applies to parse.c, the second to poptparse.c. With these 'pkg-config --cflags ...' will output include and library paths with quoted whitespace ('\ '). I'm not sure whether this is sufficient / correct, as pkg-config doesn't appear to have a test suite to look for regressions, and the docs (man page) are unfortunately quite sparse.
If you want to produce a useful diff, pass the "-u" flag to diff (u==unified diff). This will include the file names and some context around the lines you changed. It would also be a good idea to concatenate the two unified diffs before attaching them, since they will probably get reviewed as a unit. Lastly, it would be good to make the diff against the latest version of the software.
I just now find the reply from James to my initial report / patches. For some reason I didn't receive notification, even though my email appears to be correct. FWIW. I'm going to rewrite the patch against pkgconfig 0.19 and resubmit that.
Created attachment 2890 [details] patch to let pkg-config support variables containing whitespace This tarball contains a patch to make pkg-config support whitespace in variables, together with a new test to demonstrate this feature. It is a minimal patch to get the feature working. It still looks a bit fragile, i.e. some cases may not work as expected. I modified 'parse_cflags' and 'parse_libs' to not stop at whitespace while in quoted mode, and I modified poptParseArgvString() to preserve quotation marks in the generated result. Let me know if anything else is needed. PS: the patch is against the current cvs version.
Could gscanner be used to parse apart the lines into whitespace-delimited chunks, with automatic quoted-string handling, instead of manually going through character-by-character?
I'm not sure whether the last comment was addressed at me. While I agree my patch is a bit hacky (in particular since I patched code that seems to be a mirror of some other library) I'm probably least suited to work on this feature, given my lack of experience with GNOME APIs. I hope the requested feature (and at least parts of this patch) will eventually materialize in a release nevertheless, as unfortunately whitespace in file names is more frequent than one would hope. Meanwhile I'll have to work around this by not using pkg-config.
My comment 7 was a general thought about the fundamental way pkg-config currently parses lines (a custom-written parser that needs patches like this, and perhaps non-obvious hoop-jumping by .pc file authors). I didn't mean it as a critique of a patch that solves a specific problem with that existing parser. I'm a Mac user and programmer who uses pkg-config, and I'm annoyed that OS X makes such heavy use of whitespace in filenames because it exposes how few unix programs deal with it cleanly. While I was pondering, I thought "parsing a text string that contains tokens or flags and possible token/flag arguments is by no means a rare or new task" and noticed that glib, which pkgconfig already uses, already has some toolbox routines that could be useful for a rewrite of the flag collection routines. If someone wants to go crazy, the whole thing could *maybe* even be rewritten using something as simple as getopt_long().
Isn't a maintainer interested in this bug?
Hello? Is anyone maintaining pkg-config? Fixing this (via the patch, or a better one if you want it) would make life easier for people using Windows.
Fixed in: commit 69a7eaa6763bb0920e2b539fffbad51348d94deb Author: Tollef Fog Heen <tfheen@err.no> Date: Sun May 23 22:59:46 2010 +0200 Make it possible to escape paths containing special shell characters Allow paths and other components to contain shell metacharacters, but escape them on output. White space has to be escaped in the input files using quotes or backslashes Freedesktop.org #3571
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.