summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 74b8cc2)
raw | patch | inline | side by side (parent: 74b8cc2)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 8 Apr 2016 00:10:13 +0000 (03:10 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 8 Apr 2016 00:10:30 +0000 (03:10 +0300) |
diff --git a/src/sfs/sfs.pas b/src/sfs/sfs.pas
index 9615d4b4db7549457453df0d0933e3bb57725303..f79413a237e5f2fe3225ca5993bd07b094e980b0 100644 (file)
--- a/src/sfs/sfs.pas
+++ b/src/sfs/sfs.pas
function SFSReplacePathDelims (const s: TSFSString; newDelim: TSFSChar): TSFSString;
// èãíîðèðóåò ðåãèñòð ñèìâîëîâ
-// <0: s0 < s1
-// =0: s0 = s1
-// >0: s0 > s1
-function SFSStrComp (const s0, s1: TSFSString): Integer;
+function SFSStrEqu (const s0, s1: TSFSString): Boolean;
// ðàçîáðàòü òîëñòîå èìÿ ôàéëà, âåðíóòü âèðòóàëüíîå èìÿ ïîñëåäíåãî ñïèñêà
// èëè ïóñòóþ ñòîðîêó, åñëè ñïèñêîâ íå áûëî.
vi := TVolumeInfo(volumes[f]);
if not onlyPerm or vi.fPermanent then
begin
- if SFSStrComp(vi.fPackName, dataFileName) = 0 then
+ if SFSStrEqu(vi.fPackName, dataFileName) then
begin
result := f;
exit;
end;
end;
-// <0: s0 < s1
-// =0: s0 = s1
-// >0: s0 > s1
-function SFSStrComp (const s0, s1: TSFSString): Integer;
+function le2upper (ch: Char): Char;
begin
- result := AnsiCompareText(s0, s1);
+ if ch < #128 then
+ begin
+ if (ch >= 'a') and (ch <= 'z') then Dec(ch, 32);
+ end
+ else
+ begin
+ if (ch >= #224) and (ch <= #255) then
+ begin
+ Dec(ch, 32);
+ end
+ else
+ begin
+ case ch of
+ #184, #186, #191: Dec(ch, 16);
+ #162, #179: Dec(ch);
+ end;
+ end;
+ end;
+ result := ch;
+end;
+
+function SFSStrEqu (const s0, s1: TSFSString): Boolean;
+var
+ i: Integer;
+begin
+ //result := (AnsiCompareText(s0, s1) == 0);
+ result := false;
+ if length(s0) <> length(s1) then exit;
+ for i := 1 to length(s0) do
+ begin
+ if le2upper(s0[i]) <> le2upper(s1[i]) then exit;
+ end;
+ result := true;
end;
function SFSReplacePathDelims (const s: TSFSString; newDelim: TSFSChar): TSFSString;
Dec(result);
if fFiles[result] <> nil then
begin
- if (SFSStrComp(fPath, TSFSFileInfo(fFiles[result]).fPath) = 0) and
- (SFSStrComp(fName, TSFSFileInfo(fFiles[result]).fName) = 0) then exit;
+ if SFSStrEqu(fPath, TSFSFileInfo(fFiles[result]).fPath) and
+ SFSStrEqu(fName, TSFSFileInfo(fFiles[result]).fName) then exit;
end;
end;
result := -1;
diff --git a/src/sfs/sfsMemFS.pas b/src/sfs/sfsMemFS.pas
index 2256e7fc48bc28a766359551cb93b6a364d3088c..03c8be287c7890367062e86b45b5b10148670e61 100644 (file)
--- a/src/sfs/sfsMemFS.pas
+++ b/src/sfs/sfsMemFS.pas
function TSFSMemoryVolumeFactory.IsMyVolumePrefix (const prefix: TSFSString): Boolean;
begin
result :=
- (SFSStrComp(prefix, 'mem') = 0) or
- (SFSStrComp(prefix, 'slh!') = 0);
+ SFSStrEqu(prefix, 'mem') or
+ SFSStrEqu(prefix, 'slh!');
end;
procedure TSFSMemoryVolumeFactory.Recycle (vol: TSFSVolume);
diff --git a/src/sfs/sfsPlainFS.pas b/src/sfs/sfsPlainFS.pas
index bda12681ff873e4717f4d3a3bc66a1f68d705cc0..c96dbf954a4ac62f67afe58c53bbe68601553524 100644 (file)
--- a/src/sfs/sfsPlainFS.pas
+++ b/src/sfs/sfsPlainFS.pas
if c <> f then
begin
// link can't be linked to itself
- if SFSStrComp(TSFSExtFileInfo(fFiles[c]).fName, fi.fLink) = 0 then break;
+ if SFSStrEqu(TSFSExtFileInfo(fFiles[c]).fName, fi.fLink) then break;
end;
Inc(c);
end;
function TSFSPlainVolumeFactory.IsMyVolumePrefix (const prefix: TSFSString): Boolean;
begin
result :=
- (SFSStrComp(prefix, 'pak') = 0) or
- //(SFSStrComp(prefix, 'wad') = 0) or // sorry
- (SFSStrComp(prefix, 'wad2') = 0) or
- (SFSStrComp(prefix, 'grp') = 0) or
- (SFSStrComp(prefix, 'spe') = 0) or
- (SFSStrComp(prefix, 'spec') = 0) or
- (SFSStrComp(prefix, 'quake') = 0) or
- (SFSStrComp(prefix, 'doom') = 0) or
- (SFSStrComp(prefix, 'duke3d') = 0) or
- (SFSStrComp(prefix, 'abuse') = 0) or
- (SFSStrComp(prefix, 'allegro') = 0) or
- (SFSStrComp(prefix, 'dune2') = 0) or
- (SFSStrComp(prefix, 'max') = 0) or
- (SFSStrComp(prefix, 'sin') = 0);
+ SFSStrEqu(prefix, 'pak') or
+ //SFSStrEqu(prefix, 'wad') or // sorry
+ SFSStrEqu(prefix, 'wad2') or
+ SFSStrEqu(prefix, 'grp') or
+ SFSStrEqu(prefix, 'spe') or
+ SFSStrEqu(prefix, 'spec') or
+ SFSStrEqu(prefix, 'quake') or
+ SFSStrEqu(prefix, 'doom') or
+ SFSStrEqu(prefix, 'duke3d') or
+ SFSStrEqu(prefix, 'abuse') or
+ SFSStrEqu(prefix, 'allegro') or
+ SFSStrEqu(prefix, 'dune2') or
+ SFSStrEqu(prefix, 'max') or
+ SFSStrEqu(prefix, 'sin');
end;
procedure TSFSPlainVolumeFactory.Recycle (vol: TSFSVolume);
diff --git a/src/sfs/sfsZipFS.pas b/src/sfs/sfsZipFS.pas
index b3a83245b24a00609629b52bf32537e68d32a251..5b6dafda3ee2e07b5a489e143f9f34798db725d5 100644 (file)
--- a/src/sfs/sfsZipFS.pas
+++ b/src/sfs/sfsZipFS.pas
function TSFSZipVolumeFactory.IsMyVolumePrefix (const prefix: TSFSString): Boolean;
begin
result :=
- (SFSStrComp(prefix, 'zip') = 0) or
- (SFSStrComp(prefix, 'jar') = 0) or
- (SFSStrComp(prefix, 'fout2') = 0) or
- (SFSStrComp(prefix, 'vtdb') = 0) or
- (SFSStrComp(prefix, 'wad') = 0) or
- (SFSStrComp(prefix, 'dfwad') = 0);
+ SFSStrEqu(prefix, 'zip') or
+ SFSStrEqu(prefix, 'jar') or
+ SFSStrEqu(prefix, 'fout2') or
+ SFSStrEqu(prefix, 'vtdb') or
+ SFSStrEqu(prefix, 'wad') or
+ SFSStrEqu(prefix, 'dfwad');
end;
procedure TSFSZipVolumeFactory.Recycle (vol: TSFSVolume);
index 8da2b385e77822c8b8254564f25dd420f993c973..79f14b6364ab88ea17d7049f6feb39caa7ec3fa2 100644 (file)
--- a/src/shared/WADEDITOR.pas
+++ b/src/shared/WADEDITOR.pas
begin
fi := fIter.Files[f];
if fi = nil then continue;
- //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s] (%d, %d)', [Section, Resource, fFileName, fi.path, fi.name, SFSStrComp(fi.path, Section), SFSStrComp(fi.name, Resource)]), MSG_NOTIFY);
- if (SFSStrComp(fi.path, Section) = 0) and (SFSStrComp(fi.name, Resource) = 0) then
+ //e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s] (%d, %d)', [Section, Resource, fFileName, fi.path, fi.name, SFSStrEqu(fi.path, Section), SFSStrEqu(fi.name, Resource)]), MSG_NOTIFY);
+ if SFSStrEqu(fi.path, Section) and SFSStrEqu(fi.name, Resource) then
begin
// i found her!
//fn := fFileName+'::'+fi.path+fi.name;
begin
fi := fIter.Files[f];
if fi = nil then continue;
- if SFSStrComp(fi.path, Section) = 0 then
+ if SFSStrEqu(fi.path, Section) then
begin
SetLength(result, Length(result)+1);
result[high(result)] := fi.name;
if not FileExists(rfn) then
begin
//if length(rfn) >= 4 then e_WriteLog(Format('XXXX TWADEditor_1.ReadFile: [%s] [%s]', [Copy(rfn, length(rfn)-3, 4), Copy(rfn, 1, length(rfn)-4)]), MSG_NOTIFY);
- if (length(rfn) >= 4) and (SFSStrComp(Copy(rfn, length(rfn)-3, 4), '.wad') = 0) then
+ if (length(rfn) >= 4) and SFSStrEqu(Copy(rfn, length(rfn)-3, 4), '.wad') then
begin
rfn := Copy(rfn, 1, length(rfn)-4);
if FileExists(rfn+'.pk3') then rfn := rfn+'.pk3'