* Replaced hacks with resetting 'c' to zero and decreasing inputpointer by boolean parameter to skipcomment and skipoldtpcomment. This parameter specifies whether first character of comment should be read.

- in_asm_string also rendered useless by r32828, removed.

git-svn-id: trunk@32836 -
This commit is contained in:
sergei 2016-01-03 17:07:15 +00:00
parent d4d4689914
commit f69f6336e9
4 changed files with 17 additions and 36 deletions

View File

@ -417,8 +417,7 @@ const
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
if c='*' then if c='*' then
begin begin
scanner.c:=#0;{Signal skipoldtpcomment to reload a char } current_scanner.skipoldtpcomment(true);
current_scanner.skipoldtpcomment;
GetToken; GetToken;
end end
else else
@ -532,7 +531,7 @@ const
end; end;
'{' : begin '{' : begin
current_scanner.skipcomment; current_scanner.skipcomment(true);
GetToken; GetToken;
end; end;

View File

@ -574,7 +574,6 @@ unit raatt;
'''' : { char } '''' : { char }
begin begin
current_scanner.in_asm_string:=true;
actasmpattern:=''; actasmpattern:='';
repeat repeat
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
@ -599,13 +598,11 @@ unit raatt;
until false; until false;
actasmpattern:=EscapeToPascal(actasmpattern); actasmpattern:=EscapeToPascal(actasmpattern);
actasmtoken:=AS_STRING; actasmtoken:=AS_STRING;
current_scanner.in_asm_string:=false;
exit; exit;
end; end;
'"' : { string } '"' : { string }
begin begin
current_scanner.in_asm_string:=true;
actasmpattern:=''; actasmpattern:='';
repeat repeat
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
@ -630,7 +627,6 @@ unit raatt;
until false; until false;
actasmpattern:=EscapeToPascal(actasmpattern); actasmpattern:=EscapeToPascal(actasmpattern);
actasmtoken:=AS_STRING; actasmtoken:=AS_STRING;
current_scanner.in_asm_string:=false;
exit; exit;
end; end;
@ -671,12 +667,11 @@ unit raatt;
actasmtoken:=AS_LSBRACKET actasmtoken:=AS_LSBRACKET
else else
begin begin
dec(current_scanner.inputpointer); current_scanner.skipcomment(false);
current_scanner.skipcomment;
GetToken; GetToken;
end; end;
{$else arm} {$else arm}
current_scanner.skipcomment; current_scanner.skipcomment(true);
GetToken; GetToken;
{$endif arm} {$endif arm}
exit; exit;
@ -743,8 +738,7 @@ unit raatt;
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
if c='*' then if c='*' then
begin begin
scanner.c:=#0;{Signal skipoldtpcomment to reload a char } current_scanner.skipoldtpcomment(true);
current_scanner.skipoldtpcomment;
GetToken; GetToken;
end end
else else

View File

