aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-03-31 00:50:32 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-03-31 00:50:32 +0900
commit0ec0770ef2d510ff23f2ea1d5405cee174ee0b5a (patch)
tree11dda40142e9e36f4574a8271260ff85304ec472
parent5971b4bd57f43b742948cc5880c60d9439f40230 (diff)
downloadkati-0ec0770ef2d510ff23f2ea1d5405cee174ee0b5a.tar.gz
Fix the error message for "missing separator"
-rw-r--r--eval.go2
-rw-r--r--log.go12
-rwxr-xr-xruntest.rb2
-rw-r--r--test/err_missing_sep.mk4
4 files changed, 12 insertions, 8 deletions
diff --git a/eval.go b/eval.go
index 11e376b..dbff80f 100644
--- a/eval.go
+++ b/eval.go
@@ -161,7 +161,7 @@ func (ev *Evaluator) evalRawExpr(ast *RawExprAST) {
result := ev.evalExpr(ast.expr)
if result != "" {
// TODO: Fix rule_in_var.mk.
- fmt.Printf("%s:%d: *** missing separator. Stop.\n", ast.filename, ast.lineno)
+ Error(ast.filename, ast.lineno, "*** missing separator.")
}
}
diff --git a/log.go b/log.go
index 6d931e8..6f39cc6 100644
--- a/log.go
+++ b/log.go
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
+ "os"
)
func Log(f string, a ...interface{}) {
@@ -18,11 +19,8 @@ func Warn(filename string, lineno int, f string, a ...interface{}) {
fmt.Printf(f, a...)
}
-func Error(f string, a ...interface{}) {
- var buf bytes.Buffer
- buf.WriteString("error: ")
- buf.WriteString(f)
- buf.WriteByte('\n')
- fmt.Printf(buf.String(), a...)
- panic("")
+func Error(filename string, lineno int, f string, a ...interface{}) {
+ f = fmt.Sprintf("%s:%d: %s\n", filename, lineno, f)
+ fmt.Printf(f, a...)
+ os.Exit(2)
}
diff --git a/runtest.rb b/runtest.rb
index 7b86120..bb4cbd6 100755
--- a/runtest.rb
+++ b/runtest.rb
@@ -53,6 +53,8 @@ Dir.glob('test/*.mk').sort.each do |mk|
expected.gsub!(/[`'"]/, '"')
expected.gsub!(/ (?:commands|recipe) for target /,
' commands for target ')
+ expected.gsub!(' (did you mean TAB instead of 8 spaces?)', '')
+ expected.gsub!(/\s+Stop\.$/, '')
output.gsub!(/^\*kati\*.*\n/, '')
File.open('out.make', 'w'){|ofile|ofile.print(expected)}
diff --git a/test/err_missing_sep.mk b/test/err_missing_sep.mk
index 257cc56..8d51450 100644
--- a/test/err_missing_sep.mk
+++ b/test/err_missing_sep.mk
@@ -1 +1,5 @@
+test:
+
foo
+
+bar