| Line | |
|---|
| 1 | #!./perl -l
|
|---|
| 2 |
|
|---|
| 3 | # There's a bug in -P where the #! line is ignored. If this test
|
|---|
| 4 | # suddenly starts printing blank lines that bug has been fixed.
|
|---|
| 5 |
|
|---|
| 6 | print "1..3\n";
|
|---|
| 7 |
|
|---|
| 8 | #define MESS "ok 1\n"
|
|---|
| 9 | print MESS;
|
|---|
| 10 |
|
|---|
| 11 | #ifdef MESS
|
|---|
| 12 | print "ok 2\n";
|
|---|
| 13 | #else
|
|---|
| 14 | print "not ok 2\n";
|
|---|
| 15 | #endif
|
|---|
| 16 |
|
|---|
| 17 | open(TRY,">Comp_cpp.tmp") || die "Can't open temp perl file: $!";
|
|---|
| 18 |
|
|---|
| 19 | ($prog = <<'END') =~ s/X//g;
|
|---|
| 20 | X$ok = "not ok 3\n";
|
|---|
| 21 | X#include "Comp_cpp.inc"
|
|---|
| 22 | X#ifdef OK
|
|---|
| 23 | X$ok = OK;
|
|---|
| 24 | X#endif
|
|---|
| 25 | Xprint $ok;
|
|---|
| 26 | END
|
|---|
| 27 | print TRY $prog;
|
|---|
| 28 | close TRY or die "Could not close Comp_cpp.tmp: $!";
|
|---|
| 29 |
|
|---|
| 30 | open(TRY,">Comp_cpp.inc") || (die "Can't open temp include file: $!");
|
|---|
| 31 | print TRY '#define OK "ok 3\n"' . "\n";
|
|---|
| 32 | close TRY or die "Could not close Comp_cpp.tmp: $!";
|
|---|
| 33 |
|
|---|
| 34 | print `$^X "-P" Comp_cpp.tmp`;
|
|---|
| 35 | unlink "Comp_cpp.tmp", "Comp_cpp.inc";
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.