Commit ffe74394 authored by Marvin Stenger's avatar Marvin Stenger Committed by Brad Fitzpatrick

cmd/compile/internal/gc: move functions from util.go to lex.go

Moves the functions:
        isSpace(int) bool
        isAlpha(int) bool
        isDigit(int) bool
        isAlnum(int) bool
        plan9quote(string) string

Passes go build -toolexec 'toolstash -cmp' -a std.

Change-Id: I6f946981abb6f29b047ad90d5c117847e826789f
Reviewed-on: https://go-review.googlesource.com/14952
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent d08f34e7
...@@ -840,6 +840,33 @@ func cannedimports(file string, cp string) { ...@@ -840,6 +840,33 @@ func cannedimports(file string, cp string) {
incannedimport = 1 incannedimport = 1
} }
func isSpace(c int) bool {
return c == ' ' || c == '\t' || c == '\n' || c == '\r'
}
func isAlpha(c int) bool {
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'
}
func isDigit(c int) bool {
return '0' <= c && c <= '9'
}
func isAlnum(c int) bool {
return isAlpha(c) || isDigit(c)
}
func plan9quote(s string) string {
if s == "" {
return "''"
}
for _, c := range s {
if c <= ' ' || c == '\'' {
return "'" + strings.Replace(s, "'", "''", -1) + "'"
}
}
return s
}
func isfrog(c int) bool { func isfrog(c int) bool {
// complain about possibly invisible control characters // complain about possibly invisible control characters
if c < ' ' { if c < ' ' {
......
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"strings"
) )
func (n *Node) Line() string { func (n *Node) Line() string {
...@@ -18,34 +17,6 @@ func atoi(s string) int { ...@@ -18,34 +17,6 @@ func atoi(s string) int {
return int(n) return int(n)
} }
func isSpace(c int) bool {
return c == ' ' || c == '\t' || c == '\n' || c == '\r'
}
func isAlnum(c int) bool {
return isAlpha(c) || isDigit(c)
}
func isAlpha(c int) bool {
return 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z'
}
func isDigit(c int) bool {
return '0' <= c && c <= '9'
}
func plan9quote(s string) string {
if s == "" {
return "''"
}
for _, c := range s {
if c <= ' ' || c == '\'' {
return "'" + strings.Replace(s, "'", "''", -1) + "'"
}
}
return s
}
// strings.Compare, introduced in Go 1.5. // strings.Compare, introduced in Go 1.5.
func stringsCompare(a, b string) int { func stringsCompare(a, b string) int {
if a == b { if a == b {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment