Fixed the remaining omision with commandlines. It should now function as a complete drop-in replacement for the original id q3asm.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2913 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
9e3c465a79
commit
eff3e85911
1 changed files with 97 additions and 12 deletions
|
@ -829,6 +829,12 @@ void AssembleFile(struct assembler *w, int fnum, char *filename)
|
||||||
w->curseg = &w->segs[SEG_CODE];
|
w->curseg = &w->segs[SEG_CODE];
|
||||||
|
|
||||||
f = fopen(filename, "rt");
|
f = fopen(filename, "rt");
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
_snprintf(linebuffer, sizeof(linebuffer)-1, "%s.asm", filename);
|
||||||
|
f = fopen(linebuffer, "rt");
|
||||||
|
}
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
while(fgets(linebuffer, sizeof(linebuffer), f))
|
while(fgets(linebuffer, sizeof(linebuffer), f))
|
||||||
|
@ -836,7 +842,10 @@ void AssembleFile(struct assembler *w, int fnum, char *filename)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
printf("couldn't open %s\n", filename);
|
||||||
w->errorcount++;
|
w->errorcount++;
|
||||||
|
}
|
||||||
|
|
||||||
//reset the local symbol hash, so we don't find conflicting vars
|
//reset the local symbol hash, so we don't find conflicting vars
|
||||||
memset(w->localsymboltablebuckets, 0, sizeof(w->localsymboltablebuckets));
|
memset(w->localsymboltablebuckets, 0, sizeof(w->localsymboltablebuckets));
|
||||||
|
@ -1045,6 +1054,12 @@ void Assemble(struct workload *w)
|
||||||
int ParseCommandList(struct workload *w, int numcmds, char **cmds)
|
int ParseCommandList(struct workload *w, int numcmds, char **cmds)
|
||||||
{
|
{
|
||||||
char **t;
|
char **t;
|
||||||
|
|
||||||
|
FILE *f;
|
||||||
|
char *buffer, *pp, *pps;
|
||||||
|
unsigned int len, numextraargs;
|
||||||
|
char *suppargs[64];
|
||||||
|
|
||||||
while (numcmds)
|
while (numcmds)
|
||||||
{
|
{
|
||||||
if ((*cmds)[0] == '-')
|
if ((*cmds)[0] == '-')
|
||||||
|
@ -1054,18 +1069,88 @@ int ParseCommandList(struct workload *w, int numcmds, char **cmds)
|
||||||
numcmds--;
|
numcmds--;
|
||||||
cmds++;
|
cmds++;
|
||||||
|
|
||||||
//todo: include a file
|
f = fopen(*cmds, "rt");
|
||||||
printf("-f directive not supported yet\n");
|
if (!f)
|
||||||
return 1;
|
{
|
||||||
|
char blah[256];
|
||||||
|
_snprintf(blah, sizeof(blah)-1, "%s.q3asm", *cmds);
|
||||||
|
f = fopen(blah, "rt");
|
||||||
|
}
|
||||||
|
if (f)
|
||||||
|
{
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
len = ftell(f);
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
buffer = malloc((len+9));
|
||||||
|
if (buffer)
|
||||||
|
{
|
||||||
|
if (fread(buffer, 1, len, f) == len)
|
||||||
|
{
|
||||||
|
buffer[len] = 0;
|
||||||
|
numextraargs = 0;
|
||||||
|
pp = buffer;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (numextraargs == sizeof(suppargs)/sizeof(suppargs[0]))
|
||||||
|
break;
|
||||||
|
while (*pp == ' ' || *pp == '\r' || *pp == '\n')
|
||||||
|
{
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
if (*pp == '\"')
|
||||||
|
{
|
||||||
|
pp++;
|
||||||
|
pps = pp;
|
||||||
|
while (*pp && *pp != '\"')
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pps = pp;
|
||||||
|
while (*pp && !(*pp == ' ' || *pp == '\r' || *pp == '\n'))
|
||||||
|
{
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*pp)
|
||||||
|
*pp++ = 0;
|
||||||
|
suppargs[numextraargs] = pps;
|
||||||
|
numextraargs++;
|
||||||
|
} while (*pp);
|
||||||
|
ParseCommandList(w, numextraargs, suppargs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("failure reading source file\n");
|
||||||
|
}
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("out of memory\n");
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("couldn't open \"%s\"\n", *cmds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ((*cmds)[1] == 'o')
|
else if ((*cmds)[1] == 'o')
|
||||||
{
|
{
|
||||||
numcmds--;
|
numcmds--;
|
||||||
cmds++;
|
cmds++;
|
||||||
|
|
||||||
|
if (!strchr(*cmds, '.'))
|
||||||
|
{
|
||||||
|
_snprintf(w->output, sizeof(w->output)-1, "%s.qvm", *cmds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
strncpy(w->output, *cmds, sizeof(w->output)-1);
|
strncpy(w->output, *cmds, sizeof(w->output)-1);
|
||||||
w->output[sizeof(w->output)-1] = 0;
|
w->output[sizeof(w->output)-1] = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ((*cmds)[1] == 'v')
|
else if ((*cmds)[1] == 'v')
|
||||||
w->verbose = 1;
|
w->verbose = 1;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue