Browse Source

+ added maxExitCode to all System.pp
* constrained error code to be below maxExitCode in RunError et. al.

olle 21 years ago
parent
commit
9a4855aa43

+ 6 - 1
rtl/atari/system.pas

@@ -43,6 +43,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
  FileNameCaseSensitive = false;
  FileNameCaseSensitive = false;
+ maxExitCode = 255;
 
 
  sLineBreak: string [1] = LineEnding;
  sLineBreak: string [1] = LineEnding;
     { used for single computations }
     { used for single computations }
@@ -765,7 +766,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2004-01-20 23:05:31  hajny
+  Revision 1.11  2004-09-03 19:25:21  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.10  2004/01/20 23:05:31  hajny
     * ExecuteProcess fixes, ProcessID and ThreadID added
     * ExecuteProcess fixes, ProcessID and ThreadID added
 
 
   Revision 1.9  2003/10/25 23:42:35  hajny
   Revision 1.9  2003/10/25 23:42:35  hajny

+ 6 - 1
rtl/beos/system.pp

@@ -41,6 +41,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ':';
  PathSeparator = ':';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
+ maxExitCode = 255;
 
 
 const
 const
   FileNameCaseSensitive : boolean = true;
   FileNameCaseSensitive : boolean = true;
@@ -549,7 +550,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2004-06-21 18:50:51  olle
+  Revision 1.15  2004-09-03 19:25:32  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.14  2004/06/21 18:50:51  olle
     + cleanup
     + cleanup
 
 
   Revision 1.13  2004/06/17 16:16:13  peter
   Revision 1.13  2004/06/17 16:16:13  peter

+ 6 - 1
rtl/emx/system.pas

@@ -42,6 +42,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
+ maxExitCode = 255;
 
 
 type    Tos=(osDOS,osOS2,osDPMI);
 type    Tos=(osDOS,osOS2,osDPMI);
 
 
@@ -1332,7 +1333,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2004-07-24 01:15:25  hajny
+  Revision 1.27  2004-09-03 19:25:41  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.26  2004/07/24 01:15:25  hajny
     * simulated support for new heap manager
     * simulated support for new heap manager
 
 
   Revision 1.25  2004/05/16 20:39:59  hajny
   Revision 1.25  2004/05/16 20:39:59  hajny

+ 6 - 1
rtl/go32v2/system.pp

@@ -48,6 +48,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
+ maxExitCode = 255;
 
 
 
 
 const
 const
@@ -1622,7 +1623,11 @@ Begin
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.37  2004-06-20 09:24:40  peter
+  Revision 1.38  2004-09-03 19:25:49  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.37  2004/06/20 09:24:40  peter
   fixed go32v2 compile
   fixed go32v2 compile
 
 
   Revision 1.36  2004/06/17 16:16:13  peter
   Revision 1.36  2004/06/17 16:16:13  peter

+ 14 - 6
rtl/inc/system.inc

@@ -709,10 +709,12 @@ begin
   If pointer(ErrorProc)<>Nil then
   If pointer(ErrorProc)<>Nil then
     ErrorProc(Errno,addr,frame);
     ErrorProc(Errno,addr,frame);
   errorcode:=word(Errno);
   errorcode:=word(Errno);
-  exitcode:=word(Errno);
   erroraddr:=addr;
   erroraddr:=addr;
   errorbase:=frame;
   errorbase:=frame;
-  halt(errorcode);
+  if errorcode <= maxExitCode then
+    halt(errorcode)
+  else
+    halt(255)
 end;
 end;
 
 
 Procedure HandleErrorFrame (Errno : longint;frame : Pointer);
 Procedure HandleErrorFrame (Errno : longint;frame : Pointer);
@@ -736,13 +738,15 @@ begin
 end;
 end;
 
 
 
 
-procedure runerror(w : word);[alias: 'FPC_RUNERROR'];
+procedure RunError(w : word);[alias: 'FPC_RUNERROR'];
 begin
 begin
   errorcode:=w;
   errorcode:=w;
-  exitcode:=w;
   erroraddr:=get_caller_addr(get_frame);
   erroraddr:=get_caller_addr(get_frame);
   errorbase:=get_caller_frame(get_frame);
   errorbase:=get_caller_frame(get_frame);
-  halt(errorcode);
+  if errorcode <= maxExitCode then
+    halt(errorcode)
+  else
+    halt(255)
 end;
 end;
 
 
 
 
@@ -883,7 +887,11 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.63  2004-08-31 12:23:53  jonas
+  Revision 1.64  2004-09-03 19:26:01  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.63  2004/08/31 12:23:53  jonas
     * fixed compilation with 1.0.x
     * fixed compilation with 1.0.x
 
 
   Revision 1.62  2004/08/30 17:36:18  jonas
   Revision 1.62  2004/08/30 17:36:18  jonas

