[Templates] ttree 2.75 verbose output display bug with copy file match (with patch)

[prev] [thread] [next] [Date index for 2004/07/15]

From: Silas Jantzen
Subject: [Templates] ttree 2.75 verbose output display bug with copy file match (with patch)
Date: 01:36 on 15 Jul 2004
ttree's verbose mode outputs the following perl error when it reports
it is copying a file matching a regex specified by a copy directive in
the config file:

Use of uninitialized value in concatenation (.) or string at
/usr/local/bin/ttree.orig line 357.
  > index.html                        (copied, matches //)

The following patch fixes the scoping issue with $check, and breaks
out of the foreach after the first successful match to eliminate
needless regex tests.  It has the added side-effect of reducing
confusion for newbies following the ttree examples in chapter 2 of the
badger book.

In the grand scheme of ttree, it may not be the most ideal way to fix
the bug, although it works great.

The patch may not apply automatically to ActiveState PPM installed
batch-file version of ttree on Win32.

--
Silas


diff -u ttree.orig ttree
--- ttree.orig  Sun May 30 23:09:46 2004
+++ ttree       Sun May 30 23:10:09 2004
@@ -296,7 +296,7 @@
 
 sub process_file {
     my ($file, $absfile, %options) = @_;
-    my ($dest, $destfile, $filename, $check, 
+    my ($dest, $destfile, $filename, $check, $check_match,
         $srctime, $desttime, $mode, $uid, $gid);
     my ($old_suffix, $new_suffix);
     my $is_dep = 0;
@@ -325,6 +325,8 @@
     foreach $check (@$copy) {
         if ($filename =~ /$check/) {
             $copy_file = 1;
+            $check_match = $check;
+            last;
         }
     }
 
@@ -354,7 +356,7 @@
     
     # check against copy list
     if ($copy_file) {
-        printf "  > %-32s (copied, matches /$check/)\n", $file
+        printf "  > %-32s (copied, matches /$check_match/)\n", $file
             if $verbose;
 
         unless ($dryrun) {

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] ttree 2.75 verbose output display bug with copy file match (with patch)
Silas Jantzen 01:36 on 15 Jul 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52