This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid double defining the POSIX::TCSANOW constant sub
authorTony Cook <tony@develop-help.com>
Mon, 28 Nov 2011 07:18:25 +0000 (18:18 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 28 Nov 2011 07:18:25 +0000 (18:18 +1100)
On Win32 which has no native TCSANOW definition this would produce:

Constant subroutine TCSANOW redefined at ../lib/POSIX.pm line -1.

because the macro wasn't defined when building the unknown symbols
table but was defined when building the defined symbols table.

ext/POSIX/POSIX.xs
ext/POSIX/lib/POSIX.pm

index 2737559..27aabb5 100644 (file)
@@ -841,11 +841,15 @@ getattr(termios_ref, fd = 0)
     OUTPUT:
        RETVAL
 
+# If we define TCSANOW here then both a found and not found constant sub
+# are created causing a Constant subroutine TCSANOW redefined warning
 #ifndef TCSANOW
-#  define TCSANOW 0
+#  define DEF_SETATTR_ACTION 0
+#else
+#  define DEF_SETATTR_ACTION TCSANOW
 #endif
 SysRet
-setattr(termios_ref, fd = 0, optional_actions = TCSANOW)
+setattr(termios_ref, fd = 0, optional_actions = DEF_SETATTR_ACTION)
        POSIX::Termios  termios_ref
        int             fd
        int             optional_actions
index d90794d..e50ee23 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 
 our ($AUTOLOAD, %SIGRT);
 
-our $VERSION = '1.26';
+our $VERSION = '1.27';
 
 require XSLoader;