diff -ru optimizer-0.05/Changes optimizer-0.05-fixed/Changes
--- optimizer-0.05/Changes	2002-12-30 01:47:44.000000000 -0700
+++ optimizer-0.05-fixed/Changes	2005-08-20 11:58:36.000000000 -0600
@@ -1,5 +1,11 @@
 Revision history for Perl extension optimizer.
 
+0.05_01  Sat Aug 20 11:35:49 MDT 2005 (rogue patch jcromie@cpan.org)
+	Various hacks to get it to compile
+	- redefine several Perl_ symbols (possible API violations)
+	- version ifdefs for internal sv-flag change in 5.8
+	- added whitespace
+
 0.05  Mon Dec 30 09:45:09 CET 2002
 	- Applied patch from greg that removes debugging prints
 	  [rt.cpan.org 1475] http://rt.cpan.org/NoAuth/Bug.html?id=1475
diff -ru optimizer-0.05/Makefile.PL optimizer-0.05-fixed/Makefile.PL
--- optimizer-0.05/Makefile.PL	2002-12-30 01:59:51.000000000 -0700
+++ optimizer-0.05-fixed/Makefile.PL	2005-07-13 19:03:51.000000000 -0600
@@ -5,7 +5,7 @@
 WriteMakefile(
     'NAME'		=> 'optimizer',
     'VERSION_FROM'	=> 'optimizer.pm', # finds $VERSION
-    'PREREQ_PM'		=> {}, # e.g., Module::Name => 1.1
+    'PREREQ_PM'		=> { B::Generate => 0 }, # e.g., Module::Name => 1.1
     ($] >= 5.005 ?    ## Add these new keywords supported since 5.005
       (ABSTRACT_FROM => 'optimizer.pm', # retrieve abstract from module
        AUTHOR     => 'Arthur Bergman <abergman@cpan.org>') : ()),
diff -ru optimizer-0.05/optimizer.pm optimizer-0.05-fixed/optimizer.pm
--- optimizer-0.05/optimizer.pm	2002-12-30 01:48:12.000000000 -0700
+++ optimizer-0.05-fixed/optimizer.pm	2005-08-20 11:53:59.000000000 -0600
@@ -1,15 +1,15 @@
 package optimizer;
 use Carp;
 use B;
-{ no warnings 'redefine';
+
 use B::Generate;
-}
+
 use 5.7.2;
 use strict;
 use warnings;
 
 require DynaLoader;
-our $VERSION = '0.05';
+our $VERSION = '0.05_01';
 our @ISA=q(DynaLoader);
 our %callbacks;
 bootstrap optimizer $VERSION;
