|
Revision 1933, 1.1 kB
(checked in by karpet, 2 years ago)
|
perl bindings split \003 into array of strings, libswish3 pod auto-generated from source .h file
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
use strict; |
|---|
| 9 |
use warnings; |
|---|
| 10 |
|
|---|
| 11 |
sub slurp |
|---|
| 12 |
{ |
|---|
| 13 |
my $file = shift; |
|---|
| 14 |
local $/; |
|---|
| 15 |
open(F, "< $file") or die "can't open $file: $!"; |
|---|
| 16 |
my $buf = <F>; |
|---|
| 17 |
close(F); |
|---|
| 18 |
return $buf; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
sub write_file |
|---|
| 22 |
{ |
|---|
| 23 |
my ($file, $buf) = @_; |
|---|
| 24 |
open(F, "> $file") or die "can't write $file: $!"; |
|---|
| 25 |
print F $buf; |
|---|
| 26 |
close(F); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
sub make_pod |
|---|
| 41 |
{ |
|---|
| 42 |
my $buf = shift; |
|---|
| 43 |
my @Pod; |
|---|
| 44 |
while ($buf =~ m!^/\*\s+(=head2 .*?\s+)\*/(.*?)/\*\s+=cut\s+\*/!gms) |
|---|
| 45 |
{ |
|---|
| 46 |
my $head = $1; |
|---|
| 47 |
my $pod = $2; |
|---|
| 48 |
$pod =~ s,\n,\n ,g; |
|---|
| 49 |
push(@Pod, "$head$pod\n"); |
|---|
| 50 |
} |
|---|
| 51 |
return join("\n", @Pod); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
my $header = '../src/libswish3/libswish3.h'; |
|---|
| 55 |
my $tmpl = 'libswish3.3.pod.in'; |
|---|
| 56 |
my $pattern = '<<libswish3.h_HERE>>'; |
|---|
| 57 |
my $buf = make_pod(slurp($header)); |
|---|
| 58 |
my $pod = slurp($tmpl); |
|---|
| 59 |
$pod =~ s,$pattern,$buf,; |
|---|
| 60 |
my $out = $tmpl; |
|---|
| 61 |
$out =~ s,\.in$,,; |
|---|
| 62 |
write_file($out, $pod); |
|---|