mirror of
https://git.code.sf.net/p/quake/quakeforge-old
synced 2025-02-15 16:30:50 +00:00
qargs.h:
"share the software ..." put in an extern for com_cmdline qargs.c: no longer include the program name (argv[0]) in com_cmdline cmd.c: remove redundant code from Cmd_StuffCmds_f and use com_cmdline in it's place.
This commit is contained in:
parent
3a8f38c217
commit
499c3c20bd
3 changed files with 24 additions and 34 deletions
40
common/cmd.c
40
common/cmd.c
|
@ -29,6 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <qargs.h>
|
||||||
#include <cmd.h>
|
#include <cmd.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <cvar.h>
|
#include <cvar.h>
|
||||||
|
@ -230,57 +231,42 @@ void Cmd_StuffCmds_f (void)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
int s;
|
int s;
|
||||||
char *text, *build, c;
|
char *build, c;
|
||||||
|
|
||||||
// build the combined string to parse from
|
s = strlen (com_cmdline);
|
||||||
s = 0;
|
|
||||||
for (i=1 ; i<com_argc ; i++)
|
|
||||||
{
|
|
||||||
if (!com_argv[i])
|
|
||||||
continue; // NEXTSTEP nulls out -NXHost
|
|
||||||
s += Q_strlen (com_argv[i]) + 1;
|
|
||||||
}
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
text = Z_Malloc (s+1);
|
|
||||||
text[0] = 0;
|
|
||||||
for (i=1 ; i<com_argc ; i++)
|
|
||||||
{
|
|
||||||
if (!com_argv[i])
|
|
||||||
continue; // NEXTSTEP nulls out -NXHost
|
|
||||||
Q_strcat (text,com_argv[i]);
|
|
||||||
if (i != com_argc-1)
|
|
||||||
Q_strcat (text, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
// pull out the commands
|
// pull out the commands
|
||||||
build = Z_Malloc (s+1);
|
build = Z_Malloc (s+1);
|
||||||
build[0] = 0;
|
build[0] = 0;
|
||||||
|
|
||||||
for (i=0 ; i<s-1 ; i++)
|
for (i=0 ; i<s-1 ; i++)
|
||||||
{
|
{
|
||||||
if (text[i] == '+')
|
if (com_cmdline[i] == '+')
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
for (j=i ; (text[j] != '+') && (text[j] != '-') && (text[j] != 0) ; j++)
|
for (j=i ; ((com_cmdline[j] != '+')
|
||||||
|
&& (com_cmdline[j] != '-')
|
||||||
|
&& (com_cmdline[j] != 0)) ; j++)
|
||||||
;
|
;
|
||||||
|
|
||||||
c = text[j];
|
c = com_cmdline[j];
|
||||||
text[j] = 0;
|
com_cmdline[j] = 0;
|
||||||
|
|
||||||
Q_strcat (build, text+i);
|
Q_strcat (build, com_cmdline+i);
|
||||||
Q_strcat (build, "\n");
|
Q_strcat (build, "\n");
|
||||||
text[j] = c;
|
com_cmdline[j] = c;
|
||||||
i = j-1;
|
i = j-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Con_Printf("[\n%s]\n",build);
|
||||||
|
|
||||||
if (build[0])
|
if (build[0])
|
||||||
Cbuf_InsertText (build);
|
Cbuf_InsertText (build);
|
||||||
|
|
||||||
Z_Free (text);
|
|
||||||
Z_Free (build);
|
Z_Free (build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,18 +100,21 @@ void COM_InitArgv (int argc, char **argv)
|
||||||
largv[com_argc] = argv[com_argc];
|
largv[com_argc] = argv[com_argc];
|
||||||
if ((argv[com_argc]) && !Q_strcmp ("-safe", argv[com_argc]))
|
if ((argv[com_argc]) && !Q_strcmp ("-safe", argv[com_argc]))
|
||||||
safe = true;
|
safe = true;
|
||||||
len += strlen (argv[com_argc]) + 1;
|
if (com_argc)
|
||||||
|
len += strlen (argv[com_argc]) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
com_cmdline = (char*)malloc (len+1); // need strlen(com_cmdline)+2
|
com_cmdline = (char*)malloc (len+1); // need strlen(com_cmdline)+2
|
||||||
com_cmdline[0] = 0;
|
com_cmdline[0] = 0;
|
||||||
for (i=0; i < argc; i++)
|
if (len) {
|
||||||
{
|
for (i=1; i < argc; i++)
|
||||||
strncat (com_cmdline, argv[i], len);
|
{
|
||||||
assert(len - strlen(com_cmdline) > 0);
|
strncat (com_cmdline, argv[i], len);
|
||||||
strcat (com_cmdline, " ");
|
assert(len - strlen(com_cmdline) > 0);
|
||||||
|
strcat (com_cmdline, " ");
|
||||||
|
}
|
||||||
|
com_cmdline[len - 1] = '\0';
|
||||||
}
|
}
|
||||||
com_cmdline[len - 1] = '\0';
|
|
||||||
|
|
||||||
if (safe)
|
if (safe)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
extern int com_argc;
|
extern int com_argc;
|
||||||
extern char **com_argv;
|
extern char **com_argv;
|
||||||
|
extern char *com_cmdline;
|
||||||
|
|
||||||
int COM_CheckParm (char *parm);
|
int COM_CheckParm (char *parm);
|
||||||
void COM_AddParm (char *parm);
|
void COM_AddParm (char *parm);
|
||||||
|
|
Loading…
Reference in a new issue