]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix incorrect computation of miss rates due to Int/Long mixups <sigh>.
authorNicholas Nethercote <njn@valgrind.org>
Sun, 25 Sep 2005 19:11:45 +0000 (19:11 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 25 Sep 2005 19:11:45 +0000 (19:11 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4769

coregrind/m_libcprint.c
include/pub_tool_libcprint.h

index 9adb6618e1d8c7e26afaf9939a915da33575adb2..5d435e328abd3ead54bc2129529a61ac70f01deb 100644 (file)
@@ -156,13 +156,19 @@ UInt VG_(sprintf) ( Char* buf, const HChar *format, ... )
    ------------------------------------------------------------------ */
 
 // Percentify n/m with d decimal places.  Includes the '%' symbol at the end.
-void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[]) 
+// Right justifies in 'buf'.
+void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]) 
 {
    Int i, len, space;
    ULong p1;
+   Char fmt[32];
 
    if (m == 0) {
-      VG_(sprintf)(buf, "--%%");
+      // Have to generate the format string in order to be flexible about
+      // the width of the field.
+      VG_(sprintf)(fmt, "%%-%lds", n_buf);
+      // fmt is now "%<n_buf>s" where <d> is 1,2,3...
+      VG_(sprintf)(buf, fmt, "--%");
       return;
    }
    
@@ -173,7 +179,6 @@ void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[])
    } else {
       ULong p2;
       UInt  ex;
-      Char fmt[32];
       switch (d) {
       case 1: ex = 10;    break;
       case 2: ex = 100;   break;
index 8922a6a05e55d6f378b478a92ea2e2dab4fe1016..9a6ce995cd20b6e1303b55db421ac39ec1782b36 100644 (file)
@@ -46,7 +46,8 @@ extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... );
 extern UInt VG_(vsprintf)( Char* buf, const HChar* format, va_list vargs );
 
 // Percentify n/m with d decimal places.  Includes the '%' symbol at the end.
-extern void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[]);
+// Right justifies in 'buf'.
+extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
 
 /* ---------------------------------------------------------------------
    Messages for the user