Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/curl/src/mkhelp.pl @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #!/usr/bin/env perl | |
| 2 #*************************************************************************** | |
| 3 # _ _ ____ _ | |
| 4 # Project ___| | | | _ \| | | |
| 5 # / __| | | | |_) | | | |
| 6 # | (__| |_| | _ <| |___ | |
| 7 # \___|\___/|_| \_\_____| | |
| 8 # | |
| 9 # Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. | |
| 10 # | |
| 11 # This software is licensed as described in the file COPYING, which | |
| 12 # you should have received as part of this distribution. The terms | |
| 13 # are also available at https://curl.haxx.se/docs/copyright.html. | |
| 14 # | |
| 15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell | |
| 16 # copies of the Software, and permit persons to whom the Software is | |
| 17 # furnished to do so, under the terms of the COPYING file. | |
| 18 # | |
| 19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | |
| 20 # KIND, either express or implied. | |
| 21 # | |
| 22 ########################################################################### | |
| 23 | |
| 24 # Yeah, I know, probably 1000 other persons already wrote a script like | |
| 25 # this, but I'll tell ya: | |
| 26 | |
| 27 # THEY DON'T FIT ME :-) | |
| 28 | |
| 29 # Get readme file as parameter: | |
| 30 | |
| 31 if($ARGV[0] eq "-c") { | |
| 32 $c=1; | |
| 33 shift @ARGV; | |
| 34 } | |
| 35 | |
| 36 push @out, " _ _ ____ _\n"; | |
| 37 push @out, " Project ___| | | | _ \\| |\n"; | |
| 38 push @out, " / __| | | | |_) | |\n"; | |
| 39 push @out, " | (__| |_| | _ <| |___\n"; | |
| 40 push @out, " \\___|\\___/|_| \\_\\_____|\n"; | |
| 41 | |
| 42 my $olen=0; | |
| 43 while (<STDIN>) { | |
| 44 my $line = $_; | |
| 45 | |
| 46 # this should be removed: | |
| 47 $line =~ s/(.|_)//g; | |
| 48 | |
| 49 # remove trailing CR from line. msysgit checks out files as line+CRLF | |
| 50 $line =~ s/\r$//; | |
| 51 | |
| 52 if($line =~ /^([ \t]*\n|curl)/i) { | |
| 53 # cut off headers and empty lines | |
| 54 $wline++; # count number of cut off lines | |
| 55 next; | |
| 56 } | |
| 57 | |
| 58 my $text = $line; | |
| 59 $text =~ s/^\s+//g; # cut off preceding... | |
| 60 $text =~ s/\s+$//g; # and trailing whitespaces | |
| 61 | |
| 62 $tlen = length($text); | |
| 63 | |
| 64 if($wline && ($olen == $tlen)) { | |
| 65 # if the previous line with contents was exactly as long as | |
| 66 # this line, then we ignore the newlines! | |
| 67 | |
| 68 # We do this magic because a header may abort a paragraph at | |
| 69 # any line, but we don't want that to be noticed in the output | |
| 70 # here | |
| 71 $wline=0; | |
| 72 } | |
| 73 $olen = $tlen; | |
| 74 | |
| 75 if($wline) { | |
| 76 # we only make one empty line max | |
| 77 $wline = 0; | |
| 78 push @out, "\n"; | |
| 79 } | |
| 80 push @out, $line; | |
| 81 } | |
| 82 push @out, "\n"; # just an extra newline | |
| 83 | |
| 84 print <<HEAD | |
| 85 /* | |
| 86 * NEVER EVER edit this manually, fix the mkhelp.pl script instead! | |
| 87 */ | |
| 88 #ifdef USE_MANUAL | |
| 89 #include "tool_hugehelp.h" | |
| 90 HEAD | |
| 91 ; | |
| 92 if($c) { | |
| 93 # If compression requested, check that the Gzip module is available | |
| 94 # or else disable compression | |
| 95 $c = eval | |
| 96 { | |
| 97 require IO::Compress::Gzip; | |
| 98 IO::Compress::Gzip->import(); | |
| 99 1; | |
| 100 }; | |
| 101 print STDERR "Warning: compression requested but Gzip is not available\n" if (!$c) | |
| 102 } | |
| 103 | |
| 104 if($c) | |
| 105 { | |
| 106 my $content = join("", @out); | |
| 107 my $gzippedContent; | |
| 108 IO::Compress::Gzip::gzip( | |
| 109 \$content, \$gzippedContent, Level => 9, TextFlag => 1, Time=>0) or die "gzip failed:"; | |
| 110 $gzip = length($content); | |
| 111 $gzipped = length($gzippedContent); | |
| 112 | |
| 113 print <<HEAD | |
| 114 #include <zlib.h> | |
| 115 #include "memdebug.h" /* keep this as LAST include */ | |
| 116 static const unsigned char hugehelpgz[] = { | |
| 117 /* This mumbo-jumbo is the huge help text compressed with gzip. | |
| 118 Thanks to this operation, the size of this data shrank from $gzip | |
| 119 to $gzipped bytes. You can disable the use of compressed help | |
| 120 texts by NOT passing -c to the mkhelp.pl tool. */ | |
| 121 HEAD | |
| 122 ; | |
| 123 | |
| 124 my $c=0; | |
| 125 print " "; | |
| 126 for(split(//, $gzippedContent)) { | |
| 127 my $num=ord($_); | |
| 128 printf(" 0x%02x,", 0+$num); | |
| 129 if(!(++$c % 12)) { | |
| 130 print "\n "; | |
| 131 } | |
| 132 } | |
| 133 print "\n};\n"; | |
| 134 | |
| 135 print <<EOF | |
| 136 #define BUF_SIZE 0x10000 | |
| 137 static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size) | |
| 138 { | |
| 139 (void) opaque; | |
| 140 /* not a typo, keep it calloc() */ | |
| 141 return (voidpf) calloc(items, size); | |
| 142 } | |
| 143 static void zfree_func(voidpf opaque, voidpf ptr) | |
| 144 { | |
| 145 (void) opaque; | |
| 146 free(ptr); | |
| 147 } | |
| 148 /* Decompress and send to stdout a gzip-compressed buffer */ | |
| 149 void hugehelp(void) | |
| 150 { | |
| 151 unsigned char* buf; | |
| 152 int status,headerlen; | |
| 153 z_stream z; | |
| 154 | |
| 155 /* Make sure no gzip options are set */ | |
| 156 if (hugehelpgz[3] & 0xfe) | |
| 157 return; | |
| 158 | |
| 159 headerlen = 10; | |
| 160 memset(&z, 0, sizeof(z_stream)); | |
| 161 z.zalloc = (alloc_func)zalloc_func; | |
| 162 z.zfree = (free_func)zfree_func; | |
| 163 z.avail_in = (unsigned int)(sizeof(hugehelpgz) - headerlen); | |
| 164 z.next_in = (unsigned char *)hugehelpgz + headerlen; | |
| 165 | |
| 166 if (inflateInit2(&z, -MAX_WBITS) != Z_OK) | |
| 167 return; | |
| 168 | |
| 169 buf = malloc(BUF_SIZE); | |
| 170 if (buf) { | |
| 171 while(1) { | |
| 172 z.avail_out = BUF_SIZE; | |
| 173 z.next_out = buf; | |
| 174 status = inflate(&z, Z_SYNC_FLUSH); | |
| 175 if (status == Z_OK || status == Z_STREAM_END) { | |
| 176 fwrite(buf, BUF_SIZE - z.avail_out, 1, stdout); | |
| 177 if (status == Z_STREAM_END) | |
| 178 break; | |
| 179 } | |
| 180 else | |
| 181 break; /* Error */ | |
| 182 } | |
| 183 free(buf); | |
| 184 } | |
| 185 inflateEnd(&z); | |
| 186 } | |
| 187 EOF | |
| 188 ; | |
| 189 foot(); | |
| 190 exit; | |
| 191 } | |
| 192 else { | |
| 193 print <<HEAD | |
| 194 void hugehelp(void) | |
| 195 { | |
| 196 fputs( | |
| 197 HEAD | |
| 198 ; | |
| 199 } | |
| 200 | |
| 201 $outsize=0; | |
| 202 for(@out) { | |
| 203 chop; | |
| 204 | |
| 205 $new = $_; | |
| 206 | |
| 207 $outsize += length($new)+1; # one for the newline | |
| 208 | |
| 209 $new =~ s/\\/\\\\/g; | |
| 210 $new =~ s/\"/\\\"/g; | |
| 211 | |
| 212 # gcc 2.96 claims ISO C89 only is required to support 509 letter strings | |
| 213 if($outsize > 500) { | |
| 214 # terminate and make another fputs() call here | |
| 215 print ", stdout);\n fputs(\n"; | |
| 216 $outsize=length($new)+1; | |
| 217 } | |
| 218 printf("\"%s\\n\"\n", $new); | |
| 219 | |
| 220 } | |
| 221 | |
| 222 print ", stdout) ;\n}\n"; | |
| 223 | |
| 224 foot(); | |
| 225 | |
| 226 sub foot { | |
| 227 print <<FOOT | |
| 228 #else /* !USE_MANUAL */ | |
| 229 /* built-in manual is disabled, blank function */ | |
| 230 #include "tool_hugehelp.h" | |
| 231 void hugehelp(void) {} | |
| 232 #endif /* USE_MANUAL */ | |
| 233 FOOT | |
| 234 ; | |
| 235 } |
