]> git.sur5r.net Git - cc65/commitdiff
Handle arguments outside char range correctly
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 11 Nov 2002 11:58:20 +0000 (11:58 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 11 Nov 2002 11:58:20 +0000 (11:58 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1501 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/tolower.s
libsrc/common/toupper.s

index fa03146b0b8816be4c68427828aedfa28d3672f4..0c67199a312da3ebbcb20eabaf93eaa621ed0c79 100644 (file)
@@ -8,12 +8,14 @@
        .import         __ctype, __cdiff
 
 _tolower:
+        cpx     #$00            ; Outside valid range?
+        bne     L9              ; If so, return the argument unchanged
                tay                     ; Get C into Y
        lda     __ctype,y       ; Get character classification
        lsr     a
        lsr     a               ; Get bit 1 (upper case char) into carry
        tya                     ; Get char back into A
                bcc     L9              ; Jump if no upper case char
-       sbc     __cdiff         ; make lower case char (carry already set)
-L9:            rts                     ; CC are set
+       sbc     __cdiff         ; Make lower case char (carry already set)
+L9:            rts
 
index ab7711cb214ed252803342d814c741c972243296..5561eb7d4cf45d3b8565bbc0afd7336e1ace62b0 100644 (file)
@@ -8,6 +8,8 @@
        .import         __ctype, __cdiff
 
 _toupper:
+        cpx     #$00            ; Outside valid range?
+        bne     L9              ; If so, return the argument unchanged
        tay                     ; Get c into Y
        lda     __ctype,y       ; Get character classification
        lsr     a               ; Get bit 0 (lower char) into carry