@@ -22,13 +22,14 @@ TGenerator = class(TObject)
2222 FOutPutFile: String;
2323 FLineCount: Int64;
2424 FStationNames: TStringList;
25+ FLineEnding: String;
2526
2627 procedure BuildStationNames ;
2728 function GenerateProgressBar (APBPosition, APBMax, APBWIdth: Integer;
2829 AFileSize: Int64; ATimeElapsed: TDateTime): String;
2930 function Rng1brc (Range: Integer): Integer;
3031 public
31- constructor Create(AInputFile, AOutputFile: String; ALineCount: Int64; AOnly400Stations: Boolean = False );
32+ constructor Create(AInputFile, AOutputFile: String; ALineCount: Int64; AOnly400Stations: Boolean; ALineEnding: String );
3233 destructor Destroy; override;
3334
3435 procedure Generate ;
@@ -57,17 +58,17 @@ implementation
5758 stationsCapacity = 50000 ;
5859 chunkBatch = 10000 ;
5960 chunkCapacity = 20 * 1024 * 1024 ;
60- lineEnding = #13 #10 ;
6161 lineBreak = #13 ;
6262
6363{ TGenerator }
6464
65- constructor TGenerator.Create(AInputFile, AOutputFile: String; ALineCount: Int64; AOnly400Stations: Boolean);
65+ constructor TGenerator.Create(AInputFile, AOutputFile: String; ALineCount: Int64; AOnly400Stations: Boolean; ALineEnding: String );
6666begin
6767 FInputFile := AInputFile;
6868 FOutPutFile := AOutputFile;
6969 FLineCount := ALineCount;
7070 FOnly400Stations := AOnly400Stations;
71+ FLineEnding := ALineEnding;
7172
7273 FStationNames := TStringList.Create;
7374 FStationNames.Capacity := stationsCapacity;
@@ -193,6 +194,10 @@ procedure TGenerator.Generate;
193194 // Build list of station names
194195 BuildStationNames;
195196
197+ // initialize line ending if not corrected
198+ if FLineEnding <> #13 #10 then
199+ FLineEnding := #10 ;
200+
196201 outputFileStream := TFileStream.Create(FOutPutFile, fmCreate);
197202
198203 progressBatch := floor(FLineCount * (linesPercent / 100 ));
@@ -228,7 +233,7 @@ procedure TGenerator.Generate;
228233 for index := 0 to High(temperatureArray) do
229234 begin
230235 randomTempFinal := FormatFloat(' 0"."0' , index - 999 );
231- temperatureArray[index] := randomTempFinal + lineEnding ;
236+ temperatureArray[index] := randomTempFinal + FLineEnding ;
232237 LenTemperatureArray[index] := Length(temperatureArray[index]);
233238 end ;
234239
0 commit comments