浏览代码

+ unlimited file support, release tempclose

peter 27 年之前
父节点
当前提交
f29aaf6d8a
共有 2 个文件被更改,包括 39 次插入56 次删除
  1. 31 31
      compiler/cobjects.pas
  2. 8 25
      compiler/pmodules.pas

+ 31 - 31
compiler/cobjects.pas

@@ -174,7 +174,7 @@ unit cobjects;
            tempclosed : boolean;
            tempmode : byte;
            temppos : longint;
-           
+
            { inits a buffer with the size bufsize which is assigned to }
            { the file  filename                                        }
            constructor init(const filename : string;_bufsize : longint);
@@ -214,12 +214,10 @@ unit cobjects;
            { closes the file and releases the buffer }
            procedure close;
 
-{$ifdef TEST_TEMPCLOSE}
            { temporary closing }
            procedure tempclose;
            procedure tempreopen;
-{$endif TEST_TEMPCLOSE}
-           
+
            { goto the given position }
            procedure seek(l : longint);
 
@@ -1083,52 +1081,54 @@ end;
            end;
       end;
 
-{$ifdef TEST_TEMPCLOSE}
     procedure tbufferedfile.tempclose;
 
       begin
-         if iomode<>0 then
-           begin
-              temppos:=system.filepos(f);
-              tempmode:=iomode;
-              tempclosed:=true;
-              system.close(f);
-              iomode:=0;
-           end
-         else
-           tempclosed:=false;
+        if iomode<>0 then
+         begin
+           temppos:=system.filepos(f);
+           tempmode:=iomode;
+           tempclosed:=true;
+           system.close(f);
+           iomode:=0;
+         end
+        else
+         tempclosed:=false;
       end;
 
     procedure tbufferedfile.tempreopen;
 
       var
          ofm : byte;
-         
+
       begin
          if tempclosed then
            begin
-              if tempmode=1 then
-                begin
-                   ofm:=filemode;
-                   iomode:=1;
-                   filemode:=0;
-                   system.reset(f,1);
-                   filemode:=ofm;
-                end
-              else if tempmode=2 then
-                begin
-                   iomode:=2;
-                   system.rewrite(f,1);
-                end;
+              case tempmode of
+               1 : begin
+                     ofm:=filemode;
+                     iomode:=1;
+                     filemode:=0;
+                     system.reset(f,1);
+                     filemode:=ofm;
+                   end;
+               2 : begin
+                     iomode:=2;
+                     system.rewrite(f,1);
+                   end;
+              end;
               system.seek(f,temppos);
+              tempclosed:=false;
            end;
       end;
-{$endif TEST_TEMPCLOSE}
 
 end.
 {
   $Log$
-  Revision 1.8  1998-05-20 09:42:33  pierre
+  Revision 1.9  1998-06-03 23:40:37  peter
+    + unlimited file support, release tempclose
+
+  Revision 1.8  1998/05/20 09:42:33  pierre
     + UseTokenInfo now default
     * unit in interface uses and implementation uses gives error now
     * only one error for unknown symbol (uses lastsymknown boolean)

+ 8 - 25
compiler/pmodules.pas

@@ -192,15 +192,11 @@ unit pmodules;
                    Message1(unit_f_cant_compile_unit,hp^.modulename^)
                   else
                    begin
-{$ifdef TEST_TEMPCLOSE}
                       if assigned(oldhp^.current_inputfile) then
                         oldhp^.current_inputfile^.tempclose;
-{$endif TEST_TEMPCLOSE}
                       compile(hp^.mainsource^,compile_system);
-{$ifdef TEST_TEMPCLOSE}
-                      if not oldhp^.compiled then
+                      if (not oldhp^.compiled) and assigned(oldhp^.current_inputfile) then
                         oldhp^.current_inputfile^.tempreopen;
-{$endif TEST_TEMPCLOSE}
                    end;
                   exit;
                 end;
@@ -274,15 +270,11 @@ unit pmodules;
                     Message1(unit_f_cant_compile_unit,hp^.modulename^)
                    else
                     begin
-{$ifdef TEST_TEMPCLOSE}
                        if assigned(oldhp^.current_inputfile) then
                          oldhp^.current_inputfile^.tempclose;
-{$endif TEST_TEMPCLOSE}
                        compile(hp^.mainsource^,compile_system);
-{$ifdef TEST_TEMPCLOSE}
-                       if not oldhp^.compiled then
+                       if (not oldhp^.compiled) and assigned(oldhp^.current_inputfile) then
                          oldhp^.current_inputfile^.tempreopen;
-{$endif TEST_TEMPCLOSE}
                     end;
                    exit;
                 end;
@@ -335,13 +327,9 @@ unit pmodules;
                     Message1(unit_f_cant_compile_unit,hp^.unitname^)
                    else
                      begin
-{ifdef TEST_TEMPCLOSE}
                         oldhp^.current_inputfile^.tempclose;
-{endif TEST_TEMPCLOSE}
                         compile(hp^.mainsource^,compile_system);
-{ifdef TEST_TEMPCLOSE}
                         oldhp^.current_inputfile^.tempclose;
-{endif TEST_TEMPCLOSE}
                      end;
                    exit;
                 end; *)
@@ -411,15 +399,11 @@ unit pmodules;
                     Message1(unit_f_cant_compile_unit,hp^.modulename^)
                    else
                     begin
-{$ifdef TEST_TEMPCLOSE}
                        if assigned(old_current_module^.current_inputfile) then
                          old_current_module^.current_inputfile^.tempclose;
-{$endif TEST_TEMPCLOSE}
                        compile(hp^.mainsource^,compile_system);
-{$ifdef TEST_TEMPCLOSE}
-                      if not old_current_module^.compiled then
+                      if (not old_current_module^.compiled) and assigned(old_current_module^.current_inputfile) then
                          old_current_module^.current_inputfile^.tempreopen;
-{$endif TEST_TEMPCLOSE}
                     end;
                 end
               else
@@ -480,16 +464,12 @@ unit pmodules;
                     hp^.sourcefiles.done;
                     hp^.sourcefiles.init;
 {$endif not UseBrowser}
-{$ifdef TEST_TEMPCLOSE}
                    if assigned(old_current_module^.current_inputfile) then
                      old_current_module^.current_inputfile^.tempclose;
-{$endif TEST_TEMPCLOSE}
                    Message1(parser_d_compiling_second_time,hp^.mainsource^);
                    compile(hp^.mainsource^,compile_system);
-{$ifdef TEST_TEMPCLOSE}
-                   if not old_current_module^.compiled then
+                   if (not old_current_module^.compiled) and assigned(old_current_module^.current_inputfile) then
                      old_current_module^.current_inputfile^.tempreopen;
-{$endif TEST_TEMPCLOSE}
                  end;
                 current_module^.compiled:=true;
              end;
@@ -1001,7 +981,10 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.18  1998-06-03 22:49:00  peter
+  Revision 1.19  1998-06-03 23:40:38  peter
+    + unlimited file support, release tempclose
+
+  Revision 1.18  1998/06/03 22:49:00  peter
     + wordbool,longbool
     * rename bis,von -> high,low
     * moved some systemunit loading/creating to psystem.pas