summaryrefslogtreecommitdiff
path: root/libstd/cstrconv.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-04-14 17:33:24 -0700
committerOri Bernstein <ori@eigenstate.org>2015-04-14 17:33:24 -0700
commitf366166b75c22f674c6b8b5129cdf127608acc81 (patch)
tree90a12b527ab31979847b7e5e50d5ee92b98ee6d1 /libstd/cstrconv.myr
parent68dc8fd88d1fc23d6b882531343b38a8e2c7ac99 (diff)
downloadmc-f366166b75c22f674c6b8b5129cdf127608acc81.tar.gz
Get a more or less working getcwd under OSX.
TODO: It still truncates long paths.
Diffstat (limited to 'libstd/cstrconv.myr')
-rw-r--r--libstd/cstrconv.myr12
1 files changed, 12 insertions, 0 deletions
diff --git a/libstd/cstrconv.myr b/libstd/cstrconv.myr
index 969a65f..fa9e0bf 100644
--- a/libstd/cstrconv.myr
+++ b/libstd/cstrconv.myr
@@ -1,6 +1,7 @@
use "types.use"
pkg std =
+ const cstrlen : (buf : byte[:] -> size)
const cstrconv : (buf : byte[:] -> byte[:])
const cstrconvp : (p : byte# -> byte[:])
;;
@@ -26,3 +27,14 @@ const cstrconvp = {p
;;
-> p[:i]
}
+
+const cstrlen = {buf
+ var i
+
+ for i = 0; i < buf.len; i++
+ if buf[i] == 0
+ break
+ ;;
+ ;;
+ -> i
+}