ctags or cscope

450 views
Skip to first unread message

epanda

unread,
Nov 23, 2007, 3:04:33 PM11/23/07
to vim_use
Hi

I have tried ctags and cscope on my sources directory (about 1000
files), and the first thing of failure is that it cannot find an
include file.

#include "CBF.h" => this one ok (same directory)

#include "VerificateurEquationsCBF.h" ==============> (this one KO)

#include "..\..\..\confinstallation\paramcbf.h" ==============> (this
one KO)

#include "TimerSequence.h"
#include "EtatEquipementAttenteCBF.h"

#include "ModeEquipementRepos.h"



The problem could come from directories'name include sometime
whitespaces ?

John Beckett

unread,
Nov 23, 2007, 7:47:21 PM11/23/07
to vim...@googlegroups.com
epanda wrote:
> I have tried ctags and cscope on my sources directory (about
> 1000 files), and the first thing of failure is that it
> cannot find an include file.
>
> #include "CBF.h" => this one ok (same directory)
>
> #include "VerificateurEquationsCBF.h" ============> (this one KO)

>
> #include "..\..\..\confinstallation\paramcbf.h"
> ==============> (this one KO)
>
> #include "TimerSequence.h"
> #include "EtatEquipementAttenteCBF.h"
>
> #include "ModeEquipementRepos.h"
>
> The problem could come from directories'name include sometime
> whitespaces ?

Please give more precise information. If both ctags and cscope
are giving you trouble, I suggest dealing with one first to
avoid confusion. What command do you enter?

Does "this one KO" mean you got an error message? What? Or it
didn't work in some way? What?

Your examples do not include a directory with spaces. I don't
think I've ever used such a thing with ctags or cscope so I
don't know about that. However, if there is such a problem, you
should be able to make a simple test case with just a couple of
short files.

John

epanda

unread,
Nov 24, 2007, 2:40:08 AM11/24/07
to vim_use
It seems that ctags does not work with directory names including white
psace

epanda

unread,
Nov 24, 2007, 10:07:26 AM11/24/07
to vim_use
After parsing my code , this one is very slow to find pattern such as
"return". In fact it does not respond

Is anybody knows if it's a bug ? I have tried without success to
install cecscope vimscript, is anybody knows the better script to
interface cscope to vim ?

Thanks a lot

Charles E. Campbell, Jr.

unread,
Nov 24, 2007, 2:26:33 PM11/24/07
to vim...@googlegroups.com
epanda wrote:

>Is anybody knows if it's a bug ? I have tried without success to
>install cecscope vimscript, is anybody knows the better script to
>interface cscope to vim ?
>
>

What o/s are you using? First I've heard of any problems with cecscope!

Regards,
Chip Campbell

Bill McCarthy

unread,
Nov 24, 2007, 2:37:48 PM11/24/07
to epanda
On Sat 24-Nov-07 9:07am -0600, epanda wrote:

> After parsing my code , this one is very slow to find pattern such as
> "return". In fact it does not respond

What "this one" are you talking about?

> Is anybody knows if it's a bug ? I have tried without success to
> install cecscope vimscript, is anybody knows the better script to
> interface cscope to vim ?

Dr Chips' CECscope works fine here - except, of course, :CSR
- he should generalize that one by replacing "*.[ch]" to
"*.c *.h".

I assume you've read the help in "if_cscop.txt: and added the
code in "cscope-suggestions" to your vimrc.

--
Best regards,
Bill


Gary Johnson

unread,
Nov 24, 2007, 3:47:57 PM11/24/07
to vim...@googlegroups.com
On 2007-11-24, Bill McCarthy <WJ...@pobox.com> wrote:

> Dr Chips' CECscope works fine here - except, of course, :CSR
> - he should generalize that one by replacing "*.[ch]" to
> "*.c *.h".

How is "*.c *.h" more general than "*.[ch]"?

Regards,
Gary

Bill McCarthy

unread,
Nov 24, 2007, 5:21:18 PM11/24/07
to Gary Johnson

In native windows shells, *.[ch] is passed, as is to cscope
- which doesn't properly deal with it, it thinks *.[ch] is a
file which it cannot find. "*c *.h" should work in both
Windows and 'nix environments.

--
Best regards,
Bill

Gary Johnson

unread,
Nov 24, 2007, 5:38:50 PM11/24/07
to vim...@googlegroups.com
On 2007-11-24, Bill McCarthy <WJ...@pobox.com> wrote:
> On Sat 24-Nov-07 2:47pm -0600, Gary Johnson wrote:
>
> > On 2007-11-24, Bill McCarthy <WJ...@pobox.com> wrote:
> >
> >> Dr Chips' CECscope works fine here - except, of course, :CSR
> >> - he should generalize that one by replacing "*.[ch]" to
> >> "*.c *.h".
> >
> > How is "*.c *.h" more general than "*.[ch]"?
>
> In native windows shells, *.[ch] is passed, as is to cscope
> - which doesn't properly deal with it, it thinks *.[ch] is a
> file which it cannot find. "*c *.h" should work in both
> Windows and 'nix environments.

