From 3d260f6e75da2ee2b1dd0b933e9f2552cf66f2d5 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Fri, 2 Jan 2009 15:10:33 +0000 Subject: Fix warnings and formatting svn path=/trunk/netsurf/; revision=5956 --- gtk/gtk_plotters.c | 33 ++++++++++++---------- gtk/gtk_print.c | 83 ++++++++++++++++++++++++++++-------------------------- gtk/gtk_throbber.c | 7 ++++- 3 files changed, 67 insertions(+), 56 deletions(-) (limited to 'gtk') diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c index 016d487b2..2f03cc1bb 100644 --- a/gtk/gtk_plotters.c +++ b/gtk/gtk_plotters.c @@ -27,6 +27,7 @@ */ #include +#include #include #include #include "desktop/plotters.h" @@ -293,26 +294,29 @@ bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height, bool repeat_x, bool repeat_y, struct content *content) { int doneheight = 0, donewidth = 0; - GdkPixbuf *primary; - GdkPixbuf *pretiled; + GdkPixbuf *primary; + GdkPixbuf *pretiled = NULL; if (!(repeat_x || repeat_y)) { /* Not repeating at all, so just pass it on */ return nsgtk_plot_bitmap(x,y,width,height,bitmap,bg,content); } - if (repeat_x && !repeat_y) - pretiled = gtk_bitmap_get_pretile_x(bitmap); - if (repeat_x && repeat_y) - pretiled = gtk_bitmap_get_pretile_xy(bitmap); - if (!repeat_x && repeat_y) - pretiled = gtk_bitmap_get_pretile_y(bitmap); - primary = gtk_bitmap_get_primary(bitmap); - /* use the primary and pretiled widths to scale the w/h provided */ - width *= gdk_pixbuf_get_width(pretiled); - width /= gdk_pixbuf_get_width(primary); - height *= gdk_pixbuf_get_height(pretiled); - height /= gdk_pixbuf_get_height(primary); + if (repeat_x && !repeat_y) + pretiled = gtk_bitmap_get_pretile_x(bitmap); + if (repeat_x && repeat_y) + pretiled = gtk_bitmap_get_pretile_xy(bitmap); + if (!repeat_x && repeat_y) + pretiled = gtk_bitmap_get_pretile_y(bitmap); + + assert(pretiled != NULL); + + primary = gtk_bitmap_get_primary(bitmap); + /* use the primary and pretiled widths to scale the w/h provided */ + width *= gdk_pixbuf_get_width(pretiled); + width /= gdk_pixbuf_get_width(primary); + height *= gdk_pixbuf_get_height(pretiled); + height /= gdk_pixbuf_get_height(primary); if (y > cliprect.y) doneheight = (cliprect.y - height) + ((y - cliprect.y) % height); @@ -334,7 +338,6 @@ bool nsgtk_plot_bitmap_tile(int x, int y, int width, int height, if (!repeat_y) break; } - return true; } diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c index 19ed8e867..1b03f5532 100644 --- a/gtk/gtk_print.c +++ b/gtk/gtk_print.c @@ -28,6 +28,7 @@ #ifdef WITH_PDF_EXPORT #include +#include #include #include #include "desktop/plotters.h" @@ -336,48 +337,50 @@ bool nsgtk_print_plot_bitmap_tile(int x, int y, int width, int height, struct bitmap *bitmap, colour bg, bool repeat_x, bool repeat_y, struct content *content) { - int doneheight = 0, donewidth = 0; - GdkPixbuf *primary; - GdkPixbuf *pretiled; + int doneheight = 0, donewidth = 0; + GdkPixbuf *primary; + GdkPixbuf *pretiled = NULL; - if (!(repeat_x || repeat_y)) { - /* Not repeating at all, so just pass it on */ - return nsgtk_print_plot_bitmap(x,y,width,height,bitmap,bg,content); - } - - if (repeat_x && !repeat_y) - pretiled = gtk_bitmap_get_pretile_x(bitmap); - if (repeat_x && repeat_y) - pretiled = gtk_bitmap_get_pretile_xy(bitmap); - if (!repeat_x && repeat_y) - pretiled = gtk_bitmap_get_pretile_y(bitmap); - primary = gtk_bitmap_get_primary(bitmap); - /* use the primary and pretiled widths to scale the w/h provided */ - width *= gdk_pixbuf_get_width(pretiled); - width /= gdk_pixbuf_get_width(primary); - height *= gdk_pixbuf_get_height(pretiled); - height /= gdk_pixbuf_get_height(primary); - - if (y > cliprect.y) - doneheight = (cliprect.y - height) + ((y - cliprect.y) % height); - else - doneheight = y; - - while (doneheight < (cliprect.y + cliprect.height)) { - if (x > cliprect.x) - donewidth = (cliprect.x - width) + ((x - cliprect.x) % width); - else - donewidth = x; - while (donewidth < (cliprect.x + cliprect.width)) { - nsgtk_print_plot_pixbuf(donewidth, doneheight, - width, height, pretiled, bg); - donewidth += width; - if (!repeat_x) break; - } - doneheight += height; - if (!repeat_y) break; - } + if (!(repeat_x || repeat_y)) { + /* Not repeating at all, so just pass it on */ + return nsgtk_print_plot_bitmap(x,y,width,height,bitmap,bg,content); + } + if (repeat_x && !repeat_y) + pretiled = gtk_bitmap_get_pretile_x(bitmap); + if (repeat_x && repeat_y) + pretiled = gtk_bitmap_get_pretile_xy(bitmap); + if (!repeat_x && repeat_y) + pretiled = gtk_bitmap_get_pretile_y(bitmap); + + assert(pretiled != NULL); + + primary = gtk_bitmap_get_primary(bitmap); + /* use the primary and pretiled widths to scale the w/h provided */ + width *= gdk_pixbuf_get_width(pretiled); + width /= gdk_pixbuf_get_width(primary); + height *= gdk_pixbuf_get_height(pretiled); + height /= gdk_pixbuf_get_height(primary); + + if (y > cliprect.y) + doneheight = (cliprect.y - height) + ((y - cliprect.y) % height); + else + doneheight = y; + + while (doneheight < (cliprect.y + cliprect.height)) { + if (x > cliprect.x) + donewidth = (cliprect.x - width) + ((x - cliprect.x) % width); + else + donewidth = x; + while (donewidth < (cliprect.x + cliprect.width)) { + nsgtk_print_plot_pixbuf(donewidth, doneheight, + width, height, pretiled, bg); + donewidth += width; + if (!repeat_x) break; + } + doneheight += height; + if (!repeat_y) break; + } return true; } diff --git a/gtk/gtk_throbber.c b/gtk/gtk_throbber.c index 86b5f3318..6e46c8523 100644 --- a/gtk/gtk_throbber.c +++ b/gtk/gtk_throbber.c @@ -125,7 +125,12 @@ bool nsgtk_throbber_initialise_from_gif(const char *fn) /* allocate a block of sufficient size, and load the data in. */ data = (unsigned char *)malloc(size); - fread(data, size, 1, fh); + if (fread(data, size, 1, fh) != 1) { + /* interesting; we couldn't read it all in. */ + fclose(fh); + free(data); + return false; + } fclose(fh); /* create our gif animation */ -- cgit v1.2.3