X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=main.c;h=3dac2e1973cfe1bfe0a17b7359ba6e3549b515b7;hp=5717fb55c247f8e90df3b5a0a5d5357e89577f0f;hb=7e76b42f116c985f84b65b5e6f158a9a64686ed1;hpb=9af3c502dae7420714519dd13dff6aba40fc1fa3 diff --git a/main.c b/main.c index 5717fb5..3dac2e1 100644 --- a/main.c +++ b/main.c @@ -21,9 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include +#include +#include +#include +#include + + #include "gmqcc.h" #include "lexer.h" -#include /* TODO: cleanup this whole file .. it's a fuckign mess */ @@ -44,7 +50,7 @@ static ppitem *ppems = NULL; static const char *app_name; -static void version() { +static void version(void) { con_out("GMQCC %d.%d.%d Built %s %s\n" GMQCC_DEV_VERSION_STRING, GMQCC_VERSION_MAJOR, GMQCC_VERSION_MINOR, @@ -54,7 +60,7 @@ static void version() { ); } -static int usage() { +static int usage(void) { con_out("usage: %s [options] [files...]", app_name); con_out("options:\n" " -h, --help show this help message\n" @@ -656,9 +662,10 @@ int main(int argc, char **argv) { } if (!vec_size(items)) { - FILE *src; - char *line; + FILE *src; + char *line = NULL; size_t linelen = 0; + bool hasline = false; progs_src = true; @@ -669,28 +676,23 @@ int main(int argc, char **argv) { goto cleanup; } - line = NULL; - if (!progs_nextline(&line, &linelen, src) || !line[0]) { - con_err("illformatted progs.src file: expected output filename in first line\n"); - retval = 1; - goto srcdone; - } - - if (!opts_output_wasset) { - OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line); - opts_output_free = true; - } - while (progs_nextline(&line, &linelen, src)) { argitem item; + if (!line[0] || (line[0] == '/' && line[1] == '/')) continue; - item.filename = util_strdup(line); - item.type = TYPE_QC; - vec_push(items, item); + + if (hasline) { + item.filename = util_strdup(line); + item.type = TYPE_QC; + vec_push(items, item); + } else if (!opts_output_wasset) { + OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line); + opts_output_free = true; + hasline = true; + } } -srcdone: fs_file_close(src); mem_d(line); }