Browse Source

* fix for bug #2004 merged

pierre 23 years ago
parent
commit
0aceb4b76b
1 changed files with 14 additions and 6 deletions
  1. 14 6
      compiler/scanner.pas

+ 14 - 6
compiler/scanner.pas

@@ -52,6 +52,7 @@ interface
           is_used : boolean;
           is_used : boolean;
           buftext : pchar;
           buftext : pchar;
           buflen  : longint;
           buflen  : longint;
+          fileinfo : tfileposinfo;
           constructor Create(const n : string);
           constructor Create(const n : string);
           destructor  destroy;override;
           destructor  destroy;override;
        end;
        end;
@@ -117,7 +118,7 @@ interface
           procedure nextfile;
           procedure nextfile;
           procedure addfile(hp:tinputfile);
           procedure addfile(hp:tinputfile);
           procedure reload;
           procedure reload;
-          procedure insertmacro(const macname:string;p:pchar;len:longint);
+          procedure insertmacro(const macname:string;p:pchar;len,line,fileindex:longint);
         { Scanner things }
         { Scanner things }
           procedure def_macro(const s : string);
           procedure def_macro(const s : string);
           procedure set_macro(const s : string;value : string);
           procedure set_macro(const s : string;value : string);
@@ -737,7 +738,8 @@ implementation
             Message1(scan_w_include_env_not_found,path);
             Message1(scan_w_include_env_not_found,path);
            { make it a stringconst }
            { make it a stringconst }
            hs:=''''+hs+'''';
            hs:=''''+hs+'''';
-           current_scanner.insertmacro(path,@hs[1],length(hs));
+           current_scanner.insertmacro(path,@hs[1],length(hs),
+            current_scanner.line_no,current_scanner.inputfile.ref_index);
          end
          end
         else
         else
          begin
          begin
@@ -789,6 +791,7 @@ implementation
          inherited createname(n);
          inherited createname(n);
          defined:=true;
          defined:=true;
          defined_at_startup:=false;
          defined_at_startup:=false;
+         fileinfo:=akttokenpos;
          is_used:=false;
          is_used:=false;
          buftext:=nil;
          buftext:=nil;
          buflen:=0;
          buflen:=0;
@@ -1148,7 +1151,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tscannerfile.insertmacro(const macname:string;p:pchar;len:longint);
+    procedure tscannerfile.insertmacro(const macname:string;p:pchar;len,line,fileindex:longint);
       var
       var
         hp : tinputfile;
         hp : tinputfile;
       begin
       begin
@@ -1168,9 +1171,10 @@ implementation
            inputbuffer:=buf;
            inputbuffer:=buf;
            inputpointer:=buf;
            inputpointer:=buf;
            inputstart:=bufstart;
            inputstart:=bufstart;
+           ref_index:=fileindex;
          end;
          end;
       { reset line }
       { reset line }
-        line_no:=0;
+        line_no:=line;
         lastlinepos:=0;
         lastlinepos:=0;
         lasttokenpos:=0;
         lasttokenpos:=0;
       { load new c }
       { load new c }
@@ -2049,7 +2053,8 @@ implementation
                  mac:=tmacro(macros.search(pattern));
                  mac:=tmacro(macros.search(pattern));
                  if assigned(mac) and (assigned(mac.buftext)) then
                  if assigned(mac) and (assigned(mac.buftext)) then
                   begin
                   begin
-                    insertmacro(pattern,mac.buftext,mac.buflen);
+                    insertmacro(pattern,mac.buftext,mac.buflen,
+                      mac.fileinfo.line,mac.fileinfo.fileindex);
                   { handle empty macros }
                   { handle empty macros }
                     if c=#0 then
                     if c=#0 then
                      begin
                      begin
@@ -2775,7 +2780,10 @@ exit_label:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.44  2002-08-12 16:46:04  peter
+  Revision 1.45  2002-09-05 14:17:27  pierre
+   * fix for bug 2004 merged
+
+  Revision 1.44  2002/08/12 16:46:04  peter
     * tscannerfile is now destroyed in tmodule.reset and current_scanner
     * tscannerfile is now destroyed in tmodule.reset and current_scanner
       is updated accordingly. This removes all the loading and saving of
       is updated accordingly. This removes all the loading and saving of
       the old scanner and the invalid flag marking
       the old scanner and the invalid flag marking