<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>cat-texi.perl</title>
<style type="text/css">
.enscript-comment { font-style: italic; color: rgb(178,34,34); }
.enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
.enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
.enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
.enscript-reference { font-weight: bold; color: rgb(95,158,160); }
.enscript-string { font-weight: bold; color: rgb(188,143,143); }
.enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
.enscript-type { font-weight: bold; color: rgb(34,139,34); }
.enscript-highlight { text-decoration: underline; color: 0; }
</style>
</head>
<body id="top">
<h1 style="margin:8px;" id="f1">cat-texi.perl&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="cat-texi.perl">plain text</a>]</span></h1>
<hr/>
<div></div>
<pre>
<span class="enscript-comment">#!/usr/bin/perl -w
</span>
<span class="enscript-keyword">use</span> strict;
<span class="enscript-keyword">use</span> warnings;

<span class="enscript-keyword">my</span> </span>@menu = ();
<span class="enscript-keyword">my</span> </span>$output = </span>$ARGV[0];

<span class="enscript-keyword">open</span> <span class="enscript-keyword">my</span> </span>$tmp, <span class="enscript-string">'&gt;'</span>, <span class="enscript-string">&quot;$output.tmp&quot;</span>;

<span class="enscript-keyword">while</span> (&lt;STDIN&gt;) {
	<span class="enscript-keyword">next</span> <span class="enscript-keyword">if</span> (/^\\input texinfo/../\</span>@node Top/);
	<span class="enscript-keyword">next</span> <span class="enscript-keyword">if</span> (/^\</span>@bye/ || /^\.ft/);
	<span class="enscript-keyword">if</span> (<span class="enscript-keyword">s</span>/^\</span>@top (.*)/\</span>@node </span>$1,,,Top/) {
		<span class="enscript-keyword">push</span> </span>@menu, </span>$1;
	}
	<span class="enscript-keyword">s</span>/\(\</span>@pxref\{\[(URLS|REMOTES)\]}\)//;
	<span class="enscript-keyword">s</span>/\</span>@anchor\{[^{}]*\}//g;
	<span class="enscript-keyword">print</span> </span>$tmp </span>$_;
}
<span class="enscript-keyword">close</span> </span>$tmp;

<span class="enscript-keyword">print</span> <span class="enscript-string">'\input texinfo
@setfilename gitman.info
@documentencoding UTF-8
@dircategory Development
@direntry
* Git Man Pages: (gitman).  Manual pages for Git revision control system
@end direntry
@node Top,,, (dir)
@top Git Manual Pages
@documentlanguage en
@menu
'</span>;

<span class="enscript-keyword">for</span> (</span>@menu) {
	<span class="enscript-keyword">print</span> <span class="enscript-string">&quot;* ${_}::\n&quot;</span>;
}
<span class="enscript-keyword">print</span> <span class="enscript-string">&quot;\@end menu\n&quot;</span>;
<span class="enscript-keyword">open</span> </span>$tmp, <span class="enscript-string">'&lt;'</span>, <span class="enscript-string">&quot;$output.tmp&quot;</span>;
<span class="enscript-keyword">while</span> (&lt;</span>$tmp&gt;) {
	<span class="enscript-keyword">print</span>;
}
<span class="enscript-keyword">close</span> </span>$tmp;
<span class="enscript-keyword">print</span> <span class="enscript-string">&quot;\@bye\n&quot;</span>;
<span class="enscript-keyword">unlink</span> <span class="enscript-string">&quot;$output.tmp&quot;</span>;
</pre>
<hr />
</body></html>