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:
@@ -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)
|
||||
|
@@ -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
2
test/include-self.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
; Test an infinite %include loop
|
||||
%include "include-self.asm"
|
Reference in New Issue
Block a user