Author: grzegol Date: Fri Feb 25 23:54:36 2005 GMT
Module: SOURCES Tag: DEVEL
---- Log message:
- missing file from libxml++ tarball
---- Files affected:
SOURCES:
insert_example_code.pl (NONE -> 1.1.2.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/insert_example_code.pl
diff -u /dev/null SOURCES/insert_example_code.pl:1.1.2.1
--- /dev/null Sat Feb 26 00:54:36 2005
+++ SOURCES/insert_example_code.pl Sat Feb 26 00:54:31 2005
@@ -0,0 +1,82 @@
+#! /usr/bin/perl -w
+
+#sub main()
+{
+ my $examples_base = shift(@ARGV);
+
+ $examples_base .= "/" unless($examples_base =~ /\/$/);
+
+ foreach $file (@ARGV)
+ {
+ open(FILE, $file);
+
+ while(<FILE>)
+ {
+ print $_;
+
+ #Beginning of comment:
+ # Look for
+ # <para><ulink url="&url_examples_base;helloworld">Source
Code</ulink></para>
+
+ if(/<para><ulink url=\"&url_examples_base;([\/\w]+)\">Source
Code<\/ulink><\/para>/)
+ {
+ #List all the source files in that directory:
+ my $directory = $examples_base . $1;
+
+ opendir(DIR, $directory);
+ my @dir_contents = readdir(DIR);
+ closedir(DIR);
+
+ my @source_files = grep(/\.cc$/, @dir_contents);
+ my @header_files = grep(/\.h$/, @dir_contents);
+
+ print "<!-- start inserted example code -->\n";
+
+ foreach $source_file (@header_files, @source_files)
+ {
+ print "<para>File: ${source_file}\n";
+ print "<programlisting>\n";
+
+ &process_source_file("${directory}/${source_file}");
+
+ print "</programlisting>\n";
+ print "</para>\n";
+ }
+
+ print "<!-- end inserted example code -->\n";
+ }
+ }
+
+ close(FILE);
+ }
+
+ exit 0;
+}
+
+sub process_source_file($)
+{
+ my ($source_file) = @_;
+ my $found_start = 0;
+
+ open(SOURCE_FILE, $source_file);
+
+ while(<SOURCE_FILE>)
+ {
+ # Skip all text until the first code line.
+ if(!$found_start)
+ {
+ next unless /^[#\w]/;
+ $found_start = 1;
+ }
+
+ s/&/&/g;
+ s/</</g;
+ s/>/>/g;
+ s/"/"/g;
+
+ print $_;
+ }
+
+ close(SOURCE_FILE);
+}
+
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit