From 1a6b05111934a94a13145705c6f4be2a68412bf3 Mon Sep 17 00:00:00 2001 From: Rangi Date: Tue, 8 Mar 2022 21:40:32 -0500 Subject: Slightly refactor some C tools --- tools/scan_includes.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'tools/scan_includes.c') diff --git a/tools/scan_includes.c b/tools/scan_includes.c index 3e93cbad7..e57ddc358 100644 --- a/tools/scan_includes.c +++ b/tools/scan_includes.c @@ -47,17 +47,16 @@ void scan_file(const char *filename, bool strict) { ptr = strchr(ptr, '\n'); if (!ptr) { fprintf(stderr, "%s: no newline at end of file\n", filename); - break; } break; case '"': ptr++; ptr = strchr(ptr, '"'); - if (!ptr) { + if (ptr) { + ptr++; + } else { fprintf(stderr, "%s: unterminated string\n", filename); - break; } - ptr++; break; case 'I': case 'i': @@ -65,17 +64,16 @@ void scan_file(const char *filename, bool strict) { is_include = !strncmp(ptr, "INCLUDE", 7) || !strncmp(ptr, "include", 7); if (is_incbin || is_include) { ptr = strchr(ptr, '"'); - if (!ptr) { - break; - } - ptr++; - char *include_path = ptr; - size_t length = strcspn(ptr, "\""); - ptr += length + 1; - include_path[length] = '\0'; - printf("%s ", include_path); - if (is_include) { - scan_file(include_path, strict); + if (ptr) { + ptr++; + char *include_path = ptr; + size_t length = strcspn(ptr, "\""); + ptr += length + 1; + include_path[length] = '\0'; + printf("%s ", include_path); + if (is_include) { + scan_file(include_path, strict); + } } } break; -- cgit v1.2.3