]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mkhelp: simplify the generated hugehelp program
authorDaniel Stenberg <daniel@haxx.se>
Tue, 5 Mar 2024 16:32:00 +0000 (17:32 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 6 Mar 2024 14:56:00 +0000 (15:56 +0100)
Use a plain array and puts() every line, also allows us to provide the
strings without ending newlines.

- merge blank lines into the next one as a prefixed newline.
- turn eight consecutive spaces into a tab (since they can only be on the
  left side of text)
- the newly generated tool_hugehelp is 3K lines shorter and 50K smaller
- modifies the top logo layout a little by reducing the indent

Closes #13047

src/mkhelp.pl

index 5429160716f0b419b58487a41a512ab19607c65c..f1e1de1c6650e940e1480ee8173e5afa93005c33 100755 (executable)
@@ -35,11 +35,11 @@ if($ARGV[0] eq "-c") {
     shift @ARGV;
 }
 
-push @out, "                                  _   _ ____  _\n";
-push @out, "  Project                     ___| | | |  _ \\| |\n";
-push @out, "                             / __| | | | |_) | |\n";
-push @out, "                            | (__| |_| |  _ <| |___\n";
-push @out, "                             \\___|\\___/|_| \\_\\_____|\n";
+push @out, "          _   _ ____  _\n";
+push @out, "      ___| | | |  _ \\| |\n";
+push @out, "     / __| | | | |_) | |\n";
+push @out, "    | (__| |_| |  _ <| |___\n";
+push @out, "     \\___|\\___/|_| \\_\\_____|\n";
 
 my $olen=0;
 while (<STDIN>) {
@@ -157,40 +157,43 @@ exit;
 }
 else {
     print <<HEAD
-void hugehelp(void)
-{
-   fputs(
+static const char * const m[] = {
 HEAD
-         ;
+        ;
 }
 
-$outsize=0;
-for(@out) {
-    chop;
-
-    $new = $_;
+my $blank;
+for my $n (@out) {
+    chomp $n;
+    $n =~ s/\\/\\\\/g;
+    $n =~ s/\"/\\\"/g;
 
-    $outsize += length($new)+1; # one for the newline
-
-    $new =~ s/\\/\\\\/g;
-    $new =~ s/\"/\\\"/g;
-
-    # gcc 2.96 claims ISO C89 only is required to support 509 letter strings
-    if($outsize > 500) {
-        # terminate and make another fputs() call here
-        print ", stdout);\n fputs(\n";
-        $outsize=length($new)+1;
+    if(!$n) {
+        $blank++;
+    }
+    else {
+        $n =~ s/        /\\t/g;
+        printf("  \"%s%s\",\n", $blank?"\\n":"", $n);
+        $blank = 0;
     }
-    printf("\"%s\\n\"\n", $new);
-
 }
 
-print ", stdout) ;\n}\n";
+print <<ENDLINE
+  NULL
+};
+void hugehelp(void)
+{
+  int i = 0;
+  while(m[i])
+    puts(m[i++]);
+}
+ENDLINE
+    ;
 
 foot();
 
 sub foot {
-  print <<FOOT
+    print <<FOOT
 #endif /* USE_MANUAL */
 FOOT
   ;