gtranslator r3652 - trunk/src
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3652 - trunk/src
- Date: Mon, 22 Sep 2008 09:41:08 +0000 (UTC)
Author: icq
Date: Mon Sep 22 09:41:08 2008
New Revision: 3652
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3652&view=rev
Log:
2008-08-04 Ignacio Casal Quinteiro <nacho ansalon>
* po.c (po_file_is_empty), (gtranslator_po_parse):
* po.h:
Added check if the file is empty. If it is it returns on
parse with an error.
Modified:
trunk/src/ChangeLog
trunk/src/po.c
trunk/src/po.h
Modified: trunk/src/po.c
==============================================================================
--- trunk/src/po.c (original)
+++ trunk/src/po.c Mon Sep 22 09:41:08 2008
@@ -258,6 +258,24 @@
message_error = g_strdup_printf("%s.\n %s",message_text1, message_text2);
}
+static gboolean
+po_file_is_empty (po_file_t file)
+{
+ const gchar * const * domains = po_file_domains (file);
+
+ for (; *domains != NULL; domains++)
+ {
+ po_message_iterator_t iter = po_message_iterator (file, *domains);
+ if (po_next_message (iter) != NULL)
+ {
+ po_message_iterator_free (iter);
+ return FALSE;
+ }
+ po_message_iterator_free (iter);
+ }
+ return TRUE;
+}
+
/***************************** Public funcs ***********************************/
/**
@@ -333,11 +351,12 @@
&handler);
if(priv->gettext_po_file == NULL)
{
- g_set_error(error,
- GTR_PO_ERROR,
- GTR_PO_ERROR_FILENAME,
- _("Failed opening file '%s': %s"),
- priv->filename, g_strerror(errno));
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILENAME,
+ _("Failed opening file '%s': %s\n%s"),
+ priv->filename, g_strerror(errno),
+ message_error);
g_object_unref(po);
return;
}
@@ -352,6 +371,16 @@
message_error);
}
+ if (po_file_is_empty (priv->gettext_po_file))
+ {
+ g_set_error (error,
+ GTR_PO_ERROR,
+ GTR_PO_ERROR_FILE_EMPTY,
+ _("The file is empty"));
+ g_object_unref(po);
+ return;
+ }
+
/*
* Determine the message domains to track
*/
Modified: trunk/src/po.h
==============================================================================
--- trunk/src/po.h (original)
+++ trunk/src/po.h Mon Sep 22 09:41:08 2008
@@ -71,6 +71,7 @@
GTR_PO_ERROR_GETTEXT,
GTR_PO_ERROR_FILENAME,
GTR_PO_ERROR_RECOVERY,
+ GTR_PO_ERROR_FILE_EMPTY,
GTR_PO_ERROR_OTHER,
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]