@@ -3750,6 +3750,34 @@ public char[] toCharArray() {
3750
3750
return result ;
3751
3751
}
3752
3752
3753
+ /**
3754
+ * Helper function for the {@code format} function.
3755
+ * Serialize potential String.format argument to a String.
3756
+ * The returned String is never null.
3757
+ */
3758
+ static String formatArgument (Object obj )
3759
+ {
3760
+ if (obj == null )
3761
+ return "" ;
3762
+ if (obj instanceof String )
3763
+ return (String )obj ;
3764
+ if (obj instanceof Integer )
3765
+ return Integer .toHexString ((Integer )obj );
3766
+ if (obj instanceof Character )
3767
+ return String .valueOf (((Character ) obj ).charValue ());
3768
+ if (obj instanceof Byte )
3769
+ return Integer .toHexString (((Byte ) obj ).intValue ());
3770
+ if (obj instanceof Long )
3771
+ return Long .toHexString ((Long ) obj );
3772
+ if (obj instanceof Boolean )
3773
+ return ((Boolean ) obj ) ? "true" : "false" ;
3774
+ if (obj instanceof Float )
3775
+ return Integer .toHexString ((int )((Float ) obj ).floatValue ());
3776
+ if (obj instanceof Double )
3777
+ return Long .toHexString ((long )((Float ) obj ).floatValue ());
3778
+ return "" ;
3779
+ }
3780
+
3753
3781
/**
3754
3782
* Returns a formatted string using the specified format string and
3755
3783
* arguments.
@@ -3812,9 +3840,20 @@ public char[] toCharArray() {
3812
3840
* @diffblue.untested
3813
3841
*/
3814
3842
public static String format (String format , Object ... args ) {
3815
- // DIFFBLUE MODEL LIBRARY This is treated internally in CBMC
3816
- return CProver .nondetWithoutNullForNotModelled ();
3843
+ // DIFFBLUE MODEL LIBRARY
3817
3844
// return new Formatter().format(format, args).toString();
3845
+ String arg1 = args .length > 0 ? formatArgument (args [0 ]) : "" ;
3846
+ String arg2 = args .length > 1 ? formatArgument (args [1 ]) : "" ;
3847
+ String arg3 = args .length > 2 ? formatArgument (args [2 ]) : "" ;
3848
+ String arg4 = args .length > 3 ? formatArgument (args [3 ]) : "" ;
3849
+ String arg5 = args .length > 4 ? formatArgument (args [4 ]) : "" ;
3850
+ String arg6 = args .length > 5 ? formatArgument (args [5 ]) : "" ;
3851
+ String arg7 = args .length > 6 ? formatArgument (args [6 ]) : "" ;
3852
+ String arg8 = args .length > 7 ? formatArgument (args [7 ]) : "" ;
3853
+ String arg9 = args .length > 8 ? formatArgument (args [8 ]) : "" ;
3854
+ String arg10 = args .length > 9 ? formatArgument (args [9 ]) : "" ;
3855
+ return CProverString .format (format , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ,
3856
+ arg7 , arg8 , arg9 , arg10 );
3818
3857
}
3819
3858
3820
3859
/**
0 commit comments