From 5ae6545bfb26cc43af8e66284b505d819b4804df Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 22 Aug 2006 22:07:03 +0000 Subject: [PATCH] Improve the hexa displayer by separating raw and hex strings, and implement a downside mode, where data is displayed from right to left (handy to display pointers on little endian archs) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2724 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/gras/gras.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gras/gras.c b/src/gras/gras.c index 65e2ebb09a..b4a33a3e07 100644 --- a/src/gras/gras.c +++ b/src/gras/gras.c @@ -91,7 +91,7 @@ void gras_exit(void) { xbt_exit(); } -const char *hexa_str(unsigned char *data, int size) { +const char *hexa_str(unsigned char *data, int size, int downside) { static char*buff=NULL; static int buffsize=0; int i,pos=0; @@ -102,17 +102,35 @@ const char *hexa_str(unsigned char *data, int size) { buffsize=5*(size+1); buff=xbt_malloc(buffsize); } - for (i=0;i126) - sprintf(buff+pos,".(%02x)",data[i]); + sprintf(buff+pos,"."); else - sprintf(buff+pos,"%c(%02x)",data[i],data[i]); + sprintf(buff+pos,"%c",data[i]); + while (buff[++pos]); + } + sprintf(buff+pos,"("); + while (buff[++pos]); + for (i=begin; 0<=i && i