Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarren Young <warren@etr-usa.com>2013-05-02 04:10:15 +0400
committerWarren Young <warren@etr-usa.com>2013-05-02 04:10:15 +0400
commit32d9bab55e81f021d06a671176378855cc86f426 (patch)
tree8bbe3f74dead8f56c44da929e423e08b8788277e /winsup/doc/bodysnatcher.pl
parent1f8b70e2a1305540aaa469553b6e88fa905bd7d6 (diff)
Generating faq/faq.body automatically from faq/faq.html whenever latter
is updated, using new bodysnatcher.pl script.
Diffstat (limited to 'winsup/doc/bodysnatcher.pl')
-rwxr-xr-xwinsup/doc/bodysnatcher.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/winsup/doc/bodysnatcher.pl b/winsup/doc/bodysnatcher.pl
new file mode 100755
index 000000000..1db30aad4
--- /dev/null
+++ b/winsup/doc/bodysnatcher.pl
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+# Copyright © 2013 by Red Hat, Inc.
+#
+# This file is part of Cygwin.
+#
+# This software is a copyrighted work licensed under the terms of the
+# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+# details.
+
+use strict;
+
+if (@ARGV) {
+ my $infile = $ARGV[0];
+ my $outfile = $infile;
+ $outfile =~ s/\.html$/.body/;
+ if ($infile ne $outfile) {
+ open my $input, '<', $infile or die "Failed to open $infile: $!\n";
+ my $html = do { local $/; <$input> }; # slurp!
+ my ($body) = $html =~ m|<body[^>]*>(.*)</body>|is;
+ if ($body) {
+ open my $output, '>', $outfile
+ or die "Failed to write $outfile: $!\n";
+ print $output $body;
+ }
+ else {
+ print STDERR "Could not find <body> element in $infile!\n\n";
+ exit 3;
+ }
+ }
+ else {
+ print STDERR "Input file name must end in .html!\n\n";
+ exit 2;
+ }
+}
+else {
+ print STDERR <<USAGE;
+usage: $0 <input.html>
+
+ Transforms input.html to input.body by extracting whatever is
+ between <body> and </body> in input.html.
+
+USAGE
+ exit 1;
+}