@ -139,7 +139,6 @@ interface
ignoredirectives : TFPHashList; { ignore directives, used to give warnings only once } ignoredirectives : TFPHashList; { ignore directives, used to give warnings only once }
preprocstack : tpreprocstack; preprocstack : tpreprocstack;
replaystack : treplaystack; replaystack : treplaystack;
in_asm_string : boolean;
preproc_pattern : string; preproc_pattern : string;
preproc_token : ttoken; preproc_token : ttoken;
@ -215,9 +214,9 @@ interface
function readstatedefault:char; function readstatedefault:char;
procedure skipspace; procedure skipspace;
procedure skipuntildirective; procedure skipuntildirective;
procedure skipcomment; procedure skipcomment(read_first_char:boolean);
procedure skipdelphicomment; procedure skipdelphicomment;
procedure skipoldtpcomment; procedure skipoldtpcomment(read_first_char:boolean);
procedure readtoken(allowrecordtoken:boolean); procedure readtoken(allowrecordtoken:boolean);
function readpreproc:ttoken; function readpreproc:ttoken;
function asmgetchar:char; function asmgetchar:char;
@ -2649,7 +2648,6 @@ type
lasttoken:=NOTOKEN; lasttoken:=NOTOKEN;
nexttoken:=NOTOKEN; nexttoken:=NOTOKEN;
ignoredirectives:=TFPHashList.Create; ignoredirectives:=TFPHashList.Create;
in_asm_string:=false;
end; end;
@ -4373,7 +4371,7 @@ type
end end
else else
begin begin
skipoldtpcomment; skipoldtpcomment(false);
next_char_loaded:=true; next_char_loaded:=true;
end; end;
end end
@ -4410,10 +4408,11 @@ type
Comment Handling Comment Handling
****************************************************************************} ****************************************************************************}
procedure tscannerfile.skipcomment; procedure tscannerfile.skipcomment(read_first_char:boolean);
begin begin
current_commentstyle:=comment_tp; current_commentstyle:=comment_tp;
readchar; if read_first_char then
readchar;
inc_comment_level; inc_comment_level;
{ handle compiler switches } { handle compiler switches }
if (c='$') then if (c='$') then
@ -4458,7 +4457,7 @@ type
end; end;
procedure tscannerfile.skipoldtpcomment; procedure tscannerfile.skipoldtpcomment(read_first_char:boolean);
var var
found : longint; found : longint;
begin begin
@ -4466,7 +4465,7 @@ type
inc_comment_level; inc_comment_level;
{ only load a char if last already processed, { only load a char if last already processed,
was cause of bug1634 PM } was cause of bug1634 PM }
if c=#0 then if read_first_char then
readchar; readchar;
{ this is now supported } { this is now supported }
if (c='$') then if (c='$') then
@ -4574,7 +4573,7 @@ type
repeat repeat
case c of case c of
'{' : '{' :
skipcomment; skipcomment(true);
#26 : #26 :
begin begin
reload; reload;
@ -4813,8 +4812,7 @@ type
case c of case c of
'*' : '*' :
begin begin
c:=#0;{Signal skipoldtpcomment to reload a char } skipoldtpcomment(true);
skipoldtpcomment;
readtoken(false); readtoken(false);
exit; exit;
end; end;
@ -5498,11 +5496,6 @@ exit_label:
function tscannerfile.asmgetchar : char; function tscannerfile.asmgetchar : char;
begin begin
readchar; readchar;
if in_asm_string then
begin
asmgetchar:=c;
exit;
end;
repeat repeat
case c of case c of
#26 : #26 :

View File

@ -425,7 +425,6 @@ Unit Rax86int;
'''' : { string or character } '''' : { string or character }
begin begin
actasmpattern:=''; actasmpattern:='';
current_scanner.in_asm_string:=true;
repeat repeat
if c = '''' then if c = '''' then
begin begin
@ -467,14 +466,12 @@ Unit Rax86int;
else else
break; { end if } break; { end if }
until false; until false;
current_scanner.in_asm_string:=false;
actasmtoken:=AS_STRING; actasmtoken:=AS_STRING;
exit; exit;
end; end;
'"' : { string or character } '"' : { string or character }
begin begin
current_scanner.in_asm_string:=true;
actasmpattern:=''; actasmpattern:='';
repeat repeat
if c = '"' then if c = '"' then
@ -517,7 +514,6 @@ Unit Rax86int;
else else
break; { end if } break; { end if }
until false; until false;
current_scanner.in_asm_string:=false;
actasmtoken:=AS_STRING; actasmtoken:=AS_STRING;
exit; exit;
end; end;
@ -575,8 +571,7 @@ Unit Rax86int;
c:=current_scanner.asmgetchar; c:=current_scanner.asmgetchar;
if c='*' then if c='*' then
begin begin
scanner.c:=#0;{Signal skipoldtpcomment to reload a char } current_scanner.skipoldtpcomment(true);
current_scanner.skipoldtpcomment;
GetToken; GetToken;
end end
else else
@ -725,7 +720,7 @@ Unit Rax86int;
'{': '{':
begin begin
current_scanner.skipcomment; current_scanner.skipcomment(true);
GetToken; GetToken;
end; end;