From bd47bfcde4be853eea535aba03f8dd540971644d Mon Sep 17 00:00:00 2001 From: nick Date: Wed, 4 Jun 2008 17:41:15 +0000 Subject: [PATCH] Fix xcowsay bugs git-svn-id: http://svn.nickg.me.uk/work/xcowsay@434 a97b1542-0b21-0410-a459-e47997c36f34 --- ChangeLog | 6 ++++++ configure.ac | 2 +- src/display_cow.c | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8fcefb1..8d1444b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-04 Nick Gasson + + * src/display_cow.c (display_cow): Fix bug where cow would appear + off the side of the screen and fix a floating point exception in + rare circumstances. + 2008-05-23 gettextize * Makefile.am (SUBDIRS): Add po. diff --git a/configure.ac b/configure.ac index 6104f55..abcbd38 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([xcowsay], [1.0], +AC_INIT([xcowsay], [1.1], [Nick Gasson ], [xcowsay]) AM_INIT_AUTOMAKE([-Wall]) diff --git a/src/display_cow.c b/src/display_cow.c index 3026465..08b0798 100644 --- a/src/display_cow.c +++ b/src/display_cow.c @@ -364,6 +364,13 @@ void display_cow(bool debug, const char *text) GdkScreen *screen = gdk_screen_get_default(); int area_w = gdk_screen_get_width(screen) - total_width; int area_h = gdk_screen_get_height(screen) - total_height; + + // Fit the cow on the screen as best as we can + // The area can't be be zero or we'd get an FPE + if (area_w < 1) + area_w = 1; + if (area_h < 1) + area_h = 1; move_shape(xcowsay.cow, rand()%area_w, rand()%area_h); show_shape(xcowsay.cow); -- 2.39.2