+ 9 - 1
rtl/macos/system.pp

@@ -35,6 +35,8 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ',';  {Is used in MPW and OzTeX}
  PathSeparator = ',';  {Is used in MPW and OzTeX}
  FileNameCaseSensitive = false;
  FileNameCaseSensitive = false;
+ 
+ maxExitCode = 65535;
 
 
 { include heap support headers }
 { include heap support headers }
 {$I heaph.inc}
 {$I heaph.inc}
@@ -49,6 +51,8 @@ const
   sLineBreak = LineEnding;
   sLineBreak = LineEnding;
   DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCR;
   DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCR;
 
 
+
+
 var
 var
   argc : longint;
   argc : longint;
   argv : ppchar;
   argv : ppchar;
@@ -1296,7 +1300,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2004-08-20 10:18:15  olle
+  Revision 1.20  2004-09-03 19:26:08  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.19  2004/08/20 10:18:15  olle
     + added Yield routine
     + added Yield routine
 
 
   Revision 1.18  2004/07/14 23:34:07  olle
   Revision 1.18  2004/07/14 23:34:07  olle

+ 6 - 1
rtl/morphos/system.pp

@@ -39,6 +39,7 @@ const
   DirectorySeparator = '/';
   DirectorySeparator = '/';
   DriveSeparator = ':';
   DriveSeparator = ':';
   PathSeparator = ';';
   PathSeparator = ';';
+  maxExitCode = 255;
 
 
 const
 const
   UnusedHandle    : LongInt = -1;
   UnusedHandle    : LongInt = -1;
@@ -917,7 +918,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.18  2004-08-09 00:12:40  karoly
+  Revision 1.19  2004-09-03 19:26:15  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.18  2004/08/09 00:12:40  karoly
     * changes to work with updated doslib includes
     * changes to work with updated doslib includes
 
 
   Revision 1.17  2004/08/03 15:59:41  karoly
   Revision 1.17  2004/08/03 15:59:41  karoly

+ 6 - 2
rtl/netware/system.pp

@@ -43,7 +43,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
-
+ maxExitCode = 255;
 
 
 { include heap support headers }
 { include heap support headers }
 {$I heaph.inc}
 {$I heaph.inc}
@@ -889,7 +889,11 @@ Begin
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2004-08-01 20:02:48  armin
+  Revision 1.25  2004-09-03 19:26:27  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.24  2004/08/01 20:02:48  armin
   * changed dir separator from \ to /
   * changed dir separator from \ to /
   * long namespace by default
   * long namespace by default
   * dos.exec implemented
   * dos.exec implemented

+ 19 - 4
rtl/objpas/sysconst.pp

@@ -104,6 +104,8 @@ resourcestring
   SVarTypeTooManyCustom         = 'Too many custom variant types have been registered';
   SVarTypeTooManyCustom         = 'Too many custom variant types have been registered';
   SVarUnexpected                = 'Unexpected variant error';
   SVarUnexpected                = 'Unexpected variant error';
       
       
+  SFallbackError                = 'An error, whose error code is larger than can be returned to the OS, has occured';
+
   SNoToolserver                 = 'Toolserver is not installed, cannot execute Tool';
   SNoToolserver                 = 'Toolserver is not installed, cannot execute Tool';
 
 
   SShortMonthNameJan = 'Jan';
   SShortMonthNameJan = 'Jan';
@@ -148,11 +150,11 @@ resourcestring
   SLongDayNameSat = 'Saturday';
   SLongDayNameSat = 'Saturday';
   SLongDayNameSun = 'Sunday';
   SLongDayNameSun = 'Sunday';
 
 
-Function GetRunError(Errno : Byte) : String;
+Function GetRunError(Errno : Word) : String;
 
 
 Implementation
 Implementation
 
 
-Function GetRunError(Errno : Byte) : String;
+Function GetRunError(Errno : Word) : String;
 
 
 begin
 begin
   Case Errno Of
   Case Errno Of
@@ -197,8 +199,17 @@ begin
      231 : Result:=SExceptionStack;
      231 : Result:=SExceptionStack;
      232 : Result:=SNoThreadSupport;
      232 : Result:=SNoThreadSupport;
 
 
+     255 : Result:=SFallbackError;
+
+     {Error codes larger than 255 cannot be returned as an exit code to the OS,
+      for some OS's. If this happens, error 255 is returned instead.
+      Errors for which it is important that they can be distinguished,
+      shall be below 255}
+
      {Error in the range 900 - 999 is considered platform specific}
      {Error in the range 900 - 999 is considered platform specific}
