return options_long_witharg_all(optname, argc_, argv_, out, 1, false);
}
-static bool options_parse(int argc, char **argv) {
+static bool options_parse(int argc, char **argv, bool *has_progs_src) {
bool argend = false;
size_t itr;
char buffer[1024];
}
if (options_long_gcc("progsrc", &argc, &argv, &argarg)) {
OPTS_OPTION_STR(OPTION_PROGSRC) = argarg;
+ *has_progs_src = true;
continue;
}
}
item.filename = argarg;
vec_push(items, item);
+ if (item.type == TYPE_SRC) {
+ *has_progs_src = true;
+ }
break;
case '-':
}
int main(int argc, char **argv) {
- size_t itr;
- int retval = 0;
- bool operators_free = false;
- bool progs_src = false;
- FILE *outfile = nullptr;
- parser_t *parser = nullptr;
- ftepp_t *ftepp = nullptr;
+ size_t itr;
+ int retval = 0;
+ bool operators_free = false;
+ bool has_progs_src = false;
+ FILE *outfile = nullptr;
+ parser_t *parser = nullptr;
+ ftepp_t *ftepp = nullptr;
app_name = argv[0];
con_init ();
util_seed(time(0));
- if (!options_parse(argc, argv)) {
+ if (!options_parse(argc, argv, &has_progs_src)) {
return usage();
}
}
}
- if (!vec_size(items)) {
- FILE *src;
- char *line = nullptr;
- size_t linelen = 0;
- bool hasline = false;
+ if (!vec_size(items) && !has_progs_src) {
+ FILE *fp = fopen(OPTS_OPTION_STR(OPTION_PROGSRC), "rb");
+ if (fp) {
+ has_progs_src = true;
+ }
+ fclose(fp);
+ }
- progs_src = true;
+ if (has_progs_src) {
+ FILE *src;
+ char *line = nullptr;
+ size_t linelen = 0;
+ bool has_first_line = false;
src = fopen(OPTS_OPTION_STR(OPTION_PROGSRC), "rb");
if (!src) {
while (progs_nextline(&line, &linelen, src)) {
argitem item;
- if (!line[0] || (line[0] == '/' && line[1] == '/'))
+ if (!line[0] || (line[0] == '/' && line[1] == '/')) {
continue;
+ }
- if (hasline) {
+ if (has_first_line) {
item.filename = util_strdup(line);
- item.type = TYPE_QC;
+ item.type = TYPE_QC;
vec_push(items, item);
- } else if (!opts_output_wasset) {
- OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line);
- hasline = true;
+ } else {
+ if (!opts_output_wasset) {
+ OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line);
+ }
+ has_first_line = true;
}
}
if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
!OPTS_OPTION_BOOL(OPTION_PP_ONLY))
{
- con_out("Mode: %s\n", (progs_src ? "progs.src" : "manual"));
+ con_out("Mode: %s\n", (has_progs_src ? "progs.src" : "manual"));
con_out("There are %lu items to compile:\n", (unsigned long)vec_size(items));
}
("unknown"))))));
}
+ if (items[itr].type == TYPE_SRC) {
+ continue;
+ }
+
if (OPTS_OPTION_BOOL(OPTION_PP_ONLY)) {
const char *out;
if (!ftepp_preprocess_file(ftepp, items[itr].filename)) {
}
}
- if (progs_src) {
+ if (has_progs_src) {
mem_d(items[itr].filename);
items[itr].filename = nullptr;
}