mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
c9a37cf682
Original commit message from CVS: * configure.ac: * examples/Makefile.am: * examples/pwg/Makefile.am: * examples/pwg/extract.pl: Enable building the PWG examples. * docs/pwg/advanced-interfaces.xml: Add URI interface stub. * docs/pwg/advanced-types.xml: * docs/pwg/other-autoplugger.xml: * docs/pwg/appendix-porting.xml: * docs/pwg/pwg.xml: Add porting guide (mostly stubs), remove autoplugging (see ADM). * docs/pwg/building-boiler.xml: * docs/pwg/building-chainfn.xml: * docs/pwg/building-pads.xml: * docs/pwg/building-props.xml: * docs/pwg/building-state.xml: * docs/pwg/building-testapp.xml: Update the building-*.xml parts for 0.9 changes. All examples code blocks compile in examples/pwg/*.
78 lines
1.5 KiB
Perl
Executable file
78 lines
1.5 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# extract code fragments from xml program listings
|
|
# first argument: source code file to find
|
|
# second argument: xml files to extract code from
|
|
|
|
# main
|
|
|
|
# decodes xml by translating & < > back to what they should be
|
|
# and also ignore
|
|
# <![CDATA[ and ]]> and <!-- and -->
|
|
sub
|
|
xml_decode ($)
|
|
{
|
|
my $input = shift;
|
|
|
|
$input =~ s/\&/&/g;
|
|
$input =~ s/</</g;
|
|
$input =~ s/>/>/g;
|
|
|
|
if ($input =~ /<!\[CDATA\[/) { $input = ""; }
|
|
if ($input =~ /]]>/) { $input = ""; }
|
|
if ($input =~ /<!--/) { $input = ""; }
|
|
if ($input =~ /-->/) { $input = ""; }
|
|
|
|
#print "Returning line $input";
|
|
return $input;
|
|
}
|
|
|
|
# main
|
|
my $output = shift @ARGV;
|
|
|
|
$found = 0;
|
|
%blocks = ();
|
|
|
|
foreach $file (@ARGV)
|
|
{
|
|
open FILE, $file or die "Cannot open file $file";
|
|
|
|
while ($line = <FILE>)
|
|
{
|
|
if ($line =~ /<!-- example-begin $output (.*?)-->/)
|
|
{
|
|
$found = 1;
|
|
$block_id = $1;
|
|
$block = "\n/*** block $block_id from $file ***/\n";
|
|
|
|
print "Extracting $output block $block_id from $file\n";
|
|
|
|
while ($line = <FILE>)
|
|
{
|
|
if ($line =~ /<!-- example-end $output (.*?)-->/)
|
|
{
|
|
last;
|
|
}
|
|
$block .= xml_decode ($line);
|
|
}
|
|
$blocks{$block_id} = $block;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (!$found)
|
|
{
|
|
print "Could not find $output example !\n";
|
|
exit(1);
|
|
}
|
|
|
|
# now output all the blocks in the right order
|
|
open OUTPUT, ">$output";
|
|
@block_ids = keys %blocks;
|
|
foreach $block_id (sort @block_ids)
|
|
{
|
|
print "Writing $output block $block_id\n";
|
|
print OUTPUT $blocks{$block_id};
|
|
}
|
|
close OUTPUT;
|