Updated Term-ANSIColor to CPAN version 3.02
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Fri, 8 Jun 2012 12:35:48 +0000 (13:35 +0100)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Sun, 17 Jun 2012 20:26:49 +0000 (21:26 +0100)
  [DELTA]

  2012-03-18  Russ Allbery  <rra@stanford.edu>

  * ANSIColor.pm: Version 3.02 released.

  * ANSIColor.pm (AUTOLOAD): Only return pass-through behavior if
  the function that was called was one of our constants, rather than
  turning every unknown function in the Term::ANSIColor namespace
  into a passthrough join function when colors are disabled.
  * t/basic.t: Test proper error reporting with colors disabled.

  * ANSIColor.pm (AUTOLOAD): Preserve an existing value of $@ when
  generating a constant sub and restore it afterwards.  Diagnose
  errors in creating the constant sub and die instead of ignoring
  them.
  * t/eval.t: New test for $@ preservation.

  * ANSIColor.pm: Add italic and the ITALIC constant.  Document that
  the support for it is rare.
  * t/basic.t: Test italic and ITALIC support.

  * ANSIColor.pm: Add "mistyped" as a stopword, required by the
  latest aspell on Debian.

MANIFEST
Porting/Maintainers.pl
cpan/Term-ANSIColor/ANSIColor.pm
cpan/Term-ANSIColor/ChangeLog
cpan/Term-ANSIColor/README
cpan/Term-ANSIColor/t/basic.t
cpan/Term-ANSIColor/t/eval.t [new file with mode: 0644]

index 13922b1..b741d99 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -2231,6 +2231,7 @@ cpan/Term-ANSIColor/ANSIColor.pm  Perl module supporting termcap usage
 cpan/Term-ANSIColor/ChangeLog          Term::ANSIColor
 cpan/Term-ANSIColor/README             Term::ANSIColor
 cpan/Term-ANSIColor/t/basic.t          Tests for Term::ANSIColor
+cpan/Term-ANSIColor/t/eval.t
 cpan/Term-ANSIColor/t/stringify.t              Tests for Term::ANSIColor
 cpan/Term-Cap/Cap.pm                   Perl module supporting termcap usage
 cpan/Term-Cap/test.pl                  See if Term::Cap works
