another cmdlib function dies

This commit is contained in:
Bill Currie 2002-07-31 16:42:21 +00:00
parent d3ae1b5078
commit 7c26fa28dc
2 changed files with 7 additions and 75 deletions

View file

@ -50,8 +50,6 @@ static const char rcsid[] =
#include "cmdlib.h"
char qfcc_com_token[1024];
/*
Error
@ -72,73 +70,6 @@ Error (char *error, ...)
}
/*
Parse
Parse a token out of a string
*/
char *
Parse (char *data)
{
int c;
int len = 0;
qfcc_com_token[0] = 0;
if (!data)
return NULL;
// skip whitespace
skipwhite:
while ((c = *data) <= ' ') {
if (c == 0) {
return NULL; // end of file;
}
data++;
}
// skip // comments
if (c == '/' && data[1] == '/') {
while (*data && *data != '\n')
data++;
goto skipwhite;
}
// handle quoted strings specially
if (c == '\"') {
data++;
do {
c = *data++;
if (c == '\"') {
qfcc_com_token[len] = 0;
return data;
}
qfcc_com_token[len] = c;
len++;
} while (1);
}
// parse single characters
if (c == '{' || c == '}' || c == ')' || c == '(' || c == '\'' || c == ':') {
qfcc_com_token[len] = c;
len++;
qfcc_com_token[len] = 0;
return data + 1;
}
// parse a regular word
do {
qfcc_com_token[len] = c;
data++;
len++;
c = *data;
if (c == '{' || c == '}' || c == ')' || c == '(' || c == '\''
|| c == ':')
break;
} while (c > 32);
qfcc_com_token[len] = 0;
return data;
}
/*
=============================================================================

View file

@ -54,6 +54,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <stdio.h>
#include <QF/cbuf.h>
#include <QF/crc.h>
#include <QF/dstring.h>
#include <QF/hash.h>
@ -572,7 +573,7 @@ static int
progs_src_compile (void)
{
dstring_t *filename = dstring_newstr ();
char *src;
const char *src;
int crc = 0;
if (options.verbosity >= 1 && strcmp (sourcedir, "")) {
@ -588,13 +589,13 @@ progs_src_compile (void)
dsprintf (filename, "%s", progs_src);
LoadFile (filename->str, (void *) &src);
if (!(src = Parse (src))) {
if (!(src = COM_Parse (src))) {
fprintf (stderr, "No destination filename. qfcc --help for info.\n");
return 1;
}
if (!options.output_file)
options.output_file = strdup (qfcc_com_token);
options.output_file = strdup (com_token);
if (options.verbosity >= 1) {
printf ("output file: %s\n", options.output_file);
}
@ -606,7 +607,7 @@ progs_src_compile (void)
begin_compilation ();
// compile all the files
while ((src = Parse (src))) {
while ((src = COM_Parse (src))) {
int err;
//extern int yydebug;
@ -614,9 +615,9 @@ progs_src_compile (void)
if (*sourcedir)
dsprintf (filename, "%s%c%s", sourcedir, PATH_SEPARATOR,
qfcc_com_token);
com_token);
else
dsprintf (filename, "%s", qfcc_com_token);
dsprintf (filename, "%s", com_token);
if (options.verbosity >= 2)
printf ("compiling %s\n", filename->str);