Skip to content

Commit 9fb3dd0

Browse files
committed
LF support and fixed rounding in the Lurendrejer Aksen version
1 parent d721900 commit 9fb3dd0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

entries/laksen/src/laksen.lpr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
{$mode objfpc}{$h+}
44

5+
{$define LFONLY}
6+
57
uses
68
cthreads,
79
SysUtils,
@@ -212,15 +214,17 @@ TParser = class
212214
ptr := @pbyte(@ABuffer)[offset];
213215
lineEnd := IndexChar(ptr^, remainder, #$A);
214216

217+
{$IFNDEF LFONLY}
215218
// Mark EOL
216219
ptr[lineEnd-1] := 0;
220+
{$ENDIF}
217221

218222
// Find delimiter and add null terminator
219-
delim := IndexChar(ptr^, lineEnd-2, ';');
223+
delim := IndexChar(ptr^, lineEnd-{$IFNDEF LFONLY}2{$ELSE}1{$ENDIF}, ';');
220224
ptr[delim] := 0;
221225

222226
tempStart := PChar(@ptr[delim+1]);
223-
tempLen := lineEnd-2-delim;
227+
tempLen := lineEnd-{$IFNDEF LFONLY}2{$ELSE}1{$ENDIF}-delim;
224228
tempNeg := False;
225229

226230
if tempStart^ = '-' then
@@ -294,7 +298,7 @@ TParser = class
294298

295299
function AsNum(AValue, ACount: longint): string;
296300
begin
297-
Result := formatfloat('0.0', RoundExDouble(AValue/ACount)/10);
301+
Result := formatfloat('0.0', RoundExDouble(AValue/(ACount * 10)));
298302
end;
299303

300304
procedure TParser.Dump;
@@ -482,4 +486,4 @@ TParser = class
482486
p.Parse(threads);
483487
p.Dump();
484488
p.Free;
485-
end.
489+
end.

0 commit comments

Comments
 (0)