From ec8d503cc6eaddfc2d18ee68d3ff8c558b0570ab Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Mon, 14 May 2007 22:18:29 +0000 Subject: better empty string handling without throwing a exception --- src/jake2/util/Lib.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java index 269f039..37ab5c8 100644 --- a/src/jake2/util/Lib.java +++ b/src/jake2/util/Lib.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.12.2003 by RST. -// $Id: Lib.java,v 1.18 2005-12-18 22:10:12 cawe Exp $ +// $Id: Lib.java,v 1.19 2007-05-14 22:18:29 cawe Exp $ package jake2.util; @@ -75,15 +75,13 @@ public class Lib { /** Like in libc. */ public static float atof(String in) { - float res = 0; - + if (in == null || in.length() == 0) + return 0; try { - res = Float.parseFloat(in); - } - catch (Exception e) { + return Float.parseFloat(in); + } catch (Exception e) { + return 0; } - - return res; } /** Like in quake2. */ -- cgit v1.2.3