nielsAD / lape

Scripting engine with Pascal-like syntax for FPC and Delphi
118 stars 28 forks source link

Macro's & FDefines | FBaseDefines doesn't get along - A fix: #122

Closed slackydev closed 5 years ago

slackydev commented 6 years ago

So I don't have time to make this PR, but I can publish what needs to be changed:

Navigate to line 3182 in the file lpcompiler change the FDefine and FBaseDefines separators to something that wont conflict with any code, including that we need multiline defines to work, so lineending is changed as well.

  FDefines := TStringList.Create();
  FDefines.Duplicates := dupIgnore;
  FDefines.CaseSensitive := LapeCaseSensitive;
  FDefines.LineBreak := #1;          // use none-pascal symbols
  FDefines.Delimiter := #2;          //
  FDefines.NameValueSeparator := #3; //
  FConditionalStack := TLapeConditionalStack.Create(0);

  FOnHandleDirective := nil;
  FOnHandleExternal := nil;
  FOnFindFile := nil;
  FAfterParsing := TLapeCompilerNotification.Create();

  FBaseDefines := TStringList.Create();
  FBaseDefines.CaseSensitive := LapeCaseSensitive;
  FBaseDefines.LineBreak := #1;          // use none-pascal symbols
  FBaseDefines.Delimiter := #2;          //
  FBaseDefines.NameValueSeparator := #3; //

See the comments, that's what I added. Now due to the horrible way it's designed, there exists a chance strings containing one of the above characters could break it, that I actually dont know. But who the fuck write #1 and #2 and #3 to a freaking string.. That said, TStringList should probably just not be used for this.