mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
libc/runeistype: accept out of range runes
out of range runes should just return 0 for whether they're within any of the classes.
This commit is contained in:
parent
4d484968bf
commit
394e9c2235
2 changed files with 15 additions and 0 deletions
|
@ -47,6 +47,9 @@ test types and modify cases for Unicode characters.
|
|||
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
|
||||
|
|
|
@ -6,35 +6,47 @@
|
|||
int
|
||||
isspacerune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Lspace) == Lspace;
|
||||
}
|
||||
|
||||
int
|
||||
isalpharune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Lalpha) == Lalpha;
|
||||
}
|
||||
|
||||
int
|
||||
isdigitrune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Ldigit) == Ldigit;
|
||||
}
|
||||
|
||||
int
|
||||
isupperrune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Lupper) == Lupper;
|
||||
}
|
||||
|
||||
int
|
||||
islowerrune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Llower) == Llower;
|
||||
}
|
||||
|
||||
int
|
||||
istitlerune(Rune c)
|
||||
{
|
||||
if(c < 0 || c > Runemax)
|
||||
return 0;
|
||||
return (mergedlkup(c) & Ltitle) == Ltitle;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue