From: Jarkko Hietaniemi Date: Wed, 12 Dec 2001 04:12:05 +0000 (+0000) Subject: In BeOS Errno must resort to actual compilation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bf567bf92612987d2a28d55129dc1a2a6406a6f;p=p5sagit%2Fp5-mst-13.2.git In BeOS Errno must resort to actual compilation and execution for some of the error constants. p4raw-id: //depot/perl@13648 --- diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL index 5a8e9e7..826f37f 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 < +#include +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 () { + 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";