diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-01-21 16:23:59 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-01-21 16:23:59 -0800 |
commit | be2678cd315606b54041014d4d37f111766b9db4 (patch) | |
tree | aab445b06f2cd479e9937c87382590e73149361d | |
parent | f7bd02a07fa026679ff0da6b9e40be20ab282cf8 (diff) | |
download | nasm-be2678cd315606b54041014d4d37f111766b9db4.tar.gz |
nasm.c: clean up the handing of response files
Avoid using malloc/free (not nasm_malloc/nasm_free even) in the
processing of response files; move to separate function.
-rw-r--r-- | nasm.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -791,6 +791,20 @@ static void process_args(char *args) process_arg(arg, NULL); } +static void process_response_file(const char *file) +{ + char str[2048]; + FILE *f = fopen(file, "r"); + if (!f) { + perror(file); + exit(-1); + } + while (fgets(str, sizeof str, f)) { + process_args(str); + } + fclose(f); +} + static void parse_cmdline(int argc, char **argv) { FILE *rfile; @@ -822,19 +836,7 @@ static void parse_cmdline(int argc, char **argv) * different to the -@resp file processing below for regular * NASM. */ - char *str = malloc(2048); - FILE *f = fopen(&argv[0][1], "r"); - if (!str) { - printf("out of memory"); - exit(-1); - } - if (f) { - while (fgets(str, 2048, f)) { - process_args(str); - } - fclose(f); - } - free(str); + process_response_file(argv[0]+1); argc--; argv++; } |