[libgepub] lib: Fix mixed declarations and code
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgepub] lib: Fix mixed declarations and code
- Date: Thu, 22 Jun 2017 06:46:07 +0000 (UTC)
commit c48f8585e89679955c51606b080f4a8fa281f69a
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jun 21 16:43:48 2017 +0200
lib: Fix mixed declarations and code
"ISO C90 forbids mixed declarations and code"
https://bugzilla.gnome.org/show_bug.cgi?id=784050
libgepub/gepub-archive.c | 3 ++-
libgepub/gepub-widget.c | 10 ++++++----
tests/test-gepub.c | 24 ++++++++++++++++--------
3 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/libgepub/gepub-archive.c b/libgepub/gepub-archive.c
index ad246a4..0eb11ac 100644
--- a/libgepub/gepub-archive.c
+++ b/libgepub/gepub-archive.c
@@ -44,9 +44,10 @@ G_DEFINE_TYPE (GepubArchive, gepub_archive, G_TYPE_OBJECT)
static gboolean
gepub_archive_open (GepubArchive *archive)
{
+ int r;
+
archive->archive = archive_read_new ();
archive_read_support_format_zip (archive->archive);
- int r;
r = archive_read_open_filename (archive->archive, archive->path, 10240);
diff --git a/libgepub/gepub-widget.c b/libgepub/gepub-widget.c
index b5d3a85..f161945 100644
--- a/libgepub/gepub-widget.c
+++ b/libgepub/gepub-widget.c
@@ -161,16 +161,18 @@ reload_length_cb (GtkWidget *widget,
{
GepubWidget *gwidget = GEPUB_WIDGET (widget);
WebKitWebView *web_view = WEBKIT_WEB_VIEW (widget);
+ int m, f;
+ float l;
+ char *script;
webkit_web_view_run_javascript (web_view,
"window.innerWidth",
NULL, get_length_finished, (gpointer)widget);
- gint m = GEPUB_WIDGET (widget)->margin;
- gint f = GEPUB_WIDGET (widget)->font_size;
- gfloat l = GEPUB_WIDGET (widget)->line_height;
+ m = GEPUB_WIDGET (widget)->margin;
+ f = GEPUB_WIDGET (widget)->font_size;
+ l = GEPUB_WIDGET (widget)->line_height;
- gchar *script;
script = g_strdup_printf (
"if (!document.querySelector('#gepubwrap'))"
"document.body.innerHTML = '<div id=\"gepubwrap\">' + document.body.innerHTML + '</div>';"
diff --git a/tests/test-gepub.c b/tests/test-gepub.c
index 7ba869e..9bef651 100644
--- a/tests/test-gepub.c
+++ b/tests/test-gepub.c
@@ -164,11 +164,13 @@ test_read (const char *path)
guchar *file = NULL;
gsize bufsize;
GBytes *bytes;
+ GepubDoc *doc;
+ GHashTable *ht;
a = gepub_archive_new (path);
- GepubDoc *doc = gepub_doc_new (path);
- GHashTable *ht = (GHashTable*)gepub_doc_get_resources (doc);
+ doc = gepub_doc_new (path);
+ ht = (GHashTable*)gepub_doc_get_resources (doc);
g_hash_table_foreach (ht, (GHFunc)find_xhtml, &file);
bytes = gepub_archive_read_entry (a, file);
@@ -241,13 +243,16 @@ pk (gchar *key, GepubResource *value, gpointer data)
void
test_doc_resources (const char *path)
{
- GepubDoc *doc = gepub_doc_new (path);
- GHashTable *ht = (GHashTable*)gepub_doc_get_resources (doc);
- g_hash_table_foreach (ht, (GHFunc)pk, NULL);
+ GepubDoc *doc;
+ GHashTable *ht;
GBytes *ncx;
const guchar *data;
gsize size;
+ doc = gepub_doc_new (path);
+ ht = (GHashTable*)gepub_doc_get_resources (doc);
+ g_hash_table_foreach (ht, (GHFunc)pk, NULL);
+
ncx = gepub_doc_get_resource_by_id (doc, "ncx");
data = g_bytes_get_data (ncx, &size);
PTEST ("ncx:\n%s\n", data);
@@ -272,8 +277,6 @@ test_doc_spine (const char *path)
int
main (int argc, char **argv)
{
- gtk_init (&argc, &argv);
-
GtkWidget *window;
GtkWidget *vpaned;
GtkWidget *textview;
@@ -303,7 +306,12 @@ main (int argc, char **argv)
GepubDoc *doc;
GtkWidget *textview2;
- GtkWidget *widget = gepub_widget_new ();
+
+ GtkWidget *widget;
+
+ gtk_init (&argc, &argv);
+
+ widget = gepub_widget_new ();
webkit_settings_set_enable_developer_extras (
webkit_web_view_get_settings (WEBKIT_WEB_VIEW (widget)), TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]