ref: c5feb1c4f2a7b26239d074c1983b953df29ebff7
parent: 0855d34c6585b6479f74f059a91c483c58016ea8
author: Ori Bernstein <[email protected]>
date: Thu Jan 16 20:03:08 EST 2014
Add 'hassuffix' function
--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -14,6 +14,7 @@
fmt.myr \
hashfuncs.myr \
hasprefix.myr \
+ hassuffix.myr \
htab.myr \
intparse.myr \
ipparse.myr \
--- /dev/null
+++ b/libstd/hassuffix.myr
@@ -1,0 +1,17 @@
+use "cmp.use"
+pkg std =
+ const hassuffix : (s : byte[:], suff : byte[:] -> bool)
+;;
+
+const hassuffix = {s, suff
+ var tail
+
+ if suff.len >= s.len
+ tail = s[s.len - suff.len:]
+ match strncmp(tail, suff, suff.len)
+ | `Equal: -> true
+ | _: -> false
+ ;;
+ ;;
+}
+