[Scummvm-cvs-logs] SF.net SVN: scummvm:[54010] scummvm/trunk/common/util.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Nov 1 17:04:18 CET 2010


Revision: 54010
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54010&view=rev
Author:   fingolfin
Date:     2010-11-01 16:04:18 +0000 (Mon, 01 Nov 2010)

Log Message:
-----------
COMMON: Switch hexdump() to debugN instead of printf

Rational: hexdump() is used for debug output. An even better alternative
might be to change it to return a string, instead of printing anything.
This way, it could be used inside e.g. GUI debug consoles.
This is left as an exercise to the interested developer :).

Modified Paths:
--------------
    scummvm/trunk/common/util.cpp

Modified: scummvm/trunk/common/util.cpp
===================================================================
--- scummvm/trunk/common/util.cpp	2010-11-01 16:04:04 UTC (rev 54009)
+++ scummvm/trunk/common/util.cpp	2010-11-01 16:04:18 UTC (rev 54010)
@@ -38,20 +38,20 @@
 	byte c;
 	int offset = startOffset;
 	while (len >= bytesPerLine) {
-		printf("%06x: ", offset);
+		debugN("%06x: ", offset);
 		for (i = 0; i < bytesPerLine; i++) {
-			printf("%02x ", data[i]);
+			debugN("%02x ", data[i]);
 			if (i % 4 == 3)
-				printf(" ");
+				debugN(" ");
 		}
-		printf(" |");
+		debugN(" |");
 		for (i = 0; i < bytesPerLine; i++) {
 			c = data[i];
 			if (c < 32 || c >= 127)
 				c = '.';
-			printf("%c", c);
+			debugN("%c", c);
 		}
-		printf("|\n");
+		debugN("|\n");
 		data += bytesPerLine;
 		len -= bytesPerLine;
 		offset += bytesPerLine;
@@ -60,25 +60,25 @@
 	if (len <= 0)
 		return;
 
-	printf("%06x: ", offset);
+	debugN("%06x: ", offset);
 	for (i = 0; i < bytesPerLine; i++) {
 		if (i < len)
-			printf("%02x ", data[i]);
+			debugN("%02x ", data[i]);
 		else
-			printf("   ");
+			debugN("   ");
 		if (i % 4 == 3)
-			printf(" ");
+			debugN(" ");
 	}
-	printf(" |");
+	debugN(" |");
 	for (i = 0; i < len; i++) {
 		c = data[i];
 		if (c < 32 || c >= 127)
 			c = '.';
-		printf("%c", c);
+		debugN("%c", c);
 	}
 	for (; i < bytesPerLine; i++)
-		printf(" ");
-	printf("|\n");
+		debugN(" ");
+	debugN("|\n");
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list