From 0b86fcce886a0e925032ae2764b7a13265bf22a9 Mon Sep 17 00:00:00 2001 From: Thomas Enebo Date: Thu, 22 Dec 2005 03:44:31 +0000 Subject: [PATCH] Allow numbers to be print with %s,%S git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@1847 961051c9-f516-0410-bf72-c9f7e237a7b7 --- src/org/jruby/util/PrintfFormat.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/org/jruby/util/PrintfFormat.java b/src/org/jruby/util/PrintfFormat.java index afce7c81c61..f4640ed003b 100644 --- a/src/org/jruby/util/PrintfFormat.java +++ b/src/org/jruby/util/PrintfFormat.java @@ -17,6 +17,7 @@ * Copyright (C) 2004 Anders Bengtsson * Copyright (C) 2004 Thomas E Enebo * Copyright (C) 2004 Stefan Matthias Aust + * Copyright (C) 2005 Derek Berner * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -574,6 +575,10 @@ String internalsprintf(int s) throws IllegalArgumentException { case 'C' : s2 = printCFormat((char) s); break; + case 's': + case 'S': + s2 = printSFormat(String.valueOf(s)); + break; default : throw new IllegalArgumentException("Cannot format a int with a format using a " + conversionCharacter + " conversion character."); } @@ -617,7 +622,8 @@ String internalsprintf(long s) throws IllegalArgumentException { s2 = printCFormat((char) s); break; case 's' : - s2 = printSFormat(String.valueOf(s)); + case 'S' : + s2 = printSFormat(String.valueOf(s)); break; case 'b' : s2 = printBFormat(s); @@ -653,6 +659,10 @@ String internalsprintf(double s) throws IllegalArgumentException { case 'g' : s2 = printGFormat(s); break; + case 's': + case 'S': + s2 = printSFormat(String.valueOf(s)); + break; default : throw new IllegalArgumentException("Cannot format a double with a format using a " + conversionCharacter + " conversion character."); }