Author: dirk
Date: 2007-10-04 22:38:47 +0100 (Thu, 04 Oct 2007)
New Revision: 6949

Log:
implement '#' modifier for 'x' and 'X' at least

Modified:
   branches/FORMATCHECK/coregrind/m_debuglog.c


Modified: branches/FORMATCHECK/coregrind/m_debuglog.c
===================================================================
--- branches/FORMATCHECK/coregrind/m_debuglog.c 2007-10-04 21:36:40 UTC (rev 
6948)
+++ branches/FORMATCHECK/coregrind/m_debuglog.c 2007-10-04 21:38:47 UTC (rev 
6949)
@@ -446,8 +446,8 @@
 #define VG_MSG_LJUSTIFY  4 /* Must justify on the left. */
 #define VG_MSG_PAREN     8 /* Parenthesize if present (for %y) */
 #define VG_MSG_COMMA    16 /* Add commas to numbers (for %d, %u) */
+#define VG_MSG_ALTFORMAT 32 /* Convert the value to alternate format */
 
-
 /* Copy a string into the buffer. */
 static 
 UInt myvprintf_str ( void(*send)(HChar,void*),
@@ -647,25 +647,32 @@
       flags = 0;
       n_ls  = 0;
       width = 0; /* length of the field. */
-      if (format[i] == '(') {
-         flags |= VG_MSG_PAREN;
+      while (1) {
+         switch (format[i]) {
+         case '(':
+            flags |= VG_MSG_PAREN;
+            break;
+         case ',':
+            /* If ',' follows '%', commas will be inserted. */
+            flags |= VG_MSG_COMMA;
+            break;
+         case '-':
+            flags |= VG_MSG_LJUSTIFY;
+            break;
+         case '0':
+            /* If '0' follows '%', pads will be inserted. */
+            flags |= VG_MSG_ZJUSTIFY;
+            break;
+         case '#':
+            /* If '#' follows '%', alternative format will be used. */
+            flags |= VG_MSG_ALTFORMAT;
+            break;
+         default:
+            goto parse_fieldwidth;
+         }
          i++;
       }
-      /* If ',' follows '%', commas will be inserted. */
-      if (format[i] == ',') {
-         flags |= VG_MSG_COMMA;
-         i++;
-      }
-      /* If '-' follows '%', justify on the left. */
-      if (format[i] == '-') {
-         flags |= VG_MSG_LJUSTIFY;
-         i++;
-      }
-      /* If '0' follows '%', pads will be inserted. */
-      if (format[i] == '0') {
-         flags |= VG_MSG_ZJUSTIFY;
-         i++;
-      }
+parse_fieldwidth:
       /* Compute the field length. */
       while (format[i] >= '0' && format[i] <= '9') {
          width *= 10;
@@ -711,6 +718,11 @@
          case 'x': /* %x */
          case 'X': /* %X */
             caps = toBool(format[i] == 'X');
+            if (flags & VG_MSG_ALTFORMAT) {
+               ret += 2;
+               send('0',send_arg2);
+               send('x',send_arg2);
+            }
             if (is_long)
                ret += myvprintf_int64(send, send_arg2, flags, 16, width, caps,
                                       (ULong)(va_arg (vargs, ULong)));


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to