<commit_before>unit KM_CommonClasses;
{$I KaM_Remake.inc}
interface
uses
  Classes, SysUtils, KM_Points, KM_CommonTypes
  {$IFDEF WDC OR FPC_FULLVERSION >= 30200}, KM_WorkerThread{$ENDIF};

  // Delphi 11 Alexandria had bug with S.CopyFrom for TCompressionStream.
  // Bug occurs only during debugging, but its quite annoying
  // It was said this bug will be fixed in Delphi 11.1
  //
  // Related links:
  // https://quality.embarcadero.com/projects/RSP/issues/RSP-35516?filter=allopenissues
  // https://forum.fast-report.com/en/discussion/17186/tfrxpdfexport-ezcompressionerror-with-message-invalid-zstream-operation-in-delphi-11-2021-3
  // https://stackoverflow.com/questions/70242669/error-invalid-zstream-operation-delphi-11-0
  {$IFDEF VER350}{$IFDEF DEBUG} {$DEFINE NO_COMPRESSION} {$ENDIF}{$ENDIF}


type
  TKMSaveStreamFormat = (ssfBinary, ssfText);

  TKMemoryStream = class(TMemoryStream)
  private
    fShouldBeCompressed: Boolean; // Flag to show if current stream should be compressed (either while save or load operations)

    procedure AppendNotCompressedStream(aStream: TKMemoryStream; const aMarker: string);
    procedure CompressAndAppendStream(aStream: TKMemoryStream; const aMarker: string);
  public
    constructor Create(aShouldBeCompressed: Boolean = False);
<commit_msg>Compilation directives: detect Delphi 11.1, where compression bug was fixed<commit_after>unit KM_CommonClasses;
{$I KaM_Remake.inc}
interface
uses
  Classes, SysUtils, KM_Points, KM_CommonTypes
  {$IFDEF WDC OR FPC_FULLVERSION >= 30200}, KM_WorkerThread{$ENDIF};

  // Delphi 11 Alexandria had bug with S.CopyFrom for TCompressionStream.
  // Bug occurs only during debugging, but its quite annoying
  // It was fixed in Delphi 11.1
  // RTLVersion111 Define is used to determine Delphi 11.1 over Delphi 11
  //
  // Related links:
  // https://quality.embarcadero.com/projects/RSP/issues/RSP-35516?filter=allopenissues
  // https://forum.fast-report.com/en/discussion/17186/tfrxpdfexport-ezcompressionerror-with-message-invalid-zstream-operation-in-delphi-11-2021-3
  // https://stackoverflow.com/questions/70242669/error-invalid-zstream-operation-delphi-11-0
  {$IFDEF VER350}{$IF NOT RTLVersion111}{$IFDEF DEBUG} {$DEFINE NO_COMPRESSION} {$ENDIF}{$ENDIF}{$ENDIF}


type
  TKMSaveStreamFormat = (ssfBinary, ssfText);

  TKMemoryStream = class(TMemoryStream)
  private
    fShouldBeCompressed: Boolean; // Flag to show if current stream should be compressed (either while save or load operations)

    procedure AppendNotCompressedStream(aStream: TKMemoryStream; const aMarker: string);
    procedure CompressAndAppendStream(aStream: TKMemoryStream; const aMarker: string);
  public
    constructor Create(aShouldBeCompressed: Boolean = False);

{'fraction_non_alphanumeric': 0.10192937750273025, 'fraction_numerical': 0.03494721514379323, 'mean_word_length': 4.809725158562368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5301765', 'n_tokens_mistral': 956, 'n_tokens_neox': 853, 'n_words': 211}