Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implementation of Char.isCntrl #168

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## MLKit NEWS

* mael 2024-03-04: Various cleanup and fixes. Infinite reals and NaNs
may now be parsed as specified in the basis library manual.
* mael 2024-03-04: Fix issue with Char.isCntrl (issue #162).

* mael 2024-03-04: Cleanup and fixes. Infinite reals and NaNs may now
be parsed as specified in the Basis Bibrary manual (issue #163).

### MLKit version 4.7.8 is released

Expand Down
32 changes: 17 additions & 15 deletions basis/Char.sml
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,27 @@ struct (* depends on StrBase *)

fun notContains s c = not(contains s c)

fun isLower c = #"a" <= c andalso c <= #"z"
fun isAscii c = c <= #"\127"

fun isUpper c = #"A" <= c andalso c <= #"Z"
fun isLower c = #"a" <= c andalso c <= #"z"
fun isDigit c = #"0" <= c andalso c <= #"9"
fun isAlpha c = isLower c orelse isUpper c
fun isHexDigit c = #"0" <= c andalso c <= #"9"
orelse #"a" <= c andalso c <= #"f"
orelse #"A" <= c andalso c <= #"F"
fun isAlpha c = isUpper c orelse isLower c
fun isAlphaNum c = isAlpha c orelse isDigit c
fun isPrint c = c >= #" " andalso c < #"\127"
fun isSpace c = c = #" " orelse #"\009" <= c andalso c <= #"\013"
fun isGraph c = isPrint c andalso not (isSpace c)
fun isHexDigit c = isDigit c
orelse #"a" <= c andalso c <= #"f"
orelse #"A" <= c andalso c <= #"F"
fun isGraph c = #"!" <= c andalso c <= #"~"
fun isPrint c = isGraph c orelse c = #" "
fun isPunct c = isGraph c andalso not (isAlphaNum c)
fun isAscii c = c <= #"\127"
fun isCntrl c = c < #" " orelse c >= #"\127"

fun toLower c = if #"A" <= c andalso c <= #"Z" then unsafe_chr(ord c + 32)
else c
fun toUpper c = if #"a" <= c andalso c <= #"z" then unsafe_chr(ord c - 32)
else c
fun isCntrl c = isAscii c andalso not (isPrint c)
fun isSpace c = #"\t" <= c andalso c <= #"\r"
orelse c = #" "

fun toLower c = if isUpper c then unsafe_chr(ord c + 32)
else c
fun toUpper c = if isLower c then unsafe_chr(ord c - 32)
else c

fun toString c = StrBase.toMLescape c

Expand Down
Loading