when building an inverted index in cscope, if a file is
placed in the srcfiles list that is unreadable, the
file index in the database file is skewed such that
searches return hits in the wrong files.
To reproduce:
create two source files in a directory: a.c and b.c
create a main function in b.c
create a foo function in a.c
make a.c unreadable (chmod 000 a.c)
run cscope -q
search for the definition of main
The search will return that the defintion was found in
a.c rather than in b.c as it should have
I've attached a patch that corrects this. As discussed
on the mailing list, this appears to be due to a skew
in the database file which arises from a file being
listed on the srcfiles list, but not having a requisite
database entry added in the crossref() function, since
it returns early if the file is found to be unreadable.
This patch corrects the issue by placing a minimal
database entry in the database for every file in the
srcfiles list regarless of its readability status.
patch to fix database skew in inverted index
Logged In: YES
user_id=827328
Heres the patch with an alternate solution to the inverted
index on unreadable files bug that I promised you Hans. It
solves the problem by only allowing readable files on to the
srclist when building the database. Please let me know what
you think.
alternate solution for inverted index bug
Logged In: YES
user_id=27517
Is there really no cleaner solution than to actually compare
user/group IDs and test permission bits, to find out if a
file is readable? There's got to be a less involved method.
Just open the file and watch the status code, or whatever?
access()?
Logged In: YES
user_id=827328
Damn, I'd never used access() before, but that would be a
much cleaner solution. I'll put together that patch and
test it before checking it in. Thanks.
new version of patch which is more concise
Logged In: YES
user_id=827328
Hans is right, the access call is much more consice and
works just as well. Attaching the winner patch