|
From: <sv...@va...> - 2008-06-29 08:53:42
|
Author: bart
Date: 2008-06-29 09:53:47 +0100 (Sun, 29 Jun 2008)
New Revision: 8309
Log:
Re-added support for # format modifier.
Modified:
branches/FORMATCHECK/coregrind/m_debuglog.c
Modified: branches/FORMATCHECK/coregrind/m_debuglog.c
===================================================================
--- branches/FORMATCHECK/coregrind/m_debuglog.c 2008-06-29 08:42:46 UTC (rev 8308)
+++ branches/FORMATCHECK/coregrind/m_debuglog.c 2008-06-29 08:53:47 UTC (rev 8309)
@@ -446,6 +446,7 @@
#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. */
@@ -647,25 +648,34 @@
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 ',':
+ case '\'':
+ /* If ',' follows '%', commas will be inserted. */
+ flags |= VG_MSG_COMMA;
+ break;
+ case '-':
+ /* If '-' follows '%', justify on the left. */
+ 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] == ',' || 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 +721,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)));
|