summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Kendrick <rjek@netsurf-browser.org>2009-01-02 15:10:33 +0000
committerRob Kendrick <rjek@netsurf-browser.org>2009-01-02 15:10:33 +0000
commit3d260f6e75da2ee2b1dd0b933e9f2552cf66f2d5 (patch)
tree7cde4e0961bf1eeea67b2476114bb535784bc2b4
parentcc4ff674389c22f8ec24df5b4930a359af46cf30 (diff)
downloadnetsurf-3d260f6e75da2ee2b1dd0b933e9f2552cf66f2d5.tar.gz
netsurf-3d260f6e75da2ee2b1dd0b933e9f2552cf66f2d5.tar.bz2
Fix warnings and formatting
svn path=/trunk/netsurf/; revision=5956
-rw-r--r--gtk/gtk_plotters.c33
-rw-r--r--gtk/gtk_print.c83
-rw-r--r--gtk/gtk_throbber.c7
-rw-r--r--utils/filename.c2
4 files changed, 68 insertions, 57 deletions
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 <math.h>
+#include <assert.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#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 <math.h>
+#include <assert.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#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 */
diff --git a/utils/filename.c b/utils/filename.c
index f847f77e8..e48983a53 100644
--- a/utils/filename.c
+++ b/utils/filename.c
@@ -173,7 +173,7 @@ bool filename_initialise(void) {
*start = '/';
}
}
- LOG((directory));
+ LOG(("Temporary directory location: %s", directory));
mkdir(directory, S_IRWXU);
free(directory);
return true;