(I realize that this won't be fixed any time soon, due to the difficulty, but I'm still reporting it for posterity.)
While you can index files whose (properly quoted) pathnames contain spaces, a match in a file whose pathname contains a space will cause cscope to fail with a "File does not have expected format" error. It is important to note that cscope will appear to work fine, as long as all matches are in files whose pathnames do not contain spaces. However, if a match occurs in a file whose pathname contains a space, cscope will fail.
This is caused by the use of fscanf() to parse pathnames, where whitespace is used to separate the fields. This will, of course, fail if the pathname contains a space.
The main example for this is in countrefs(), in src/command.c, near line 897:
while (EOF != (i = fscanf(refsfound, "%" PATHLEN_STR "s%" PATLEN_STR "s%" NUMLEN_STR "s %" TEMPSTRING_LEN_STR "[^\n]", file, function, linenum, tempstring ) ) ) {
If the filename contains a space, the above will improperly parse the filename, resulting in an eventual error.
Unfortunately, fixing this is non-trivial, as the use of scanf() and friends occurs in a number of places, and would likely require a slightly modified database format.
Hello,
A user Debiian submitted a more comprehensive patch to address this problem. You'll find it at: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579531 or in attachment.
Can integrate it please?
Thank you for your help.
Regards,
--
Stéphane Aulery
Last edit: Stéphane Aulery 2014-11-20
The patch only improves the situation from "problems with pathnames containing whitespace" to "problems with pathnames containing tabulators". While that's an improvement, I don't feel comfortable with the externally visible changes it causes to the files handled by commands '<', '>', '^' and '|'.
I can accept the change to cscope-indexer as-is.
I can't vouch for the change to cscope.el any more than the OP on the debian tracker could, and our own ELisp expert-in-charge, Darryl Okahata, vanished a long time ago. Do you have an experienced ELisp hacker who could check this?
Hello,
Le jeudi 20 novembre 2014 à 07:01:43, Hans-Bernhard Broeker a écrit :
Below are the answers I got. I'm forcing you to anything. Please tell me
only if you accept the patch in whole or in part. If the problem of space in
file names can not be resolved properly in the current state, it could be
documented, maybe.
Josh Triplett josh@joshtriplett.org:
Matthias Urlichs matthias@urlichs.de:
Remi Vanicat vanicat@debian.org:
Regards,
--
Stéphane Aulery
I must say that I am triaging bug and I haven't verified the accuracy of the patch. Sorry. I can try to dig up a ELisp dev. on a Debian list.