#!/usr/bin/perl
die "Usage: $0 functionName\n" unless @ARGV==1;
$parifile="~pari/doc/usersch3.tex";
$help=shift;
%transl=(
	 '\\', '\backslash',
	 '^',  '\hat{}',
	 '!',  'fact',
	 '~',  'trans',
	 '_',  'conj',
	 '-',  '\+',
	 '%',  '\%',
	 'min',  'max',
	 'log',  'ln',
);
if    ($transl{$help}) {$help=$transl{$help}}
if ($help =~ /^[<>=!]=?|[|&]{1,2}$/) 
      {$help='comparison and \ref{boolean operators}'}
$help =~ s/(\W)/\\$1/g;
#print $help;
open(DOC,$parifile) || die "Cannot find file $parifile, stopped";
while (<DOC>) {
    last if /\\subsec[\\{}ref]*[\\\${]$help[}\\\$]/o;
}
print "Not found!\n" if eof(DOC);
#$_=$';
&TeXprint;
while (<DOC>) {
  last if /The\s+library|\\(sub)?sec/i;
  &TeXprint;
}
close(DOC) || die "Cannot close file $parifile, stopped";

sub TeXprint {
  s/\$-/-/g;
  s/\$/ /g;
  s/\\\///g;
  s/\\backslash/\\/g;
  s/\\hat(\{\\\s+\})?/^/g;
  s/\\(subsec(ref)?|smallskip|sl|sref[ a-z]*|bf|ref|Bbb|text|tt|\|)[ \t]*//g;
  s/(^|\s)\{(\w+)\}/$1$2/g;
  print;
}
