Make strerror() return a valid error string for unknown errno values.

This is required by C99 and later.
This commit is contained in:
Stephen Heumann 2018-09-09 21:26:21 -05:00
parent 2d20af84fd
commit 2be73c4e5d
2 changed files with 7 additions and 2 deletions

View File

@ -2946,7 +2946,7 @@ sys_errlist start
dc a4'EEXISTS'
dc a4'ENOSPC'
! Note: if more errors are added, change maxErr in perror().
! Note: if more errors are added, change maxErr in perror() and strerror().
EUNDEF cstr 'invalid error number'
EDOM cstr 'domain error'

View File

@ -17,6 +17,7 @@
****************************************************************
*
String start dummy routine
copy equates.asm
end
@ -888,6 +889,7 @@ lb2 sty set set the disp past the current disp
****************************************************************
*
strerror start
maxErr equ ENOSPC max error in sys_errlist
phb get the error number
plx
@ -897,7 +899,10 @@ strerror start
phx
phk use local data bank
plb
asl A compute the index
cmp #maxErr+1
blt lb1
lda #0
lb1 asl A compute the index
asl A
tay
ldx sys_errlist+2,Y load the address