authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-03-28 14:16:48-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-04-11 10:05:00-07:00
log7851377e95f1a0e9467a7e69dd506b47a4f45b87
tree5a37939443fc40c09f8eb46e7a544f2fdd79ab79
parentd2681d2537b630359657e117ed77cf12a15bb7df

Improve whitespace-handling in (compile-error) test manifest parsing


1 files changed, 11 insertions(+), 8 deletions(-)

src/test.zig+11-8
......@@ -720,14 +720,17 @@ pub const TestContext = struct {
720720 // Move to beginning of line
721721 while (cursor > 0 and src[cursor - 1] != '\n') cursor -= 1;
722722
723 // Check if line is non-empty and does not start with "//"
724 if (cursor + 1 < src.len and src[cursor + 1] != '\n' and src[cursor + 1] != '\r') {
725 if (std.mem.startsWith(u8, src[cursor..], "//")) {
726 manifest_start = cursor;
727 } else {
728 break;
729 }
730 } else manifest_end = cursor;
723 if (std.mem.startsWith(u8, src[cursor..], "//")) {
724 manifest_start = cursor; // Contiguous comment line, include in manifest
725 } else {
726 if (manifest_start != null) break; // Encountered non-comment line, end of manifest
727
728 // We ignore all-whitespace lines following the comment block, but anything else
729 // means that there is no manifest present.
730 if (std.mem.trim(u8, src[cursor..manifest_end], " \r\n\t").len == 0) {
731 manifest_end = cursor;
732 } else break; // If it's not whitespace, there is no manifest
733 }
731734
732735 // Move to previous line
733736 if (cursor != 0) cursor -= 1 else break;