Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace {% use_bytes %} with a Makefile.PL-time source filter, and

cross my fingers.  If this works out, it'll eliminate the last use of
POE::Preprocessor, and I'll finally get to spin it off into a separate
distribution.
  • Loading branch information...
commit c9f1c190066c8bcea3146d687c36e5958f91a402 1 parent 1714b67
@rcaputo authored
View
24 Makefile.PL
@@ -67,10 +67,30 @@ if($ret =~ /^Y$/i) {
print "\n";
+# Comment out "use bytes" if it's not supported.
+
+use File::Find;
+my $code;
+if ($] < 5.006) {
+ print "Perl $] does not support bytes.pm. Commenting it out...\n";
+ $code = 's/^(\s*)(use bytes;).*/$1#$2 # perl version $] at install/';
+}
+else {
+ print "Perl $] supports bytes.pm. Ensuring it's in...\n";
+ $code = 's/^(\s*)#\s*(use bytes;).*/$1$2/';
+}
+
+find(
+ sub {
+ next unless -f and /\.pm$/;
+ system $^X, "-p", "-i.bak", "-e", $code, $_;
+ },
+ "lib"
+);
+
# Which kind of makefile should we build?
-eval "use 5.005_04";
-if ($@) {
+if ($] < 5.005004) {
warn(
"\n",
"===============================================================\n",
View
7 lib/POE/Driver/SysRW.pm
@@ -5,7 +5,6 @@
# and/or modify it under the same terms as Perl itself.
package POE::Driver::SysRW;
-use POE::Preprocessor ( isa => "POE::Macro::UseBytes" );
use strict;
@@ -58,7 +57,8 @@ sub put {
my ($self, $chunks) = @_;
my $old_queue_octets = $self->[TOTAL_OCTETS_LEFT];
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
foreach (grep { length } @$chunks) {
$self->[TOTAL_OCTETS_LEFT] += length;
@@ -124,7 +124,8 @@ sub get {
sub flush {
my ($self, $handle) = @_;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# syswrite() it, like we're supposed to
while (@{$self->[OUTPUT_QUEUE]}) {
View
7 lib/POE/Filter/Block.pm
@@ -1,7 +1,6 @@
# $Id$
package POE::Filter::Block;
-use POE::Preprocessor ( isa => "POE::Macro::UseBytes" );
use strict;
use POE::Filter;
@@ -95,7 +94,8 @@ sub get_one_start {
sub get_one {
my $self = shift;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# If a block size is specified, then pull off a block of that many
# bytes.
@@ -136,7 +136,8 @@ sub put {
my ($self, $blocks) = @_;
my @raw;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# If a block size is specified, then just assume the put is right.
# This will cause quiet framing errors on the receiving side. Then
View
7 lib/POE/Filter/HTTPD.pm
@@ -12,7 +12,6 @@
# and from HTTPD filters, they should submit their request as a patch.
package POE::Filter::HTTPD;
-use POE::Preprocessor ( isa => "POE::Macro::UseBytes" );
use strict;
use POE::Filter;
@@ -51,7 +50,8 @@ sub new {
sub get {
my ($self, $stream) = @_;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# Why?
local($_);
@@ -308,7 +308,8 @@ sub _http_version {
sub build_basic_response {
my ($self, $content, $content_type, $status) = @_;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
$content_type ||= 'text/html';
$status ||= RC_OK;
View
7 lib/POE/Filter/Reference.pm
@@ -4,7 +4,6 @@
# <artur@vogon-solutions.com>. Partial copyright 1999 Philip Gwyn.
package POE::Filter::Reference;
-use POE::Preprocessor ( isa => "POE::Macro::UseBytes" );
use strict;
use POE::Filter;
@@ -168,7 +167,8 @@ sub get_one_start {
sub get_one {
my $self = shift;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
if (
$self->{buffer} =~ /^(\d+)\0/ and
@@ -190,7 +190,8 @@ sub get_one {
sub put {
my ($self, $references) = @_;
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
my @raw = map {
my $frozen = $self->{freeze}->($_);
View
2  lib/POE/Wheel/ReadLine.pm
@@ -3,7 +3,7 @@
package POE::Wheel::ReadLine;
use strict;
-use bytes; # don't assume UTF while reading bizarre key sequences
+use bytes;
use vars qw($VERSION);
$VERSION = do {my@r=(q$Revision$=~/\d+/g);sprintf"%d."."%04d"x$#r,@r};
View
7 lib/POE/Wheel/SocketFactory.pm
@@ -1,7 +1,6 @@
# $Id$
package POE::Wheel::SocketFactory;
-use POE::Preprocessor ( isa => "POE::Macro::UseBytes" );
use strict;
@@ -713,7 +712,8 @@ sub new {
: INADDR_ANY
);
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# Resolve the bind address if it's not already packed.
unless (length($bind_address) == 4) {
@@ -785,7 +785,8 @@ sub new {
}
}
- {% use_bytes %}
+ # Need to check lengths in octets, not characters.
+ use bytes;
# Resolve the bind address.
my @info = Socket6::getaddrinfo(
Please sign in to comment.
Something went wrong with that request. Please try again.