OK, now I understand. Thanks for the explanation.

Regards,
Gary

epanda

unread,
Nov 25, 2007, 11:16:05 AM11/25/07
to vim_use
I am working on windows .

cscope is slow.
pathnames with whitespaces are problems.


Today I have very difficult to browse my code cscope.
Can I send you a little part of it in order to test it ?

Thanks
epanda

On 24 nov, 23:38, Gary Johnson <garyj...@spk.agilent.com> wrote:
> On 2007-11-24, Bill McCarthy <W...@pobox.com> wrote:
>
> > On Sat 24-Nov-07 2:47pm -0600, Gary Johnson wrote:
>

Charles E Campbell Jr

unread,
Nov 26, 2007, 10:36:22 AM11/26/07
to vim...@googlegroups.com
Bill McCarthy wrote:

I'll include this... Thanks! See v3d of cecscope from my website:
http://mysite.verizon.net/astronaut/vim/index.html#CECSCOPE

Chip Campbell

Gary Johnson

unread,
Nov 26, 2007, 12:05:03 PM11/26/07
to vim...@googlegroups.com
On 2007-11-25, epanda <callin...@hotmail.fr> wrote:
> I am working on windows .
>
> cscope is slow.
> pathnames with whitespaces are problems.
>
>
> Today I have very difficult to browse my code cscope.
> Can I send you a little part of it in order to test it ?

I don't know what you would send to have someone else test it. As
John suggested initially, I think you should construct a small test
case on your system that demonstrates the problem. Then report back
here with exactly how the directories of the test case are
structured, how you constructed the cscope database, what cscope
commands you execute that appear not to work, and what the results
of those commands are, including the exact text of any error
messages. With that information, perhaps someone here can verify
the problem and discover its cause. Otherwise, we're all just
guessing at what the problem might be.

I use cscope on Unix but not on Windows, so I won't be of much help.

Regards,
Gary

epanda

unread,
Nov 26, 2007, 5:33:42 PM11/26/07
to vim_use
Charles, I have tried your link but the errors below seems show that
it does not work. (I have vim 7.1 windows, my directories have
necessary permissions)
Although, I have already tried your originally cecscope and on
contrary on its own help, there is only file to unzip and nothing to
extract in doc directory
.

I don't understand

Tomorrow I'll tried to provide you an example on my problem
Thanks a lot
epanda

Vimball Archive
extracted <plugin/cecscope.vim>: 311 lines
Erreur détectée en traitant function vimball#Vimball :
ligne 115 :
"C:\Program\ Files\Vim\vimfiles\plugin\cecscope.vim" E212: Impossible
d'ouvrir le fichier pour y écri
re
wrote C:\Program\\ Files\Vim\vimfiles\plugin\cecscope.vim
extracted <doc/cecscope.txt>: 134 lines
"C:\Program\ Files\Vim\vimfiles\doc\cecscope.txt" E212: Impossible
d'ouvrir le fichier pour y écrire
wrote C:\Program\\ Files\Vim\vimfiles\doc\cecscope.txt
ligne 142 :
E150: C:\Program\ Files\Vim\vimfiles\doc n'est pas un répertoire
did helptags
Appuyez sur ENTRÉE ou tapez une commande pour continuer


On 26 nov, 16:36, Charles E Campbell Jr <drc...@campbellfamily.biz>
wrote:
> Bill McCarthy wrote:
> >On Sat 24-Nov-07 2:47pm -0600, Gary Johnson wrote:
>

Charles E Campbell Jr

unread,
Nov 27, 2007, 2:34:31 PM11/27/07
to vim...@googlegroups.com
epanda wrote:

>Vimball Archive
>extracted <plugin/cecscope.vim>: 311 lines
>Erreur détectée en traitant function vimball#Vimball :
>ligne 115 :
>"C:\Program\ Files\Vim\vimfiles\plugin\cecscope.vim" E212: Impossible
>d'ouvrir le fichier pour y écri
>re
>wrote C:\Program\\ Files\Vim\vimfiles\plugin\cecscope.vim
>extracted <doc/cecscope.txt>: 134 lines
>"C:\Program\ Files\Vim\vimfiles\doc\cecscope.txt" E212: Impossible
>d'ouvrir le fichier pour y écrire
>wrote C:\Program\\ Files\Vim\vimfiles\doc\cecscope.txt
>ligne 142 :
>E150: C:\Program\ Files\Vim\vimfiles\doc n'est pas un répertoire
>did helptags
>Appuyez sur ENTRÉE ou tapez une commande pour continuer
>
>

