Skip Menu |

This queue is for tickets about the C-Scan-Constants CPAN distribution.

Report information
The Basics
Id: 34986
Status: resolved
Priority: 0/
Queue: C-Scan-Constants

People
Owner: philip.monsen [...] gmail.com
Requestors: lee [...] leeland.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.017
Fixed in: (no value)



Subject: Single constant skipped in extract_constants_from()
When running extract_constants_from() on the attached header file (linux input.h), the constant "KEY_H" ( found on line 148 of the input.h file attached) is not returned when running extract_constants_from() on the header. All the other KEY_* defines seem to be there, certainly the define before it, and the defines after. (KEY_A..KEY_G, KEY_I..KEY_Z). The version I am running is 1.017, I don't know if the same behavior is exhibited in earlier versions. Thanks, -Lee xxx@phobos:~/$ uname -a Linux phobos 2.6.20-16-generic #2 SMP Sun Sep 23 19:50:39 UTC 2007 i686 GNU/Linux xxx@phobos:~/$ perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
Subject: test.pl
#!/usr/bin/perl use strict; use warnings; use C::Scan::Constants; my @hdr_files = ( './input.h' ); my %constants = map { $_ => 1 } extract_constants_from( @hdr_files ); my @expected = map {"KEY_$_"} ('A'..'Z', '0'..'9'); foreach (@expected){ print "$_ not found\n" unless exists $constants{$_}; }
Subject: input.h

Message body is not shown because it is too large.

I took a look at the code and it's painfully obvious why this is happening: my @constant_names = ( @enums, grep { my $defn = $_; # Toss header file identifiers. $defn !~ /_H[_]?$/ and $defn !~ /_$/ # Toss string constants. and $defs->{$defn} !~ /^["]/ } keys %{$defs} ); As you can see I'm explicitly throwing away any constants that end in _H! So I'll have to apply some additional heuristic(s) to avoid doing it for things that aren't actually header file identifiers. Thanks for pointing it out and for supplying the sample input and test code. --Phil On Mon Apr 14 01:06:56 2008, perl@leeland.net wrote: Show quoted text
> When running extract_constants_from() on the attached header file (linux > input.h), the constant "KEY_H" ( found on line 148 of the input.h file > attached) is not returned when running extract_constants_from() on the > header. > > All the other KEY_* defines seem to be there, certainly the define > before it, and the defines after. (KEY_A..KEY_G, KEY_I..KEY_Z). > > The version I am running is 1.017, I don't know if the same behavior is > exhibited in earlier versions. > > Thanks, > -Lee > > xxx@phobos:~/$ uname -a > Linux phobos 2.6.20-16-generic #2 SMP Sun Sep 23 19:50:39 UTC 2007 i686 > GNU/Linux > > xxx@phobos:~/$ perl -v > This is perl, v5.8.8 built for i486-linux-gnu-thread-multi > >
This will be fixed in 1.018
C::Scan::Constants v1.018, just uploaded to PAUSE, fixes this issue.