diff options
author | Erich Eckner <git@eckner.net> | 2020-07-03 11:30:48 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2020-07-03 11:30:48 +0200 |
commit | 93c56550a45fb7061a16bbd50f0ee5efe5d49b6c (patch) | |
tree | e39e78a7f03f8018b5f05e73781015055c6a99ce | |
parent | 2fd3fe7404cdaf41b898d2e830ec970c0e073eac (diff) | |
download | units-93c56550a45fb7061a16bbd50f0ee5efe5d49b6c.tar.xz |
lowlevelunit.pas: readALine() und readAnAndorString() sind nun function statt procedure - workaround für fpc-3.2.0 regression
-rw-r--r-- | lowlevelunit.pas | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lowlevelunit.pas b/lowlevelunit.pas index b9036e2..e87e383 100644 --- a/lowlevelunit.pas +++ b/lowlevelunit.pas @@ -171,9 +171,9 @@ function permutation(len,rest,maxBasis: longint; basen: tLongintArray): tLongint procedure llPermutation(len,offset: longint; var ar: tLongintArray); inline; procedure fuegeSortiertHinzu(x: extended; var xa: tExtendedArray); -procedure readALine(var f: file; out s: string); -procedure readAnAndorString(var f: file; out s: string; const len: int64; checkEOL: boolean); overload; -procedure readAnAndorString(var f: file; out s: string; checkEOL: boolean); overload; +function readALine(var f: file): string; +function readAnAndorString(var f: file; const len: int64; checkEOL: boolean): string; overload; +function readAnAndorString(var f: file; checkEOL: boolean): string; overload; procedure splitStrToInt(s: string; out ia: tLongintArray); function intArrayToStr(ia: tLongintArray): string; @@ -1383,43 +1383,43 @@ begin xa[mi]:=x; end; -procedure readALine(var f: file; out s: string); +function readALine(var f: file): string; var fPos,fSize,rLen: int64; begin fPos:=filePos(f); fSize:=fileSize(f); rLen:=0; - s:=''; - while (pos(#10,s)=0) and (rLen+fPos<fSize) do begin + result:=''; + while (pos(#10,result)=0) and (rLen+fPos<fSize) do begin rLen:=min(rLen+1024,fSize-fPos); - setLength(s,rLen); - blockRead(f,s[1],rLen); + setLength(result,rLen); + blockRead(f,result[1],rLen); seek(f,fPos); end; - if pos(#10,s)<>0 then begin - rLen:=pos(#10,s); - setLength(s,rLen-1); + if pos(#10,result)<>0 then begin + rLen:=pos(#10,result); + setLength(result,rLen-1); end; seek(f,fPos+rLen); end; -procedure readAnAndorString(var f: file; out s: string; const len: int64; checkEOL: boolean); +function readAnAndorString(var f: file; const len: int64; checkEOL: boolean): string; begin - setLength(s,len+2*byte(checkEOL)); - if length(s)>0 then - blockRead(f,s[1],length(s)); + setLength(result,len+2*byte(checkEOL)); + if length(result)>0 then + blockRead(f,result[1],length(result)); if checkEOL then begin - if rightStr(s,2)<>' '#10 then - raise exception.create('readAnAndorString: EOL check failed: '''+s+'''!'); - setLength(s,length(s)-2); + if rightStr(result,2)<>' '#10 then + raise exception.create('readAnAndorString: EOL check failed: '''+result+'''!'); + setLength(result,length(result)-2); end; end; -procedure readAnAndorString(var f: file; out s: string; checkEOL: boolean); +function readAnAndorString(var f: file; checkEOL: boolean): string; begin - readALine(f,s); - readAnAndorString(f,s,strToInt64(s),checkEOL); + result:=readALine(f); + result:=readAnAndorString(f,strToInt64(result),checkEOL); end; procedure splitStrToInt(s: string; out ia: tLongintArray); |