I'm afraid that my French isn't nearly as good as your English --- but
the above looks like a problem that vimball is having dealing with M$'s
spaces-in-filenames fetish, not with cecscope.vim itself. I'll look
into it.

Regards,
Chip Campbell

Ben Schmidt

unread,
Nov 27, 2007, 6:07:50 PM11/27/07
to vim...@googlegroups.com

That seems right, Chip. The relevant parts of the French translate as "Can't open
the file for writing" and "is not a directory" which would point to this.

Ben.


Send instant messages to your online friends http://au.messenger.yahoo.com

epanda

unread,
Nov 28, 2007, 12:27:43 AM11/28/07
to vim_use
About the errorsabove , I would notify that my directories are NOT
read only.
And I have tried to use original cecscope in order to go in front of
the message like "C:\Program\ Files\Vim\vimfiles\plugin\cecscope.vim"
E212: Impossible
d'ouvrir le fichier pour y écrire"



Meanwhile Charles is looking on that, I would like to talk again about
ctags.
Ctags now works well but I would like to know if I can use Ctags (the
tags file in fact) in place of a vimgrep to know all sources affected
by a keyword tagged ?

Thanks
epanda

Tony Mechelynck

unread,
Nov 28, 2007, 11:29:50 AM11/28/07
to vim...@googlegroups.com
epanda wrote:
> About the errorsabove , I would notify that my directories are NOT
> read only.
> And I have tried to use original cecscope in order to go in front of
> the message like "C:\Program\ Files\Vim\vimfiles\plugin\cecscope.vim"
> E212: Impossible
> d'ouvrir le fichier pour y écrire"

i.e., "Cannot open the file for writing to it"

>
>
>
> Meanwhile Charles is looking on that, I would like to talk again about
> ctags.
> Ctags now works well but I would like to know if I can use Ctags (the
> tags file in fact) in place of a vimgrep to know all sources affected
> by a keyword tagged ?
>
> Thanks
> epanda

It may depend on circumstances, and especially on what you want to search for
and on how often the sources are modified.

Vimgrep has the advantage that you don't need a preconstructed tagfile: a Vim
pattern and a "where to search" filepathname (with wildcards) are enough.
Therefore Vimgrep doesn't "get out of date" if the searched files are
modified: indeed, every use of vimgrep reconstructs the required quickfix
results file. (I'm not calling it a "quickfix errorfile" here, but only
because vimgrep results are not really "errors".)

Ctags has the advantage that it has better knowledge of the searched files'
source syntax, and allows you to get to "where the symbol is defined" without
stopping at every place "where the symbol is used".

FYI, with the Vim sources themselves, you can "make tags" (at least on
Unix-like systems, using the top-level Makefile) to generate a tags file for
the Vim sources. You can then use the tag-navigation facility contained in
your version of Vim or gvim in order to browse its own sources.


Best regards,
Tony.
--
Noncombatant, n.:
A dead Quaker.
-- Ambrose Bierce

Tony Mechelynck

unread,
Nov 28, 2007, 11:44:16 AM11/28/07
to vim...@googlegroups.com

P.S. What concerns "what you're looking for", using ctags or vimgrep is
approximately parallel to searching the Vim help with ":help <name>" (which
requires a preexisting tags file, and brings you where the help tag is
defined) or with ":helpgrep pattern" (which finds every match for /pattern/ in
the help text) respectively.


Best regards,
Tony.
--
Support wildlife -- vote for an orgy.

epanda

unread,
Nov 29, 2007, 2:47:50 AM11/29/07
to vim_use
Thank you Tony for your explanation.

I am a unix user since 6 years so I knew what vimgrep can offeras
functionnalities and difference with a hash file like tags.

About Vimgrep, I found amazing that so few scripts are written around
it.
Second thing about vimgrep, it is very slower than the Visual Studio 6
internal search tools , why ?

About ctags, I don't know if you can search any word into the hash
file tags such as vimgrep command. I use Ctags only with CTRL-
MouseLeft and CTRL-MouseRight
Have you got some others command to learn to me ?

Thanks

NB: Cscope : I am waiting for Charles...


On 28 nov, 17:44, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:

Tony Mechelynck

unread,
Nov 29, 2007, 11:42:56 AM11/29/07
to vim...@googlegroups.com
epanda wrote:
> Thank you Tony for your explanation.
>
> I am a unix user since 6 years so I knew what vimgrep can offeras
> functionnalities and difference with a hash file like tags.
>
> About Vimgrep, I found amazing that so few scripts are written around
> it.
> Second thing about vimgrep, it is very slower than the Visual Studio 6
> internal search tools , why ?
>
> About ctags, I don't know if you can search any word into the hash
> file tags such as vimgrep command. I use Ctags only with CTRL-
> MouseLeft and CTRL-MouseRight
> Have you got some others command to learn to me ?
>
> Thanks
>
> NB: Cscope : I am waiting for Charles...

