* s[0] ->setlength(s, first round, to ease experimentation with ansistrings

git-svn-id: trunk@35970 -
This commit is contained in:
marco 2017-04-27 16:03:51 +00:00
parent ff1ee6836d
commit 75eea3c220
2 changed files with 11 additions and 11 deletions

View File

@ -547,7 +547,7 @@ end;
function CharStr(C: char; Count: byte): string; function CharStr(C: char; Count: byte): string;
var S: string; var S: string;
begin begin
S[0]:=chr(Count); setlength(s,count);
if Count>0 then FillChar(S[1],Count,C); if Count>0 then FillChar(S[1],Count,C);
CharStr:=S; CharStr:=S;
end; end;

View File

@ -269,7 +269,7 @@ procedure ReadlnFromStream(Stream: PStream; var S:string;var linecomplete,hasCR
linecomplete:=true; linecomplete:=true;
if (c=#10) then if (c=#10) then
hasCR:=true; hasCR:=true;
s[0]:=chr(i); setlength(s,i);
end; end;
procedure ReadlnFromFile(var f : file; var S:string; procedure ReadlnFromFile(var f : file; var S:string;
@ -324,13 +324,13 @@ procedure ReadlnFromFile(var f : file; var S:string;
(LastSpacePos>1) then (LastSpacePos>1) then
begin begin
{$ifdef DEBUG} {$ifdef DEBUG}
s[0]:=chr(i); setlength(s,i);
filename:=strpas(@(filerec(f).Name)); filename:=strpas(@(filerec(f).Name));
DebugMessage(filename,'s='+s,1,1); DebugMessage(filename,'s='+s,1,1);
{$endif DEBUG} {$endif DEBUG}
i:=LastSpacePos; i:=LastSpacePos;
{$ifdef DEBUG} {$ifdef DEBUG}
s[0]:=chr(i); setlength(s,i);
DebugMessage(filename,'reduced to '+s,1,1); DebugMessage(filename,'reduced to '+s,1,1);
{$endif DEBUG} {$endif DEBUG}
system.seek(f,LastSpaceFilePos); system.seek(f,LastSpaceFilePos);
@ -341,13 +341,13 @@ procedure ReadlnFromFile(var f : file; var S:string;
linecomplete:=true; linecomplete:=true;
if (c=#10) then if (c=#10) then
hasCR:=true; hasCR:=true;
s[0]:=chr(i); setlength(s,i);
end; end;
function MemToStr(var B; Count: byte): string; function MemToStr(var B; Count: byte): string;
var S: string; var S: string;
begin begin
S[0]:=chr(Count); setlength(s,count);
if Count>0 then Move(B,S[1],Count); if Count>0 then Move(B,S[1],Count);
MemToStr:=S; MemToStr:=S;
end; end;
@ -376,7 +376,7 @@ begin
end end
else if Count>255 then else if Count>255 then
Count:=255; Count:=255;
CharStr[0]:=chr(Count); setlength(CharStr,Count);
FillChar(CharStr[1],Count,C); FillChar(CharStr[1],Count,C);
end; end;
@ -389,7 +389,7 @@ begin
UpCaseStr[I]:=chr(ord(S[I])-32) UpCaseStr[I]:=chr(ord(S[I])-32)
else else
UpCaseStr[I]:=S[I]; UpCaseStr[I]:=S[I];
UpcaseStr[0]:=S[0]; Setlength(UpcaseStr,length(s));
end; end;
function RExpand(const S: string; MinLen: byte): string; function RExpand(const S: string; MinLen: byte): string;
@ -598,7 +598,7 @@ begin
i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2)); i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
if (i>0) and (i<=high(hs2)) then if (i>0) and (i<=high(hs2)) then
begin begin
hs2[0]:=chr(strlen(@hs2[1])); setlength(hs2,strlen(@hs2[1]));
GetShortName:=hs2; GetShortName:=hs2;
end; end;
{$endif} {$endif}
@ -910,7 +910,7 @@ procedure TFastBufStream.Readline(var s:string;var linecomplete,hasCR : boolean)
linecomplete:=true; linecomplete:=true;
if (c=#10) then if (c=#10) then
hasCR:=true; hasCR:=true;
s[0]:=chr(i); setlength(s,i);
end; end;