-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitscanutils.pas
40 lines (32 loc) · 1008 Bytes
/
gitscanutils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
unit gitscanutils;
interface
type
TCharSet = set of AnsiChar;
function ScanWhile(const str: string; WhileInChars: TCharSet; var idx: integer): string;
function ScanTo(const str: string; ToChars: TCharSet; var idx: integer): string;
const
WhiteSpace = [#32,#9,#10,#13];
DefaultSymbols = ['&','-','$','<','>','+','*','\','/'];
AlphaLow = ['a'..'z'];
AlphaUp = ['A'..'Z'];
Alpha = AlphaUp + AlphaLow;
UnixEoln = [#10];
Tabs = [#9];
implementation
function ScanWhile(const str: string; WhileInChars: TCharSet; var idx: integer): string;
var
i : integer;
begin
i:=idx;
while (idx<=length(str)) and (str[idx] in WhileInChars) do inc(idx);
Result:=copy(str, i, idx-i);
end;
function ScanTo(const str: string; ToChars: TCharSet; var idx: integer): string;
var
i : integer;
begin
i:=idx;
while (idx<=length(str)) and not (str[idx] in ToChars) do inc(idx);
Result:=copy(str, i, idx-i);
end;
end.