|
From: <sv...@va...> - 2005-09-14 20:07:31
|
Author: njn
Date: 2005-09-14 21:07:27 +0100 (Wed, 14 Sep 2005)
New Revision: 4659
Log:
Merged in part of r4527 from the trunk:
Change slightly the way integers are printed by printf() and friends.
Previously, %d printed a 32-bit int. %ld and %lld printed 64-bit ints.
So if you wanted to print a word-sized int (eg. a SizeT variable), you
had to cast it to a Long and then print with %lld in order to work on
both 32-bit and 64-bit platforms.
I changed things so that %d prints a 32-bit int, %ld prints a word-sized
int, and %lld prints a 64-bit int. There are two advantages to this:
- it now matches the way the normal glibc printf() works;
- you can print word-sized ints without casting.
I also made the corresponding change for %u/lu/llu and %x/lx/llx.
Modified:
branches/ASPACEM/coregrind/m_debuglog.c
Modified: branches/ASPACEM/coregrind/m_debuglog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_debuglog.c 2005-09-14 19:38:15 UTC (rev =
4658)
+++ branches/ASPACEM/coregrind/m_debuglog.c 2005-09-14 20:07:27 UTC (rev =
4659)
@@ -384,6 +384,7 @@
Int i;
Int flags;
Int width;
+ Int n_ls;
Bool is_long;
=20
/* We assume that vargs has already been initialised by the=20
@@ -408,7 +409,7 @@
continue;
}
flags =3D 0;
- is_long =3D False;
+ n_ls =3D 0;
width =3D 0; /* length of the field. */
if (format[i] =3D=3D '(') {
flags |=3D VG_MSG_PAREN;
@@ -436,9 +437,16 @@
}
while (format[i] =3D=3D 'l') {
i++;
- is_long =3D True;
+ n_ls++;
}
=20
+ // %d means print a 32-bit integer.
+ // %ld means print a word-size integer.
+ // %lld means print a 64-bit integer.
+ if (0 =3D=3D n_ls) { is_long =3D False; }
+ else if (1 =3D=3D n_ls) { is_long =3D ( sizeof(void*) =3D=3D sizeo=
f(Long) ); }
+ else { is_long =3D True; }
+
switch (format[i]) {
case 'd': /* %d */
flags |=3D VG_MSG_SIGNED;
|