]> Cypherpunks.ru repositories - goredo.git/blobdiff - dot.go
Do not forget to install redo-inode
[goredo.git] / dot.go
diff --git a/dot.go b/dot.go
index d59bc408a02d3c772a500bce5a98f3ecce44c9ce..b8c28b75346e8d451be77cceb1a8dbb521006adf 100644 (file)
--- a/dot.go
+++ b/dot.go
@@ -1,6 +1,6 @@
 /*
-goredo -- redo implementation on pure Go
-Copyright (C) 2020 Sergey Matveev <stargrave@stargrave.org>
+goredo -- djb's redo implementation on pure Go
+Copyright (C) 2020-2023 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 package main
 
 import (
+       "errors"
        "fmt"
        "io"
        "os"
@@ -38,7 +39,7 @@ func dotWalker(data map[DotNodes]bool, tgtOrig string) (map[DotNodes]bool, error
        depPath := path.Join(cwd, RedoDir, tgt+DepSuffix)
        fdDep, err := os.Open(depPath)
        if err != nil {
-               return nil, err
+               return nil, ErrLine(err)
        }
        defer fdDep.Close()
        var dep string
@@ -46,18 +47,21 @@ func dotWalker(data map[DotNodes]bool, tgtOrig string) (map[DotNodes]bool, error
        for {
                m, err := r.NextMap()
                if err != nil {
-                       if err == io.EOF {
+                       if errors.Is(err, io.EOF) {
                                break
                        }
-                       return nil, err
+                       return nil, ErrLine(err)
                }
                switch m["Type"] {
                case DepTypeIfcreate:
                        data[DotNodes{tgtOrig, cwdMustRel(cwd, m["Target"])}] = true
                case DepTypeIfchange:
                        dep = m["Target"]
+                       if dep == tgt {
+                               continue
+                       }
                        data[DotNodes{tgtOrig, cwdMustRel(cwd, dep)}] = false
-                       if isSrc(cwd, dep) || dep == tgt {
+                       if isSrc(cwd, dep) {
                                continue
                        }
                        data, err = dotWalker(data, cwdMustRel(cwd, dep))