mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 12:49:20 +02:00
* Address error found in pas2js+test
This commit is contained in:
parent
1cda7d8e36
commit
012dab8bd3
@ -4032,26 +4032,29 @@ var
|
||||
i : Integer;
|
||||
|
||||
begin
|
||||
i:=MultilineStringsTrimLeft;
|
||||
if I=-1 then
|
||||
// auto unindent -> use line indent of first line
|
||||
I:=StartPos+1;
|
||||
if I>0 then
|
||||
// Start of line, take indent into account
|
||||
if ({$ifdef UsePChar}TokenStart=PAnsichar(FCurLine){$ELSE}Tokenstart=1{$ENDIF}) then
|
||||
begin
|
||||
// fixed unindent -> remove up to I leading spaces
|
||||
While ({$ifdef UsePChar} TokenStart^{$ELSE}FCurLine[TokenStart]{$ENDIF} in [' ',#9]) and (TokenStart<=FTokenPos) and (I>0) do
|
||||
i:=MultilineStringsTrimLeft;
|
||||
if I=-1 then
|
||||
// auto unindent -> use line indent of first line
|
||||
I:=StartPos+1;
|
||||
if I>0 then
|
||||
begin
|
||||
Inc(TokenStart);
|
||||
Dec(I);
|
||||
// fixed unindent -> remove up to I leading spaces
|
||||
While ({$ifdef UsePChar} TokenStart^{$ELSE}FCurLine[TokenStart]{$ENDIF} in [' ',#9]) and (TokenStart<=FTokenPos) and (I>0) do
|
||||
begin
|
||||
Inc(TokenStart);
|
||||
Dec(I);
|
||||
end;
|
||||
end
|
||||
else if I=-2 then
|
||||
begin
|
||||
// no indent -> remove all leading spaces
|
||||
While ({$ifdef UsePChar} TokenStart^{$ELSE}FCurLine[TokenStart]{$ENDIF} in [' ',#9]) and (TokenStart<=FTokenPos) do
|
||||
Inc(TokenStart);
|
||||
end;
|
||||
end
|
||||
else if I=-2 then
|
||||
begin
|
||||
// no indent -> remove all leading spaces
|
||||
While ({$ifdef UsePChar} TokenStart^{$ELSE}FCurLine[TokenStart]{$ENDIF} in [' ',#9]) and (TokenStart<=FTokenPos) do
|
||||
Inc(TokenStart);
|
||||
end;
|
||||
|
||||
{$ifdef UsePChar}
|
||||
Add(TokenStart,FTokenPos - TokenStart);
|
||||
{$else}
|
||||
@ -4189,6 +4192,9 @@ begin
|
||||
AddToCurString(false);
|
||||
AddApostroph;
|
||||
TokenStart := FTokenPos;
|
||||
// Can happen if the last char on the line was the quote..
|
||||
if ({$ifdef UsePChar}FTokenPos[0] = #0{$else}FTokenPos>l{$endif}) then
|
||||
Dec(FTokenPos);
|
||||
end;
|
||||
end;
|
||||
Inc(FTokenPos);
|
||||
|
@ -138,6 +138,7 @@ type
|
||||
procedure TestMultilineStringTrimAll;
|
||||
procedure TestMultilineStringTrimAuto;
|
||||
procedure TestMultilineStringTrim2;
|
||||
procedure TestMultilineStringQuoted;
|
||||
Procedure TestDelphiMultiLine;
|
||||
procedure TestDelphiMultiLineNotEnabled;
|
||||
procedure TestDelphiMultiLineWrongIndent;
|
||||
@ -925,6 +926,23 @@ begin
|
||||
AssertEquals('Correct trim 2',S2,TestTokenString);
|
||||
end;
|
||||
|
||||
procedure TTestScanner.TestMultilineStringQuoted;
|
||||
|
||||
const Src = '`'+sLineBreak+
|
||||
'message: ''DataNodeProcessor "'' + this.nodeID + ''" already waiting for data'''+sLineBreak+
|
||||
'`';
|
||||
Res = #39+sLineBreak+
|
||||
'message: ''''DataNodeProcessor "'''' + this.nodeID + ''''" already waiting for data'''''+sLineBreak+
|
||||
'''';
|
||||
begin
|
||||
SCanner.MultilineStringsTrimLeft:=2;
|
||||
Scanner.CurrentModeSwitches:=[msMultiLineStrings];
|
||||
Scanner.MultilineStringsEOLStyle:=elLF;
|
||||
Scanner.SkipWhiteSpace:=True;
|
||||
DoTestToken(pscanner.tkString,Src);
|
||||
AssertEquals('Correct trim',Res,TestTokenString);
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestScanner.DoTestDelphiMultiLineString;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user