Integrate with Sarathy.
[p5sagit/p5-mst-13.2.git] / x2p / s2p.PL
index fa0d567..4f7bf8c 100644 (file)
@@ -2,6 +2,7 @@
 
 use Config;
 use File::Basename qw(&basename &dirname);
+use Cwd;
 
 # List explicitly here the variables you want Configure to
 # generate.  Metaconfig only looks for shell variables, so you
@@ -12,6 +13,7 @@ use File::Basename qw(&basename &dirname);
 
 # This forces PL files to create target in same directory as PL file.
 # This is so that make depend always knows where to find PL derivatives.
+$origdir = cwd;
 chdir dirname($0);
 $file = basename($0, '.PL');
 $file .= '.com' if $^O eq 'VMS';
@@ -49,7 +51,7 @@ B<s2p [options] filename>
 
 =head1 DESCRIPTION
 
-I<S2p> takes a sed script specified on the command line (or from
+I<s2p> takes a sed script specified on the command line (or from
 standard input) and produces a comparable I<perl> script on the
 standard output.
 
@@ -91,7 +93,7 @@ $\ and chop.
 
 =head1 ENVIRONMENT
 
-S2p uses no environment variables.
+s2p uses no environment variables.
 
 =head1 AUTHOR
 
@@ -102,7 +104,7 @@ Larry Wall E<lt>F<larry@wall.org>E<gt>
 =head1 SEE ALSO
 
  perl  The perl compiler/interpreter
+
  a2p   awk to perl translator
 
 =head1 DIAGNOSTICS
@@ -337,11 +339,11 @@ if ($appendseen || $tseen || !$assumen) {
 :          if ($atext) { chop $atext; print $atext; $atext = ''; }
 :      #endif
 EOT
+}
 
 print BODY &q(<<'EOT');
 :      }
 EOT
-}
 
 unless ($debug) {
 
@@ -550,6 +552,11 @@ EOT
                        substr($_,$i-1,1) = '$';
                    }
                }
+               elsif ($c eq '@') {
+                   substr($_, $i, 0) = '\\';
+                   $i++;
+                   $len++;
+               }
                elsif ($c eq '&' && $repl) {
                    substr($_, $i, 0) = '$';
                    $i++;
@@ -669,7 +676,7 @@ EOT
        }
 
        if (/^H/) {
-           $_ = '$hold .= "\n"; $hold .= $_;';
+           $_ = '$hold .= "\n", $hold .= $_;';
            next;
        }
 
@@ -679,7 +686,7 @@ EOT
        }
 
        if (/^G/) {
-           $_ = '$_ .= "\n"; $_ .= $hold;';
+           $_ = '$_ .= "\n", $_ .= $hold;';
            next;
        }
 
@@ -795,6 +802,7 @@ sub fetchpat {
        }
     }
     $addr =~ s/\t/\\t/g;
+    $addr =~ s/\@/\\@/g;
     &simplify($addr);
     $addr;
 }
@@ -843,3 +851,4 @@ sub skip {
 close OUT or die "Can't close $file: $!";
 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;