diff options
| author | Baitinq <[email protected]> | 2025-05-12 23:07:05 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-05-12 23:07:05 +0200 |
| commit | 127fc0b27f98b12e4ff618e2c5bf116711002ad6 (patch) | |
| tree | 32175eb254c0b398368ab633f16bf2e102c5a252 /std | |
| parent | Feature: Add support for GE and LE comparisons (diff) | |
| download | pry-lang-127fc0b27f98b12e4ff618e2c5bf116711002ad6.tar.gz pry-lang-127fc0b27f98b12e4ff618e2c5bf116711002ad6.tar.bz2 pry-lang-127fc0b27f98b12e4ff618e2c5bf116711002ad6.zip | |
std: Add strcmp
Diffstat (limited to 'std')
| -rw-r--r-- | std/stdlib.src | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/std/stdlib.src b/std/stdlib.src index 5c09a55..5904bef 100644 --- a/std/stdlib.src +++ b/std/stdlib.src @@ -5,3 +5,27 @@ let println = (str: *i8, args: varargs) => void { printf("\n"); return; }; + +let strcmp = (stra: *i8, strb: *i8) => bool { + let i = 0; + while true { + let ca = (*(stra + i)); + let cb = (*(strb + i)); + + if ca == '\0' { + return cb == '\0'; + }; + + if cb == '\0' { + return ca == '\0'; + }; + + if !(ca == cb) { + return false; + }; + + i = i + 1; + }; + + return true; +}; |