@@ -39,22 +39,29 @@
     }
     if ($type eq 'C' or $type eq 'c') {
         optimizer::uninstall();
-    } elsif ($type =~ /^Perl$/i) {
+    }
+    elsif ($type =~ /^Perl$/i) {
         optimizer::install( sub { optimizer::peepextend($_[0], sub {}) });
-    } elsif ($type eq "callback" or $type eq "extend" or $type eq "mine") {
+    }
+    elsif ($type eq "callback" or $type eq "extend" or $type eq "mine") {
         my $subref = shift;
         croak "Supplied callback was not a subref" unless ref $subref eq "CODE";
-        optimizer::install( sub { callbackoptimizer($_[0],$subref) }) if $type eq "callback";
-        optimizer::install( sub { optimizer::peepextend($_[0], $subref) }) if $type eq "extend";
-        optimizer::install( $subref ) if $type eq "mine";
-    } elsif ($type eq 'extend-c') {
 
+        optimizer::install( sub { callbackoptimizer($_[0],$subref) })
+	    if $type eq "callback";
+        optimizer::install( sub { optimizer::peepextend($_[0], $subref) })
+	    if $type eq "extend";
+        optimizer::install( $subref ) if $type eq "mine";
+    }
+    elsif ($type eq 'extend-c') {
       optimizer::c_extend_install(shift);
-    } elsif ($type eq 'sub-detect') {
+    }
+    elsif ($type eq 'sub-detect') {
       my ($package, $filename, $line) = caller;
       $callbacks{$package} = shift;
       optimizer::c_sub_detect_install();
-    } else { croak "Unknown optimizer option '$type'"; }
+    }
+    else { croak "Unknown optimizer option '$type'"; }
 }
 
 sub unimport {
@@ -78,24 +85,26 @@
     # Oh boy
     my ($o, $callback) = @_;
     my $oldop = 0;
-
+    
     return if !$$o or $o->seq;
-
+    
     op_seqmax_inc() unless op_seqmax();
     while ($$o) {
         #warn ("Trying op $o ($$o) -> ".$o->name."\n");
         if ($o->isa("B::COP")) {
-
+	    
             $o->seq(optimizer::op_seqmax_inc());
             update($o); # For warnings
-
-        } elsif ($o->name eq "const") {
-            optimizer::die("Bareword ",$o->sv->sv, " not allowed while \"strict subs\" in use")
-                if ($o->private & 8);
-
-            relocatetopad($o,$o->find_cv());
-            $o->seq(optimizer::op_seqmax_inc());
-        } elsif ($o->name eq "concat") {
+        }
+	elsif ($o->name eq "const") {
+            optimizer::die("Bareword ",$o->sv->sv,
+			   " not allowed while \"strict subs\" in use")
+		if ($o->private & 8);
+
+	    relocatetopad($o,$o->find_cv());
+	    $o->seq(optimizer::op_seqmax_inc());
+	}
+	elsif ($o->name eq "concat") {
             if ($o->next && $o->next->name eq "stringify" and !($o->flags &64)) {
                 if ($o->next->private & 16) {
                     $o->targ($o->next->targ);
@@ -108,7 +117,8 @@
         #    CORE::die "Eep.";
         #} elsif ($o->name eq "null") {
         #   CORE::die "Eep.";
-        } elsif ($o->name eq "scalar" or $o->name eq "lineseq" or $o->name eq "scope") {
+        }
+	elsif ($o->name eq "scalar" or $o->name eq "lineseq" or $o->name eq "scope") {
             if ($$oldop and ${$o->next}) {
                 $oldop->next($o->next);
                 $o=$o->next;
@@ -117,20 +127,28 @@
             $o->seq(optimizer::op_seqmax_inc());
         #} elsif ($o->name eq "gv") { 
         #    CORE::die "Eep.";
-        } elsif ($o->name =~ /^((map|grep)while|(and|or)(assign)?|cond_expr|range)$/) {
+        }
+	elsif ($o->name =~ /^((map|grep)while|(and|or)(assign)?|cond_expr|range)$/) {
             $o->seq(optimizer::op_seqmax_inc());
             $o->other($o->other->next) while $o->other->name eq "null";
             peepextend($o->other, $callback); # Weee.
-        } elsif ($o->name =~ /^enter(loop|iter)/) {
+        }
+	elsif ($o->name =~ /^enter(loop|iter)/) {
             $o->seq(optimizer::op_seqmax_inc());
-            $o->redoop($o->redoop->next) while $o->redoop->name eq "null"; peepextend($o->redoop, $callback);
-            $o->nextop($o->nextop->next) while $o->nextop->name eq "null"; peepextend($o->nextop, $callback);
-            $o->lastop($o->lastop->next) while $o->lastop->name eq "null"; peepextend($o->lastop, $callback);
-        } elsif ($o->name eq "qr" or $o->name eq "match" or $o->name eq "subst") {
+            $o->redoop($o->redoop->next) while $o->redoop->name eq "null";
+	    peepextend($o->redoop, $callback);
+            $o->nextop($o->nextop->next) while $o->nextop->name eq "null";
+	    peepextend($o->nextop, $callback);
+            $o->lastop($o->lastop->next) while $o->lastop->name eq "null";
+	    peepextend($o->lastop, $callback);
+        }
+	elsif ($o->name eq "qr" or $o->name eq "match" or $o->name eq "subst") {
             $o->seq(optimizer::op_seqmax_inc());
-            $o->pmreplstart($o->pmreplstart->next) while ${$o->pmreplstart} and $o->pmreplstart->name eq "null"; 
+            $o->pmreplstart($o->pmreplstart->next) 
+		while ${$o->pmreplstart} and $o->pmreplstart->name eq "null"; 
             peepextend($o->pmreplstart, $callback);
-        } elsif ($o->name eq "exec") {
+        }
+	elsif ($o->name eq "exec") {
             $o->seq(optimizer::op_seqmax_inc());
             if (${$o->next} and $o->next->name eq "nextstate" and
                 ${$o->next->sibling} and $o->next->sibling->type !~ /exit|warn|die/) {
diff -ru optimizer-0.05/optimizer.xs optimizer-0.05-fixed/optimizer.xs
--- optimizer-0.05/optimizer.xs	2002-12-30 01:44:45.000000000 -0700
+++ optimizer-0.05-fixed/optimizer.xs	2005-07-13 19:03:51.000000000 -0600
@@ -10,6 +10,11 @@
 #define PL_opargs (get_opargs())
 #endif
 
+#undef save_op
+#define save_op() Perl_save_op(aTHX)
+#undef pad_alloc
+#define pad_alloc(o,s) Perl_pad_alloc(aTHX_ o,s)
+
 typedef enum { OPc_NULL, OPc_BASEOP, OPc_UNOP, OPc_BINOP, OPc_LOGOP, OPc_LISTOP, 
     OPc_PMOP, OPc_SVOP, OPc_PADOP, OPc_PVOP, OPc_CVOP, OPc_LOOP, OPc_COP } opclass;
 
@@ -162,7 +167,8 @@
 STATIC void
 no_bareword_allowed(pTHX_ OP *o)
 {
-    qerror(Perl_mess(aTHX_
+    Perl_qerror(aTHX_ 
+		Perl_mess(aTHX_
 		     "Bareword \"%s\" not allowed while \"strict subs\" in use",
 		     SvPV_nolen(cSVOPo_sv)));
 }
@@ -446,8 +452,13 @@
 	    sv = newSViv(ind);
 	    if (SvREADONLY(*svp))
 		SvREADONLY_on(sv);
+#	if PERL_VERSION > 8
+	    SvFLAGS(sv) |= (SvFLAGS(*svp)
+			    & (SVs_PADSTALE|SVs_PADTMP|SVs_PADMY));
+#	else
 	    SvFLAGS(sv) |= (SvFLAGS(*svp)
 			    & (SVs_PADBUSY|SVs_PADTMP|SVs_PADMY));
+#	endif
 	    SvREFCNT_dec(*svp);
 	    *svp = sv;
 	    break;
@@ -509,8 +520,13 @@
 		sv = newSViv(ind);
 		if (SvREADONLY(*svp))
 		    SvREADONLY_on(sv);
+#	if PERL_VERSION > 8
+		SvFLAGS(sv) |= (SvFLAGS(*svp)
+				& (SVs_PADSTALE|SVs_PADTMP|SVs_PADMY));
+#	else
 		SvFLAGS(sv) |= (SvFLAGS(*svp)
 				& (SVs_PADBUSY|SVs_PADTMP|SVs_PADMY));
+#	endif
 		SvREFCNT_dec(*svp);
 		*svp = sv;
 	    }
@@ -535,7 +551,7 @@
      by the fact that doing stuff while optimization is highly dangerous
   */
     
-  peep(o);
+  Perl_peep(aTHX_ o);
     
   /* Since we get the start here, we should try and find the
      leave by following next until we find it
@@ -576,6 +592,8 @@
 
 MODULE = optimizer		PACKAGE = optimizer		PREFIX = PEEP_
 
+PROTOTYPES: DISABLE
+
 U32
 PEEP_op_seqmax()
 
