Implement findstring
diff --git a/func.go b/func.go
index ff09650..7ada6ba 100644
--- a/func.go
+++ b/func.go
@@ -46,7 +46,14 @@
}
func funcFindstring(ev *Evaluator, args []string) string {
- // TODO(hamaji): Implement
+ if len(args) < 2 {
+ panic(fmt.Sprintf("*** insufficient number of arguments (%d) to function `findstring'.", len(args)))
+ }
+ f := ev.evalExpr(args[0])
+ text := ev.evalExpr(strings.Join(args[1:], ","))
+ if strings.Index(text, f) >= 0 {
+ return f
+ }
return ""
}
diff --git a/test/findstring.mk b/test/findstring.mk
new file mode 100644
index 0000000..5f53ad9
--- /dev/null
+++ b/test/findstring.mk
@@ -0,0 +1,6 @@
+test:
+ echo $(findstring a, a b c)
+ echo $(findstring b, a b c)
+ echo $(findstring b c, a b c)
+ echo $(findstring a, b c)
+ echo $(findstring a, b c, a)