[Scummvm-git-logs] scummvm master -> 046b6a6328075a4c876d8ee83c5755efff9da7d9

bluegr noreply at scummvm.org
Sun Apr 17 11:35:02 UTC 2022


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
571e11d724 GUI: Add tail md5 option to the md5 and md5mac debugger commands
db049e37be BASE: Improve format of command line md5 command result
046b6a6328 GUI: Improve format of debugger md5 command result


Commit: 571e11d72491fff1d46e9b25be1276dbb77a8cfb
    https://github.com/scummvm/scummvm/commit/571e11d72491fff1d46e9b25be1276dbb77a8cfb
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-04-17T14:34:59+03:00

Commit Message:
GUI: Add tail md5 option to the md5 and md5mac debugger commands

To compute the tail md5, you need to specify a negative length,
which is consistent with how it is done for the command line
option.

Changed paths:
    gui/debugger.cpp


diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 166d529b647..d7d89d3b2be 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -635,8 +635,9 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 	if (argc < 2) {
 		debugPrintf("md5 [-n length] <filename | pattern>\n");
 	} else {
-		uint32 length = 0;
+		int32 length = 0;
 		uint paramOffset = 0;
+		bool tail = false;
 
 		// If the user supplied an -n parameter, set the bytes to read
 		if (!strcmp(argv[1], "-n")) {
@@ -646,6 +647,10 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 				return true;
 			}
 			length = atoi(argv[2]);
+			if (length < 0) {
+				length = -length;
+				tail = true;
+			}
 			paramOffset = 2;
 		}
 
@@ -662,8 +667,10 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 			sort(list.begin(), list.end(), ArchiveMemberLess());
 			for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
 				Common::SeekableReadStream *stream = (*iter)->createReadStream();
+				if (tail && stream->size() > length)
+					stream->seek(-length, SEEK_END);
 				Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-				debugPrintf("%s  %s  %d\n", md5.c_str(), (*iter)->getName().c_str(), (int32)stream->size());
+				debugPrintf("%s  %s  %d%s\n", md5.c_str(), (*iter)->getName().c_str(), (int32)stream->size(), tail ? ", tail" : "");
 				delete stream;
 			}
 		}
@@ -675,8 +682,9 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 	if (argc < 2) {
 		debugPrintf("md5mac [-n length] <base filename>\n");
 	} else {
-		uint32 length = 0;
+		int32 length = 0;
 		uint paramOffset = 0;
+		bool tail = false;
 
 		// If the user supplied an -n parameter, set the bytes to read
 		if (!strcmp(argv[1], "-n")) {
@@ -686,6 +694,10 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 				return true;
 			}
 			length = atoi(argv[2]);
+			if (length < 0) {
+				length = -length;
+				tail = true;
+			}
 			paramOffset = 2;
 		}
 
@@ -707,13 +719,15 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 			} else {
 				// The resource fork is probably the most relevant one.
 				if (macResMan.hasResFork()) {
-					Common::String md5 = macResMan.computeResForkMD5AsString(length);
-					debugPrintf("%s  %s (resource)  %d\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), macResMan.getResForkDataSize());
+					Common::String md5 = macResMan.computeResForkMD5AsString(length, tail);
+					debugPrintf("%s  %s (resource)  %d%s\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), macResMan.getResForkDataSize(), tail ? ", tail" : "");
 				}
 				if (macResMan.hasDataFork()) {
 					Common::SeekableReadStream *stream = macResMan.getDataFork();
+					if (tail && stream->size() > length)
+						stream->seek(-length, SEEK_END);
 					Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-					debugPrintf("%s  %s (data)  %d\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), (int32)stream->size());
+					debugPrintf("%s  %s (data)  %d%s\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), (int32)stream->size(), tail ? ", tail" : "");
 				}
 			}
 			macResMan.close();


Commit: db049e37be9961052d0a7108daac657d20df28e4
    https://github.com/scummvm/scummvm/commit/db049e37be9961052d0a7108daac657d20df28e4
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-04-17T14:34:59+03:00

Commit Message:
BASE: Improve format of command line md5 command result

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index c1fe09b7ec9..a21c1c37163 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -1388,8 +1388,9 @@ static void calcMD5(Common::FSNode &path, int32 length) {
 		}
 
 		Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-		printf("(hash) : %s, (filename) : %s, (bytes) : %d%s\n", md5.c_str(), path.getName().c_str(), length && length <= stream->size() ? (int32)length : (int32)stream->size(), tail ? ", tail" : "");
-
+		if (length != 0 && length < stream->size())
+			md5 += Common::String::format(" (%s %d bytes)", tail ? "last" : "first", length);
+		printf("%s: %s, %llu bytes\n", path.getName().c_str(), md5.c_str(), (unsigned long long)stream->size());
 		delete stream;
 	} else {
 		printf("Usage : --md5 --md5-path=<PATH> [--md5-length=NUM]\n");


Commit: 046b6a6328075a4c876d8ee83c5755efff9da7d9
    https://github.com/scummvm/scummvm/commit/046b6a6328075a4c876d8ee83c5755efff9da7d9
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-04-17T14:34:59+03:00

Commit Message:
GUI: Improve format of debugger md5 command result

Changed paths:
    gui/debugger.cpp


diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index d7d89d3b2be..2c0f612ccfb 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -670,7 +670,9 @@ bool Debugger::cmdMd5(int argc, const char **argv) {
 				if (tail && stream->size() > length)
 					stream->seek(-length, SEEK_END);
 				Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-				debugPrintf("%s  %s  %d%s\n", md5.c_str(), (*iter)->getName().c_str(), (int32)stream->size(), tail ? ", tail" : "");
+				if (length != 0 && length < stream->size())
+					md5 += Common::String::format(" (%s %d bytes)", tail ? "last" : "first", length);
+				debugPrintf("%s: %s, %llu bytes\n", (*iter)->getName().c_str(), md5.c_str(), (unsigned long long)stream->size());
 				delete stream;
 			}
 		}
@@ -720,14 +722,18 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) {
 				// The resource fork is probably the most relevant one.
 				if (macResMan.hasResFork()) {
 					Common::String md5 = macResMan.computeResForkMD5AsString(length, tail);
-					debugPrintf("%s  %s (resource)  %d%s\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), macResMan.getResForkDataSize(), tail ? ", tail" : "");
+					if (length != 0 && length < macResMan.getResForkDataSize())
+						md5 += Common::String::format(" (%s %d bytes)", tail ? "last" : "first", length);
+					debugPrintf("%s (resource): %s, %llu bytes\n", macResMan.getBaseFileName().toString().c_str(), md5.c_str(), (unsigned long long)macResMan.getResForkDataSize());
 				}
 				if (macResMan.hasDataFork()) {
 					Common::SeekableReadStream *stream = macResMan.getDataFork();
 					if (tail && stream->size() > length)
 						stream->seek(-length, SEEK_END);
 					Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-					debugPrintf("%s  %s (data)  %d%s\n", md5.c_str(), macResMan.getBaseFileName().toString().c_str(), (int32)stream->size(), tail ? ", tail" : "");
+					if (length != 0 && length < stream->size())
+						md5 += Common::String::format(" (%s %d bytes)", tail ? "last" : "first", length);
+					debugPrintf("%s (data): %s, %llu bytes\n", macResMan.getBaseFileName().toString().c_str(), md5.c_str(), (unsigned long long)stream->size());
 				}
 			}
 			macResMan.close();




More information about the Scummvm-git-logs mailing list