]> git.imager.perl.org - imager.git/commitdiff
- the internal function used to probe file formats if the type
authorTony Cook <tony@develop=help.com>
Wed, 11 May 2005 13:43:29 +0000 (13:43 +0000)
committerTony Cook <tony@develop=help.com>
Wed, 11 May 2005 13:43:29 +0000 (13:43 +0000)
  parameter wasn't passed to the read() method would produce
  diagnostics on stdout, precluding use in web applications.  Silenced
  it.

Changes
MANIFEST
t/t1000files.t [new file with mode: 0644]
tga.c

diff --git a/Changes b/Changes
index 7d2017f58fb99c5e962cce5f108131574e0191ba..f7675260bd3ae203435b7db606647fe8ac8cea98 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1087,6 +1087,10 @@ Revision history for Perl extension Imager.
 - removed the bug reporting email address to prevent spammers stripping
   it.  The URL is still there and if someone knows how rt.cpan.org works
   they can still figure out the email.
 - removed the bug reporting email address to prevent spammers stripping
   it.  The URL is still there and if someone knows how rt.cpan.org works
   they can still figure out the email.
+- the internal function used to probe file formats if the type
+  parameter wasn't passed to the read() method would produce
+  diagnostics on stdout, precluding use in web applications.  Silenced
+  it.
 
 =================================================================
 
 
 =================================================================
 
index 023a442906a0464fd0b9f6349c202c0c56af08ff..cd91da0c6721f519b3d82009f1cdf18905a4af23 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -123,6 +123,7 @@ t/t022double.t          Test double/sample images
 t/t023palette.t                Test paletted images
 t/t05error.t
 t/t07iolayer.t
 t/t023palette.t                Test paletted images
 t/t05error.t
 t/t07iolayer.t
+t/t1000files.t          Format independent file tests
 t/t101jpeg.t
 t/t102png.t
 t/t103raw.t
 t/t101jpeg.t
 t/t102png.t
 t/t103raw.t
diff --git a/t/t1000files.t b/t/t1000files.t
new file mode 100644 (file)
index 0000000..60d1637
--- /dev/null
@@ -0,0 +1,46 @@
+#!perl -w
+
+# This file is for testing file functionality that is independent of
+# the file format
+
+use strict;
+use Test::More tests => 3;
+use Imager;
+
+Imager::init_log("testout/t1000files.log", 1);
+
+SKIP:
+{
+  # Initally I tried to write this test using open to redirect files,
+  # but there was a buffering problem that made it so the data wasn't
+  # being written to the output file.  This external perl call avoids
+  # that problem
+
+  my $test_script = 'testout/t1000files_probe.pl';
+
+  # build a temp test script to use
+  ok(open(SCRIPT, "> $test_script"), "open test script")
+    or skip("no test script $test_script: $!", 2);
+  print SCRIPT <<'PERL';
+#!perl
+use Imager;
+use strict;
+my $file = shift or die "No file supplied";
+open FH, "< $file" or die "Cannot open file: $!";
+binmode FH;
+my $io = Imager::io_new_fd(fileno(FH));
+Imager::i_test_format_probe($io, -1);
+PERL
+  close SCRIPT;
+  my $perl = $^X;
+  $perl = qq/"$perl"/ if $perl =~ / /;
+  
+  print "# script: $test_script\n";
+  my $cmd = "$perl -Mblib $test_script t/t1000files.t";
+  print "# command: $cmd\n";
+
+  my $out = `$cmd`;
+  is($?, 0, "command successful");
+  is($out, '', "output should be empty");
+}
+
diff --git a/tga.c b/tga.c
index 00be830236a8435c28c6c251d686fe0aaed6786c..13758117f0576e4108b63b949410a9cc2cb9ddda 100644 (file)
--- a/tga.c
+++ b/tga.c
@@ -320,14 +320,14 @@ tga_header_unpack(tga_header *header, unsigned char headbuf[18]) {
 }
 
 
 }
 
 
-
+/* this function should never produce diagnostics to stdout, maybe to the logfile */
 int
 tga_header_verify(unsigned char headbuf[18]) {
   tga_header header;
   tga_header_unpack(&header, headbuf);
   switch (header.datatypecode) { 
   default:
 int
 tga_header_verify(unsigned char headbuf[18]) {
   tga_header header;
   tga_header_unpack(&header, headbuf);
   switch (header.datatypecode) { 
   default:
-               printf("bad typecode!\n");
+    /*printf("bad typecode!\n");*/
     return 0;
   case 0:
   case 1:  /* Uncompressed, color-mapped images */ 
     return 0;
   case 0:
   case 1:  /* Uncompressed, color-mapped images */ 
@@ -341,7 +341,7 @@ tga_header_verify(unsigned char headbuf[18]) {
 
   switch (header.colourmaptype) { 
   default:
 
   switch (header.colourmaptype) { 
   default:
-               printf("bad colourmaptype!\n");
+    /*printf("bad colourmaptype!\n");*/
     return 0;
   case 0:
   case 1:
     return 0;
   case 0:
   case 1:
@@ -464,7 +464,7 @@ destination is compressed.
 static
 int
 tga_dest_write(tga_dest *s, unsigned char *buf, size_t pixels) {
 static
 int
 tga_dest_write(tga_dest *s, unsigned char *buf, size_t pixels) {
-  int cp = 0, j;
+  int cp = 0;
 
   if (!s->compressed) {
     if (s->ig->writecb(s->ig, buf, pixels*s->bytepp) != pixels*s->bytepp) return 0;
 
   if (!s->compressed) {
     if (s->ig->writecb(s->ig, buf, pixels*s->bytepp) != pixels*s->bytepp) return 0;