summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-10-01 11:26:31 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-10-01 11:26:31 -0700
commit59ddd26aac7504d49ced00cd9c8757fdc58c86f1 (patch)
treebfaaba5f0d4d1401cfd008948506ec7df960fff7
parentfcce07f171c69d499feebf355f9700ee4f6024ee (diff)
downloadnasm-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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/nasm.c b/nasm.c
index 32fa078..559749a 100644
--- a/nasm.c
+++ b/nasm.c
@@ -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);
+ }
}
}