Many of the tags commands are commonly used with the Vim help: e.g.,
double-click or Ctrl-] to go to the definition of the keyword under the
cursor; Ctrl-T (synonym of Ctrl-MouseRight, but I don't like operations which
require using both the keyboard with one hand and the mouse with the other); etc.

See
:help 29.1 (introduction)
:help tagsrch.txt (full details)

and, by the way, "learn" and "teach" are not synonymous in English, even
though they both correspond to the French word "apprendre" ;-) (unlike "to
learn", "to teach" can also be translated as "enseigner"). It's only in very
"unacademical" English that "I'll larn ya" can be used for "Je vais
t'apprendre, moi!". (Me too, I'm a native French-speaker, and I know how
difficult it is for a French-speaker to learn never to use "learn" when
"teach" is meant: for some people, it requires constant attention.)


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
145. You e-mail your boss, informing him you'll be late.

Charles E Campbell Jr

unread,
Nov 29, 2007, 1:02:33 PM11/29/07
to vim...@googlegroups.com
epanda wrote:

>NB: Cscope : I am waiting for Charles...
>
>

Currently, as in "as time is available", I'm trying to knock off a netrw
bug. Vimball is next...

Regards,
Chip Campbell

John Little

unread,
Nov 29, 2007, 7:13:03 PM11/29/07
to vim...@googlegroups.com
An OT aside:

> and, by the way, "learn" and "teach" are not synonymous...
> It's only in very "unacademical" English...

"unacademical American" I would've said. Huckleberry Finn, or the
bumpkin in cowboy movies springs to mind. I never heard the usage in
even the broadest local dialects (that I could understand) in England.
My dictionary gives it as archaic or slang. I wonder if an
"American" or "Ebonics" speaker can tell us if it's current in the
U.S.?

Sorry, curiosity got the better of me, John

Gary Johnson

unread,
Nov 29, 2007, 7:46:35 PM11/29/07
to vim...@googlegroups.com

It is used currently in the U.S., but only by those with a
substandard education.

Regards,
Gary

Gene Kwiecinski

unread,
Nov 30, 2007, 11:03:41 AM11/30/07
to vim...@googlegroups.com
>>>and, by the way, "learn" and "teach" are not synonymous...
>>>It's only in very "unacademical" English...

>>"unacademical American" I would've said. Huckleberry Finn, or the
>>bumpkin in cowboy movies springs to mind. I never heard the usage in
>>even the broadest local dialects (that I could understand) in England.
>>My dictionary gives it as archaic or slang. I wonder if an
>>"American" or "Ebonics" speaker can tell us if it's current in the
>>U.S.?

>It is used currently in the U.S., but only by those with a
>substandard education.

And by people who "conversate" with each other... and then get
"fustrated" and feel "vunerable" when someone objects to that usage.

And those who wear "jewlery".

And who fear "nuculer" energy.

And those who use "ATM machines" and punch in their "PIN numbers".

I can go on... >:D

sc

unread,
Nov 30, 2007, 5:34:48 PM11/30/07
to vim...@googlegroups.com

please don't -- it's like hearing fingernails on a chalkboard
(dear lord our own president is PROUD of our nuculer energy
and the way he mis-pronounces it)

sc

epanda

unread,
Dec 1, 2007, 6:44:07 AM12/1/07
to vim_use
Sorry if I disturb the audience and sorry for my poor english language
but my problems were about browsing efficiently my source code.

vimgrep is slower than Visual Studio grep
cscope does not work very well

I am trying ctags.

Thanks

epanda

unread,
Dec 1, 2007, 9:42:07 AM12/1/07
to vim_use
There is an example that I don't understand.

I have some files .asm .c .cpp etc..
I focus on a file named Rtfile.cpp with this source code inside :


//##ModelId=393CB8FA0240
const int RtFile::write(char buffer_p[],long taille_p)
{
bool retour_l=false;
DWORD number_l = 0;
if (hFile!=0)
{
int retourBOOL;
//on prend la taille du buffer plus 1 à cause du \0
retourBOOL=WriteFile(hFile,buffer_p,taille_p,&number_l,NULL);
retour_l=(retourBOOL==1?true:false);
}
else
{
retour_l=false;
}
return retour_l;
}


When I do "ctags --langmap C++ -R ." from my project directory the
result I obtain is a tags file with that :
EXTRN .\Dev_PC_DEV1\viden0he_chambre\videN0HE_chambre_workspace
\Application_nt\Release\DebugFile.asm /^EXTRN
__imp__GetSystemTimeAsFileTime@4:NEAR$/;" l
EXTRN .\Dev_PC_DEV1\viden0he_chambre\videN0HE_chambre_workspace
\Application_nt\Release\DebugFile.asm /^EXTRN __imp__MoveFileA@8:NEAR
$/;" l
EXTRN .\Dev_PC_DEV1\viden0he_chambre\videN0HE_chambre_workspace
\Application_nt\Release\DebugFile.asm /^EXTRN
__imp__SetFileTime@16:NEAR$/;" l
EXTRN .\Dev_PC_DEV1\viden0he_chambre\videN0HE_chambre_workspace
\Application_nt\Release\DebugFile.asm /^EXTRN __imp__WriteFile@20:NEAR
$/;" l


But I just want ctags to scan cpp files and not asm.

Sibin Thomas

unread,
Dec 1, 2007, 11:15:22 AM12/1/07
to vim...@googlegroups.com
On Dec 1, 2007 5:14 PM, epanda <callin...@hotmail.fr> wrote:

Sorry if I disturb the audience and sorry for my poor english language
but my problems were about browsing efficiently my source code.

vimgrep is slower than Visual Studio grep
cscope does not work very well

I am trying ctags.

Thanks
I use gvim 7.0 on windows and have found code browsing using cscope to be extremely  pleasant (good features plus its fast). I have added the following lines to my _vimrc to enable this brilliant synergy between cscope and vim -

" run cscope and add the cscope.out database to the session
nmap csc :CSC<CR>

" simple find
nmap <C-F1> :cs find 0 <C-R>=expand("<cword>")<CR><CR>

" find definition
nmap <C-F2> :cs find 1 <C-R>=expand("<cword>")<CR><CR>

" functions called by this function
nmap <C-F3> :cs find 2 <C-R>=expand("<cword>")<CR><CR>

" functions calling this function
nmap <C-F4><F4> :cs find 3 <C-R>=expand("<cword>")<CR><CR>

" Find this file
nmap <C-F5> :cs find 7 <C-R>=expand("<cfile>")<CR><CR>

" Find files #including this file
nmap <C-F6> :cs find 8 <C-R>=expand("<cfile>")<CR><CR>

command CSC :if cscope_connection()==1 | exe "cs kill 0" | :silent exe "!del /f cscope.out" | :endif | :silent exe "!cscope -b -R" | :cs add cscope.out

if has("cscope")
"You will have to change the path in the next two lines according to where your cscope.exe exists
    if findfile("cscope.exe","D:/cscope/bin")!=""
        se csprg=D:\cscope\bin\cscope.exe
        set csto=0
        set cst
        set nocsverb
        " add any database in current directory
        if filereadable("cscope.out")
            cs add cscope.out
            " else add database pointed to by environment
        elseif $CSCOPE_DB != ""
            cs add $CSCOPE_DB
        endif
        set csverb
    endif
endif
noh

I hope this helps.

Regards,
Sibin

epanda

unread,
Dec 1, 2007, 11:50:46 AM12/1/07
to vim_use
cscope does not detect a class method like this :

