Add '-response' command line argument.
Doom has always had the ability to load response files containing extra command line arguments but the command line syntax of '@filename.rsp' is unpleasant to use on modern Unix shells because it breaks tab completion. It's actually more convenient to just have a normal command line argument, so add one.
This commit is contained in:
parent
2531f324e3
commit
5e32affd97
1 changed files with 30 additions and 10 deletions
40
src/m_argv.c
40
src/m_argv.c
|
|
@ -72,21 +72,18 @@ int M_CheckParm(const char *check)
|
|||
|
||||
#define MAXARGVS 100
|
||||
|
||||
static void LoadResponseFile(int argv_index)
|
||||
static void LoadResponseFile(int argv_index, const char *filename)
|
||||
{
|
||||
FILE *handle;
|
||||
int size;
|
||||
char *infile;
|
||||
char *file;
|
||||
char *response_filename;
|
||||
char **newargv;
|
||||
int newargc;
|
||||
int i, k;
|
||||
|
||||
response_filename = myargv[argv_index] + 1;
|
||||
|
||||
// Read the response file into memory
|
||||
handle = fopen(response_filename, "rb");
|
||||
handle = fopen(filename, "rb");
|
||||
|
||||
if (handle == NULL)
|
||||
{
|
||||
|
|
@ -94,7 +91,7 @@ static void LoadResponseFile(int argv_index)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
printf("Found response file %s!\n", response_filename);
|
||||
printf("Found response file %s!\n", filename);
|
||||
|
||||
size = M_FileLength(handle);
|
||||
|
||||
|
|
@ -113,7 +110,7 @@ static void LoadResponseFile(int argv_index)
|
|||
|
||||
if (k < 0)
|
||||
{
|
||||
I_Error("Failed to read full contents of '%s'", response_filename);
|
||||
I_Error("Failed to read full contents of '%s'", filename);
|
||||
}
|
||||
|
||||
i += k;
|
||||
|
|
@ -173,7 +170,7 @@ static void LoadResponseFile(int argv_index)
|
|||
if (k >= size || infile[k] == '\n')
|
||||
{
|
||||
I_Error("Quotes unclosed in response file '%s'",
|
||||
response_filename);
|
||||
filename);
|
||||
}
|
||||
|
||||
// Cut off the string at the closing quote
|
||||
|
|
@ -230,15 +227,38 @@ static void LoadResponseFile(int argv_index)
|
|||
|
||||
void M_FindResponseFile(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
if (myargv[i][0] == '@')
|
||||
{
|
||||
LoadResponseFile(i);
|
||||
LoadResponseFile(i, myargv[i] + 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
//!
|
||||
// @arg filename
|
||||
//
|
||||
// Load extra command line arguments from the given response file.
|
||||
// Arguments read from the file will be inserted into the command
|
||||
// line replacing this argument. A response file can also be loaded
|
||||
// using the abbreviated syntax '@filename.rsp'.
|
||||
//
|
||||
i = M_CheckParmWithArgs("-response", 1);
|
||||
if (i <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// Replace the -response argument so that the next time through
|
||||
// the loop we'll ignore it. Since some parameters stop reading when
|
||||
// an argument beginning with a '-' is encountered, we keep something
|
||||
// that starts with a '-'.
|
||||
myargv[i] = "-_";
|
||||
LoadResponseFile(i + 1, myargv[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the name of the executable used to start the program:
|
||||
|
|
|
|||
Loading…
Reference in a new issue