A little further changing is needed to let it work as suspected. Even if the macro is included via include file. In my first writing I didn't recognize that the calling of insertmacro for _ID token is done with mac.fileinfo.line and .fileindex, which is the point of definition.
Changed to current_scanner.line_no and current_scanner.inputfile.ref_index. Is this a problem for error recognition?, I think not, because the info from the defining context is saved in the tmacro class. Best regards Jörg
Index: compiler/fmodule.pas =================================================================== --- compiler/fmodule.pas (Revision 17417) +++ compiler/fmodule.pas (Arbeitskopie) @@ -235,6 +235,7 @@ function get_source_file(moduleindex,fileindex : longint) : tinputfile; procedure addloadedunit(hp:tmodule); function find_module_from_symtable(st:tsymtable):tmodule; + function ascend_from_macros(f:tinputfile) : tinputfile; implementation @@ -336,6 +337,13 @@ end; + function ascend_from_macros(f:tinputfile) : tinputfile; + begin + while assigned(f) and f.is_macro do f:=f.next; + ascend_from_macros:=f; + end; + + procedure addloadedunit(hp:tmodule); begin hp.moduleid:=loaded_units.count; Index: compiler/scanner.pas =================================================================== --- compiler/scanner.pas (Revision 17417) +++ compiler/scanner.pas (Arbeitskopie) @@ -1712,11 +1712,24 @@ hs:=getdatestr else if hs='FILE' then - hs:=current_module.sourcefiles.get_file_name(current_filepos.fileindex) + begin + hp:=ascend_from_macros(current_module.sourcefiles.get_file(current_filepos.fileindex)); + if assigned(hp) then hs:=hp.name^ else hs:='unknown' + end else if hs='LINE' then - hs:=tostr(current_filepos.line) + begin + hp:=ascend_from_macros(current_module.sourcefiles.get_file(current_filepos.fileindex)); + if assigned(hp) then hs:=tostr(hp.saveline_no) else hs:='unknown' + end else + if hs='PATH' then + begin + hp:=ascend_from_macros(current_module.sourcefiles.get_file(current_filepos.fileindex)); + if assigned(hp) then hs:=hp.path^ else hs:='unknown'; + if hs='' then hs:=CurDirRelPath(target_info) + end + else if hs='FPCVERSION' then hs:=version_string else @@ -3473,7 +3486,7 @@ mac.is_used:=true; inc(yylexcount); insertmacro(pattern,mac.buftext,mac.buflen, - mac.fileinfo.line,mac.fileinfo.fileindex); + current_scanner.line_no,current_scanner.inputfile.ref_index); { handle empty macros } if c=#0 then reload;
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel