From: Marvin Stenger Date: Thu, 24 Sep 2015 13:41:05 +0000 (+0200) Subject: cmd/compile/internal/gc: move functions from util.go to lex.go X-Git-Tag: go1.6beta1~987 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ffe743945fedb43fd29cf578f06be5d5d0577f57;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go index 3f27e61823..1fafdf453c 100644 --- a/src/cmd/compile/internal/gc/lex.go +++ b/src/cmd/compile/internal/gc/lex.go @@ -840,6 +840,33 @@ func cannedimports(file string, cp string) { 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 { // complain about possibly invisible control characters if c < ' ' { diff --git a/src/cmd/compile/internal/gc/util.go b/src/cmd/compile/internal/gc/util.go index fc9173e383..b75bc20518 100644 --- a/src/cmd/compile/internal/gc/util.go +++ b/src/cmd/compile/internal/gc/util.go @@ -5,7 +5,6 @@ import ( "runtime" "runtime/pprof" "strconv" - "strings" ) func (n *Node) Line() string { @@ -18,34 +17,6 @@ func atoi(s string) int { 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. func stringsCompare(a, b string) int { if a == b {