summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ea052b)
raw | patch | inline | side by side (parent: 3ea052b)
author | Stas'M <x86corez@gmail.com> | |
Wed, 23 May 2018 14:36:03 +0000 (17:36 +0300) | ||
committer | Stas'M <x86corez@gmail.com> | |
Wed, 23 May 2018 14:37:41 +0000 (17:37 +0300) |
http://doom2d.org/forum/viewtopic.php?f=36&t=2566
src/shared/WADEDITOR.pas | patch | blob | history | |
src/shared/utils.pas | patch | blob | history |
index d2183553cb10fbe67272913c96002f72b0fbff0a..5e0573ec38406d092a9fee06516c2fcd2b87837b 100644 (file)
--- a/src/shared/WADEDITOR.pas
+++ b/src/shared/WADEDITOR.pas
Exit;
end;
- Section := UpperCase(Section);
- Resource := UpperCase(Resource);
+ Section := toLowerCase1251(Section);
+ Resource := toLowerCase1251(Resource);
i := -1;
for a := 0 to High(FResTable) do
begin
if FResTable[a].Length = 0 then
begin
- CurrentSection := FResTable[a].ResourceName;
+ CurrentSection := toLowerCase1251(FResTable[a].ResourceName);
Continue;
end;
- if (FResTable[a].ResourceName = Resource) and
+ if (toLowerCase1251(FResTable[a].ResourceName) = Resource) and
(CurrentSection = Section) then
begin
i := a;
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 04780bb6eae7a0ee216ab2465c71ec19d6d8b234..14e6f767537a9ef1a39fd50f8a63bcaf5b6fa17b 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
// convert number to strig with nice commas
function Int64ToStrComma (i: Int64): AnsiString;
-function UpCase1251 (ch: Char): Char;
-function LoCase1251 (ch: Char): Char;
+function UpCase1251 (ch: AnsiChar): AnsiChar; inline;
+function LoCase1251 (ch: AnsiChar): AnsiChar; inline;
+
+function toLowerCase1251 (const s: AnsiString): AnsiString;
// `true` if strings are equal; ignoring case for cp1251
function StrEquCI1251 (const s0, s1: AnsiString): Boolean;
end;
-function UpCase1251 (ch: Char): Char;
+function UpCase1251 (ch: AnsiChar): AnsiChar; inline;
begin
if ch < #128 then
begin
end;
-function LoCase1251 (ch: Char): Char;
+function LoCase1251 (ch: AnsiChar): AnsiChar; inline;
begin
if ch < #128 then
begin
end;
+function toLowerCase1251 (const s: AnsiString): AnsiString;
+var
+ f: Integer;
+ ch: AnsiChar;
+begin
+ for ch in s do
+ begin
+ if (ch <> LoCase1251(ch)) then
+ begin
+ result := '';
+ SetLength(result, Length(s));
+ for f := 1 to Length(s) do result[f] := LoCase1251(s[f]);
+ exit;
+ end;
+ end;
+ // nothing to do
+ result := s;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
// utils
// `ch`: utf8 start