libgweather r521 - in trunk: . data libgweather



Author: vuntz
Date: Tue Nov 25 21:18:38 2008
New Revision: 521
URL: http://svn.gnome.org/viewvc/libgweather?rev=521&view=rev

Log:
2008-11-25  Vincent Untz  <vuntz gnome org>

	* configure.in: add --enable-locations-compression to compress the
	Locations.xml files.
	* data/Makefile.am: compress data files if requested.
	* libgweather/parser.c: (gweather_parser_new): look for .gz files too.
	Thanks to libxml2, we don't have to do anything to support compressed
	files.
	Fix bug #552868.


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/data/   (props changed)
   trunk/data/Makefile.am
   trunk/libgweather/parser.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Nov 25 21:18:38 2008
@@ -41,6 +41,18 @@
         [enable_big_xml=no])
 AM_CONDITIONAL(USE_ONE_BIG_XML, test "x$enable_big_xml" = "xyes")
 
+AC_ARG_ENABLE(locations-compression,
+        [AC_HELP_STRING([--enable-locations-compression],
+                        [Compress Locations.xml files])],
+        [enable_locations_compression=yes],
+        [enable_locations_compression=no])
+if test "x$enable_locations_compression" = "xyes"; then
+    COMPRESS_EXT=.gz
+else
+    COMPRESS_EXT=
+fi
+AC_SUBST(COMPRESS_EXT)
+
 GNOME_COMPILE_WARNINGS
 
 dnl ***************************************************************************
@@ -234,4 +246,5 @@
 	Source code location:		${srcdir}
 	Compiler:			${CC}
 	Locations.xml translations:	${LOCATIONS_XML_TRANSLATIONS}
+	Locations.xml compression:	${enable_locations_compression}
 " >&2

Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am	(original)
+++ trunk/data/Makefile.am	Tue Nov 25 21:18:38 2008
@@ -8,10 +8,13 @@
 
 LOCATIONS_STAMP = 
 
-libgweatherlocations_DATA = $(libgweatherlocations_in_files:.xml.in=.xml)
+libgweatherlocations_DATA = $(libgweatherlocations_in_files:.xml.in=.xml$(COMPRESS_EXT))
 
-%.xml: %.xml.in $(wildcard $(top_srcdir)/po-locations/*.po)
-	LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po-locations/.intltool-merge-cache $(top_srcdir)/po-locations $< $@
+%.xml$(COMPRESS_EXT): %.xml.in $(wildcard $(top_srcdir)/po-locations/*.po)
+	LC_ALL=C $(INTLTOOL_MERGE) -x -u -c $(top_builddir)/po-locations/.intltool-merge-cache $(top_srcdir)/po-locations $< `echo $@ | sed "s/.xml$(COMPRESS_EXT)/.xml/"`
+	if test "x$(COMPRESS_EXT)" = "x.gz"; then				\
+		gzip --force `echo $@ | sed "s/.xml$(COMPRESS_EXT)/.xml/"`;	\
+	fi
 
 else # USE_ONE_BIG_XML
 
@@ -22,24 +25,30 @@
 # Helper variable
 libgweatherlocations_data = $(libgweatherlocations_in_files:.xml.in=.xml)
 
-libgweatherlocations_DATA = $(shell echo $(PO_LOCATIONS) | sed "s|$(top_srcdir)/po-locations/|Locations.|g;s|\.po|.xml|g") $(libgweatherlocations_data)
+libgweatherlocations_DATA = $(shell echo $(PO_LOCATIONS) | sed "s|$(top_srcdir)/po-locations/|Locations.|g;s|\.po|.xml$(COMPRESS_EXT)|g") $(libgweatherlocations_data)$(COMPRESS_EXT)
 
 # We need this step so that we merge all the make Locations.xy.xml destinations
 # into one unique destination. This makes -j2 work. (Else, we end up with
 # multiple and conflicting calls to intltool-merge)
 $(libgweatherlocations_DATA): $(LOCATIONS_STAMP)
 
-$(LOCATIONS_STAMP): $(libgweatherlocations_in_files) $(PO_LOCATIONS)
+$(LOCATIONS_STAMP): $(libgweatherlocations_in_files) $(PO_LOCATIONS) Makefile
 	LC_ALL=C $(INTLTOOL_MERGE) --multiple-output --xml-style --utf8 --cache=$(top_builddir)/po-locations/.intltool-merge-cache $(top_srcdir)/po-locations $< $(libgweatherlocations_data)
 	for pofile in $(PO_LOCATIONS); do \
 		locale=`echo $$pofile | sed "s;$(top_srcdir)/po-locations/\(.*\)\.po;\1;"`;	\
 		xmllint --noblanks -o Locations.$$locale.xml $$locale/$(libgweatherlocations_data); \
 		rm -f $$locale/$(libgweatherlocations_data);		\
 		test -d $$locale && rmdir $$locale;			\
+		if test "x$(COMPRESS_EXT)" = "x.gz"; then		\
+			gzip --force Locations.$$locale.xml;		\
+		fi;							\
 	done
 	xmllint --noblanks -o Locations.xml C/$(libgweatherlocations_data)
 	rm -f C/$(libgweatherlocations_data)
 	test -d C && rmdir C
+	if test "x$(COMPRESS_EXT)" = "x.gz"; then			\
+		gzip --force Locations.xml;				\
+	fi
 	touch $@
 
 endif # USE_ONE_BIG_XML

Modified: trunk/libgweather/parser.c
==============================================================================
--- trunk/libgweather/parser.c	(original)
+++ trunk/libgweather/parser.c	Tue Nov 25 21:18:38 2008
@@ -155,6 +155,7 @@
 gweather_parser_new (gboolean use_regions)
 {
     GWeatherParser *parser;
+    int zlib_support;
     int i, keep_going;
     char *filename;
     char *tagname, *format;
@@ -165,6 +166,8 @@
     parser->use_regions = use_regions;
     parser->locales = g_get_language_names ();
 
+    zlib_support = xmlHasFeature (XML_WITH_ZLIB);
+
     /* First try to load a locale-specific XML. It's much faster. */
     filename = NULL;
     for (i = 0; parser->locales[i] != NULL; i++) {
@@ -177,6 +180,19 @@
 
 	g_free (filename);
 	filename = NULL;
+
+        if (!zlib_support)
+            continue;
+
+	filename = g_strdup_printf ("%s/Locations.%s.xml.gz",
+				    GWEATHER_XML_LOCATION_DIR,
+				    parser->locales[i]);
+
+	if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+	    break;
+
+	g_free (filename);
+	filename = NULL;
     }
 
     /* Fall back on the file containing either all translations, or only
@@ -185,6 +201,11 @@
     if (!filename)
 	filename = g_strdup (GWEATHER_XML_LOCATION_DIR "/Locations.xml");
 
+    if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR) && zlib_support) {
+        g_free (filename);
+	filename = g_strdup (GWEATHER_XML_LOCATION_DIR "/Locations.xml.gz");
+    }
+
     /* Open the xml file containing the different locations */
     parser->xml = xmlNewTextReaderFilename (filename);
     g_free (filename);



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