Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested response files. #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions asm/nasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct forwrefinfo { /* info held on forward refs. */

const char *_progname;

static void open_and_process_respfile(char *, int);
static void parse_cmdline(int, char **, int);
static void assemble_file(const char *, struct strlist *);
static bool skip_this_pass(errflags severity);
Expand Down Expand Up @@ -1000,13 +1001,16 @@ static bool process_arg(char *p, char *q, int pass)
return false;

if (p[0] == '-' && !stopoptions) {
if (strchr("oOfpPdDiIlLFXuUZwW", p[1])) {
if (strchr("oOfpPdDiIlLFXuUZwW@", p[1])) {
/* These parameters take values */
if (!(param = get_param(p, q, &advance)))
return advance;
}

switch (p[1]) {
case '@':
open_and_process_respfile(param, pass);
break;
case 's':
if (pass == 1)
error_file = stdout;
Expand Down Expand Up @@ -1480,10 +1484,22 @@ static void process_response_file(const char *file, int pass)
fclose(f);
}

static void parse_cmdline(int argc, char **argv, int pass)
static void open_and_process_respfile(char *respfile, int pass)
{
FILE *rfile;
char *envreal, *envcopy = NULL, *p;

rfile = nasm_open_read(respfile, NF_TEXT);
if (rfile) {
process_respfile(rfile, pass);
fclose(rfile);
} else {
nasm_nonfatalf(ERR_USAGE, "unable to open response file `%s'", respfile);
}
}

static void parse_cmdline(int argc, char **argv, int pass)
{
char *envreal, *envcopy = NULL;

/*
* Initialize all the warnings to their default state, including
Expand Down Expand Up @@ -1519,19 +1535,8 @@ static void parse_cmdline(int argc, char **argv, int pass)
argc--;
argv++;
}
if (!stopoptions && argv[0][0] == '-' && argv[0][1] == '@') {
p = get_param(argv[0], argc > 1 ? argv[1] : NULL, &advance);
if (p) {
rfile = nasm_open_read(p, NF_TEXT);
if (rfile) {
process_respfile(rfile, pass);
fclose(rfile);
} else {
nasm_nonfatalf(ERR_USAGE, "unable to open response file `%s'", p);
}
}
} else
advance = process_arg(argv[0], argc > 1 ? argv[1] : NULL, pass);

advance = process_arg(argv[0], argc > 1 ? argv[1] : NULL, pass);
argv += advance, argc -= advance;
}

Expand Down