ref: b1bbbbe6083bf5db8e0a16ee7c06fca0a86b7be3
parent: 2476b4fcea4299d2961a1542f5d73c4657320c2b
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Oct 4 20:06:50 EDT 2024
libc/runeistype: accept out of range runes out of range runes should just return 0 for whether they're within any of the classes.
--- a/sys/man/2/isalpharune
+++ b/sys/man/2/isalpharune
@@ -47,6 +47,9 @@
The names are self-explanatory.
.PP
The case-conversion routines return the character unchanged if it has no case.
+.PP
+If a rune contains a value that is not a valid codepoint (ie, values less than
+zero, or greater than Runemax), these routines return 0.
.SH SOURCE
.B /sys/src/libc/port/mkrunetype.c
.br
--- a/sys/src/libc/port/runeistype.c
+++ b/sys/src/libc/port/runeistype.c
@@ -6,6 +6,8 @@
int
isspacerune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Lspace) == Lspace;
}
@@ -12,6 +14,8 @@
int
isalpharune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Lalpha) == Lalpha;
}
@@ -18,6 +22,8 @@
int
isdigitrune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Ldigit) == Ldigit;
}
@@ -24,6 +30,8 @@
int
isupperrune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Lupper) == Lupper;
}
@@ -30,6 +38,8 @@
int
islowerrune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Llower) == Llower;
}
@@ -36,5 +46,7 @@
int
istitlerune(Rune c)
{
+ if(c < 0 || c > Runemax)
+ return 0;
return (mergedlkup(c) & Ltitle) == Ltitle;
}
--
⑨