Skip Menu |

This queue is for tickets about the Image-Xpm CPAN distribution.

Report information
The Basics
Id: 51053
Status: resolved
Priority: 0/
Queue: Image-Xpm

People
Owner: SREZIC [...] cpan.org
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

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



CC: Slaven Rezic <slaven [...] rezic.de>
Subject: [PATCH] support for static const char
Date: Mon, 2 Nov 2009 23:27:56 +0100
To: bug-Image-Xpm [...] rt.cpan.org
From: Slaven Rezic <slaven [...] rezic.de>
--- MANIFEST | 1 + Xpm.pm | 4 ++-- t/const.t | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100755 t/const.t diff --git a/MANIFEST b/MANIFEST index 7c6d4c1..8a80645 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,5 @@ Xpm.pm +t/const.t t/xpm.t MANIFEST Makefile.PL diff --git a/Xpm.pm b/Xpm.pm index c639db3..8021e8b 100644 --- a/Xpm.pm +++ b/Xpm.pm @@ -5,7 +5,7 @@ package Image::Xpm; # Documented at the __END__ use strict; use vars qw($VERSION @ISA); -$VERSION = '1.09'; +$VERSION = '1.10'; use Image::Base; @@ -381,7 +381,7 @@ sub load { # Object method # Name of C string if ($state == $STATE_ARRAY) { croak "$err does not have a proper C array name" - unless /static\s+char\s+\*\s*\w+\[\s*\]\s*=\s*\{/o; #} + unless /static\s+(?:const\s+)?char\s+\*\s*\w+\[\s*\]\s*=\s*\{/o; #} $state = $STATE_VALUES; next LINE; } diff --git a/t/const.t b/t/const.t new file mode 100755 index 0000000..793ca43 --- /dev/null +++ b/t/const.t @@ -0,0 +1,44 @@ +use strict; + +BEGIN { + if (!eval q{ + use Test::More; + 1; + }) { + print "1..0 # skip no Test::More module\n"; + exit; + } +} + +plan tests => 2; + +use Image::Xpm; + +my $TestImage = <<'EOT'; +/* XPM */ +static const char *noname[] = { +/* width height ncolors chars_per_pixel */ +"4 10 4 1", +/* colors */ +"` c #000000", +"a c #FA1340", +"b c #3BFA34", +"c c #FFFF00", +/* pixels */ +"````", +"`aa`", +"`aa`", +"````", +"`cc`", +"`cc`", +"````", +"`bb`", +"`bb`", +"````" +}; +EOT + +my $xpm = Image::Xpm->new(-width => 0, -height => 0); +$xpm->load(\$TestImage); +is($xpm->get('-width'), 4, 'Image with static const char loaded'); +is($xpm->get('-height'), 10); -- 1.6.1
Just a note to this patch: it seems that it is valid to start an xpm file with "static const char". Image::Xpm only accepts "static char". The patch fixes this, adds a test case and increased the version number, so everything should be in place for a release. You can find a couple of sample xpm images with the "const" in the Alien-FLTK CPAN distribution. Regards, Slaven
Resolved in 1.09_50.