From c6a78767204e30c0cb9b6e736b46f48d25f16685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 13 Jun 2007 16:23:36 +0200 Subject: Rewrite the xine_hexdump function not to use _only_ fprintf even when it's overkill (constant strings or single characters). --- src/xine-utils/utils.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index 858a754ae..f79d2ebce 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -475,38 +475,39 @@ void xine_usec_sleep(unsigned usec) { /* print a hexdump of length bytes from the data given in buf */ void xine_hexdump (const void *buf_gen, int length) { - int i,j; - unsigned char c; + static const char separator[70] = "---------------------------------------------------------------------"; + const uint8_t *const buf = (const uint8_t*)buf; + int j = 0; /* printf ("Hexdump: %i Bytes\n", length);*/ - for(j=0; j<69; j++) - printf ("-"); - printf ("\n"); + puts(separator); - j=0; while(j=32) && (c<127)) - printf ("%c", c); - else - printf ("."); + c = '.'; + + fputc(c, stdout); } j=i; - printf("\n"); + + fputc('\n', stdout); } - for(j=0; j<69; j++) - printf("-"); - printf("\n"); + puts(separator); } -- cgit v1.2.3