Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quote and escape file names in index file and allow whitespaces #23

Closed
wants to merge 1 commit into from
Closed

Quote and escape file names in index file and allow whitespaces #23

wants to merge 1 commit into from

Conversation

bertogg
Copy link
Contributor

@bertogg bertogg commented Aug 28, 2020

cscope can handle files with whitespaces and other special characters,
but they must be properly quoted and escaped in the index file. This
can be fixed by filtering the output of 'find' through 'sed'.

cscope still complains when a symbol is found in a file with a
whitespace in its name ("File does not have expected format") but at
least it works (partially) now. On the other hand, filenames with
double quotes or backslashes seem to work just fine.

In addition to that, the regular expression that parses the cscope
output needs to be modified to allow whitespaces in file names. The
new regular expression still does not allow tabs in file names, but
they are extremely unlikely to happen and cscope does not seem to
support them anyway.

cscope can handle files with whitespaces and other special characters,
but they must be properly quoted and escaped in the index file. This
can be fixed by filtering the output of 'find' through 'sed'.

cscope still complains when a symbol is found in a file with a
whitespace in its name ("File does not have expected format") but at
least it works (partially) now. On the other hand, filenames with
double quotes or backslashes seem to work just fine.

In addition to that, the regular expression that parses the cscope
output needs to be modified to allow whitespaces in file names. The
new regular expression still does not allow tabs in file names, but
they are extremely unlikely to happen and cscope does not seem to
support them anyway.
@dkogan
Copy link
Owner

dkogan commented Aug 29, 2020

Hi. Thanks for the patch. I tried it out, and it doesn't work for me. I made two test directories: one with " and \ and spaces in the filenames, and another with just " and . Both fail with "File does not have expected format". The test directories can both be downloaded here: http://notes.secretsauce.net/xcscope.specialchars.tar.gz

I would C-c s I to index in each one: that worked without complaint. Then I would C-c s g main to find the main symbol in each directory, and this would produce the error in each case. Can you please try on this test directory, or let me know how your test directory differs.

Thanks!

@dkogan
Copy link
Owner

dkogan commented Aug 29, 2020

Actually, never mind. I was testing it wrong. It now looks like it actually does work in both the with-spaces and no-spaces cases. It still says "File does not have expected format", but that looks like a non-breaking warning. Is that your experience?

@bertogg
Copy link
Contributor Author

bertogg commented Aug 31, 2020

Yes, I get that warning but things seem to work (although I think I had a case in which C-c s g <symbol> would not find anything, but wit the test that you uploaded it does work fine).

@bertogg
Copy link
Contributor Author

bertogg commented Aug 31, 2020

Btw, if you prefer a cleaner cscope.files you can also change the last sed parameter like this:

"-e" "/[ \\\\]/s/.*/\"&\"/")) " ") " > "

This way only the filenames with special characters or whitespaces get surrounded by double quotes in cscope.files.

@dkogan
Copy link
Owner

dkogan commented Sep 13, 2020

The patch looks reasonable to me. Thanks! Let me dog-food this for a while, and then do a release.

@dkogan dkogan closed this Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants