]> sourceware.org Git - newlib-cygwin.git/commitdiff
Generating faq/faq.body automatically from faq/faq.html whenever latter
authorWarren Young <warren@etr-usa.com>
Thu, 2 May 2013 00:10:15 +0000 (00:10 +0000)
committerWarren Young <warren@etr-usa.com>
Thu, 2 May 2013 00:10:15 +0000 (00:10 +0000)
is updated, using new bodysnatcher.pl script.

winsup/doc/ChangeLog
winsup/doc/Makefile.in
winsup/doc/bodysnatcher.pl [new file with mode: 0755]

index aeb214ebffcb798b723a4ee3d9ff587b96a72210..3aa225f0ca93830c6b81dc39b971b0eb2ab027a1 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-01  Warren Young  <warren@etr-usa.com>
+
+       * bodysnatcher.pl: Created
+       * Makefile.in (faq/faq.body): Added target to create this file from
+       faq/faq.html using new bodysnatcher.pl script.
+
 2013-05-01  Warren Young  <warren@etr-usa.com>
 
        * cygwin-ug.xml: Renamed from cygwin-ug.in.sgml
index c81de105862625f267ffa8d11b663b15d647c0de..f9445852f7d34e3d5052c6f0b691c260350f674c 100644 (file)
@@ -24,13 +24,16 @@ include $(srcdir)/../Makefile.common
 
 FAQ_SOURCES:= faq*.xml
 
-.SUFFIXES:
+.SUFFIXES: .html .body
+
+.html.body:
+       $(srcdir)/bodysnatcher.pl $<
 
 all: Makefile \
        cygwin-ug-net/cygwin-ug-net.html \
        cygwin-ug-net/cygwin-ug-net-nochunks.html.gz \
        cygwin-api/cygwin-api.html \
-       faq/faq.html \
+       faq/faq.body faq/faq.html \
        cygwin-ug-net/cygwin-ug-net.pdf \
        cygwin-api/cygwin-api.pdf
 
diff --git a/winsup/doc/bodysnatcher.pl b/winsup/doc/bodysnatcher.pl
new file mode 100755 (executable)
index 0000000..1db30aa
--- /dev/null
@@ -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;
+}
This page took 0.037064 seconds and 5 git commands to generate.