commit 648b862b5e7f20e48d299581e46d1ce04acc9616
parent e34b4c6eb9f4b2c598bbca6b40c12ee8e3e5fee1
Author: Sebastian <sebastian@sebsite.pw>
Date: Tue, 22 Feb 2022 18:46:17 -0500
ascii: improve strcasecmp docs
This is necessary because ASCII characters exist between A-Z and a-z, so
it makes a difference whether letters are capitalized or made lowercase.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ascii/strcmp.ha b/ascii/strcmp.ha
@@ -36,8 +36,12 @@ export fn strcmp(a: str, b: str) (int | void) = {
};
};
-// Similar to [[strcmp]], but compares strings irrespective of their uppercase or
-// lowercase classification within the ASCII character set.
+// Compares two strings by their ASCII sort order, treating all capital letters
+// as their lowercase counterpart (i.e. a case-insensitive comparison is
+// performed). If either string is not entirely composed of ASCII characters,
+// void is returned. Otherwise, zero is returned if the strings are equal, a
+// negative value if a is less than b, or a positive value if a is greater than
+// b.
export fn strcasecmp(a: str, b: str) (int | void) = {
let a = strings::iter(a), b = strings::iter(b);
for (true) {