diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-12-12 04:12:05 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-12-12 04:12:05 +0000 |
commit | 7bf567bf92612987d2a28d55129dc1a2a6406a6f (patch) | |
tree | 0d7dc1fdbff8df0cef58292b0a3d6f9a47154e18 /ext/Errno | |
parent | 4024c853fe54761ed855ab7a98d8b015be1ec94d (diff) | |
download | perl-7bf567bf92612987d2a28d55129dc1a2a6406a6f.tar.gz |
In BeOS Errno must resort to actual compilation
and execution for some of the error constants.
p4raw-id: //depot/perl@13648
Diffstat (limited to 'ext/Errno')
-rw-r--r-- | ext/Errno/Errno_pm.PL | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 5a8e9e76b4..826f37fa38 100644 --- a/ext/Errno/Errno_pm.PL +++ b/ext/Errno/Errno_pm.PL @@ -212,6 +212,40 @@ sub write_errno_pm { close(CPPO); } + # Many of the E constants (including ENOENT, which is being + # used in the Perl test suite a lot), are available only as + # enums in BeOS, so compiling and executing some code is about + # only way to find out what the numeric Evalues are. + + if ($^O eq 'beos') { + if (open(C, ">errno.c")) { + my @zero = grep { !$err{$_} } keys %err; + print C <<EOF; +#include <errno.h> +#include <stdio.h> +int main() { +EOF + for (@zero) { + print C qq[printf("$_ %d\n", $_);] + } + print C "}\n"; + close C; + system("cc -o errno errno.c"); + unlink("errno.c"); + if (open(C, "./errno|")) { + while (<C>) { + if (/^(\w+) (-?\d+)$/) { $err{$1} = $2 } + } + close(C); + } else { + die "failed to execute ./errno: $!\n"; + } + unlink("errno"); + } else { + die "failed to create errno.c: $!\n"; + } + } + # Write Errno.pm print <<"EDQ"; |