[Scummvm-cvs-logs] CVS: scummvm/common util.cpp,1.11,1.12 util.h,1.12,1.13

Max Horn fingolfin at users.sourceforge.net
Fri May 2 14:30:11 CEST 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv19169

Modified Files:
	util.cpp util.h 
Log Message:
make hexdump width variable

Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- util.cpp	2 May 2003 09:36:58 -0000	1.11
+++ util.cpp	2 May 2003 21:29:05 -0000	1.12
@@ -96,24 +96,25 @@
 }
 
 //
-// Print hexdump of the data passed in, 8 bytes a row
+// Print hexdump of the data passed in
 //
-void hexdump(const byte * data, int len) {
+void hexdump(const byte * data, int len, int bytes_per_line) {
+	assert(1 <= bytes_per_line && bytes_per_line <= 32);
 	int i;
 	byte c;
-	while (len >= 8) {
-		for (i = 0; i < 8; i++)
+	while (len >= bytes_per_line) {
+		for (i = 0; i < bytes_per_line; i++)
 			printf("%02x ", data[i]);
 		printf(" |");
-		for (i = 0; i < 8; i++) {
+		for (i = 0; i < bytes_per_line; i++) {
 			c = data[i];
 			if (c < 32 || c >= 127)
 				c = '.';
 			printf("%c", c);
 		}
 		printf("|\n");
-		data += 8;
-		len -= 8;
+		data += bytes_per_line;
+		len -= bytes_per_line;
 	}
 
 	if (len <= 0) 
@@ -121,7 +122,7 @@
 
 	for (i = 0; i < len; i++)
 		printf("%02x ", data[i]);
-	for (; i < 8; i++)
+	for (; i < bytes_per_line; i++)
 		printf("   ");
 	printf(" |");
 	for (i = 0; i < len; i++) {
@@ -130,7 +131,7 @@
 			c = '.';
 		printf("%c", c);
 	}
-	for (; i < 8; i++)
+	for (; i < bytes_per_line; i++)
 		printf(" ");
 	printf("|\n");
 }

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- util.h	6 Mar 2003 21:45:32 -0000	1.12
+++ util.h	2 May 2003 21:29:05 -0000	1.13
@@ -43,9 +43,9 @@
 void ClearBlendCache(byte *palette, int weight);
 
 /*
- * Print hexdump of the data passed in, 8 bytes a row
+ * Print hexdump of the data passed in
  */
-void hexdump(const byte * data, int len);
+void hexdump(const byte * data, int len, int bytes_per_line = 8);
 
 class RandomSource {
 private:





More information about the Scummvm-git-logs mailing list