www.github.com/google/codesearch.git
Advanced tools
+16
-0
@@ -166,1 +166,17 @@ // Copyright 2011 The Go Authors. All rights reserved. | ||
| } | ||
| func TestHeap(t *testing.T) { | ||
| h := &postHeap{} | ||
| es := []postEntry{7, 4, 3, 2, 4} | ||
| for _, e := range es { | ||
| h.addMem([]postEntry{e}) | ||
| } | ||
| if len(h.ch) != len(es) { | ||
| t.Fatalf("wrong heap size: %d, want %d", len(h.ch), len(es)) | ||
| } | ||
| for a, b := h.next(), h.next(); b.trigram() != (1<<24 - 1); a, b = b, h.next() { | ||
| if a > b { | ||
| t.Fatalf("%d should <= %d", a, b) | ||
| } | ||
| } | ||
| } |
+1
-0
@@ -448,2 +448,3 @@ // Copyright 2011 The Go Authors. All rights reserved. | ||
| ch[i], ch[j] = ch[j], ch[i] | ||
| j = i | ||
| } | ||
@@ -450,0 +451,0 @@ } |
+1
-3
| Code Search is a tool for indexing and then performing | ||
| regular expression searches over large bodies of source code. | ||
| It is a set of command-line programs written in Go. | ||
| Binary downloads are available for those who do not have Go installed. | ||
| See https://github.com/google/codesearch. | ||
@@ -16,4 +14,4 @@ For background and an overview of the commands, | ||
| Russ Cox | ||
| Russ Cox | ||
| rsc@swtch.com | ||
| June 2015 |
+10
-3
@@ -420,3 +420,6 @@ // Copyright 2011 The Go Authors. All rights reserved. | ||
| if err == nil { | ||
| end = bytes.LastIndex(buf, nl) + 1 | ||
| i := bytes.LastIndex(buf, nl) | ||
| if i >= 0 { | ||
| end = i + 1 | ||
| } | ||
| } else { | ||
@@ -446,2 +449,6 @@ endText = true | ||
| line := buf[lineStart:lineEnd] | ||
| nl := "" | ||
| if len(line) == 0 || line[len(line)-1] != '\n' { | ||
| nl = "\n" | ||
| } | ||
| switch { | ||
@@ -451,5 +458,5 @@ case g.C: | ||
| case g.N: | ||
| fmt.Fprintf(g.Stdout, "%s%d:%s", prefix, lineno, line) | ||
| fmt.Fprintf(g.Stdout, "%s%d:%s%s", prefix, lineno, line, nl) | ||
| default: | ||
| fmt.Fprintf(g.Stdout, "%s%s", prefix, line) | ||
| fmt.Fprintf(g.Stdout, "%s%s%s", prefix, line, nl) | ||
| } | ||
@@ -456,0 +463,0 @@ if needLineno { |