-//     900 : Result:=SNoToolserver;    {Mac OS specific}
+
+     900 : Result:=SNoToolserver;    {Mac OS specific}
+
   end;
   end;
   If length(Result)=0 then
   If length(Result)=0 then
 {$ifdef VER1_0}  
 {$ifdef VER1_0}  
@@ -214,7 +225,11 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2004-08-25 15:29:58  peter
+  Revision 1.13  2004-09-03 19:26:42  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.12  2004/08/25 15:29:58  peter
     * disbaled error 900 that is out of range
     * disbaled error 900 that is out of range
 
 
   Revision 1.11  2004/08/20 10:18:58  olle
   Revision 1.11  2004/08/20 10:18:58  olle

+ 6 - 1
rtl/palmos/system.pp

@@ -30,6 +30,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
  FileNameCaseSensitive = false;
  FileNameCaseSensitive = false;
+ maxExitCode = 255; {$ERROR TODO: CONFIRM THIS}
 
 
     Type
     Type
        { type and constant declartions doesn't hurt }
        { type and constant declartions doesn't hurt }
@@ -103,7 +104,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2002-09-07 16:01:25  peter
+  Revision 1.5  2004-09-03 19:26:52  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.4  2002/09/07 16:01:25  peter
     * old logs removed and tabs fixed
     * old logs removed and tabs fixed
 
 
 }
 }

+ 9 - 1
rtl/template/system.pp

@@ -42,6 +42,10 @@ const
  PathSeparator = ';';
  PathSeparator = ';';
  FileNameCaseSensitive = false;
  FileNameCaseSensitive = false;
 
 
+ {The highest exit code which can be returned to the operating system.
+  Should be at least 255.}
+ maxExitCode = 255;
+
 const
 const
   UnusedHandle    = -1;
   UnusedHandle    = -1;
   StdInputHandle  = 0;
   StdInputHandle  = 0;
@@ -316,7 +320,11 @@ Begin
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2004-06-17 16:16:14  peter
+  Revision 1.12  2004-09-03 19:26:57  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.11  2004/06/17 16:16:14  peter
     * New heapmanager that releases memory back to the OS, donated
     * New heapmanager that releases memory back to the OS, donated
       by Micha Nelissen
       by Micha Nelissen
 
 

+ 6 - 2
rtl/unix/sysunixh.inc

@@ -39,7 +39,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ':';
  PathSeparator = ':';
 { FileNameCaseSensitive is defined below! }
 { FileNameCaseSensitive is defined below! }
-
+ maxExitCode = 255;
 
 
 const
 const
   UnusedHandle    = -1;
   UnusedHandle    = -1;
@@ -60,7 +60,11 @@ var argc:longint;external name 'operatingsystem_parameter_argc';
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2004-07-03 22:52:33  daniel
+  Revision 1.22  2004-09-03 19:27:10  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.21  2004/07/03 22:52:33  daniel
     * No envp,argv,argc declaration for Darwin
     * No envp,argv,argc declaration for Darwin
 
 
   Revision 1.20  2004/07/03 21:50:31  daniel
   Revision 1.20  2004/07/03 21:50:31  daniel

+ 6 - 1
rtl/watcom/system.pp

@@ -42,6 +42,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
+ maxExitCode = 255;
 
 
 const
 const
 { Default filehandles }
 { Default filehandles }
@@ -1553,7 +1554,11 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2004-06-17 16:16:14  peter
+  Revision 1.15  2004-09-03 19:27:16  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.14  2004/06/17 16:16:14  peter
     * New heapmanager that releases memory back to the OS, donated
     * New heapmanager that releases memory back to the OS, donated
       by Micha Nelissen
       by Micha Nelissen
 
 

+ 6 - 1
rtl/win32/system.pp

@@ -46,6 +46,7 @@ const
  DriveSeparator = ':';
  DriveSeparator = ':';
  PathSeparator = ';';
  PathSeparator = ';';
 { FileNameCaseSensitive is defined separately below!!! }
 { FileNameCaseSensitive is defined separately below!!! }
+ maxExitCode = 65535;
 
 
 type
 type
    PEXCEPTION_FRAME = ^TEXCEPTION_FRAME;
    PEXCEPTION_FRAME = ^TEXCEPTION_FRAME;
@@ -1621,7 +1622,11 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2004-06-27 11:57:18  florian
+  Revision 1.61  2004-09-03 19:27:25  olle
+    + added maxExitCode to all System.pp
+    * constrained error code to be below maxExitCode in RunError et. al.
+
+  Revision 1.60  2004/06/27 11:57:18  florian
     * finally (hopefully) fixed sysalloc trouble
     * finally (hopefully) fixed sysalloc trouble
 
 
   Revision 1.59  2004/06/26 15:05:14  florian
   Revision 1.59  2004/06/26 15:05:14  florian