summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Harris <pharris@opentext.com>2013-03-13 16:59:15 -0400
committerPeter Harris <pharris@opentext.com>2013-03-13 16:59:15 -0400
commita2b2b6d475054fd87d624eff0b726a44347b60e8 (patch)
tree315f906767c53c549f652ff4e54dc1481d7094ea
parentf848a900034254478adf4b57e08524a35ee386d1 (diff)
Update for Go 1HEADmaster
go fix, shuffle directories for the go tool so we don't need a Makefile, and remove the Makefile.
-rw-r--r--.gitignore6
-rw-r--r--Makefile22
-rw-r--r--noop/noop.go (renamed from noop.go)0
-rw-r--r--test/test.go (renamed from test.go)2
-rw-r--r--util/atom.go (renamed from xgob/util/atom.go)6
-rw-r--r--xau/xau.go (renamed from xau.go)6
-rw-r--r--xgob.go24
-rw-r--r--xlsclients/xlsclients.go (renamed from xlsclients.go)38
-rw-r--r--xmu/xmu.go (renamed from xmu.go)6
-rw-r--r--xproto/xproto.go (renamed from xgob/xproto.go)0
10 files changed, 41 insertions, 69 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 5da7293..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-test
-noop
-xlsclients
-build
-*.6
-*.xcodeproj
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 21a55a9..0000000
--- a/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# Don't delete intermediates
-.SECONDARY:
-
-# How to compile a .go file
-%.6: %.go
- 6g -I. -o $@ $<
-
-%: %.6
- 6l -L. -o $@ $<
-
-# Compile our simple test apps
-all: test noop xlsclients
-
-# Dependencies
-xgob.6: xau.6
-xgob/util/atom.6: xgob/xproto.6 xgob.6
-xgob/xproto.6: xgob.6
-xmu.6: xgob/util/atom.6 xgob/xproto.6 xgob.6
-test.6: xgob.6
-noop.6: xgob.6
-xlsclients.6: xgob.6 xmu.6 xgob/xproto.6 xgob/util/atom.6
diff --git a/noop.go b/noop/noop.go
index 1068f31..1068f31 100644
--- a/noop.go
+++ b/noop/noop.go
diff --git a/test.go b/test/test.go
index 6182640..e5640e8 100644
--- a/test.go
+++ b/test/test.go
@@ -60,7 +60,7 @@ func main() {
}
i++
case e := <-error:
- fmt.Printf("Error of type %d", e.Error)
+ fmt.Printf("Error of type %d", e.Err)
fmt.Println()
fmt.Printf(" request %d.%d", e.Major, e.Minor)
fmt.Println()
diff --git a/xgob/util/atom.go b/util/atom.go
index 88d2ce0..5e2e3a3 100644
--- a/xgob/util/atom.go
+++ b/util/atom.go
@@ -1,4 +1,4 @@
-package atom
+package util
import (
"fmt"
@@ -33,7 +33,7 @@ func newState(c *xgob.Connection) state {
func (s *state) internAtom(name string) xproto.Atom {
c, ok := s.pendingAtom[name]
if ok {
- s.pendingAtom[name] = nil, false
+ delete(s.pendingAtom, name)
} else {
c = xproto.InternAtom(s.c, false, name)
}
@@ -49,7 +49,7 @@ func (s *state) internAtom(name string) xproto.Atom {
s.name[reply.Atom] = name
s.atom[name] = reply.Atom
} else {
- println("Atom Error", reply.Error.Error)
+ println("Atom Error", reply.Error.Err)
}
return reply.Atom
}
diff --git a/xau.go b/xau/xau.go
index f42e3aa..2f3ec9a 100644
--- a/xau.go
+++ b/xau/xau.go
@@ -145,7 +145,7 @@ func GetBestAuthByAddr(family uint16, address []byte, number []byte, types []str
return best
}
-func readShort(file *os.File) (uint16, os.Error) {
+func readShort(file *os.File) (uint16, error) {
var buf [2]byte
_, err := io.ReadFull(file, buf[:])
@@ -155,7 +155,7 @@ func readShort(file *os.File) (uint16, os.Error) {
return uint16(buf[0])*256 + uint16(buf[1]), nil
}
-func readCountedString(file *os.File) ([]byte, os.Error) {
+func readCountedString(file *os.File) ([]byte, error) {
len, err := readShort(file)
if err != nil {
return nil, err
@@ -173,7 +173,7 @@ func readCountedString(file *os.File) ([]byte, os.Error) {
func readAuth(auth_file *os.File) *Xauth {
var local Xauth
- var err os.Error
+ var err error
local.Family, err = readShort(auth_file)
if err != nil {
return nil
diff --git a/xgob.go b/xgob.go
index 2cdf00b..758411e 100644
--- a/xgob.go
+++ b/xgob.go
@@ -9,7 +9,8 @@ import (
"strconv"
"strings"
"sync"
- "xau"
+ "time"
+ "xgob/xau"
)
const X_TCP_PORT = 6000
@@ -93,7 +94,7 @@ type Error struct {
BadValue uint32
Minor uint16
Major uint8
- Error uint8
+ Err uint8
}
type Reply struct {
@@ -137,7 +138,7 @@ func parse_display(name string) (host string, protocol string, display int, scre
}
}
- var err os.Error
+ var err error
dot := strings.LastIndex(name, ".")
if dot >= 0 {
@@ -203,7 +204,7 @@ func open_tcp(host string, protocol string, port int) io.ReadWriteCloser {
conn, err := net.Dial(proto, host+":"+strconv.Itoa(port))
// TODO - remove
if err != nil {
- println("TCP error ", err.String())
+ println("TCP error ", err.Error())
}
return conn
}
@@ -216,7 +217,7 @@ func open_unix(protocol string, file string) io.ReadWriteCloser {
conn, err := net.Dial("unix", file)
// TODO - remove
if err != nil {
- println("Unix socket error ", err.String())
+ println("Unix socket error ", err.Error())
}
return conn
}
@@ -403,7 +404,7 @@ func (c *Connection) read_setup(in *bufio.Reader) bool {
println("Server requires authentication")
println(bytes.NewBuffer(todo).String())
default:
- panic("Unexpected return value from server " + strconv.Uitoa(uint(status)))
+ panic("Unexpected return value from server " + strconv.FormatUint(uint64(status), 10))
}
return false
}
@@ -441,16 +442,16 @@ func (c *Connection) postReply(seq uint64, reply interface{}) {
c.replyMutex.Lock()
if seq != c.lastSequenceRead {
- c.reply[c.lastSequenceRead] = nil, false
+ delete(c.reply, c.lastSequenceRead)
}
for i := c.lastSequenceRead + 1; i < seq; i++ {
if target := c.reply[i]; target != nil {
target <- nil
- c.reply[i] = nil, false
+ delete(c.reply, i)
}
if target := c.callback[i]; target != nil {
target(nil)
- c.callback[i] = nil, false
+ delete(c.callback, i)
}
}
@@ -482,7 +483,7 @@ func (c *Connection) read(in *bufio.Reader) {
switch t {
case 0:
var e Error
- e.Error, _ = in.ReadByte()
+ e.Err, _ = in.ReadByte()
e.Sequence = c.fullSeq(readUint16(in))
e.BadValue = readUint32(in)
e.Minor = readUint16(in)
@@ -628,8 +629,7 @@ func computeAuth(auth *xau.Xauth, sockaddr net.Addr) *AuthInfo {
default:
return nil
}
- time, _, _ := os.Time()
- info.Data = appendUint32(info.Data, uint32(time))
+ info.Data = appendUint32(info.Data, uint32(time.Now().Unix()))
for len(info.Data) < 192/8 {
info.Data = append(info.Data, 0)
}
diff --git a/xlsclients.go b/xlsclients/xlsclients.go
index a235de6..887d61c 100644
--- a/xlsclients.go
+++ b/xlsclients/xlsclients.go
@@ -7,9 +7,9 @@ import (
"strings"
"unicode"
"xgob"
- "xgob/util/atom"
+ "xgob/util"
"xgob/xproto"
- "xmu"
+ "xgob/xmu"
)
var display = flag.String("display", "", "Display to connect to")
@@ -18,16 +18,16 @@ var all = flag.Bool("all", false, "Show all screens")
var verbose = flag.Bool("long", false, "Verbose output")
func initAtoms(c *xgob.Connection) {
- atom.PreloadAtom(c, "WM_STATE")
+ util.PreloadAtom(c, "WM_STATE")
/* The rest of these are pre-defined atoms.
They can be removed when we have a real xproto generator. */
- atom.PreloadAtom(c, "WM_CLIENT_MACHINE")
- atom.PreloadAtom(c, "WM_COMMAND")
- atom.PreloadAtom(c, "WM_NAME")
- atom.PreloadAtom(c, "WM_ICON_NAME")
- atom.PreloadAtom(c, "WM_CLASS")
- atom.PreloadAtom(c, "STRING")
+ util.PreloadAtom(c, "WM_CLIENT_MACHINE")
+ util.PreloadAtom(c, "WM_COMMAND")
+ util.PreloadAtom(c, "WM_NAME")
+ util.PreloadAtom(c, "WM_ICON_NAME")
+ util.PreloadAtom(c, "WM_CLASS")
+ util.PreloadAtom(c, "STRING")
}
func formatTextField(c *xgob.Connection, s string, t *xproto.GetPropertyReply) string {
@@ -37,7 +37,7 @@ func formatTextField(c *xgob.Connection, s string, t *xproto.GetPropertyReply) s
rv := s
- if t.Type == atom.Atom(c, "STRING") && t.Format == 8 {
+ if t.Type == util.Atom(c, "STRING") && t.Format == 8 {
rv += string(t.Value)
} else {
rv += "<unknown type "
@@ -45,7 +45,7 @@ func formatTextField(c *xgob.Connection, s string, t *xproto.GetPropertyReply) s
rv += "None"
} else {
/* This should happen so rarely as to make no odds. Eat a round-trip: */
- rv += atom.AtomName(c, t.Type)
+ rv += util.AtomName(c, t.Type)
}
rv += fmt.Sprintf(" (%d) or format %d>", t.Type, t.Format)
}
@@ -66,7 +66,7 @@ func quotedWord(buf *bytes.Buffer, word []byte, maxlen uint) uint {
*/
needQuote := false
for _, c := range word {
- if !(c < 0x80 && (unicode.IsLetter(int(c)) || unicode.IsDigit(int(c))) ||
+ if !(c < 0x80 && (unicode.IsLetter(rune(c)) || unicode.IsDigit(rune(c))) ||
(c == '-' || c == '_' || c == '.' || c == '+' ||
c == '/' || c == '=' || c == ':' || c == ',')) {
needQuote = true
@@ -84,7 +84,7 @@ func quotedWord(buf *bytes.Buffer, word []byte, maxlen uint) uint {
printed++
}
for _, c := range word {
- if int(c) == quote {
+ if rune(c) == quote {
if inQuote {
buf.WriteRune(quote)
printed++
@@ -96,7 +96,7 @@ func quotedWord(buf *bytes.Buffer, word []byte, maxlen uint) uint {
quote = tmp
inQuote = true
}
- buf.WriteRune(int(c))
+ buf.WriteRune(rune(c))
printed++
if printed >= maxlen {
break
@@ -132,15 +132,15 @@ func quotedWords(prop []byte) string {
}
func clientProperties(c *xgob.Connection, win xproto.Window, result chan string) {
- machineCookie := xproto.GetProperty(c, false, win, atom.Atom(c, "WM_CLIENT_MACHINE"), xproto.Atom(0), 0, 1000000)
- commandCookie := xproto.GetProperty(c, false, win, atom.Atom(c, "WM_COMMAND"), xproto.Atom(0), 0, 1000000)
+ machineCookie := xproto.GetProperty(c, false, win, util.Atom(c, "WM_CLIENT_MACHINE"), xproto.Atom(0), 0, 1000000)
+ commandCookie := xproto.GetProperty(c, false, win, util.Atom(c, "WM_COMMAND"), xproto.Atom(0), 0, 1000000)
var nameCookie chan xproto.GetPropertyReply
var iconNameCookie chan xproto.GetPropertyReply
var classCookie chan xproto.GetPropertyReply
if *verbose {
- nameCookie = xproto.GetProperty(c, false, win, atom.Atom(c, "WM_NAME"), xproto.Atom(0), 0, 1000000)
- iconNameCookie = xproto.GetProperty(c, false, win, atom.Atom(c, "WM_ICON_NAME"), xproto.Atom(0), 0, 1000000)
- classCookie = xproto.GetProperty(c, false, win, atom.Atom(c, "WM_CLASS"), xproto.Atom(0), 0, 1000000)
+ nameCookie = xproto.GetProperty(c, false, win, util.Atom(c, "WM_NAME"), xproto.Atom(0), 0, 1000000)
+ iconNameCookie = xproto.GetProperty(c, false, win, util.Atom(c, "WM_ICON_NAME"), xproto.Atom(0), 0, 1000000)
+ classCookie = xproto.GetProperty(c, false, win, util.Atom(c, "WM_CLASS"), xproto.Atom(0), 0, 1000000)
}
c.Flush()
diff --git a/xmu.go b/xmu/xmu.go
index db62241..449eea6 100644
--- a/xmu.go
+++ b/xmu/xmu.go
@@ -2,7 +2,7 @@ package xmu
import (
"xgob"
- "xgob/util/atom"
+ "xgob/util"
"xgob/xproto"
)
@@ -17,7 +17,7 @@ func tryChildren(c *xgob.Connection, children []xproto.Window) xproto.Window {
queryCookies := make([]chan xproto.QueryTreeReply, 0)
propCookies := make([]chan xproto.GetPropertyReply, 0)
- state := atom.Atom(c, "WM_STATE")
+ state := util.Atom(c, "WM_STATE")
for {
if len(children) == 0 {
@@ -50,7 +50,7 @@ func tryChildren(c *xgob.Connection, children []xproto.Window) xproto.Window {
}
func ClientWindow(c *xgob.Connection, win xproto.Window) xproto.Window {
- stateCookie := xproto.GetProperty(c, false, win, atom.Atom(c, "WM_STATE"), xproto.Atom(0), 0, 0)
+ stateCookie := xproto.GetProperty(c, false, win, util.Atom(c, "WM_STATE"), xproto.Atom(0), 0, 0)
treeCookie := xproto.QueryTree(c, win)
c.Flush()
state := <-stateCookie
diff --git a/xgob/xproto.go b/xproto/xproto.go
index 3791ae2..3791ae2 100644
--- a/xgob/xproto.go
+++ b/xproto/xproto.go