summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-08-26 03:24:42 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-08-26 03:24:42 +0900
commitaf809c966150f4623f9316e8b63e146491134e50 (patch)
tree6154e9deb5e0278694a48874724abbc609163ba8
parent329de8f41664ab0e10ad934abe3623a07988e83f (diff)
Minor refactorings
-rw-r--r--src/ansi.go2
-rw-r--r--src/reader.go2
-rw-r--r--src/tokenizer.go2
-rw-r--r--src/util/chars.go2
4 files changed, 4 insertions, 4 deletions
diff --git a/src/ansi.go b/src/ansi.go
index e1c85291..d7c81d30 100644
--- a/src/ansi.go
+++ b/src/ansi.go
@@ -79,7 +79,7 @@ func extractColor(str string, state *ansiState, proc func(string, *ansiState) bo
// Make sure that we found an ANSI code
offset := ansiRegex.FindStringIndex(str[idx:])
- if offset == nil {
+ if len(offset) < 2 {
idx++
continue
}
diff --git a/src/reader.go b/src/reader.go
index 401b8f0f..22ce4ba0 100644
--- a/src/reader.go
+++ b/src/reader.go
@@ -76,7 +76,7 @@ func (r *Reader) feed(src io.Reader) {
// end in delim.
bytea, err := reader.ReadBytes(delim)
byteaLen := len(bytea)
- if len(bytea) > 0 {
+ if byteaLen > 0 {
if err == nil {
// get rid of carriage return if under Windows:
if util.IsWindows() && byteaLen >= 2 && bytea[byteaLen-2] == byte('\r') {
diff --git a/src/tokenizer.go b/src/tokenizer.go
index 5b7a8b6f..6c1d8cab 100644
--- a/src/tokenizer.go
+++ b/src/tokenizer.go
@@ -147,7 +147,7 @@ func Tokenize(text string, delimiter Delimiter) []Token {
if delimiter.regex != nil {
for len(text) > 0 {
loc := delimiter.regex.FindStringIndex(text)
- if loc == nil {
+ if len(loc) < 2 {
loc = []int{0, len(text)}
}
last := util.Max(loc[1], 1)
diff --git a/src/util/chars.go b/src/util/chars.go
index b06a682b..9e58313b 100644
--- a/src/util/chars.go
+++ b/src/util/chars.go
@@ -160,7 +160,7 @@ func (chars *Chars) CopyRunes(dest []rune) {
copy(dest, runes)
return
}
- for idx, b := range chars.slice {
+ for idx, b := range chars.slice[:len(dest)] {
dest[idx] = rune(b)
}
return