ohcount won't parse whole perl file

Avatar

Peter Stuifzand

about 1 year ago

Hi,

I was trying ohcount and it seems that it doesn't parse the whole file. A lot of my files have a large POD block at the end. Ohcount parses these blocks only if there is a '=cut' line at the end if the file. If that line is missing it will stop just before the beginning of the POD block.

I hope someone can patch the parser to take this into account.


Avatar

Robin Luckey

about 1 year ago

Hi Peter,

If you send me a link to a sample file I'll take a look.


Avatar

Peter Stuifzand

about 1 year ago

Hi Robin,

I've created an example file for you: http://peterstuifzand.nl/files/ohcount_testfile.pl. In there are a lot of comments. Almost the whole file. But ohcount says there are zero. When you add a '=cut' line at the end, then ohcount counts the comments.


Avatar

Robin Luckey

about 1 year ago

Hi Peter,

Thanks for the link.

I can confirm that Ohcount fails to parse this...

=head1 NAME

...but does parse this:

=head1 NAME
=cut

Our parser won't return the comment block until it is closed. Because the perlpod comment started by =head is never explicitly closed, our parser never surfaces the completed comment.

This raises the question, is a =head unclosed by a =cut valid syntax?

I'll come right out and say that we do not at all prioritize trying to parse invalid syntax.

However, I'm no perl expert, and maybe I'm wrong. Is the =cut truly optional?

Our parser might have some trouble with structures that are opened and then only optionally closed. This might take some fiddling to get that working.


Avatar

Peter Stuifzand

about 1 year ago

Thanks for looking into this. I found a POD specification in the Perl documentation: perlpodspec

It mentions the pod blocks continue to =cut or end-of-file. See the line that starts with 'Pod content is contained'.


Avatar

Robin Luckey

about 1 year ago

Hi Peter,

I've opened a ticket for this bug. Unfortunately I won't have time to work on this anytime this week, but there are some savvy Ohcount folks out there who might pick up on this.

Thanks, Robin


Avatar

mitchell

about 1 year ago

I'll look into it this week when I have time off of school


Avatar

Robin Luckey

about 1 year ago

Peter,

Mitchell has come up with the fix, and I've applied it to the main line. If you want to pull the latest code, you should receive the fix.

If you have some particular projects on Ohloh that you'd like to have recounted, let me know and I'll get them started.

Thanks, Robin


Avatar

Peter Stuifzand

about 1 year ago

Thanks Mitchell and Robin for your help.