Share

cscope

Tracker: Bugs

5 Line number offset while browsing perl code - ID: 2716761
Last Update: Comment added ( broeker )

Hi everybody

While browsing perl code (for example "apvsys" which is a sourceforge
project) using Cscope, line numbers indicated in the cscope output does not
match line numbers in the editor.

For perl it is systematic, but this can happen also while browsing C++
code.

Has any body already encountered this issue and has it already been solved.


Regards
Farouk


farouk ( eemffr ) - 2009-03-27 11:23

5

Open

None

Nobody/Anonymous

None

None

Public


Comments ( 6 )

Date: 2009-08-23 15:37
Sender: broekerProject Admin

> //#########################################################

> They are used to separate or make visible parts of code. When they are
not
> ended by a double slash ‘//’ this activate the bug.

Ahem, you mean it _begins_ with a double slash.

The reason is still the same: cscope is neither meant to parse Perl, nor
is it likely to be any good at it. The issue you're stumbling over is just
one of many possible pitfalls: one language's

#comment

is the other's

#preprocessor statement

Putting random garbage in a C pre-processor instruction causes your
troubles.


Date: 2009-03-31 13:55
Sender: eemffr

Hi,

I have investigated about our C code, and there may be like:

//#########################################################

They are used to separate or make visible parts of code. When they are not
ended by a double slash ‘//’ this activate the bug.

Such lines are used also to frame the license header in sources files.

Thanks.




Date: 2009-03-30 15:03
Sender: eemffr

Many thanks for your answer.

Fist I had observed the issue on perl code projects. But we had also a
ticket from a user working on a C++ project. As C projects are extra
larges, and this issue seemed to happen randomly, I preferred first to
investigate using perl code where the issue was almost assured.

I made tests using a unique file project (see previous posts), and
launched cscope-15.6 like follows:

cscope -qu -i cscope.files

And once more time like this

cscope -i cscope.files

Then, the command line interface was displayed. I searched for SymLink
using "Find this C symbol" option. It gives the same results.

I doubted first about linebreaks for files that are imported from windows.
But applying the dos2unix tool does not improve things as long as the
‘#’ remained at end of line. File created within UNIX system are not
excluded also.

Regards.


Date: 2009-03-29 11:56
Sender: broekerProject Admin

First, a reminder: please be aware that this program is cscope. It's not
Perlscope, nor anylanguagescope. Using it on anything else but C source is
not meant, nor particularly likely, to do anything useful.

> In examples below we are searching for SymLink reference

Search for it how, exactly? How did you build the database, and what were
the options at query time?

Is there any chance the linebreaks in the input files were the wrong ones
for cscope?


Date: 2009-03-27 15:44
Sender: eemffr

Hi again

I have investigated about the reason of this line number offset.

It seems that when Cscope encounters the character sequence: "#<EOL>" ,
The line index is reduced by one.

In examples below we are searching for SymLink reference
______________________________
#
#
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : no result.
_______________________________
#
#

sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 2.
________________________
# Subroutine comments
# over two lines
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 3.
__________________________
# Subroutine comments #
# over two lines
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 2.




Date: 2009-03-27 15:40
Sender: eemffr

Hi again

I have investigated about the reason of this line number offset.

It seems that when Cscope encounters the character sequence: "#<EOL>" ,
The line index is reduced by one.

In examples below we are searching for SymLink reference
______________________________
#
#
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : no result.
_______________________________
#
#

sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 2.
________________________
# Subroutine comments
# over two lines
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 3.
__________________________
# Subroutine comments #
# over two lines
sub SymLink {
my ( $from, $to ) = @_;
print "Linking $to -> $from\n";
symlink $from, $to;
}

====> Cscope output : line 2.

Farouk




Attached File

No Files Currently Attached

Change ( 1 )

Field Old Value Date By
category_id Linebased interface 2009-03-29 11:56 broeker