logo       

[PATCH] fix integer truncation in hp2ps output: msg#00004

lang.haskell.glasgow.bugs

Subject: [PATCH] fix integer truncation in hp2ps output


Hi,

The following patch fixes a bug in hp2ps that causes silly numbers like

84,762,122,-646

to appear in the heading. The problem was that 'n' is (can be) a 64-bit
type, and converting to an int before doing the modulo gives rounding
errors.

The fix is courtesy of Ralf Wildenhues (Ralf.Wildenhues@xxxxxx).

N


Index: massif/hp2ps/Utilities.c
===================================================================
RCS file: /home/kde/valgrind/massif/hp2ps/Utilities.c,v
retrieving revision 1.2
diff -u -r1.2 Utilities.c
--- massif/hp2ps/Utilities.c 15 Feb 2004 15:38:08 -0000 1.2
+++ massif/hp2ps/Utilities.c 2 Apr 2004 12:24:45 -0000
@ -77,7 +77,7 @
fprintf(fp, "%d", (int)n);
} else {
CommaPrint(fp, n / ONETHOUSAND);
- fprintf(fp, ",%03d", (int)n % ONETHOUSAND);
+ fprintf(fp, ",%03d", (int)(n % ONETHOUSAND));
}
}


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise