From 9c7703ace1dcf05707a15fb15db8048d016fa208 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Jun 2003 12:54:34 +0000 Subject: Based on Dan Fandrich's patch and gzip unpack function, we now compress the 'hugehelp' text if libz and gzip are available at build time. --- src/mkhelp.pl | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 13 deletions(-) (limited to 'src/mkhelp.pl') diff --git a/src/mkhelp.pl b/src/mkhelp.pl index d58ccf989..8487b8782 100644 --- a/src/mkhelp.pl +++ b/src/mkhelp.pl @@ -6,10 +6,10 @@ # THEY DON'T FIT ME :-) # Get readme file as parameter: -$README = $ARGV[0]; +my $README = $ARGV[0]; if($README eq "") { - print "usage: mkreadme.pl \n"; + print "usage: mkreadme.pl [-c] < manpage\n"; exit; } @@ -20,8 +20,8 @@ push @out, " / __| | | | |_) | | \n"; push @out, " | (__| |_| | _ <| |___ \n"; push @out, " \\___|\\___/|_| \\_\\_____|\n"; -$head=0; -loop: +my $head=0; + while () { $line = $_; @@ -34,13 +34,13 @@ while () { if($line =~ /^curl/i) { # cut off the page headers $head=1; - next loop; + next; } if($line =~ /^[ \t]*\n/) { $wline++; # we only make one empty line max - next loop; + next; } if($wline) { $wline = 0; @@ -54,20 +54,113 @@ while () { push @out, "\n"; # just an extra newline open(READ, "<$README") || - die "couldn't read the README infile"; + die "couldn't read the README infile $README"; while() { push @out, $_; } close(READ); +# if compressed +if($c) { + my @test = `gzip --version 2>&1`; + if($test[0] =~ /gzip/) { + open(GZIP, "|gzip -9 >dumpit.gz"); + binmode GZIP; + for(@out) { + print GZIP $_; + $gzip += length($_); + } + close(GZIP); + + open(GZIP, ") { + push @gzip, $_; + $gzipped += length($_); + } + close(GZIP); + } + else { + # no gzip, no compression! + undef $c; + print STDERR "MEEEP: Couldn't find gzip, disable compression\n"; + } +} -print "/* NEVER EVER edit this manually, fix the mkhelp script instead! */\n" -; -print "#include \n"; -print "void hugehelp(void)\n"; -print "{\n"; -print " fputs (\n"; +$now = localtime; +print < +HEAD + ; +if($c) { + print "/* gzip shrunk this data from $gzip to $gzipped bytes */\n", + "#include \nstatic const unsigned char hugehelpgz[] = {\n "; + my $c=0; + for(@gzip) { + my @all=split(//, $_); + for(@all) { + my $num=ord($_); + printf("0x%02x, ", 0+$num); + if(++$c>11) { + print "\n "; + $c=0; + } + } + } + print "\n};\n"; + + print <