From: Ken Youens-Clark Date: Thu, 24 Apr 2003 19:40:52 +0000 (+0000) Subject: Fixed bug (illegal div by 0) if "no_columns" wasn't numeric, also fixed X-Git-Tag: v0.02~173 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=550022e517e34500a58896ab7fb952a80b344bd5;p=dbsrgits%2FSQL-Translator.git Fixed bug (illegal div by 0) if "no_columns" wasn't numeric, also fixed return of production if not writing to a file. --- diff --git a/lib/SQL/Translator/Producer/Diagram.pm b/lib/SQL/Translator/Producer/Diagram.pm index a62404a..f96e278 100644 --- a/lib/SQL/Translator/Producer/Diagram.pm +++ b/lib/SQL/Translator/Producer/Diagram.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Diagram; # ------------------------------------------------------------------- -# $Id: Diagram.pm,v 1.1 2003-04-24 16:36:49 kycl4rk Exp $ +# $Id: Diagram.pm,v 1.2 2003-04-24 19:40:52 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark # @@ -26,7 +26,7 @@ use Data::Dumper; use SQL::Translator::Utils qw(debug); use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use constant VALID_FONT_SIZE => { @@ -74,6 +74,7 @@ sub produce { $font_size eq 'medium' ? gdSmallFont : $font_size eq 'large' ? gdLargeFont : gdGiantFont; my $no_tables = scalar keys %$data; + $no_columns = 0 unless $no_columns =~ /^\d+$/; $no_columns ||= sprintf( "%.0f", sqrt( $no_tables ) + .5 ); $no_columns ||= .5; my $no_per_col = sprintf( "%.0f", $no_tables/$no_columns + .5 ); @@ -543,7 +544,7 @@ sub produce { close $fh; } else { - print $gd->$image_type; + return $gd->$image_type; } }