Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exact line modified #152

Open
aureFeliu opened this issue Jan 17, 2017 · 3 comments
Open

Exact line modified #152

aureFeliu opened this issue Jan 17, 2017 · 3 comments

Comments

@aureFeliu
Copy link

Hello, I've used cloc for a while now and I find it very useful, specially the diff functionality. But I was wondering if there is an option to print out exactly which lines have been modified, the exact line numbers for each file pair analyzed, in the report, or maybe in the alignment file (when using --diff-alignment).
If this is not currently supported, which is the best way to tackle this modification? I've been taking a look at the code, but my Perl is terrible.
Thanks for the tool and for your time
Aurelio

@AlDanial
Copy link
Owner

There isn't an option to print line numbers where diff's occur. Adding such a feature wouldn't be simple because blank lines are removed early in the processing chain; the positions of removed blank lines would need to be maintained and passed along.

Having said that, line number information (ignoring blanks) is kept in the diff code. If you're curious, uncomment lines 10237 and 10238 at the bottom of the subroutine array_diff(). This is from cloc-1.72.pl:

10236     }
10237 use Data::Dumper::Simple;
10238 print Dumper($rah_diff_L, $rah_diff_R);
10239 
10240     print "<- array_diff\n" if $opt_v > 2;
10241 } # 1}}}

then run with --diff. There will be a lot of output. If the line numbers look meaningful I can make the output more legible.

@aureFeliu
Copy link
Author

In the output generated by that modification, are the line numbers returned absolute (ignoring blank lines, already removed) or are they further divided into comment and code lines?
For example, if it says a certain line is the 7th, is that the 7th line in the program (not counting blanks) or the 7th line OF CODE (ignoring blanks and comments).
Thank you for the answer

@AlDanial
Copy link
Owner

The answer is actually both: array_diff() is called four times for each file pair. The first two times lnum has absolute line counts (ignoring blanks). The next two times it computes the differences in code only and in comments only so there lnum is relative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants