summaryrefslogtreecommitdiff
path: root/x2p
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1992-06-08 04:52:59 +0000
committerLarry Wall <lwall@netlabs.com>1992-06-08 04:52:59 +0000
commit2b69d0c297460bce3a8d8eefe2bd0de0a6451872 (patch)
tree918d4cf76b228b2cec26aede54e1c35e6b024c25 /x2p
parent32c2e4fbb7ba898d9e58e8d2292dd45b8692070d (diff)
downloadperl-2b69d0c297460bce3a8d8eefe2bd0de0a6451872.tar.gz
perl 4.0 patch 31: patch #20, continued
See patch #20.
Diffstat (limited to 'x2p')
-rw-r--r--x2p/s2p.SH34
1 files changed, 29 insertions, 5 deletions
diff --git a/x2p/s2p.SH b/x2p/s2p.SH
index 818d36211b..6bb8c51c68 100644
--- a/x2p/s2p.SH
+++ b/x2p/s2p.SH
@@ -20,18 +20,27 @@ echo "Extracting s2p (with variable substitutions)"
: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
: Protect any dollar signs and backticks that you do not want interpreted
: by putting a backslash in front. You may delete these comments.
+rm -f s2p
$spitshell >s2p <<!GROK!THIS!
#!$bin/perl
+eval 'exec $bin/perl -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+
\$bin = '$bin';
!GROK!THIS!
: In the following dollars and backticks do not need the extra backslash.
$spitshell >>s2p <<'!NO!SUBS!'
-# $RCSfile: s2p.SH,v $$Revision: 4.0.1.1 $$Date: 91/06/07 12:19:18 $
+# $RCSfile: s2p.SH,v $$Revision: 4.0.1.2 $$Date: 92/06/08 17:26:31 $
#
# $Log: s2p.SH,v $
+# Revision 4.0.1.2 92/06/08 17:26:31 lwall
+# patch20: s2p didn't output portable startup code
+# patch20: added ... as variant on ..
+# patch20: s2p didn't translate s/pat/\&/ or s/pat/\$/ or s/pat/\\1/ right
+#
# Revision 4.0.1.1 91/06/07 12:19:18 lwall
# patch4: s2p now handles embedded newlines better and optimizes common idioms
#
@@ -162,7 +171,12 @@ while (<>) {
} else {
&Die("Invalid second address at line $.\n");
}
- $addr1 .= " .. $addr2";
+ if ($addr2 =~ /^\d+$/) {
+ $addr1 .= "..$addr2";
+ }
+ else {
+ $addr1 .= "...$addr2";
+ }
}
# Now we check for metacommands {, }, and ! and worry
@@ -488,6 +502,19 @@ EOT
substr($_,$i,1) =~ /^[<>]$/) {
substr($_,$i,1) = 'b';
}
+ elsif ($repl && substr($_,$i,1) =~ /^\d$/) {
+ substr($_,$i-1,1) = '$';
+ }
+ }
+ elsif ($c eq '&' && $repl) {
+ substr($_, $i, 0) = '$';
+ $i++;
+ $len++;
+ }
+ elsif ($c eq '$' && $repl) {
+ substr($_, $i, 0) = '\\';
+ $i++;
+ $len++;
}
elsif ($c eq '[' && !$repl) {
$i++ if substr($_,$i,1) eq '^';
@@ -515,9 +542,6 @@ EOT
$end = substr($_, $end + 1, 1000);
&simplify($pat);
$dol = '$';
- $repl =~ s/\$/\\$/;
- $repl =~ s'&'$&'g;
- $repl =~ s/[\\]([0-9])/$dol$1/g;
$subst = "$pat$repl$delim";
$cmd = '';
while ($end) {