aboutsummaryrefslogtreecommitdiff
path: root/core/strings
diff options
context:
space:
mode:
authorTetralux <tetralux@teknik.io>2020-02-12 10:26:38 +0000
committerTetralux <tetralux@teknik.io>2020-02-12 11:25:12 +0000
commit1f0c1943daa21a4c06c21c8d3b8f704bb7f191f8 (patch)
tree793511c5c0bccd3696a1da145ec5396d153755d8 /core/strings
parent0b7711684bae15ac5bfe3ac78230e9d6e9057673 (diff)
Fix #552.
- Fix comparisons involving one or more empty string. - Fix comparisons against two strings of different lengths.
Diffstat (limited to 'core/strings')
-rw-r--r--core/strings/strings.odin2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/strings/strings.odin b/core/strings/strings.odin
index 6e004993a..a477b9e13 100644
--- a/core/strings/strings.odin
+++ b/core/strings/strings.odin
@@ -52,6 +52,8 @@ unsafe_string_to_cstring :: proc(str: string) -> cstring {
return cstring(d.data);
}
+// Compares two strings, returning a value representing which one comes first lexiographically.
+// -1 for `a`; 1 for `b`, or 0 if they are equal.
compare :: proc(lhs, rhs: string) -> int {
return mem.compare(transmute([]byte)lhs, transmute([]byte)rhs);
}