[Scummvm-git-logs] scummvm master -> 399285b76b1836aec7b4fdf1351eba781a37327a
sev-
noreply at scummvm.org
Tue Jan 3 23:50:55 UTC 2023
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:
a404ddaee6 BASE: Fix potential memory override when parsing long options
6cb1c7df81 BASE: Implement autorun mode with executable name
399285b76b BASE: Added support for autorun file.
Commit: a404ddaee6dfe154e7ab1a2554e3821ea14518ca
https://github.com/scummvm/scummvm/commit/a404ddaee6dfe154e7ab1a2554e3821ea14518ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-01-03T23:46:59+01:00
Commit Message:
BASE: Fix potential memory override when parsing long options
Changed paths:
base/commandLine.cpp
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index bda58ccc6b2..772843abef1 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -458,7 +458,7 @@ static Common::String createTemporaryTarget(const Common::String &engineId, cons
// Use this for options which have an *optional* value
#define DO_OPTION_OPT(shortCmd, longCmd, defaultVal) \
- if (isLongCmd ? (!strcmp(s + 2, longCmd) || !memcmp(s + 2, longCmd"=", sizeof(longCmd"=") - 1)) : (tolower(s[1]) == shortCmd)) { \
+ if (isLongCmd ? (!strcmp(s + 2, longCmd) || !strncmp(s + 2, longCmd"=", sizeof(longCmd"=") - 1)) : (tolower(s[1]) == shortCmd)) { \
s += 2; \
if (isLongCmd) { \
s += sizeof(longCmd) - 1; \
Commit: 6cb1c7df81cfab0eb335123ecd9b83fdcbeda4de
https://github.com/scummvm/scummvm/commit/6cb1c7df81cfab0eb335123ecd9b83fdcbeda4de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-01-04T00:02:02+01:00
Commit Message:
BASE: Implement autorun mode with executable name
Rename scummvm executable into 'scummvm-auto*' and it is equivalent
of 'scummvm -p . --auto-run'. All additional arguments on the command
line are also processed and override the automatic arguments.
Changed paths:
base/main.cpp
diff --git a/base/main.cpp b/base/main.cpp
index eedba6649ae..c59966df986 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -405,8 +405,32 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Parse the command line
Common::StringMap settings;
+ Common::String autoCommand;
+
+ // Check for the autorun name
+ if (argv[0]) {
+ const char *s = strrchr(argv[0], '/');
+
+ if (!s)
+ s = strrchr(argv[0], '\\');
+
+ const char *appName =s ? (s + 1) : argv[0];
+
+ if (!scumm_strnicmp(appName, "scummvm-auto", strlen("scummvm-auto"))) {
+ warning("Running in autodetection mode");
+ // Simulate autodetection
+ const char * const arguments[] = { "scummvm-auto", "-p", ".", "--auto-detect" };
+
+ autoCommand = Base::parseCommandLine(settings, ARRAYSIZE(arguments), arguments);
+ }
+ }
+
command = Base::parseCommandLine(settings, argc, argv);
+ // We allow overriding the automatic command
+ if (command.empty())
+ command = autoCommand;
+
// Load the config file (possibly overridden via command line):
if (settings.contains("config")) {
ConfMan.loadConfigFile(settings["config"]);
Commit: 399285b76b1836aec7b4fdf1351eba781a37327a
https://github.com/scummvm/scummvm/commit/399285b76b1836aec7b4fdf1351eba781a37327a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-01-04T00:46:49+01:00
Commit Message:
BASE: Added support for autorun file.
Place file named 'scummvm=autorun' next to the ScummVM.
If the file is empty, scummvm will run in autodetect mode, basically
as './scummvm -p . --auto-detect'.
If the file is not empty, then command line parameters will be read
from it one per line. Empty lines and lines starting from '#' are ignored.
If the user supplies more parameters at the command line, those
will also be used and will override the parameters from the autorun file.
Changed paths:
base/main.cpp
diff --git a/base/main.cpp b/base/main.cpp
index c59966df986..18fcbacaf17 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -42,6 +42,7 @@
#include "common/debug-channels.h" /* for debug manager */
#include "common/events.h"
#include "gui/EventRecorder.h"
+#include "common/file.h"
#include "common/fs.h"
#ifdef ENABLE_EVENTRECORDER
#include "common/recorderfile.h"
@@ -406,6 +407,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Parse the command line
Common::StringMap settings;
Common::String autoCommand;
+ bool autodetect = false;
// Check for the autorun name
if (argv[0]) {
@@ -417,10 +419,69 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
const char *appName =s ? (s + 1) : argv[0];
if (!scumm_strnicmp(appName, "scummvm-auto", strlen("scummvm-auto"))) {
- warning("Running in autodetection mode");
+ warning("Will run in autodetection mode");
+ autodetect = true;
+ }
+ }
+
+ Common::StringArray autorunArgs;
+
+ // Check for the autorun file
+ if (Common::File::exists("scummvm-autorun")) {
+ // Okay, the file exists. We open it and if it is empty, then run in the autorun mode
+ // If the file is not empty, we read command line arguments from it, one per line
+ warning("Autorun file is detected");
+
+ Common::File autorun;
+ Common::String line;
+ Common::String res;
+
+ autorunArgs.push_back(argv[0]);
+
+ if (autorun.open("scummvm-autorun")) {
+ while (!autorun.eos()) {
+ line = autorun.readLine();
+
+ if (!line.empty() && line[0] != '#') {
+ autorunArgs.push_back(line);
+
+ res += Common::String::format("\"%s\" ", line.c_str());
+ }
+ }
+ }
+
+ if (!res.empty())
+ warning("Autorun command: %s", res.c_str());
+ else
+ warning("Empty autorun file");
+
+ autorun.close();
+
+ autodetect = true;
+ }
+
+ if (autodetect) {
+ if (autorunArgs.size() > 1) {
+ uint argumentsSize = autorunArgs.size();
+ char **arguments = (char **)malloc(argumentsSize * sizeof(char *));
+
+ for (uint i = 0; i < argumentsSize; i++) {
+ arguments[i] = (char *)malloc(autorunArgs[i].size() + 1);
+ Common::strlcpy(arguments[i], autorunArgs[i].c_str(), autorunArgs[i].size() + 1);
+ }
+
+ autoCommand = Base::parseCommandLine(settings, argumentsSize, arguments);
+
+ for (uint i = 0; i < argumentsSize; i++)
+ free(arguments[i]);
+
+ free(arguments);
+ } else {
// Simulate autodetection
const char * const arguments[] = { "scummvm-auto", "-p", ".", "--auto-detect" };
+ warning("Running autodetection");
+
autoCommand = Base::parseCommandLine(settings, ARRAYSIZE(arguments), arguments);
}
}
More information about the Scummvm-git-logs
mailing list