diff --git a/tools/scan_includes.c b/tools/scan_includes.c index 1c6fb035e17..3a0da3b7494 100644 --- a/tools/scan_includes.c +++ b/tools/scan_includes.c @@ -76,15 +76,11 @@ void scan_file(const char *filename, bool strict) { if (is_incbin || is_include) { // Check that an INCLUDE/INCBIN ends as its own token char after = is_include ? *(ptr + 7) : *(ptr + 6); - if (after != ' ' && after != '\t' && after != '"') { + if (after != ' ' && after != '\t' && after != '\n' && after != '"') { break; } ptr = strpbrk(ptr, "\"\n"); - if (!ptr) { - fprintf(stderr, "%s: no file path after INC%s\n", filename, is_include ? "LUDE" : "BIN"); - goto done; - } - else if (*ptr == '"') { + if (*ptr == '"') { ptr++; char *include_path = ptr; size_t length = strcspn(ptr, "\""); @@ -95,6 +91,12 @@ void scan_file(const char *filename, bool strict) { scan_file(include_path, strict); } } + else { + fprintf(stderr, "%s: no file path after INC%s\n", filename, is_include ? "LUDE" : "BIN"); + if (!ptr) { + goto done; + } + } } break; }