|
@@ -8,12 +8,10 @@ import "C"
|
|
|
import (
|
|
|
"bufio"
|
|
|
"bytes"
|
|
|
- "io"
|
|
|
"log"
|
|
|
"strings"
|
|
|
"syscall"
|
|
|
"time"
|
|
|
- "unicode"
|
|
|
"unsafe"
|
|
|
)
|
|
|
|
|
@@ -31,8 +29,6 @@ func RuneToInt8(r rune) int8 {
|
|
|
return int8(r)
|
|
|
}
|
|
|
|
|
|
-const READ_SIZE = 16 // Size of read buffer
|
|
|
-
|
|
|
func Reader(d *Door) {
|
|
|
// handle syscall.Handle, readerChannel *chan byte
|
|
|
C.init_wsa()
|
|
@@ -78,7 +74,8 @@ func Reader(d *Door) {
|
|
|
|
|
|
if r == 0 {
|
|
|
// timeout
|
|
|
- process(d, false)
|
|
|
+ ReadRune(d, runeread, true)
|
|
|
+ // process(d, false)
|
|
|
continue
|
|
|
}
|
|
|
gobytes := C.GoBytes(unsafe.Pointer(readerbuffer), read)
|
|
@@ -89,46 +86,50 @@ func Reader(d *Door) {
|
|
|
|
|
|
runebuffer.Write(gobytes)
|
|
|
|
|
|
- var input rune
|
|
|
+ ReadRune(d, runeread, false)
|
|
|
|
|
|
- // Is this unicode?
|
|
|
+ /*
|
|
|
+ var input rune
|
|
|
|
|
|
- var err error = nil
|
|
|
- for err == nil {
|
|
|
- //RuneRead:
|
|
|
+ // Is this unicode?
|
|
|
|
|
|
- input, _, err = runeread.ReadRune()
|
|
|
+ var err error = nil
|
|
|
+ for err == nil {
|
|
|
+ //RuneRead:
|
|
|
|
|
|
- if err == io.EOF {
|
|
|
- break // continue
|
|
|
- }
|
|
|
- if err != nil {
|
|
|
- if DEBUG_INPUT {
|
|
|
- log.Printf("ReadRune: %#v\n", err)
|
|
|
+ input, _, err = runeread.ReadRune()
|
|
|
+
|
|
|
+ if err == io.EOF {
|
|
|
+ break // continue
|
|
|
}
|
|
|
- // errors EOF
|
|
|
- break // continue // break for loop
|
|
|
- }
|
|
|
- if input == unicode.ReplacementChar {
|
|
|
- runeread.UnreadRune()
|
|
|
- b, _ := runeread.ReadByte()
|
|
|
- if DEBUG_INPUT {
|
|
|
- log.Printf("Reader (byte) >> %x\n", b)
|
|
|
+ if err != nil {
|
|
|
+ if DEBUG_INPUT {
|
|
|
+ log.Printf("ReadRune: %#v\n", err)
|
|
|
+ }
|
|
|
+ // errors EOF
|
|
|
+ break // continue // break for loop
|
|
|
}
|
|
|
- readerBuffer = append(readerBuffer, rune(b))
|
|
|
- // d.readerChannel <- rune(b)
|
|
|
- } else {
|
|
|
- if DEBUG_INPUT {
|
|
|
- log.Printf("Reader >> %x\n", input)
|
|
|
+ if input == unicode.ReplacementChar {
|
|
|
+ runeread.UnreadRune()
|
|
|
+ b, _ := runeread.ReadByte()
|
|
|
+ if DEBUG_INPUT {
|
|
|
+ log.Printf("Reader (byte) >> %x\n", b)
|
|
|
+ }
|
|
|
+ readerBuffer = append(readerBuffer, rune(b))
|
|
|
+ // d.readerChannel <- rune(b)
|
|
|
+ } else {
|
|
|
+ if DEBUG_INPUT {
|
|
|
+ log.Printf("Reader >> %x\n", input)
|
|
|
+ }
|
|
|
+ readerBuffer = append(readerBuffer, input)
|
|
|
+ // d.readerChannel <- input
|
|
|
}
|
|
|
- readerBuffer = append(readerBuffer, input)
|
|
|
- // d.readerChannel <- input
|
|
|
- }
|
|
|
- // process(d, true)
|
|
|
+ // process(d, true)
|
|
|
|
|
|
- } // goto RuneRead
|
|
|
+ } // goto RuneRead
|
|
|
|
|
|
- process(d, true)
|
|
|
+ process(d, true)
|
|
|
+ */
|
|
|
|
|
|
}
|
|
|
}
|