From: sof Date: Tue, 21 Sep 1999 09:46:04 +0000 (+0000) Subject: [project @ 1999-09-21 09:46:04 by sof] X-Git-Tag: Approximately_9120_patches~5750 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ece1981634d7a8723d996f0536cf07414286fc19;p=ghc-hetmet.git [project @ 1999-09-21 09:46:04 by sof] v1.2 of Show Addr instance, pad out to fixed length --- diff --git a/ghc/lib/exts/Addr.lhs b/ghc/lib/exts/Addr.lhs index 5e02bf2..58d45de 100644 --- a/ghc/lib/exts/Addr.lhs +++ b/ghc/lib/exts/Addr.lhs @@ -5,6 +5,8 @@ \section[Addr]{Module @Addr@} \begin{code} +#include "MachDeps.h" + module Addr ( Addr @@ -51,8 +53,12 @@ import Int ( indexInt8OffAddr, indexInt16OffAddr \begin{code} instance Show Addr where - showsPrec p (A# a) = showHex int + showsPrec p (A# a) rs = pad_out (showHex int rs) where + -- want 0s prefixed to pad it out to a fixed length. + pad_out ('0':'x':ls) = + '0':'x':(replicate (2*ADDR_SIZE_IN_BYTES - length ls) '0') ++ ls + int = case word2Integer# (int2Word# (addr2Int# a)) of (# s, d #) -> J# s d