summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/utils/c2ph.PL
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-08-09 18:10:42 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-08-09 18:10:42 +0000
commitb30707e4885ca231ff72a496671faa7830e8002a (patch)
treeceefb7d8635e495c31ba663e183cdcad8a9b157c /gnu/usr.bin/perl/utils/c2ph.PL
parent3c5182ca6f3c3cb0d292743e65788c0b1d03b596 (diff)
merge 5.8.5 into HEAD
remove now-unused files crank libperl shared library major number update Makefile.bsd-wrapper tweak openbsd hints file for arm and m68k
Diffstat (limited to 'gnu/usr.bin/perl/utils/c2ph.PL')
-rw-r--r--gnu/usr.bin/perl/utils/c2ph.PL26
1 files changed, 17 insertions, 9 deletions
diff --git a/gnu/usr.bin/perl/utils/c2ph.PL b/gnu/usr.bin/perl/utils/c2ph.PL
index 91ecc04552b..9334aa10436 100644
--- a/gnu/usr.bin/perl/utils/c2ph.PL
+++ b/gnu/usr.bin/perl/utils/c2ph.PL
@@ -278,8 +278,9 @@ Anyway, here it is. Should run on perl v4 or greater. Maybe less.
=cut
-$RCSID = '$Id: c2ph,v 1.7 95/10/28 10:41:47 tchrist Exp Locker: tchrist $';
+$RCSID = '$Id: c2ph.PL,v 1.7 2003/12/03 03:02:50 millert Exp $';
+use File::Temp;
######################################################################
@@ -480,6 +481,13 @@ sub defvar {
printf "%-16s%-15s %s\n", $var, eval "\$$var", $msg;
}
+sub safedir {
+ $SAFEDIR = File::Temp::tempdir("c2ph.XXXXXX", TMPDIR => 1, CLEANUP => 1)
+ unless (defined($SAFEDIR));
+}
+
+undef $SAFEDIR;
+
$recurse = 1;
if (@ARGV) {
@@ -495,15 +503,15 @@ if (@ARGV) {
}
elsif (@ARGV == 1 && $ARGV[0] =~ /\.c$/) {
local($dir, $file) = $ARGV[0] =~ m#(.*/)?(.*)$#;
- $chdir = "cd $dir; " if $dir;
+ $chdir = "cd $dir && " if $dir;
&system("$chdir$CC $CFLAGS $DEFINES $file") && exit 1;
$ARGV[0] =~ s/\.c$/.s/;
}
else {
- $TMPDIR = tempdir(CLEANUP => 1);
- $TMP = "$TMPDIR/c2ph.$$.c";
+ &safedir;
+ $TMP = "$SAFEDIR/c2ph.$$.c";
&system("cat @ARGV > $TMP") && exit 1;
- &system("cd $TMPDIR; $CC $CFLAGS $DEFINES $TMP") && exit 1;
+ &system("cd $SAFEDIR && $CC $CFLAGS $DEFINES $TMP") && exit 1;
unlink $TMP;
$TMP =~ s/\.c$/.s/;
@ARGV = ($TMP);
@@ -1274,8 +1282,8 @@ sub fetch_template {
}
sub compute_intrinsics {
- $TMPDIR ||= tempdir(CLEANUP => 1);
- local($TMP) = "$TMPDIR/c2ph-i.$$.c";
+ &safedir;
+ local($TMP) = "$SAFEDIR/c2ph-i.$$.c";
open (TMP, ">$TMP") || die "can't open $TMP: $!";
select(TMP);
@@ -1303,7 +1311,7 @@ EOF
close TMP;
select(STDOUT);
- open(PIPE, "cd $TMPDIR && $CC $TMP && $TMPDIR/a.out|");
+ open(PIPE, "cd $SAFEDIR && $CC $TMP && $SAFEDIR/a.out|");
while (<PIPE>) {
chop;
split(' ',$_,2);;
@@ -1312,7 +1320,7 @@ EOF
$intrinsics{$_[1]} = $template{$_[0]};
}
close(PIPE) || die "couldn't read intrinsics!";
- unlink($TMP, '$TMPDIR/a.out');
+ unlink($TMP, '$SAFEDIR/a.out');
print STDERR "done\n" if $trace;
}