From 571c601b66ee893483617d8a6b47b923c99361c5 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 9 Jun 2019 19:12:51 -0500 Subject: [PATCH] strtoul: return 0 when given an empty string, as required by the C standards. The issue was introduced in commit 6e9790667. errno is now set to EINVAL in this case. (This is not required by the C standards, but is consistent with various other implementations.) This fixes the cases in #23 related to strtol() and strtoul(). --- stdlib.asm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib.asm b/stdlib.asm index 9d3b212..91f94ba 100644 --- a/stdlib.asm +++ b/stdlib.asm @@ -926,6 +926,9 @@ cn4 inc4 str next char cn5 lda foundOne if no digits were found, flag the error bne rt1 + lda #EINVAL + sta >errno + bra rt2 ; ; flag an error ;