From 56ff54bcebd1520d5aaea7a8e8a809e04c2f5715 Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Sun, 16 Oct 2011 18:00:43 +0200
Subject: [PATCH] * converted photo.t to Test::More

---
 t/photo.t | 48 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

Index: Tk-804.028/t/photo.t
===================================================================
--- Tk-804.028.orig/t/photo.t
+++ Tk-804.028/t/photo.t
@@ -1,7 +1,7 @@
 BEGIN { $^W = 1; $| = 1;}
 use strict;
 use File::Temp qw(tempfile);
-use Test;
+use Test::More;
 use Tk;
 use Tk::Photo;
 
@@ -24,7 +24,7 @@ foreach my $leaf('Tk.xbm','Xcamel.gif')
  {
   my $file = Tk->findINC($leaf);
   my $src = $mw->Photo(-file => $file);
-  ok(defined($src),1," Cannot load $file");
+  ok defined($src), "Load $file";
   my $kind = 'Initial';
   my $col = 0;
   $mw->Label(-text  => 'Initial')->grid(-row => $row, -column => $col);
@@ -33,19 +33,17 @@ foreach my $leaf('Tk.xbm','Xcamel.gif')
 
   foreach $kind ($src->formats)
    {
-    print "# Testing $kind\n";
     my $f = lc("t/test.$kind");
     my $p = $f;
     push(@files,$f);
-    print "$kind - $f\n";
     eval { $src->write($f, -format => "$kind") };
-    ok($@,''," write $@");
-    ok($p,$f,"File name corrupted");
-    ok(-f $f,1,"No $f created");
+    is $@, '', "No error writing $f as $kind";
+    is $p, $f, "File name is not corrupted ($f)";
+    ok -f $f, "File $f was created";
     my $new;
     eval { $new = $mw->Photo(-file => $f, -format => "$kind") };
-    ok($@,''," load $@");
-    ok(defined($new),1,"Could not load $f");
+    is $@, '', "No error loading $f as $kind";
+    ok defined($new), "Loading $f ($kind)";
 
     my $skip_unsupported_data_format = $kind =~ /^(PPM|gif)$/ ? "$kind is not supported" : "";
 
@@ -54,21 +52,21 @@ foreach my $leaf('Tk.xbm','Xcamel.gif')
     if ($skip_unsupported_data_format)
      {
       Tk::catch { $data = $src->data(-format => $kind) };
-      ok($@,qr/image string format "$kind" is not supported/,"Error messaage");
-      skip("No data for $kind",1,1);
+      like $@, qr/image string format "$kind" is not supported/, "Error message for $kind";
+      SKIP: { skip "No data for $kind", 1 }
      }
     else
      {
       $data = $src->data(-format => $kind);
-      ok(defined($data) && $data ne "", 1, "$kind returns data");
+      ok defined($data) && $data ne "", "$kind returns data";
       if (defined $data)
        {
         $new2 = $mw->Photo(-data => $data, -format => $kind) if defined $data;
-        ok(defined $new2, 1,"Data back to image");
+        ok defined $new2, "Data back to image";
        }
       else
        {
-        skip("No data was returned",1);
+	SKIP: { skip "No data was returned", 1 }
        }
      }
 
@@ -89,27 +87,25 @@ $mw->Label(-text => "Extra tests")->grid
 my $file = Tk->findINC('Xcamel.gif');
 my $data = do { open my $fh, $file or die $!; binmode $fh; local $/; <$fh> };
 
-if ($Tk::VERSION <= 804.027)
- {
-  skip("Binary GIF data not supported",1,1);
- }
-else
+SKIP:
  {
+  skip "Binary GIF data not supported", 1
+   if $Tk::VERSION <= 804.027;
+
   my $image = $mw->Photo(-data => $data);
-  ok(defined $image, 1, "Read binary GIF data");
+  ok defined $image, "Read binary GIF data";
   $mw->Label(-background => 'white', -image => $image)->grid(-row => $row, -column => $col);
   $mw->update;
  }
 $col++;
 
-if (!eval { require MIME::Base64; 1 })
- {
-  skip("Need MIME::Base64 module",1,1);
- }
-else
+SKIP:
  {
+  skip "Need MIME::Base64 module", 1
+   if !eval { require MIME::Base64; 1 };
+
   my $image = $mw->Photo(-data => MIME::Base64::encode_base64($data));
-  ok(defined $image, 1, "Read base64 encoded GIF data");
+  ok defined $image, "Read base64 encoded GIF data";
   $mw->Label(-background => 'white', -image => $image)->grid(-row => $row, -column => $col);
   $mw->update;
  }
From b6bb9ee16d7aa6b9220e1a1487f5c94ce0183a2c Mon Sep 17 00:00:00 2001
From: Slaven Rezic <slaven@rezic.de>
Date: Sun, 16 Oct 2011 17:52:42 +0200
Subject: [PATCH] * RT #70429: show correct file name if image loading failed

---
 pTk/mTk/generic/tkImgPhoto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pTk/mTk/generic/tkImgPhoto.c b/pTk/mTk/generic/tkImgPhoto.c
index d3e90ce0..213f159c 100644
--- a/pTk/mTk/generic/tkImgPhoto.c
+++ b/pTk/mTk/generic/tkImgPhoto.c
@@ -4092,7 +4092,7 @@ MatchFileFormat(interp, chan, fileName, formatObj, imageFormatPtr,
 	} else {
 	    Tcl_AppendResult(interp,
 		    "couldn't recognize data in image file \"",
-		    fileName, "\"", (char *) NULL);
+		    Tcl_GetString(fileName), "\"", (char *) NULL);
 	}
 	return TCL_ERROR;
     }
