mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 20:15:03 -05:00
mkhelp: simplified the gzip code
This eliminates the need for an external gzip program, which wasn't working with Busybox's gzip, anyway. It now compresses using perl's IO::Compress::Gzip
This commit is contained in:
parent
7d62502d6c
commit
9f3bc40f7f
@ -102,39 +102,6 @@ while(<READ>) {
|
|||||||
}
|
}
|
||||||
close(READ);
|
close(READ);
|
||||||
|
|
||||||
# if compressed
|
|
||||||
if($c) {
|
|
||||||
my @test = `gzip --version 2>&1`;
|
|
||||||
if($test[0] =~ /gzip/) {
|
|
||||||
open(GZIP, ">dumpit") ||
|
|
||||||
die "can't create the dumpit file, try without -c";
|
|
||||||
binmode GZIP;
|
|
||||||
for(@out) {
|
|
||||||
print GZIP $_;
|
|
||||||
$gzip += length($_);
|
|
||||||
}
|
|
||||||
close(GZIP);
|
|
||||||
|
|
||||||
system("gzip --best --no-name dumpit");
|
|
||||||
|
|
||||||
open(GZIP, "<dumpit.gz") ||
|
|
||||||
die "can't read the dumpit.gz file, try without -c";
|
|
||||||
binmode GZIP;
|
|
||||||
while(<GZIP>) {
|
|
||||||
push @gzip, $_;
|
|
||||||
$gzipped += length($_);
|
|
||||||
}
|
|
||||||
close(GZIP);
|
|
||||||
|
|
||||||
unlink("dumpit.gz");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# no gzip, no compression!
|
|
||||||
undef $c;
|
|
||||||
print STDERR "MEEEP: Couldn't find gzip, disable compression\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$now = localtime;
|
$now = localtime;
|
||||||
print <<HEAD
|
print <<HEAD
|
||||||
/*
|
/*
|
||||||
@ -146,27 +113,33 @@ print <<HEAD
|
|||||||
HEAD
|
HEAD
|
||||||
;
|
;
|
||||||
if($c) {
|
if($c) {
|
||||||
|
# if compressed
|
||||||
|
use IO::Compress::Gzip;
|
||||||
|
my $content = join("", @out);
|
||||||
|
my $gzippedContent;
|
||||||
|
IO::Compress::Gzip::gzip(
|
||||||
|
\$content, \$gzippedContent, Level => 9, TextFlag => 1) or die "gzip failed:";
|
||||||
|
$gzip = length($content);
|
||||||
|
$gzipped = length($gzippedContent);
|
||||||
|
|
||||||
print <<HEAD
|
print <<HEAD
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "memdebug.h" /* keep this as LAST include */
|
#include "memdebug.h" /* keep this as LAST include */
|
||||||
static const unsigned char hugehelpgz[] = {
|
static const unsigned char hugehelpgz[] = {
|
||||||
/* This mumbo-jumbo is the huge help text compressed with gzip.
|
/* This mumbo-jumbo is the huge help text compressed with gzip.
|
||||||
Thanks to this operation, the size of this data shrunk from $gzip
|
Thanks to this operation, the size of this data shrank from $gzip
|
||||||
to $gzipped bytes. You can disable the use of compressed help
|
to $gzipped bytes. You can disable the use of compressed help
|
||||||
texts by NOT passing -c to the mkhelp.pl tool. */
|
texts by NOT passing -c to the mkhelp.pl tool. */
|
||||||
HEAD
|
HEAD
|
||||||
;
|
;
|
||||||
|
|
||||||
my $c=0;
|
my $c=0;
|
||||||
print " ";
|
print " ";
|
||||||
for(@gzip) {
|
for(split(//, $gzippedContent)) {
|
||||||
my @all=split(//, $_);
|
my $num=ord($_);
|
||||||
for(@all) {
|
printf(" 0x%02x,", 0+$num);
|
||||||
my $num=ord($_);
|
if(!(++$c % 12)) {
|
||||||
printf(" 0x%02x,", 0+$num);
|
print "\n ";
|
||||||
if(++$c>11) {
|
|
||||||
print "\n ";
|
|
||||||
$c=0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "\n};\n";
|
print "\n};\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user