diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-10-01 11:26:31 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-10-01 11:26:31 -0700 |
commit | 59ddd26aac7504d49ced00cd9c8757fdc58c86f1 (patch) | |
tree | bfaaba5f0d4d1401cfd008948506ec7df960fff7 | |
parent | fcce07f171c69d499feebf355f9700ee4f6024ee (diff) | |
download | nasm-59ddd26aac7504d49ced00cd9c8757fdc58c86f1.tar.gz nasm-59ddd26aac7504d49ced00cd9c8757fdc58c86f1.tar.bz2 nasm-59ddd26aac7504d49ced00cd9c8757fdc58c86f1.zip |
Check for the most basic filename overlaps
Check for the most basic filename overlaps, in case we have the
opportunity to save the user from himself.
-rw-r--r-- | nasm.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -780,16 +780,25 @@ static void parse_cmdline(int argc, char **argv) if (!*inname) report_error(ERR_NONFATAL | ERR_NOFILE | ERR_USAGE, "no input file specified"); - else { - if (*errname) { - error_file = fopen(errname, "w"); - if (!error_file) { - error_file = stderr; /* Revert to default! */ - report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, - "cannot open file `%s' for error messages", - errname); - } - } + + /* Look for basic command line typos. This definitely doesn't + catch all errors, but it might help cases of fumbled fingers. */ + if ((errname && !strcmp(inname, errname)) || + (outname && !strcmp(inname, outname)) || + (listname && !strcmp(inname, listname))) { + report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + "file `%s' is both input and output file", + inname); + } + + if (*errname) { + error_file = fopen(errname, "w"); + if (!error_file) { + error_file = stderr; /* Revert to default! */ + report_error(ERR_FATAL | ERR_NOFILE | ERR_USAGE, + "cannot open file `%s' for error messages", + errname); + } } } |