Sunday, January 28, 2007

 

findref

findref is one of the program I use on daily basis. It a small opensource program (a single C source file written by Mr. Brian Wilson) that can be complied with any decent C compiler. It finds all references to a string in a C/C++ files in current directory and its subdirectory.
e.g.

c:\wx\samples>findref -i wxarraystring
.\console\console.cpp(259): wxArrayString args = wxCmdLineParser::ConvertStringToArgs(cmdline);
.\console\console.cpp(399): wxArrayString files;
.\console\console.cpp(587): wxArrayString output;
.\console\console.cpp(835): wxArrayString dirs = fn.GetDirs();
.\console\console.cpp(1672): wxArrayString mimetypes;
.\console\console.cpp(1678): wxArrayString exts;
.\console\console.cpp(3206): wxArrayString files;
.\console\console.cpp(3349): wxArrayString files;
.\console\console.cpp(3815): wxArrayString volumes = wxFSVolume::GetVolumes();
.\console\console.cpp(5622): static void PrintArray(const wxChar* name, const wxArrayString& array)
.\console\console.cpp(6260): wxArrayString a1;
.\console\console.cpp(6272): wxArrayString a2(a1);
.\dialogs\dialogs.cpp(516): wxArrayString paths, filenames;
.\dialup\nettest.cpp(305): wxArrayString names;
.\dnd\dnd.cpp(87): const wxArrayString& filenames);
.\dnd\dnd.cpp(1372): wxArrayString filenames;
.\dnd\dnd.cpp(1481): bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
.\exec\exec.cpp(124): const wxArrayString& output,
.\exec\exec.cpp(684): wxArrayString output, errors;
.\exec\exec.cpp(927): const wxArrayString& output,
.\font\font.cpp(345): const wxArrayString& GetFacenames() const
.\font\font.cpp(356): wxArrayString m_facenames;
.\listbox\lboxtest.cpp(524): wxArrayString items;
.\listbox\lboxtest.cpp(635): wxArrayString items;
.\mobile\wxedit\wxedit.h(60): wxArrayString m_history;
.\widgets\combobox.cpp(334): wxArrayString items;
.\widgets\listbox.cpp(345): wxArrayString items;
.\widgets\listbox.cpp(454): wxArrayString items;
.\widgets\widgets.cpp(291): wxArrayString labels;
Where -i is ignore case. It has many other options like not to span some directory.

I then use vim + line_number somefile.cpp to start editing the file.
Its also useful to find out how a variable is used in a project.

You can use grep along with find command, but findref is lot more convenient.

Next time I will write about how to use GNU ID utils, GLOBAL, Source Navigator and CSCOPE as C source tag system.

Labels:


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?