summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-20 22:28:29 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-21 20:27:46 -0700
commit16aa8c14d53c4d2e55651d64de26c68f23f21824 (patch)
tree7d76bc253e246d307cf7adf97bf8485bff3bfe34
parent49f6758a734dc98ed7764d2f2ff8dfb77d4c75b0 (diff)
downloadmc-16aa8c14d53c4d2e55651d64de26c68f23f21824.tar.gz
Add a function to skip whitespace in bio.myr
-rw-r--r--lib/bio/bio.myr15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr
index 301822b..4242721 100644
--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -50,6 +50,7 @@ pkg bio =
const readln : (f : file# -> std.option(byte[:]))
const readto : (f : file#, delim : byte[:] -> std.option(byte[:]))
const skipto : (f : file#, delim : byte[:] -> bool)
+ const skipspace : (f : file# -> void)
/* formatted i/o */
const put : (f : file#, fmt : byte[:], args : ... -> std.size)
@@ -349,6 +350,20 @@ const skipto = {f, delim
;;
}
+const skipspace = {f
+ while true
+ match bio.peekc(f)
+ | `std.Some c:
+ if std.isspace(c)
+ break
+ ;;
+ bio.getc(f)
+ | `std.None:
+ break
+ ;;
+ ;;
+}
+
/* Same as readto, but the delimiter is always a '\n' */
const readln = {f
-> readto(f, "\n")