* Moved multiple similar checks for FPC_HAS_FEATURE_EXITCODE and FPC_LIMITED_EXITCODE to Halt() procedure. Now these checks appear only once.

git-svn-id: trunk@19597 -
This commit is contained in:
sergei 2011-11-05 16:48:12 +00:00
parent 56900b4754
commit ebe1d74d6e
2 changed files with 11 additions and 32 deletions

View File

@ -159,12 +159,7 @@ begin
if erroraddr = nil then if erroraddr = nil then
RunError(217) RunError(217)
else else
{$ifdef FPC_LIMITED_EXITCODE} Halt(errorcode);
if errorcode > maxExitCode then
halt(255)
else
{$endif FPC_LIMITED_EXITCODE}
halt(errorcode);
end; end;

View File

@ -939,7 +939,14 @@ end;
Procedure Halt(ErrNum: Longint); Procedure Halt(ErrNum: Longint);
Begin Begin
ExitCode:=Errnum; {$ifdef FPC_HAS_FEATURE_EXITCODE}
{$ifdef FPC_LIMITED_EXITCODE}
if ErrNum > maxExitCode then
ExitCode:=255
else
{$endif FPC_LIMITED_EXITCODE}
ExitCode:=ErrNum;
{$endif FPC_HAS_FEATURE_EXITCODE}
Do_Exit; Do_Exit;
end; end;
@ -961,17 +968,7 @@ begin
if ExceptAddrStack <> nil then if ExceptAddrStack <> nil then
raise TObject(nil) at addr,frame; raise TObject(nil) at addr,frame;
{$endif FPC_HAS_FEATURE_EXCEPTIONS} {$endif FPC_HAS_FEATURE_EXCEPTIONS}
Halt(errorcode);
{$ifdef FPC_HAS_FEATURE_EXITCODE}
{$ifdef FPC_LIMITED_EXITCODE}
if errorcode > maxExitCode then
halt(255)
else
{$endif FPC_LIMITED_EXITCODE}
halt(errorcode);
{$else FPC_HAS_FEATURE_EXITCODE}
halt;
{$endif FPC_HAS_FEATURE_EXITCODE}
end; end;
Procedure HandleErrorFrame (Errno : longint;frame : Pointer); Procedure HandleErrorFrame (Errno : longint;frame : Pointer);
@ -1000,16 +997,7 @@ begin
errorcode:=w; errorcode:=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);
{$ifdef FPC_HAS_FEATURE_EXITCODE} Halt(errorcode);
{$ifdef FPC_LIMITED_EXITCODE}
if errorcode > maxExitCode then
halt(255)
else
{$endif FPC_LIMITED_EXITCODE}
halt(errorcode);
{$else FPC_HAS_FEATURE_EXITCODE}
halt;
{$endif FPC_HAS_FEATURE_EXITCODE}
end; end;
@ -1269,11 +1257,7 @@ begin
write(stderr,msg); write(stderr,msg);
Writeln(stderr,' (',FName,', line ',LineNo,').'); Writeln(stderr,' (',FName,', line ',LineNo,').');
Writeln(stderr,''); Writeln(stderr,'');
{$ifdef FPC_HAS_FEATURE_EXITCODE}
Halt(227); Halt(227);
{$else FPC_HAS_FEATURE_EXITCODE}
halt;
{$endif FPC_HAS_FEATURE_EXITCODE}
{$endif FPC_HAS_FEATURE_CONSOLEIO} {$endif FPC_HAS_FEATURE_CONSOLEIO}
end; end;