0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

preproc: error out if an include file exists but can't be opened

If an include file exists, but cannot be opened, that is still a
critical error.

However, downgrade this from a fatal to a nonfatal error. There really
isn't any reason to stop cold here.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel)
2020-06-01 12:32:35 -07:00
parent 6e71496e3c
commit 5d68f9823e
3 changed files with 12 additions and 6 deletions

View File

@@ -2241,12 +2241,15 @@ static FILE *inc_fopen(const char *file,
strlist_add(dhead, file);
}
if (!path) {
if (omode == INC_NEEDED)
nasm_fatal("unable to open include file `%s'", file);
} else {
if (!fp && omode != INC_PROBE)
if (path && !fp && omode != INC_PROBE)
fp = nasm_open_read(path, fmode);
if (omode == INC_NEEDED && !fp) {
if (!path)
errno = ENOENT;
nasm_nonfatal("unable to open include file `%s': %s",
file, strerror(errno));
}
if (found_path)

View File

@@ -88,6 +88,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>

2
test/include-self.asm Normal file
View File

@@ -0,0 +1,2 @@
; Test an infinite %include loop
%include "include-self.asm"