[gnumeric] embedder: handle compression of ui files.



commit 66416092dfda5efdd1624de07b10f2ebc5f8d836
Author: Morten Welinder <terra gnome org>
Date:   Tue Oct 18 14:20:03 2011 -0400

    embedder: handle compression of ui files.

 tools/ChangeLog |    4 ++++
 tools/embedder  |   21 +++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/tools/ChangeLog b/tools/ChangeLog
index ae39c5e..e40ec57 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,3 +1,7 @@
+2011-10-18  Morten Welinder  <terra gnome org>
+
+	* embedder (embed): Handler compression.
+
 2011-07-31  Morten Welinder <terra gnome org>
 
 	* Release 1.10.17
diff --git a/tools/embedder b/tools/embedder
index 21a7571..e2ae05c 100644
--- a/tools/embedder
+++ b/tools/embedder
@@ -2,6 +2,7 @@
 
 use strict;
 use Getopt::Long;
+use IO::Compress::Gzip qw(gzip $GzipError);
 
 my $myself = $0;
 $myself =~ s|^.*/||;
@@ -25,8 +26,17 @@ foreach (@includes) {
 
 my $fileno = 0;
 my $reg = "";
+my $docompress = 0;
 foreach my $file (@ARGV) {
-    &embed ($file);
+    if ($file eq 'COMPRESS') {
+	$docompress = 1;
+	next;
+    }
+    if ($file eq 'NOCOMPRESS') {
+	$docompress = 0;
+	next;
+    }
+    &embed ($file, $docompress);
 }
 print "void\n";
 print "$regfunc (void)\n";
@@ -35,7 +45,7 @@ print $reg;
 print "}\n";
 
 sub embed {
-    my ($file) = @_;
+    my ($file, $docompress) = @_;
 
     print "/* Embedded file $file */\n";
 
@@ -48,6 +58,13 @@ sub embed {
 	$data = <FIL>;
     }
 
+    if ($docompress) {
+	my $zdata;
+	gzip \$data => \$zdata
+	    or die "gzip failed: $GzipError\n";
+	$data = $zdata;
+    }
+
     my $id = "data$fileno";
     $fileno++;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]