Part of my ‘day job’ is trolling thru source code when looking for answers. My preferred mechanism, other than a recursive grep, is to use cscope
Cscope is a useful tool for searching a source code tree after you build a list of files to search
The Problem
However, in this conundrum, when I would use any of the search options within cscope the File list (or list of source files) was empty, blank, envisible… basically, I could not SEE any of the results!
Example
Recreating the issue
In the following example, I built a list of files so that I could populate cscope
# cd /export/hg/default/pstoolkit
# find PstkCore/ -type f -not -path "*__In*" -not -path "*__Out*" -not -path "*ThirdPart*" -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cs*" > cscope.files
Then I read the results into cscope
# ls -al cscope.files
-rw-rw-r-- 1 bpatridge bpatridge 77196 Feb 13 12:46 cscope.files
# cscope -q -R -b -i cscope.files
#
Now I attempt to open cscope
# cscope -d
Now I see the window:
However,
When I search for string “TimeOfDay” the search results are invisible?
I even attempted to change the colors but the results were the same
Oddly enough, when I scroll down and press enter I CAN still view one of the source files?
However when I return it is still empty.
The Solution
The solution in this case was surprising.
I trolled the internet for weeks until I finally found a nugget on old ye faithful – stackoverflow which mentioned that cscope has problems with control characters!
I noted when viewing the contents of several files there was a ^M appended to each line.
Therefore I ran dos2unix on all of the files in cscope.files
# cat cscope.files |xargs -n1 -I{} dos2unix {}
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/SraPeerArray.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/SraPrepareReverseReplicationResponse.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RecommendationSpaceOutcome.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RemoteCopyInfo.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ReplLinkStat.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ReplicationStat.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestApi.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestApiPrivilege.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestoreInfo.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ServiceGroup.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ServiceGroupOperationStatus.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/Severity.cs to Unix format ...
....
After this was complete, I was able to run cscope normally and now I can see the search results!!!