-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_pperl_h
47 lines (34 loc) · 907 Bytes
/
write_pperl_h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!perl -w
use strict;
my $debug = shift || 0;
open(PPERL, ">pperl.h") || die "Can't write to pperl.h: $!";
open(PPERL_HEAD, "<pperl.h.header") || die "Can't read pperl.h.header: $!";
print PPERL <<'EOT';
/* pperl.h - autogenerated from pperl.h.header by write_pperl_h */
#define perl_header ""\
EOT
sub spool {
while (<PPERL_HEAD>) {
last if /#### Your Code Here ####/;
s/^\s*log_error.*// # lose log_error calls
unless $debug;
s/\\/\\\\/g; # double up all backslashes
s/"/\\"/g; # backslash all quotes
s/^(.*)$/"$1\\n"\\/; # wrap in quotes
print PPERL $_;
}
}
spool();
print PPERL << 'EOT';
"\n"
#define perl_footer ""\
EOT
spool();
print PPERL << 'EOT';
"\n"
EOT
my $version = `grep 'VERSION =' PPerl.pm | cut -d"'" -f2`;
chomp($version);
print PPERL '#define PPERL_VERSION "'. "$version\"\n";
close PPERL;
close PPERL_HEAD;