//##ModelId=3A7EBA7200F5
void DailyLogFile::handleEntry(WORD ref_p, void* value_p)
{


On 1 déc, 17:15, "Sibin Thomas" <sibinptho...@gmail.com> wrote:

epanda

unread,
Dec 1, 2007, 12:12:55 PM12/1/07
to vim_use
When I do a simple grep text with cscope it does not found string
"WriteFile" and says File does not have expected format !

The string is in this sample source wich is here D:
\Dev_PC_DEV1\communs_he\SRC\utilitaires\RTX

//##ModelId=393CB8FA0240
const int RtFile::write(char buffer_p[],long taille_p)
{
bool retour_l=false;
DWORD number_l = 0;
if (hFile!=0)
{
int retourBOOL;
//on prend la taille du buffer plus 1 à cause du \0

retourBOOL=WriteFile(hFile,buffer_p,taille_p,&number_l,NULL);
retour_l=(retourBOOL==1?true:false);
}
else
{
retour_l=false;
}
return retour_l;

}



epanda

unread,
Dec 1, 2007, 12:28:25 PM12/1/07
to vim_use
ok cscope does not work with C++ code

Gary Johnson

unread,
Dec 1, 2007, 1:40:33 PM12/1/07
to vim...@googlegroups.com

If you want to have ctags generate tags for only files of a
particular language, I believe the option you want is "--languages"
and not "--langmap", e.g.,

ctags --languages=C++ -R .

The "--langmap" option is used to tell ctags what languages are
associated with file names that it doesn't already understand.

HTH,
Gary

Gary Johnson

unread,
Dec 1, 2007, 3:42:25 PM12/1/07
to vim...@googlegroups.com
On 2007-12-01, epanda <callin...@hotmail.fr> wrote:

> On 1 déc, 18:12, epanda <callingel...@hotmail.fr> wrote:
> > When I do a simple grep text with cscope it does not found string
> > "WriteFile" and says File does not have expected format !
> >
> > The string is in this sample source wich is here D:
> > \Dev_PC_DEV1\communs_he\SRC\utilitaires\RTX
> >
> > //##ModelId=393CB8FA0240
> > const int RtFile::write(char buffer_p[],long taille_p)
> > {
> > bool retour_l=false;
> > DWORD number_l = 0;
> > if (hFile!=0)
> > {
> > int retourBOOL;
> > //on prend la taille du buffer plus 1 à cause du \0
> >
> > retourBOOL=WriteFile(hFile,buffer_p,taille_p,&number_l,NULL);
> > retour_l=(retourBOOL==1?true:false);
> > }
> > else
> > {
> > retour_l=false;
> > }
> > return retour_l;
> >
> > }
> >
> > On 1 déc, 17:50, epanda <callingel...@hotmail.fr> wrote:
> >
> > > cscope does not detect a class method like this :
> >
> > > //##ModelId=3A7EBA7200F5
> > > void DailyLogFile::handleEntry(WORD ref_p, void* value_p)
> > > {

> ok cscope does not work with C++ code

I don't think that's true. I copied both your examples to a couple
of files in a temporary directory and ran cscope on them. Using

:cs find t WriteFile

to find WriteFile worked just fine as did using

:cs find g handleEntry

to find the definition of handleEntry. I also use cscope daily in
my work with C and C++, and while it seems to occasionally miss some
items (I haven't kept careful track of them), it generally works
well.

Granted, this was using cscope on Unix, but I think it demonstrates
that cscope itself works with C++. It appears from your experience
that there may be problems with it on Windows or with your
particular installation or usage.

Regards,
Gary

Bill McCarthy

unread,
Dec 1, 2007, 4:04:00 PM12/1/07
to epanda
On Sat 1-Dec-07 11:12am -0600, epanda wrote:

> When I do a simple grep text with cscope it does not found string
> "WriteFile" and says File does not have expected format !
>
> The string is in this sample source wich is here D:
> \Dev_PC_DEV1\communs_he\SRC\utilitaires\RTX
>
> //##ModelId=393CB8FA0240
> const int RtFile::write(char buffer_p[],long taille_p)
> {
> bool retour_l=false;
> DWORD number_l = 0;
> if (hFile!=0)
> {
> int retourBOOL;
> //on prend la taille du buffer plus 1 à cause du \0
>
> retourBOOL=WriteFile(hFile,buffer_p,taille_p,&number_l,NULL);
> retour_l=(retourBOOL==1?true:false);
> }
> else
> {
> retour_l=false;
> }
> return retour_l;
>
> }

I used your snippet with cscope without a problem. I called
the snippet prog.cpp and set up with "cscope -b prog.cpp".

To find WriteFile:

:cs find e WriteFile

brought me to the correct line.

:cs find s retour_l

showed me all four in a quickfix window.

:cs find g write

Put me on the "const int RtFile::write" line.

In my vimrc, I have the following (only the "set
csprg=c:/util/cscope" needs to be changed):

" Cscope

if has("cscope")
set csprg=c:/util/cscope


set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif

set cscopequickfix=s-,c-,d-,i-,t-,e-

nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>

--
Best regards,
Bill

epanda

unread,
Dec 1, 2007, 4:56:44 PM12/1/07
to vim_use
Ok I don't understand. After using this command ,
cscope -b -R, the cscope.out file does not contain writefile.

Is it a normal thnig ?

my version of cscope is cscope: version 16.0a

I have tried in another directory F:\utilities\*.cpp and it does not
store WriteFile

glups....

Bill McCarthy

unread,
Dec 1, 2007, 5:59:52 PM12/1/07
to epanda
On Sat 1-Dec-07 3:56pm -0600, epanda wrote:

> Ok I don't understand. After using this command ,
> cscope -b -R, the cscope.out file does not contain writefile.

That wouldn't store anything here with *.cpp files. I would
have to write: cscope -b -R *.cpp *.h

BTW, I write no C++ - mainly C. From the vim71/src
directory, typing "cscope -b" produces the same result as
typing "cscope -b *.c *.h". It takes a few seconds to build
the first time, but after adding patches 165 and 166 today,
it built nearly instantly - it uses the current cscope.out
to update with the latest changes.

> Is it a normal thnig ?

Yes it is normal. By default, cscope stores a compressed
file. If you really feel the need to read it, try:

cscope -b -c -R *.cpp *.h

or whatever you call your c++ compilation units.



> my version of cscope is cscope: version 16.0a

So is mine. BTW, I'm running on WinXP and building using
MinGW - the native Gnu C for windows.

> I have tried in another directory F:\utilities\*.cpp and it does not
> store WriteFile

Assuming you tell it to store cpp files, it should be
storing a representation of WriteFile.

--
Best regards,
Bill

epanda

unread,
Dec 1, 2007, 7:13:03 PM12/1/07
to vim_use
ok I have tried 2 tests:
first one in the directory , this commands is a success : cscope -b
*.cpp *.h

second one : in a parent directory , the following command fails :
cscope -b -c -R *.cpp *.h

Sorry
Epanda

John Beckett

unread,
Dec 1, 2007, 10:53:36 PM12/1/07
to vim...@googlegroups.com
epanda wrote:
> second one : in a parent directory , the following command fails :
> cscope -b -c -R *.cpp *.h

I'm guessing that you see an error like "no source files".

What works is to make a file called cscope.files where each line contains
the path of one of your source files. When I last did this on Windows, I
used a script to generate that file (on Unix you would use 'find').

The simplest would be for you to manually create a file named "cscope.files"
containing lines like:

sample/first.cpp
sample/second.cpp
sample/first.h
sample/second.h

The forward slash works under Windows. This assumes you are going to run
cscope in a directory where 'sample' is a subdirectory, and 'first.cpp' is
one of your source files in that subdirectory.

Then, build the cscope database like this (run this in the directory
containing sample):

cscope -b -c

I think you can add -q for an inverted index providing you have certain
tools. If you don't have the tools that cscope wants, the database built
with -q will not find anything.

John

Bill McCarthy

unread,
Dec 2, 2007, 1:28:26 AM12/2/07
to John Beckett
On Sat 1-Dec-07 9:53pm -0600, John Beckett wrote:

> epanda wrote:
>> second one : in a parent directory , the following command fails :
>> cscope -b -c -R *.cpp *.h

> I'm guessing that you see an error like "no source files".

I saw no such strangeness in Windows using C. For example,
from vim71\src:

del cscope.out
cscope -b -R
gvim
:cs find s etoa64

This finds etoa64 in vim71\src\xxd\xxd.c

HOWEVER, if instead I wrote:

del cscope.out
cscope -b -R *.c *.h

cscope failed to recurse the directories. It behaves like
many broken unix ports to windows - like grep. When you
specify recursion in grep, and maybe cscope too, it only
recurses into directories that match the patterns. A proper
windows app will recurse into all directories looking for
pattern matches of files in those directories.

--
Best regards,
Bill

Ben Schmidt

unread,
Dec 2, 2007, 5:49:47 AM12/2/07
to vim...@googlegroups.com

FWIW, I would call that behaviour broken. If I give recursion on the commandline
and specify a pattern or folder on the commandline, I expect just the matches to
be recursed, not everything in the directory.

It wouldn't surprise me to find this is standard Windows behaviour though, as
Windows is generally broken...

Bill McCarthy

unread,
Dec 2, 2007, 1:28:12 PM12/2/07
to Ben Schmidt
On Sun 2-Dec-07 4:49am -0600, Ben Schmidt wrote:

> Bill McCarthy wrote:

>> HOWEVER, if instead I wrote:
>>
>> del cscope.out
>> cscope -b -R *.c *.h
>>
>> cscope failed to recurse the directories. It behaves like
>> many broken unix ports to windows - like grep. When you
>> specify recursion in grep, and maybe cscope too, it only
>> recurses into directories that match the patterns. A proper
>> windows app will recurse into all directories looking for
>> pattern matches of files in those directories.
>
> FWIW, I would call that behaviour broken. If I give
> recursion on the commandline
> and specify a pattern or folder on the commandline, I expect just the matches to
> be recursed, not everything in the directory.

I suppose it depends on how you set up projects. I might
use a structure like:

project_a
functions_x
functions_y

where I keep my .c and .h files within there respective
directories. You might use:

project_a.c
functions_x.c
functions_y.c

project_a.h
functions_x.h
functiion_y.h

In that case using cscope or grep recursion will work fine
for you but not so well for me.

> It wouldn't surprise me to find this is standard Windows behaviour though, as
> Windows is generally broken...

Not standard windows behavior, but the typical behavior of
most windows utilities. I'm generally interested in finding
file patterns in a directory and its subdirectories - not
only in those subdirectories that match my file pattern.

IMHO, that's what most people want. I rarely need to search
for a file, say 'foo', in only directories also named 'foo'
- but if I did, I could do that with a little effort.

With the "unbroken" method you seem to like, it is very easy
to find 'foo' in 'foo' directories, but more work to just
find all 'foo' in the current tree. That's poor design.

--
Best regards,
Bill

Gary Johnson

unread,
Dec 3, 2007, 3:31:08 AM12/3/07
to vim...@googlegroups.com
On 2007-12-02, Bill McCarthy <WJ...@pobox.com> wrote:
> On Sun 2-Dec-07 4:49am -0600, Ben Schmidt wrote:
>
> > Bill McCarthy wrote:
>
> >> HOWEVER, if instead I wrote:
> >>
> >> del cscope.out
> >> cscope -b -R *.c *.h
> >>
> >> cscope failed to recurse the directories. It behaves like
> >> many broken unix ports to windows - like grep. When you
> >> specify recursion in grep, and maybe cscope too, it only
> >> recurses into directories that match the patterns. A proper
> >> windows app will recurse into all directories looking for
> >> pattern matches of files in those directories.

I believe the behavior of cscope and grep are correct on both
Windows and Unix and that the ports are not broken.

> > It wouldn't surprise me to find this is standard Windows
> > behaviour though, as Windows is generally broken...
>
> Not standard windows behavior, but the typical behavior of
> most windows utilities. I'm generally interested in finding
> file patterns in a directory and its subdirectories - not
> only in those subdirectories that match my file pattern.

If you want to search all the .c and .h files in the current
directory and all subdirectories, the command would be

grep -R --include=*.[hc] pattern .

The specification of the directory or directories in which grep
begins its recursive searching is different from the specification
of the file names that grep searches in those directories, as it
should be.

The behaviors of cscope and grep are different when no file name is
given: cscope defaults to the current working directory while grep
defaults to reading stdin.

Cscope doesn't normally need a filename pattern since it's normally
only interested in C files and it knows what those file names look
like. Unfortunately, it appears that to search C++ files, cscope
must be given a list of all the files to search, not just a filename
pattern.

Regards,
Gary

Bill McCarthy

unread,
Dec 3, 2007, 12:25:29 PM12/3/07
to Gary Johnson
On Mon 3-Dec-07 2:31am -0600, Gary Johnson wrote:

> If you want to search all the .c and .h files in the current
> directory and all subdirectories, the command would be
>
> grep -R --include=*.[hc] pattern .
>
> The specification of the directory or directories in which grep
> begins its recursive searching is different from the specification
> of the file names that grep searches in those directories, as it
> should be.

Thanks for the explanation Gary!

--
Best regards,
Bill

Charles E Campbell Jr

unread,
Dec 19, 2007, 1:23:45 PM12/19/07
to vim...@googlegroups.com
Charles E Campbell Jr wrote:

>epanda wrote:
>
>
>
>>Vimball Archive
>>extracted <plugin/cecscope.vim>: 311 lines
>>Erreur détectée en traitant function vimball#Vimball :
>>ligne 115 :


>>"C:\Program\ Files\Vim\vimfiles\plugin\cecscope.vim" E212: Impossible
>>d'ouvrir le fichier pour y écri
>>re

>>wrote C:\Program\\ Files\Vim\vimfiles\plugin\cecscope.vim
>>extracted <doc/cecscope.txt>: 134 lines
>>"C:\Program\ Files\Vim\vimfiles\doc\cecscope.txt" E212: Impossible


>>d'ouvrir le fichier pour y écrire

>>wrote C:\Program\\ Files\Vim\vimfiles\doc\cecscope.txt
>>ligne 142 :
>>E150: C:\Program\ Files\Vim\vimfiles\doc n'est pas un répertoire
>>did helptags
>>Appuyez sur ENTRÉE ou tapez une commande pour continuer
>>
>>
>>
>>
>
>I'm afraid that my French isn't nearly as good as your English --- but
>the above looks like a problem that vimball is having dealing with M$'s
>spaces-in-filenames fetish, not with cecscope.vim itself. I'll look
>into it.
>
>
Hello!

Please try v24d of vimball -- I think I've got the spaces in directory
names problem fixed. That version is available from:
http://mysite.verizon.net/astronaut/vim/index.html#VIMBALL

(as a tarball, since I figure its not good to have vimball needed to
extract itself)

Regards,
Chip Campbell

Charles E Campbell Jr

unread,
Jan 2, 2008, 5:03:59 PM1/2/08
to vim...@googlegroups.com

I'm afraid that I haven't gotten any feedback about this fix -- has
anyone tried it yet?

Happy New Year!
Chip Campbell

epanda

unread,
Feb 19, 2008, 12:11:39 PM2/19/08
to vim_use
Charles

The link is ko for cecscope
http://mysite.verizon.net/astronaut/vim/vbafiles

On 2 jan, 23:03, Charles E Campbell Jr <drc...@campbellfamily.biz>

Charles E. Campbell, Jr.

unread,
Feb 19, 2008, 9:03:20 PM2/19/08
to vim...@googlegroups.com
epanda wrote:

>Charles
>
>The link is ko for cecscope
>http://mysite.verizon.net/astronaut/vim/vbafiles
>
>

Hmm -- the problem was with vimball extraction, not cecscope; so the
link I gave was, if I may repeat:

http://mysite.verizon.net/astronaut/vim/index.html#VIMBALL

I just tried the link out and it worked for me.

Hope that helps,
Chip Campbell

epanda

unread,
Feb 20, 2008, 3:45:57 PM2/20/08
to vim_use
Vimlball ok, the link f cecscope does not work

On 20 fév, 03:03, "Charles E. Campbell, Jr."
Reply all
Reply to author
Forward
0 new messages