From a1af6f361415610d726ff3be053691333abbbe9f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 26 Jun 2003 11:34:07 +0000 Subject: [PATCH] adjusted the compressed generation to be more helpful in comments etc --- src/mkhelp.pl | 59 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/src/mkhelp.pl b/src/mkhelp.pl index 2ff41a291..731f6598f 100644 --- a/src/mkhelp.pl +++ b/src/mkhelp.pl @@ -20,34 +20,39 @@ push @out, " / __| | | | |_) | | \n"; push @out, " | (__| |_| | _ <| |___ \n"; push @out, " \\___|\\___/|_| \\_\\_____|\n"; -my $head=0; - while () { - $line = $_; + my $line = $_; - # this kind should be removed first: - $line =~ s/_//g; + # this should be removed: + $line =~ s/(.|_)//g; - # then this: - $line =~ s/.//g; - - if($line =~ /^curl/i) { - # cut off the page headers - $head=1; - next; - } - - if($line =~ /^[ \t]*\n/) { - $wline++; - # we only make one empty line max + if($line =~ /^([ \t]*\n|curl)/i) { + # cut off headers and empty lines + $wline++; # count number of cut off lines next; } + + my $text = $line; + $text =~ s/^\s+//g; # cut off preceeding... + $text =~ s/\s+$//g; # and trailing whitespaces + + $tlen = length($text); + + if($wline && ($olen == $tlen)) { + # if the previous line with contents was exactly as long as + # this line, then we ignore the newlines! + + # We do this magic because a header may abort a paragraph at + # any line, but we don't want that to be noticed in the output + # here + $wline=0; + } + $olen = $tlen; + if($wline) { + # we only make one empty line max $wline = 0; - if(!$head) { - push @out, "\n"; - } - $head =0; + push @out, "\n"; } push @out, $line; } @@ -101,9 +106,17 @@ print <\nstatic const unsigned char hugehelpgz[] = {\n "; + print < +static const unsigned char hugehelpgz[] = { + /* This mumbo-jumbo is the huge help text compressed with gzip. + Thanks to this operation, the size of this data shrunk from $gzip + to $gzipped bytes. You can disable the use of compressed help + texts by NOT passing -c to the mkhelp.pl tool. */ +HEAD +; my $c=0; + print " "; for(@gzip) { my @all=split(//, $_); for(@all) {