Skip to content

Commit 6f48f8f

Browse files
zturnerbxhpax
authored andcommitted
Support nested response files.
This allows response files specified with -@ to reference other response files. This keeps parity with many other common toolchains such as MSVC, GCC, and Clang which all support nested response files. Signed-off-by: Zachary Turner <zturner@roblox.com>
1 parent 9e03a95 commit 6f48f8f

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

asm/nasm.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct forwrefinfo { /* info held on forward refs. */
4242

4343
const char *_progname;
4444

45+
static void open_and_process_respfile(char *, int);
4546
static void parse_cmdline(int, char **, int);
4647
static void assemble_file(const char *, struct strlist *);
4748
static bool skip_this_pass(errflags severity);
@@ -966,13 +967,16 @@ static bool process_arg(char *p, char *q, int pass)
966967
return false;
967968

968969
if (p[0] == '-' && !stopoptions) {
969-
if (strchr("oOfpPdDiIlLFXuUZwW", p[1])) {
970+
if (strchr("oOfpPdDiIlLFXuUZwW@", p[1])) {
970971
/* These parameters take values */
971972
if (!(param = get_param(p, q, &advance)))
972973
return advance;
973974
}
974975

975976
switch (p[1]) {
977+
case '@':
978+
open_and_process_respfile(param, pass);
979+
break;
976980
case 's':
977981
if (pass == 1)
978982
error_file = stdout;
@@ -1454,10 +1458,22 @@ static void process_response_file(const char *file, int pass)
14541458
fclose(f);
14551459
}
14561460

1457-
static void parse_cmdline(int argc, char **argv, int pass)
1461+
static void open_and_process_respfile(char *respfile, int pass)
14581462
{
14591463
FILE *rfile;
1460-
char *envreal, *envcopy = NULL, *p;
1464+
1465+
rfile = nasm_open_read(respfile, NF_TEXT);
1466+
if (rfile) {
1467+
process_respfile(rfile, pass);
1468+
fclose(rfile);
1469+
} else {
1470+
nasm_nonfatalf(ERR_USAGE, "unable to open response file `%s'", respfile);
1471+
}
1472+
}
1473+
1474+
static void parse_cmdline(int argc, char **argv, int pass)
1475+
{
1476+
char *envreal, *envcopy = NULL;
14611477

14621478
/*
14631479
* Initialize all the warnings to their default state, including
@@ -1493,19 +1509,8 @@ static void parse_cmdline(int argc, char **argv, int pass)
14931509
argc--;
14941510
argv++;
14951511
}
1496-
if (!stopoptions && argv[0][0] == '-' && argv[0][1] == '@') {
1497-
p = get_param(argv[0], argc > 1 ? argv[1] : NULL, &advance);
1498-
if (p) {
1499-
rfile = nasm_open_read(p, NF_TEXT);
1500-
if (rfile) {
1501-
process_respfile(rfile, pass);
1502-
fclose(rfile);
1503-
} else {
1504-
nasm_nonfatalf(ERR_USAGE, "unable to open response file `%s'", p);
1505-
}
1506-
}
1507-
} else
1508-
advance = process_arg(argv[0], argc > 1 ? argv[1] : NULL, pass);
1512+
1513+
advance = process_arg(argv[0], argc > 1 ? argv[1] : NULL, pass);
15091514
argv += advance, argc -= advance;
15101515
}
15111516

0 commit comments

Comments
 (0)