index 80aac89..6bf3241 100755 (executable)
@@ -1677,7 +1677,7 @@ use File::Glob qw(:case);
 
     'Term::ANSIColor' => {
         'MAINTAINER'   => 'rra',
-        'DISTRIBUTION' => 'RRA/Term-ANSIColor-3.01.tar.gz',
+        'DISTRIBUTION' => 'RRA/Term-ANSIColor-3.02.tar.gz',
         'FILES'        => q[cpan/Term-ANSIColor],
         'EXCLUDED'     => [
             qr{^tests/},
index bc2fc7e..9e3530e 100644 (file)
@@ -1,7 +1,7 @@
 # Term::ANSIColor -- Color screen output using ANSI escape sequences.
 #
 # Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010,
-#     2011 Russ Allbery <rra@stanford.edu> and Zenin
+#     2011, 2012 Russ Allbery <rra@stanford.edu> and Zenin
 # PUSH/POP support submitted 2007 by openmethods.com voice solutions
 #
 # This program is free software; you may redistribute it and/or modify it
@@ -17,7 +17,7 @@
 package Term::ANSIColor;
 require 5.001;
 
-$VERSION = '3.01';
+$VERSION = '3.02';
 
 use strict;
 use vars qw($AUTOLOAD $AUTOLOCAL $AUTORESET @COLORLIST @COLORSTACK $EACHLINE
@@ -28,8 +28,8 @@ use Exporter ();
 BEGIN {
     @COLORLIST = qw(
         CLEAR           RESET             BOLD            DARK
-        FAINT           UNDERLINE         UNDERSCORE      BLINK
-        REVERSE         CONCEALED
+        FAINT           ITALIC            UNDERLINE       UNDERSCORE
+        BLINK           REVERSE           CONCEALED
 
         BLACK           RED               GREEN           YELLOW
         BLUE            MAGENTA           CYAN            WHITE
@@ -59,6 +59,7 @@ BEGIN {
                'bold'           => 1,
                'dark'           => 2,
                'faint'          => 2,
+               'italic'         => 3,
                'underline'      => 4,
                'underscore'     => 4,
                'blink'          => 5,
@@ -116,12 +117,13 @@ for (reverse sort keys %ATTRIBUTES) {
 # write scripts that also work on systems without any ANSI support, like
 # Windows consoles.
 sub AUTOLOAD {
-    if (defined $ENV{ANSI_COLORS_DISABLED}) {
-        return join ('', @_);
-    }
     if ($AUTOLOAD =~ /^([\w:]*::([A-Z_]+))$/ and defined $ATTRIBUTES{lc $2}) {
+        if (defined $ENV{ANSI_COLORS_DISABLED}) {
+            return join ('', @_);
+        }
         $AUTOLOAD = $1;
         my $attr = "\e[" . $ATTRIBUTES{lc $2} . 'm';
+        my $saved = $@;
         eval qq {
             sub $AUTOLOAD {
                 if (\$AUTORESET && \@_) {
@@ -133,6 +135,8 @@ sub AUTOLOAD {
                 }
             }
         };
+        die "failed to generate constant $1" if $@;
+        $@ = $saved;
         goto &$AUTOLOAD;
     } else {
         require Carp;
@@ -284,7 +288,7 @@ Term::ANSIColor - Color screen output using ANSI escape sequences
 cyan colorize namespace runtime TMTOWTDI cmd.exe 4nt.exe command.com NT
 ESC Delvare SSH OpenSSH aixterm ECMA-048 Fraktur overlining Zenin
 reimplemented Allbery PUSHCOLOR POPCOLOR LOCALCOLOR openmethods.com
-grey ATTR
+grey ATTR urxvt mistyped
 
 =head1 SYNOPSIS
 
@@ -388,14 +392,16 @@ Term::ANSIColor 3.0.
 
 The function interface uses attribute strings to describe the colors and
 text attributes to assign to text.  The recognized non-color attributes
-are clear, reset, bold, dark, faint, underline, underscore, blink,
+are clear, reset, bold, dark, faint, italic, underline, underscore, blink,
 reverse, and concealed.  Clear and reset (reset to default attributes),
 dark and faint (dim and saturated), and underline and underscore are
 equivalent, so use whichever is the most intuitive to you.
 
 Note that not all attributes are supported by all terminal types, and some
-terminals may not support any of these sequences.  Dark and faint, blink,
-and concealed in particular are frequently not implemented.
+terminals may not support any of these sequences.  Dark and faint, italic,
+blink, and concealed in particular are frequently not implemented.
+
+Support for italic was added in Term::ANSIColor 3.02.
 
 The recognized normal foreground color attributes (colors 0 to 7) are:
 
@@ -483,8 +489,8 @@ Alternately, if you import C<:constants>, you can use the following
 constants directly:
 
   CLEAR           RESET             BOLD            DARK
-  FAINT           UNDERLINE         UNDERSCORE      BLINK
-  REVERSE         CONCEALED
+  FAINT           ITALIC            UNDERLINE       UNDERSCORE
+  BLINK           REVERSE           CONCEALED
 
   BLACK           RED               GREEN           YELLOW
   BLUE            MAGENTA           CYAN            WHITE
@@ -508,6 +514,8 @@ to
 (Note that the newline is kept separate to avoid confusing the terminal as
 described above since a background color is being used.)
 
+Support for C<ITALIC> was added in Term::ANSIColor 3.02.
+
 When using the constants, if you don't want to have to remember to add the
 C<, RESET> at the end of each print line, you can set
 $Term::ANSIColor::AUTORESET to a true value.  Then, the display mode will
@@ -693,14 +701,19 @@ given attribute as something else instead.  Note that on an aixterm, clear
 doesn't reset colors; you have to explicitly set the colors back to what
 you want.  More entries in this table are welcome.
 
-Note that codes 3 (italic), 6 (rapid blink), and 9 (strike-through) are
-specified in ANSI X3.64 and ECMA-048 but are not commonly supported by
-most displays and emulators and therefore aren't supported by this module
-at the present time.  ECMA-048 also specifies a large number of other
-attributes, including a sequence of attributes for font changes, Fraktur
-characters, double-underlining, framing, circling, and overlining.  As
-none of these attributes are widely supported or useful, they also aren't
-currently supported by this module.
+Support for code 3 (italic) is rare and therefore not mentioned in that
+table.  It is not believed to be fully supported by any of the terminals
+listed, although it's displayed as green in the Linux console, but it is
+reportedly supported by urxvt.
+
+Note that codes 6 (rapid blink) and 9 (strike-through) are specified in
+ANSI X3.64 and ECMA-048 but are not commonly supported by most displays
+and emulators and therefore aren't supported by this module at the present
+time.  ECMA-048 also specifies a large number of other attributes,
+including a sequence of attributes for font changes, Fraktur characters,
+double-underlining, framing, circling, and overlining.  As none of these
+attributes are widely supported or useful, they also aren't currently
+supported by this module.
 
 =head1 SEE ALSO
 
@@ -724,10 +737,10 @@ Russ with input from Zenin.  Russ Allbery now maintains this module.
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009, 2010,
-2011 Russ Allbery <rra@stanford.edu> and Zenin.  This program is free
-software; you may redistribute it and/or modify it under the same terms as
-Perl itself.
+Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2008, 2009,
+2010, 2011, 2012 Russ Allbery <rra@stanford.edu> and Zenin.  This program
+is free software; you may redistribute it and/or modify it under the same
+terms as Perl itself.
 
 PUSHCOLOR, POPCOLOR, and LOCALCOLOR were contributed by openmethods.com
 voice solutions.
index 77de255..9706b2f 100644 (file)
@@ -1,3 +1,26 @@
+2012-03-18  Russ Allbery  <rra@stanford.edu>
+
+       * ANSIColor.pm: Version 3.02 released.
+
+       * ANSIColor.pm (AUTOLOAD): Only return pass-through behavior if
+       the function that was called was one of our constants, rather than
+       turning every unknown function in the Term::ANSIColor namespace
+       into a passthrough join function when colors are disabled.
+       * t/basic.t: Test proper error reporting with colors disabled.
+
+       * ANSIColor.pm (AUTOLOAD): Preserve an existing value of $@ when
+       generating a constant sub and restore it afterwards.  Diagnose
+       errors in creating the constant sub and die instead of ignoring
+       them.
+       * t/eval.t: New test for $@ preservation.
+
+       * ANSIColor.pm: Add italic and the ITALIC constant.  Document that
+       the support for it is rare.
+       * t/basic.t: Test italic and ITALIC support.
+
+       * ANSIColor.pm: Add "mistyped" as a stopword, required by the
+       latest aspell on Debian.
+
 2011-07-20  Russ Allbery  <rra@stanford.edu>
 
        * ANSIColor.pm: Version 3.01 released.
index 051c7c3..cd2d1fb 100644 (file)
@@ -1,15 +1,16 @@
-                       Term::ANSIColor version 3.01
+                       Term::ANSIColor version 3.02
               (A simple ANSI text attribute control module)
 
   Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2007, 2009,
-  2010, 2011 Russ Allbery <rra@stanford.edu> and Zenin.  This program is
-  free software; you may redistribute it and/or modify it under the same
-  terms as Perl itself.
+  2010, 2011, 2012 Russ Allbery <rra@stanford.edu> and Zenin.  This
+  program is free software; you may redistribute it and/or modify it under
+  the same terms as Perl itself.
 
-  I welcome bug reports and patches for this package at rra@stanford.edu.
-  However, please be aware that I tend to be extremely busy and to get a
-  lot of mail.  I'll save your mail and get to it as soon as I can, but
-  depending on how busy I am it may take me a couple of months.
+  I welcome bug reports and patches for this package at rra@stanford.edu
+  or via the CPAN bug tracker at <http://rt.cpan.org/>.  However, please
+  be aware that I tend to be extremely busy and to get a lot of mail.
+  I'll save your mail and get to it as soon as I can, but depending on how
+  busy I am it may take me a couple of months.
 
 BLURB
 
@@ -100,6 +101,12 @@ HOMEPAGE AND SOURCE REPOSITORY
 
       http://git.eyrie.org/?p=perl/ansicolor.git
 
+  For bug tracking, this package uses the CPAN bug tracker at:
+
+      https://rt.cpan.org/
+
+  Look for the Term-ANSIColor distribution.
+
 THANKS
 
   To Jon Lennox for looking at early versions of this module, providing
@@ -159,4 +166,10 @@ THANKS
   non-array references with stringification defined, and providing a test
   case.
 
+  To Kent Fredric for the request for italic and the report of a terminal
+  emulator that supports it.
+
+  To Simon Wistow for reporting that Term::ANSIColor was inadvertantly
+  clobbering $@ when generating constant subs.
+
   To Larry Wall, as always, for Perl.
index c6fed3e..7f6bfff 100644 (file)
@@ -2,14 +2,14 @@
 #
 # t/basic.t -- Test suite for the Term::ANSIColor Perl module.
 #
-# Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010
+# Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010, 2012
 #     Russ Allbery <rra@stanford.edu>
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the same terms as Perl itself.
 
 use strict;
-use Test::More tests => 51;
+use Test::More tests => 54;
 
 BEGIN {
     delete $ENV{ANSI_COLORS_DISABLED};
@@ -58,6 +58,10 @@ is ((BRIGHT_RED "test"), "\e[91mtest\e[0m", '...and as a constant');
 is (color ('on_bright_red'), "\e[101m", '...as is on bright red');
 is ((ON_BRIGHT_RED "test"), "\e[101mtest\e[0m", '...and as a constant');
 
+# Test italic, which was added in 3.02.
+is (color ('italic'), "\e[3m", 'Italic is supported');
+is ((ITALIC 'test'), "\e[3mtest\e[0m", '...and as a constant');
+
 # Test colored with 0 and EACHLINE.
 $Term::ANSIColor::EACHLINE = "\n";
 is (colored ('0', 'blue', 'bold'), "\e[34;1m0\e[0m",
@@ -137,3 +141,11 @@ like ($@, qr/^undefined subroutine \&Term::ANSIColor::RSET called at /,
 eval { Term::ANSIColor::reset () };
 like ($@, qr/^undefined subroutine \&Term::ANSIColor::reset called at /,
       'Correct error from a lowercase attribute');
+
+# Ensure that we still get proper error reporting for unknown constants when
+# when colors are disabled.
+$ENV{ANSI_COLORS_DISABLED} = 1;
+eval { Term::ANSIColor::RSET () };
+like ($@, qr/^undefined subroutine \&Term::ANSIColor::RSET called at /,
+      'Correct error from undefined attribute with disabled colors');
+delete $ENV{ANSI_COLORS_DISABLED};
diff --git a/cpan/Term-ANSIColor/t/eval.t b/cpan/Term-ANSIColor/t/eval.t
new file mode 100644 (file)
index 0000000..394368e
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -Tw
+#
+# t/eval.t -- Test suite for $@ preservation with constants.
+#
+# Copyright 2012 Russ Allbery <rra@stanford.edu>
+#
+# This program is free software; you may redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+use strict;
+use Test::More tests => 5;
+
+BEGIN {
+    delete $ENV{ANSI_COLORS_DISABLED};
+    use_ok ('Term::ANSIColor', qw/:constants/);
+}
+
+# Ensure that using a constant doesn't leak anything in $@.
+is ((BOLD 'test'), "\e[1mtest", 'BOLD works');
+is ($@, '', '... and $@ is empty');
+
+# Store something in $@ and ensure it doesn't get clobbered.
+eval 'sub { syntax';
+is ((BLINK 'test'), "\e[5mtest", 'BLINK works after eval failure');
+isnt ($@, '', '... and $@ still contains something useful');