Change 13648 by jhi@alpha on 2001/12/12 04:12:05
In BeOS Errno must resort to actual compilation
and execution for some of the error constants.
Affected files ...
.... //depot/perl/ext/Errno/Errno_pm.PL#31 edit
Differences ...
==== //depot/perl/ext/Errno/Errno_pm.PL#31 (text) ====
Index: perl/ext/Errno/Errno_pm.PL
--- perl/ext/Errno/Errno_pm.PL.~1~ Tue Dec 11 21:15:06 2001
+++ perl/ext/Errno/Errno_pm.PL Tue Dec 11 21:15:06 2001
@@ -212,6 +212,40 @@
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";
End of Patch.