//======================================================================
//============================= main.c =================================
//======================================================================
+enum {
+ COMPILER_QCC, /* circa QuakeC */
+ COMPILER_FTEQCC, /* fteqcc QuakeC */
+ COMPILER_QCCX, /* qccx QuakeC */
+ COMPILER_GMQCC /* this QuakeC */
+};
extern int opts_debug;
extern int opts_memchk;
#endif
VECTOR_MAKE(argitem, items);
/* global options */
-int opts_debug = 0;
-int opts_memchk = 0;
+int opts_debug = 0;
+int opts_memchk = 0;
+int opts_compiler = COMPILER_GMQCC;
static const int usage(const char *const app) {
printf("usage:\n");
printf(" additional flags:\n");
printf(" -debug -- turns on compiler debug messages\n");
printf(" -memchk -- turns on compiler memory leak check\n");
-
+ printf(" -help -- prints this help/usage text\n");
+ printf(" -std -- select the QuakeC compile type (types below):\n");
+ printf(" -std=qcc -- original QuakeC\n");
+ printf(" -std=ftqecc -- fteqcc QuakeC\n");
+ printf(" -std=qccx -- qccx QuakeC\n");
+ printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n");
return -1;
}
default:
if (!strncmp(&argv[1][1], "debug" , 5)) { opts_debug = 1; break; }
if (!strncmp(&argv[1][1], "memchk", 6)) { opts_memchk = 1; break; }
+ if (!strncmp(&argv[1][1], "help", 4)) {
+ return usage(app);
+ break;
+ }
+ /* compiler type selection */
+ if (!strncmp(&argv[1][1], "std=qcc" , 7 )) { opts_compiler = COMPILER_QCC; break; }
+ if (!strncmp(&argv[1][1], "std=fteqcc", 10)) { opts_compiler = COMPILER_FTEQCC; break; }
+ if (!strncmp(&argv[1][1], "std=qccx", 8 )) { opts_compiler = COMPILER_QCCX; break; }
+ if (!strncmp(&argv[1][1], "std=gmqcc", 9 )) { opts_compiler = COMPILER_GMQCC; break; }
+ if (!strncmp(&argv[1][1], "std=", 4 )) {
+ printf("invalid std selection, supported types:\n");
+ printf(" -std=qcc -- original QuakeC\n");
+ printf(" -std=ftqecc -- fteqcc QuakeC\n");
+ printf(" -std=qccx -- qccx QuakeC\n");
+ printf(" -std=gmqcc -- this compiler QuakeC (default selection)\n");
+ return 0;
+ }
return usage(app);
}
if (opts_memchk && !opts_debug)
printf("Warning: cannot enable -memchk, without -debug.\n");
+ util_debug("COM", "starting ...\n");
/* multi file multi path compilation system */
for (; itr < items_elements; itr++) {
switch (items_data[itr].type) {
break;
}
}
-
+
+ util_debug("COM", "cleaning ...\n");
/* clean list */
for (itr = 0; itr < items_elements; itr++)
mem_d(items_data[itr].name);
Total allocations: %llu\n\
Total deallocations: %llu\n\
Total allocated: %llu (bytes)\n\
- Total deallocated: %llu (bytes)\n",
+ Total deallocated: %llu (bytes)\n\
+ Leaks found: lost %llu (bytes) in %d allocations\n",
mem_at, mem_dt,
- mem_ab, mem_db
+ mem_ab, mem_db,
+ (mem_ab - mem_db),
+ (mem_at - mem_dt)
);
}
-//#ifndef mem_d
-//#define mem_d(x) util_memory_d((x), __LINE__, __FILE__)
-//#endif
-//#ifndef mem_a
-//#define mem_a(x) util_memory_a((x), __LINE__, __FILE__)
-//#endif
-
/*
* Some string utility functions, because strdup uses malloc, and we want
* to track all memory (without replacing malloc).