summaryrefslogtreecommitdiff
path: root/tools/scan_includes.c
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2022-03-08 21:40:32 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2022-03-08 21:47:23 -0500
commit1a6b05111934a94a13145705c6f4be2a68412bf3 (patch)
tree7f4f9c49ae568f3ab1cc3ef5bebdb9faee1d5fbb /tools/scan_includes.c
parente068f9cf695a86a9e7ad1fb45743b753dd129088 (diff)
Slightly refactor some C tools
Diffstat (limited to 'tools/scan_includes.c')
-rw-r--r--tools/scan_includes.c28
1 files changed, 13 insertions, 15 deletions
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;