diff --git a/IncludeToolboxShared/Util/ParseIncludes.cs b/IncludeToolboxShared/Util/ParseIncludes.cs index 27473a7..724bedc 100644 --- a/IncludeToolboxShared/Util/ParseIncludes.cs +++ b/IncludeToolboxShared/Util/ParseIncludes.cs @@ -17,6 +17,7 @@ public static partial class Parser public static IncludeLine[] ParseInclues(ReadOnlySpan text, bool ignore_ifdefs = true) { + if (text.IsEmpty) return new IncludeLine[0]; List lines = new(); Lexer.Context lctx = new(text); diff --git a/IncludeToolboxShared/Util/Utils.cs b/IncludeToolboxShared/Util/Utils.cs index 3667be8..6d931f5 100644 --- a/IncludeToolboxShared/Util/Utils.cs +++ b/IncludeToolboxShared/Util/Utils.cs @@ -32,6 +32,7 @@ public static ReadOnlySpan GetIncludeSpanRO(string text) { int[] line = new int[2]; line[0] = text.IndexOf("#include"); //first + if (line[0] == -1) return new ReadOnlySpan(); line[1] = text.IndexOf("\n", text.LastIndexOf("#include")) - line[0] + 1; //last return text.AsSpan(line[0], line[1]); }