ref: 9f9d134454de4f796e3e7338a2c59e0ee59a3560
parent: e95be05dfa0c5fcc46dbfc6dba6e6a3e7e3d04d6
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Oct 3 13:43:14 EDT 2014
Add function to split source into compns. Splits source filename into base, platform, suffix tuple. eg: foo+linux-i686.myr => ("foo", "+linux-i686", ".myr")
--- a/util.myr
+++ b/util.myr
@@ -2,11 +2,11 @@
pkg bld =
const run : (cmd : byte[:][:], dir : byte[:] -> void)
+ const srcsplit : (src : byte[:] -> (byte[:], byte[:], byte[:]))
const swapsuffix : (f : byte[:], suff : byte[:], newsuff : byte[:] -> byte[:])
const strlistfree : (sl : byte[:][:] -> void)
;;
-
const run = {cmd, dir
var pid
var status
@@ -46,6 +46,25 @@
;;
;;
std.put("\n")
+}
+
+const srcsplit = {src
+ var platf, suff
+
+ platf = ""
+ suff = ""
+ match std.strrfind(src, ".")
+ | `std.Some i:
+ suff = src[i:]
+ src = src[:i]
+ ;;
+
+ match std.strrfind(src, "+")
+ | `std.Some i:
+ platf = src[i:]
+ src = src[:i]
+ ;;
+ -> (src, platf, suff)
}
const swapsuffix = {f, suff, newsuff