This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ca2f05  GROOVY-9014: printf does not respect "out" property (closes 
#889)
8ca2f05 is described below

commit 8ca2f0584b60f43f64c7c36a4fa6ebb9a4cbc355
Author: Paul King <pa...@asert.com.au>
AuthorDate: Wed Mar 6 11:10:20 2019 +1000

    GROOVY-9014: printf does not respect "out" property (closes #889)
---
 .../groovy/runtime/DefaultGroovyMethods.java       | 43 +++++++++++++++++++---
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 
b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 6368600..d27f322 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -839,11 +839,11 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     }
 
     /**
-     * Printf to a console.
+     * Printf to the standard output stream.
      *
      * @param self   any Object
      * @param format a format string
-     * @param values values referenced by the format specifiers in the format 
string.
+     * @param values values referenced by the format specifiers in the format 
string
      * @since 1.0
      */
     public static void printf(Object self, String format, Object[] values) {
@@ -854,11 +854,45 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     }
 
     /**
+     * Printf 0 or more values to the standard output stream using a format 
string.
+     * This method delegates to the owner to execute the method.
+     *
+     * @param self   a generated closure
+     * @param format a format string
+     * @param values values referenced by the format specifiers in the format 
string
+     * @since 3.0.0
+     */
+    public static void printf(Closure self, String format, Object[] values) {
+        Object owner = getClosureOwner(self);
+        Object[] newValues = new Object[values.length + 1];
+        newValues[0] = format;
+        System.arraycopy(values, 0, newValues, 1, values.length);
+        InvokerHelper.invokeMethod(owner, "printf", newValues);
+    }
+
+    /**
+     * Printf a value to the standard output stream using a format string.
+     * This method delegates to the owner to execute the method.
+     *
+     * @param self   a generated closure
+     * @param format a format string
+     * @param value  value referenced by the format specifier in the format 
string
+     * @since 3.0.0
+     */
+    public static void printf(Closure self, String format, Object value) {
+        Object owner = getClosureOwner(self);
+        Object[] newValues = new Object[2];
+        newValues[0] = format;
+        newValues[1] = value;
+        InvokerHelper.invokeMethod(owner, "printf", newValues);
+    }
+
+    /**
      * Sprintf to a string.
      *
      * @param self   any Object
      * @param format a format string
-     * @param values values referenced by the format specifiers in the format 
string.
+     * @param values values referenced by the format specifiers in the format 
string
      * @return the resulting formatted string
      * @since 1.5.0
      */
@@ -870,8 +904,7 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
     }
 
     /**
-     * Prints a formatted string using the specified format string and
-     * arguments.
+     * Prints a formatted string using the specified format string and 
arguments.
      * <p>
      * Examples:
      * <pre>

Reply via email to