]> granicus.if.org Git - curl/commitdiff
adjusted the compressed generation to be more helpful in comments etc
authorDaniel Stenberg <daniel@haxx.se>
Thu, 26 Jun 2003 11:34:07 +0000 (11:34 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Jun 2003 11:34:07 +0000 (11:34 +0000)
src/mkhelp.pl

index 2ff41a291090b7dcabc776af23404754a74f14d4..731f6598f637ffdf3de6612559a15ab9cde41d70 100644 (file)
@@ -20,34 +20,39 @@ push @out, "                             / __| | | | |_) | |    \n";
 push @out, "                            | (__| |_| |  _ <| |___ \n";
 push @out, "                             \\___|\\___/|_| \\_\\_____|\n";
 
-my $head=0;
-
 while (<STDIN>) {
-    $line = $_;
-
-    # this kind should be removed first:
-    $line =~ s/_\b//g;
+    my $line = $_;
 
-    # then this:
-    $line =~ s/\b.//g;
+    # this should be removed:
+    $line =~ s/(\b.|_\b)//g;
 
-    if($line =~ /^curl/i) {
-       # cut off the page headers
-        $head=1;
+    if($line =~ /^([ \t]*\n|curl)/i) {
+        # cut off headers and empty lines
+       $wline++; # count number of cut off lines
        next;
-    } 
+    }
 
-    if($line =~ /^[ \t]*\n/) {
-       $wline++;
-       # we only make one empty line max
-       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 <<HEAD
 HEAD
     ;
 if($c) {
-    print "/* gzip shrunk this data from $gzip to $gzipped bytes */\n",
-    "#include <zlib.h>\nstatic const unsigned char hugehelpgz[] = {\n  ";
+    print <<HEAD
+#include <zlib.h>
+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) {