Move command line handling into a module

This commit is contained in:
2025-08-15 18:37:40 +03:00
parent cec020ea92
commit f880e3d2d7
6 changed files with 25 additions and 81 deletions

View File

@@ -3,7 +3,7 @@
obtain one at https://mozilla.org/MPL/2.0/. *)
module;
import cstdio, cstring, common;
import cstdio, cstring, cctype, cstdlib, common;
const
CHUNK_SIZE := 85536;
@@ -301,21 +301,20 @@ proc compare_keyword(keyword: String, token_start: BufferPosition, token_end: ^C
var
result: Bool;
index: Word;
keyword_length: Word;
continue: Bool;
begin
index := 0u;
result := true;
keyword_length := Length(keyword);
continue := (index < keyword_length) & (token_start.iterator <> token_end);
continue := (index < keyword.length) & (token_start.iterator <> token_end);
while continue & result do
result := (keyword[index] = token_start.iterator^) or (Lower(keyword[index]) = token_start.iterator^);
result := keyword[index] = token_start.iterator^
or cast(tolower(cast(keyword[index]: Int)): Char) = token_start.iterator^;
token_start.iterator := token_start.iterator + 1;
index := index + 1u;
continue := (index < keyword_length) & (token_start.iterator <> token_end)
continue := (index < keyword.length) & (token_start.iterator <> token_end)
end;
result := result & (index = Length(keyword));
result := result & index = keyword.length;
return result & (token_start.iterator = token_end)
end;