The cscope program allows finding/replacing text in a full C code distributed in many files, and navigating easily through the source code. Does anyone know how to search-and-replace patterns that contain the character '*' with cscope?
Whenever I look for a string containing '*' I always get the error message "Could not find the text string: *ptr" (here I looked for '*ptr' which does exists in the code).
According to the source code of cscope (I am using version 15.7a), "findstring" will just escape the characters '. * [ \ ^ $ + ? | ( ) ' with '\' and then search for an egrep pattern ('find.c' @ line 474).
Using directly egrep on a given file and escaping '*' with '\' works. Using cscope to find an egrep pattern instead of a string does not work either.
You happened to have picked a buggy version of cscope. It was reported as not working in version 15.8a but working in 15.5, so broke somewhere in between. It was fixed again and works as expected in 15.8b.
More details at #87 special char escaping broken in 15.8 in egrep
You're testing by using the egrep
command-line utility, but that isn't what's used by cscope. cscope is using a custom regex implementation, see src/egrep.y
. The bug was in there.