$README = $ARGV[0];
if($README eq "") {
print "usage: mkreadme.pl <README>\n";
exit;
}
push @out, " _ _ ____ _ \n";
push @out, " Project ___| | | | _ \\| | \n";
push @out, " / __| | | | |_) | | \n";
push @out, " | (__| |_| | _ <| |___ \n";
push @out, " \\___|\\___/|_| \\_\\_____|\n";
$head=0;
loop:
while (<STDIN>) {
$line = $_;
$line =~ s/_//g;
$line =~ s/.//g;
if($line =~ /^curl/i) {
$head=1;
next loop;
}
if($line =~ /^[ \t]*\n/) {
$wline++;
next loop;
}
if($wline) {
$wline = 0;
if(!$head) {
push @out, "\n";
}
$head =0;
}
push @out, $line;
}
push @out, "\n";
open(READ, "<$README") ||
die "couldn't read the README infile";
while(<READ>) {
push @out, $_;
}
close(READ);
print "/* NEVER EVER edit this manually, fix the mkhelp script instead! */\n"
;
print "#include <stdio.h>\n";
print "void hugehelp(void)\n";
print "{\n";
print "puts (\n";
$outsize=0;
for(@out) {
chop;
$new = $_;
$outsize += length($new)+1;
$new =~ s/\\/\\\\/g;
$new =~ s/\"/\\\"/g;
if($outsize > 500) {
print ");\n puts(\n";
$outsize=length($new)+1;
}
printf("\"%s\\n\"\n", $new);
}
print " ) ;\n}\n"