diff options
author | Carsten Weisse <[email protected]> | 2007-05-14 22:18:29 +0000 |
---|---|---|
committer | Carsten Weisse <[email protected]> | 2007-05-14 22:18:29 +0000 |
commit | ec8d503cc6eaddfc2d18ee68d3ff8c558b0570ab (patch) | |
tree | c8853ffad2ba5cd4e5d1647fd10306b332f763ae /src/jake2/util/Lib.java | |
parent | 2604e81ac41dc1c13e7ddba81bc2823b6b9b3bb2 (diff) |
better empty string handling without throwing a exception
Diffstat (limited to 'src/jake2/util/Lib.java')
-rw-r--r-- | src/jake2/util/Lib.java | 14 |
1 files changed, 6 insertions, 8 deletions
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. */ |