From 3844bf1f727d4ffcec79f668ce07e9b55c732c86 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 5 Dec 2023 23:52:43 +0100 Subject: [PATCH] fix string.isupper() --- compiler/res/prog8lib/string.p8 | 14 ++++++++++---- docs/source/libraries.rst | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/compiler/res/prog8lib/string.p8 b/compiler/res/prog8lib/string.p8 index 07575d440..ad9d0e2d4 100644 --- a/compiler/res/prog8lib/string.p8 +++ b/compiler/res/prog8lib/string.p8 @@ -399,15 +399,21 @@ fail clc ; yes, no match found, return with c=0 } asmsub isupper(ubyte character @A) -> bool @Pc { + ; shifted petscii has 2 ranges that contain the upper case letters... %asm {{ - cmp #'A' + cmp #97 bcs + rts -+ cmp #'Z'+1 - bcc + ++ cmp #122+1 + bcc _yes + cmp #193 + bcs + + rts ++ cmp #218+1 + bcc _yes clc rts -+ sec +_yes sec rts }} } diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 7b7ba7c8c..ff9596479 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -261,13 +261,16 @@ Provides string manipulation routines. Uppercases the PETSCII-string in place. ``lowerchar (char)`` - Returns lowercased character. + Returns lowercased PETSCII character. ``upperchar (char)`` - Returns uppercased character. + Returns uppercased PETSCII character. -``isdigit (char)``, ``islower (char)``, ``isupper (char)``, ``isletter (char)`` - Returns boolean if the character is a numerical digit 0-0, lowercase letter, uppercase letter, or any letter. +``isdigit (char)`` + Returns boolean if the character is a numerical digit 0-9 + +``islower (char)``, ``isupper (char)``, ``isletter (char)`` + Returns boolean if the character is a shifted-PETSCII lowercase letter, uppercase letter, or any letter. ``startswith (string, prefix) -> bool`` Returns true if string starts with prefix, otherwise false