size_t operator_count = 0;
typedef struct { char *filename; int type; } argitem;
-VECTOR_MAKE(argitem, items);
+static argitem *items = NULL;
#define TYPE_QC 0
#define TYPE_ASM 1
static int usage() {
con_out("usage: %s [options] [files...]", app_name);
con_out("options:\n"
- " -h, --help show this help message\n"
- " -debug turns on compiler debug messages\n"
- " -memchk turns on compiler memory leak check\n");
+ " -h, --help show this help message\n"
+ " -debug turns on compiler debug messages\n"
+ " -memchk turns on compiler memory leak check\n");
con_out(" -o, --output=file output file, defaults to progs.dat\n"
- " -a filename add an asm file to be assembled\n"
- " -s filename add a progs.src file to be used\n");
+ " -a filename add an asm file to be assembled\n"
+ " -s filename add a progs.src file to be used\n");
con_out(" -E stop after preprocessing\n");
con_out(" -f<flag> enable a flag\n"
- " -fno-<flag> disable a flag\n"
- " -std standard select one of the following standards\n"
- " -std=qcc original QuakeC\n"
- " -std=fteqcc fteqcc QuakeC\n"
- " -std=gmqcc this compiler (default)\n");
+ " -fno-<flag> disable a flag\n"
+ " -std standard select one of the following standards\n"
+ " -std=qcc original QuakeC\n"
+ " -std=fteqcc fteqcc QuakeC\n"
+ " -std=gmqcc this compiler (default)\n");
con_out(" -W<warning> enable a warning\n"
- " -Wno-<warning> disable a warning\n"
- " -Wall enable all warnings\n"
- " -Werror treat warnings as errors\n");
+ " -Wno-<warning> disable a warning\n"
+ " -Wall enable all warnings\n"
+ " -Werror treat warnings as errors\n");
con_out(" -force-crc=num force a specific checksum into the header\n");
con_out("\n");
con_out("flags:\n"
- " -fadjust-vector-fields\n"
- " when assigning a vector field, its _y and _z fields also get assigned\n"
+ " -fadjust-vector-fields\n"
+ " when assigning a vector field, its _y and _z fields also get assigned\n"
);
return -1;
}
static bool options_parse(int argc, char **argv) {
bool argend = false;
size_t itr;
- char buffer[1024];
+ char buffer[1024];
+ char *redirout = (char*)stdout;
+ char *redirerr = (char*)stderr;
+
while (!argend && argc > 1) {
char *argarg;
argitem item;
opts_forced_crc = strtol(argarg, NULL, 0);
continue;
}
+ if (options_long_gcc("redirout", &argc, &argv, &redirout)) {
+ continue;
+ }
+ if (options_long_gcc("redirerr", &argc, &argv, &redirerr)) {
+ continue;
+ }
+
if (!strcmp(argv[0]+1, "debug")) {
opts_debug = true;
continue;
opts_memchk = true;
continue;
}
+ if (!strcmp(argv[0]+1, "nocolor")) {
+ con_color(0);
+ continue;
+ }
switch (argv[0][1]) {
/* -h, show usage but exit with 0 */
return false;
}
item.filename = argarg;
- items_add(item);
+ vec_push(items, item);
break;
case '-':
argitem item;
item.filename = argv[0];
item.type = TYPE_QC;
- items_add(item);
+ vec_push(items, item);
}
}
+ con_change(redirout, redirerr);
return true;
}
/* returns the line number, or -1 on error */
-static bool progs_nextline(char **out, size_t *alen,FILE *src)
-{
+static bool progs_nextline(char **out, size_t *alen,FILE *src) {
int len;
char *line;
char *start;
util_debug("COM", "starting ...\n");
- if (items_elements) {
+ if (vec_size(items)) {
con_out("Mode: manual\n");
- con_out("There are %lu items to compile:\n", (unsigned long)items_elements);
- for (itr = 0; itr < items_elements; ++itr) {
+ con_out("There are %lu items to compile:\n", (unsigned long)vec_size(items));
+ for (itr = 0; itr < vec_size(items); ++itr) {
con_out(" item: %s (%s)\n",
- items_data[itr].filename,
- ( (items_data[itr].type == TYPE_QC ? "qc" :
- (items_data[itr].type == TYPE_ASM ? "asm" :
- (items_data[itr].type == TYPE_SRC ? "progs.src" :
+ items[itr].filename,
+ ( (items[itr].type == TYPE_QC ? "qc" :
+ (items[itr].type == TYPE_ASM ? "asm" :
+ (items[itr].type == TYPE_SRC ? "progs.src" :
("unknown"))))));
- if (!parser_compile_file(items_data[itr].filename))
- {
+ if (opts_pp_only) {
+ if (!ftepp_preprocess_file(items[itr].filename)) {
+ retval = 1;
+ goto cleanup;
+ }
+ }
+ else if (!parser_compile_file(items[itr].filename)) {
retval = 1;
goto cleanup;
}
cleanup:
util_debug("COM", "cleaning ...\n");
-
- mem_d(items_data);
+ con_close();
+ vec_free(items);
parser_cleanup();
if (opts_output_free)