mirror of
https://github.com/golang/go
synced 2024-11-25 05:47:57 -07:00
log: rename Exit* to Fatal*
This aligns the naming scheme with the testing package and also lets govet work on more logging calls. R=rsc CC=golang-dev https://golang.org/cl/4001048
This commit is contained in:
parent
6a13175f7d
commit
eea18d959e
@ -21,7 +21,7 @@ func main() {
|
|||||||
if *addr {
|
if *addr {
|
||||||
l, err := net.Listen("tcp", "127.0.0.1:0")
|
l, err := net.Listen("tcp", "127.0.0.1:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer l.Close()
|
defer l.Close()
|
||||||
fmt.Print(l.Addr())
|
fmt.Print(l.Addr())
|
||||||
@ -29,7 +29,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
url := flag.Arg(0)
|
url := flag.Arg(0)
|
||||||
if url == "" {
|
if url == "" {
|
||||||
log.Exit("no url supplied")
|
log.Fatal("no url supplied")
|
||||||
}
|
}
|
||||||
var r *http.Response
|
var r *http.Response
|
||||||
var err os.Error
|
var err os.Error
|
||||||
@ -40,11 +40,11 @@ func main() {
|
|||||||
r, _, err = http.Get(url)
|
r, _, err = http.Get(url)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
_, err = io.Copy(os.Stdout, r.Body)
|
_, err = io.Copy(os.Stdout, r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ func main() {
|
|||||||
fs := token.NewFileSet()
|
fs := token.NewFileSet()
|
||||||
file, err := parser.ParseFile(fs, *srcFn, nil, 0)
|
file, err := parser.ParseFile(fs, *srcFn, nil, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// create printer
|
// create printer
|
||||||
p := &printer.Config{
|
p := &printer.Config{
|
||||||
|
@ -1653,7 +1653,7 @@ correctness of the program state before real execution begins.
|
|||||||
<pre>
|
<pre>
|
||||||
func init() {
|
func init() {
|
||||||
if USER == "" {
|
if USER == "" {
|
||||||
log.Exit("$USER not set")
|
log.Fatal("$USER not set")
|
||||||
}
|
}
|
||||||
if HOME == "" {
|
if HOME == "" {
|
||||||
HOME = "/usr/" + USER
|
HOME = "/usr/" + USER
|
||||||
@ -2871,7 +2871,7 @@ func main() {
|
|||||||
http.Handle("/", http.HandlerFunc(QR))
|
http.Handle("/", http.HandlerFunc(QR))
|
||||||
err := http.ListenAndServe(*addr, nil)
|
err := http.ListenAndServe(*addr, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("ListenAndServe:", err)
|
log.Fatal("ListenAndServe:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ func read() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
n := len(lines)
|
n := len(lines)
|
||||||
lines = lines[0 : n+1]
|
lines = lines[0 : n+1]
|
||||||
|
@ -66,24 +66,24 @@ func main() {
|
|||||||
for i, builder := range flag.Args() {
|
for i, builder := range flag.Args() {
|
||||||
b, err := NewBuilder(builder)
|
b, err := NewBuilder(builder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
builders[i] = b
|
builders[i] = b
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(*buildroot); err != nil {
|
if err := os.RemoveAll(*buildroot); err != nil {
|
||||||
log.Exitf("Error removing build root (%s): %s", *buildroot, err)
|
log.Fatalf("Error removing build root (%s): %s", *buildroot, err)
|
||||||
}
|
}
|
||||||
if err := os.Mkdir(*buildroot, mkdirPerm); err != nil {
|
if err := os.Mkdir(*buildroot, mkdirPerm); err != nil {
|
||||||
log.Exitf("Error making build root (%s): %s", *buildroot, err)
|
log.Fatalf("Error making build root (%s): %s", *buildroot, err)
|
||||||
}
|
}
|
||||||
if err := run(nil, *buildroot, "hg", "clone", hgUrl, goroot); err != nil {
|
if err := run(nil, *buildroot, "hg", "clone", hgUrl, goroot); err != nil {
|
||||||
log.Exit("Error cloning repository:", err)
|
log.Fatal("Error cloning repository:", err)
|
||||||
}
|
}
|
||||||
// if specified, build revision and return
|
// if specified, build revision and return
|
||||||
if *buildRevision != "" {
|
if *buildRevision != "" {
|
||||||
c, err := getCommit(*buildRevision)
|
c, err := getCommit(*buildRevision)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("Error finding revision: ", err)
|
log.Fatal("Error finding revision: ", err)
|
||||||
}
|
}
|
||||||
for _, b := range builders {
|
for _, b := range builders {
|
||||||
if err := b.buildCommit(c); err != nil {
|
if err := b.buildCommit(c); err != nil {
|
||||||
|
@ -42,7 +42,7 @@ func main() {
|
|||||||
case "386":
|
case "386":
|
||||||
archChar = "8"
|
archChar = "8"
|
||||||
default:
|
default:
|
||||||
log.Exitln("unrecognized GOARCH:", runtime.GOARCH)
|
log.Fatalln("unrecognized GOARCH:", runtime.GOARCH)
|
||||||
}
|
}
|
||||||
|
|
||||||
// source of unique numbers
|
// source of unique numbers
|
||||||
@ -54,7 +54,7 @@ func main() {
|
|||||||
|
|
||||||
http.HandleFunc("/", FrontPage)
|
http.HandleFunc("/", FrontPage)
|
||||||
http.HandleFunc("/compile", Compile)
|
http.HandleFunc("/compile", Compile)
|
||||||
log.Exit(http.ListenAndServe(*httpListen, nil))
|
log.Fatal(http.ListenAndServe(*httpListen, nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FrontPage is an HTTP handler that renders the goplay interface.
|
// FrontPage is an HTTP handler that renders the goplay interface.
|
||||||
|
@ -625,11 +625,11 @@ func readTemplate(name string) *template.Template {
|
|||||||
path := pathutil.Join(*goroot, "lib/godoc/"+name)
|
path := pathutil.Join(*goroot, "lib/godoc/"+name)
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exitf("ReadFile %s: %v", path, err)
|
log.Fatalf("ReadFile %s: %v", path, err)
|
||||||
}
|
}
|
||||||
t, err := template.Parse(string(data), fmap)
|
t, err := template.Parse(string(data), fmap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exitf("%s: %v", name, err)
|
log.Fatalf("%s: %v", name, err)
|
||||||
}
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *tabwidth < 0 {
|
if *tabwidth < 0 {
|
||||||
log.Exitf("negative tabwidth %d", *tabwidth)
|
log.Fatalf("negative tabwidth %d", *tabwidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
initHandlers()
|
initHandlers()
|
||||||
@ -284,7 +284,7 @@ func main() {
|
|||||||
|
|
||||||
// Start http server.
|
// Start http server.
|
||||||
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
|
if err := http.ListenAndServe(*httpAddr, handler); err != nil {
|
||||||
log.Exitf("ListenAndServe %s: %v", *httpAddr, err)
|
log.Fatalf("ListenAndServe %s: %v", *httpAddr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -301,7 +301,7 @@ func main() {
|
|||||||
for i := 0; i < flag.NArg(); i++ {
|
for i := 0; i < flag.NArg(); i++ {
|
||||||
res, err := remoteSearch(flag.Arg(i))
|
res, err := remoteSearch(flag.Arg(i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exitf("remoteSearch: %s", err)
|
log.Fatalf("remoteSearch: %s", err)
|
||||||
}
|
}
|
||||||
io.Copy(os.Stdout, res.Body)
|
io.Copy(os.Stdout, res.Body)
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ func main() {
|
|||||||
info = cmdHandler.getPageInfo(abspath, relpath, "", mode)
|
info = cmdHandler.getPageInfo(abspath, relpath, "", mode)
|
||||||
}
|
}
|
||||||
if info.Err != nil {
|
if info.Err != nil {
|
||||||
log.Exitf("%v", info.Err)
|
log.Fatalf("%v", info.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have more than one argument, use the remaining arguments for filtering
|
// If we have more than one argument, use the remaining arguments for filtering
|
||||||
@ -352,7 +352,7 @@ func main() {
|
|||||||
args := flag.Args()[1:]
|
args := flag.Args()[1:]
|
||||||
rx := makeRx(args)
|
rx := makeRx(args)
|
||||||
if rx == nil {
|
if rx == nil {
|
||||||
log.Exitf("illegal regular expression from %v", args)
|
log.Fatalf("illegal regular expression from %v", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
filter := func(s string) bool { return rx.MatchString(s) }
|
filter := func(s string) bool { return rx.MatchString(s) }
|
||||||
|
@ -27,7 +27,7 @@ func TestLookPathNotFound(t *testing.T) {
|
|||||||
t.Fatal("LookPath error is not a PathError")
|
t.Fatal("LookPath error is not a PathError")
|
||||||
}
|
}
|
||||||
if perr.Name != name {
|
if perr.Name != name {
|
||||||
t.Fatal("want PathError name %q, got %q", name, perr.Name)
|
t.Fatalf("want PathError name %q, got %q", name, perr.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ func Serve(l net.Listener, handler Handler) os.Error {
|
|||||||
// http.HandleFunc("/hello", HelloServer)
|
// http.HandleFunc("/hello", HelloServer)
|
||||||
// err := http.ListenAndServe(":12345", nil)
|
// err := http.ListenAndServe(":12345", nil)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Exit("ListenAndServe: ", err.String())
|
// log.Fatal("ListenAndServe: ", err.String())
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
func ListenAndServe(addr string, handler Handler) os.Error {
|
func ListenAndServe(addr string, handler Handler) os.Error {
|
||||||
@ -745,7 +745,7 @@ func ListenAndServe(addr string, handler Handler) os.Error {
|
|||||||
// log.Printf("About to listen on 10443. Go to https://127.0.0.1:10443/")
|
// log.Printf("About to listen on 10443. Go to https://127.0.0.1:10443/")
|
||||||
// err := http.ListenAndServeTLS(":10443", "cert.pem", "key.pem", nil)
|
// err := http.ListenAndServeTLS(":10443", "cert.pem", "key.pem", nil)
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// log.Exit(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
// Simple logging package. It defines a type, Logger, with methods
|
// Simple logging package. It defines a type, Logger, with methods
|
||||||
// for formatting output. It also has a predefined 'standard' Logger
|
// for formatting output. It also has a predefined 'standard' Logger
|
||||||
// accessible through helper functions Print[f|ln], Exit[f|ln], and
|
// accessible through helper functions Print[f|ln], Fatal[f|ln], and
|
||||||
// Panic[f|ln], which are easier to use than creating a Logger manually.
|
// Panic[f|ln], which are easier to use than creating a Logger manually.
|
||||||
// That logger writes to standard error and prints the date and time
|
// That logger writes to standard error and prints the date and time
|
||||||
// of each logged message.
|
// of each logged message.
|
||||||
// The Exit functions call os.Exit(1) after writing the log message.
|
// The Fatal functions call os.Exit(1) after writing the log message.
|
||||||
// The Panic functions call panic after writing the log message.
|
// The Panic functions call panic after writing the log message.
|
||||||
package log
|
package log
|
||||||
|
|
||||||
@ -164,20 +164,20 @@ func (l *Logger) Print(v ...interface{}) { l.Output(2, fmt.Sprint(v...)) }
|
|||||||
// Arguments are handled in the manner of fmt.Println.
|
// Arguments are handled in the manner of fmt.Println.
|
||||||
func (l *Logger) Println(v ...interface{}) { l.Output(2, fmt.Sprintln(v...)) }
|
func (l *Logger) Println(v ...interface{}) { l.Output(2, fmt.Sprintln(v...)) }
|
||||||
|
|
||||||
// Exit is equivalent to l.Print() followed by a call to os.Exit(1).
|
// Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
|
||||||
func (l *Logger) Exit(v ...interface{}) {
|
func (l *Logger) Fatal(v ...interface{}) {
|
||||||
l.Output(2, fmt.Sprint(v...))
|
l.Output(2, fmt.Sprint(v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exitf is equivalent to l.Printf() followed by a call to os.Exit(1).
|
// Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
|
||||||
func (l *Logger) Exitf(format string, v ...interface{}) {
|
func (l *Logger) Fatalf(format string, v ...interface{}) {
|
||||||
l.Output(2, fmt.Sprintf(format, v...))
|
l.Output(2, fmt.Sprintf(format, v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exitln is equivalent to l.Println() followed by a call to os.Exit(1).
|
// Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
|
||||||
func (l *Logger) Exitln(v ...interface{}) {
|
func (l *Logger) Fatalln(v ...interface{}) {
|
||||||
l.Output(2, fmt.Sprintln(v...))
|
l.Output(2, fmt.Sprintln(v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -238,20 +238,20 @@ func Println(v ...interface{}) {
|
|||||||
std.Output(2, fmt.Sprintln(v...))
|
std.Output(2, fmt.Sprintln(v...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit is equivalent to Print() followed by a call to os.Exit(1).
|
// Fatal is equivalent to Print() followed by a call to os.Exit(1).
|
||||||
func Exit(v ...interface{}) {
|
func Fatal(v ...interface{}) {
|
||||||
std.Output(2, fmt.Sprint(v...))
|
std.Output(2, fmt.Sprint(v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exitf is equivalent to Printf() followed by a call to os.Exit(1).
|
// Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
|
||||||
func Exitf(format string, v ...interface{}) {
|
func Fatalf(format string, v ...interface{}) {
|
||||||
std.Output(2, fmt.Sprintf(format, v...))
|
std.Output(2, fmt.Sprintf(format, v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exitln is equivalent to Println() followed by a call to os.Exit(1).
|
// Fatalln is equivalent to Println() followed by a call to os.Exit(1).
|
||||||
func Exitln(v ...interface{}) {
|
func Fatalln(v ...interface{}) {
|
||||||
std.Output(2, fmt.Sprintln(v...))
|
std.Output(2, fmt.Sprintln(v...))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func (client *expClient) run() {
|
|||||||
nch.acked()
|
nch.acked()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.Exit("netchan export: unknown payload type", hdr.PayloadType)
|
log.Fatal("netchan export: unknown payload type", hdr.PayloadType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.exp.delClient(client)
|
client.exp.delClient(client)
|
||||||
|
@ -176,10 +176,10 @@ func (imp *Importer) Import(name string, chT interface{}, dir Dir, size int) os.
|
|||||||
// ImportNValues(name string, chT chan T, dir Dir, size, n int) os.Error
|
// ImportNValues(name string, chT chan T, dir Dir, size, n int) os.Error
|
||||||
// Example usage:
|
// Example usage:
|
||||||
// imp, err := NewImporter("tcp", "netchanserver.mydomain.com:1234")
|
// imp, err := NewImporter("tcp", "netchanserver.mydomain.com:1234")
|
||||||
// if err != nil { log.Exit(err) }
|
// if err != nil { log.Fatal(err) }
|
||||||
// ch := make(chan myType)
|
// ch := make(chan myType)
|
||||||
// err = imp.ImportNValues("name", ch, Recv, 1, 1)
|
// err = imp.ImportNValues("name", ch, Recv, 1, 1)
|
||||||
// if err != nil { log.Exit(err) }
|
// if err != nil { log.Fatal(err) }
|
||||||
// fmt.Printf("%+v\n", <-ch)
|
// fmt.Printf("%+v\n", <-ch)
|
||||||
func (imp *Importer) ImportNValues(name string, chT interface{}, dir Dir, size, n int) os.Error {
|
func (imp *Importer) ImportNValues(name string, chT interface{}, dir Dir, size, n int) os.Error {
|
||||||
ch, err := checkChan(chT, dir)
|
ch, err := checkChan(chT, dir)
|
||||||
|
@ -73,7 +73,7 @@
|
|||||||
rpc.HandleHTTP()
|
rpc.HandleHTTP()
|
||||||
l, e := net.Listen("tcp", ":1234")
|
l, e := net.Listen("tcp", ":1234")
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Exit("listen error:", e)
|
log.Fatal("listen error:", e)
|
||||||
}
|
}
|
||||||
go http.Serve(l, nil)
|
go http.Serve(l, nil)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
client, err := rpc.DialHTTP("tcp", serverAddress + ":1234")
|
client, err := rpc.DialHTTP("tcp", serverAddress + ":1234")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("dialing:", err)
|
log.Fatal("dialing:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Then it can make a remote call:
|
Then it can make a remote call:
|
||||||
@ -92,7 +92,7 @@
|
|||||||
var reply int
|
var reply int
|
||||||
err = client.Call("Arith.Multiply", args, &reply)
|
err = client.Call("Arith.Multiply", args, &reply)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("arith error:", err)
|
log.Fatal("arith error:", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Arith: %d*%d=%d", args.A, args.B, *reply)
|
fmt.Printf("Arith: %d*%d=%d", args.A, args.B, *reply)
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ func (server *Server) register(rcvr interface{}, name string, useName bool) os.E
|
|||||||
sname = name
|
sname = name
|
||||||
}
|
}
|
||||||
if sname == "" {
|
if sname == "" {
|
||||||
log.Exit("rpc: no service name for type", s.typ.String())
|
log.Fatal("rpc: no service name for type", s.typ.String())
|
||||||
}
|
}
|
||||||
if s.typ.PkgPath() != "" && !isExported(sname) && !useName {
|
if s.typ.PkgPath() != "" && !isExported(sname) && !useName {
|
||||||
s := "rpc Register: type " + sname + " is not exported"
|
s := "rpc Register: type " + sname + " is not exported"
|
||||||
@ -445,7 +445,7 @@ func (server *Server) Accept(lis net.Listener) {
|
|||||||
for {
|
for {
|
||||||
conn, err := lis.Accept()
|
conn, err := lis.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Exit("rpc.Serve: accept:", err.String()) // TODO(r): exit?
|
log.Fatal("rpc.Serve: accept:", err.String()) // TODO(r): exit?
|
||||||
}
|
}
|
||||||
go server.ServeConn(conn)
|
go server.ServeConn(conn)
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func (t *Arith) Error(args *Args, reply *Reply) os.Error {
|
|||||||
func listenTCP() (net.Listener, string) {
|
func listenTCP() (net.Listener, string) {
|
||||||
l, e := net.Listen("tcp", "127.0.0.1:0") // any available address
|
l, e := net.Listen("tcp", "127.0.0.1:0") // any available address
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Exitf("net.Listen tcp :0: %v", e)
|
log.Fatalf("net.Listen tcp :0: %v", e)
|
||||||
}
|
}
|
||||||
return l, l.Addr().String()
|
return l, l.Addr().String()
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ func runSyslog(c net.PacketConn, done chan<- string) {
|
|||||||
func startServer(done chan<- string) {
|
func startServer(done chan<- string) {
|
||||||
c, e := net.ListenPacket("udp", "127.0.0.1:0")
|
c, e := net.ListenPacket("udp", "127.0.0.1:0")
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Exitf("net.ListenPacket failed udp :0 %v", e)
|
log.Fatalf("net.ListenPacket failed udp :0 %v", e)
|
||||||
}
|
}
|
||||||
serverAddr = c.LocalAddr().String()
|
serverAddr = c.LocalAddr().String()
|
||||||
c.SetReadTimeout(100e6) // 100ms
|
c.SetReadTimeout(100e6) // 100ms
|
||||||
|
@ -141,11 +141,11 @@ const (
|
|||||||
func parseCategory(line string) (state State) {
|
func parseCategory(line string) (state State) {
|
||||||
field := strings.Split(line, ";", -1)
|
field := strings.Split(line, ";", -1)
|
||||||
if len(field) != NumField {
|
if len(field) != NumField {
|
||||||
logger.Exitf("%5s: %d fields (expected %d)\n", line, len(field), NumField)
|
logger.Fatalf("%5s: %d fields (expected %d)\n", line, len(field), NumField)
|
||||||
}
|
}
|
||||||
point, err := strconv.Btoui64(field[FCodePoint], 16)
|
point, err := strconv.Btoui64(field[FCodePoint], 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exitf("%.5s...: %s", line, err)
|
logger.Fatalf("%.5s...: %s", line, err)
|
||||||
}
|
}
|
||||||
lastChar = uint32(point)
|
lastChar = uint32(point)
|
||||||
if point == 0 {
|
if point == 0 {
|
||||||
@ -157,7 +157,7 @@ func parseCategory(line string) (state State) {
|
|||||||
char := &chars[point]
|
char := &chars[point]
|
||||||
char.field = field
|
char.field = field
|
||||||
if char.codePoint != 0 {
|
if char.codePoint != 0 {
|
||||||
logger.Exitf("point %U reused", point)
|
logger.Fatalf("point %U reused", point)
|
||||||
}
|
}
|
||||||
char.codePoint = lastChar
|
char.codePoint = lastChar
|
||||||
char.category = field[FGeneralCategory]
|
char.category = field[FGeneralCategory]
|
||||||
@ -167,7 +167,7 @@ func parseCategory(line string) (state State) {
|
|||||||
// Decimal digit
|
// Decimal digit
|
||||||
_, err := strconv.Atoi(field[FNumericValue])
|
_, err := strconv.Atoi(field[FNumericValue])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exitf("%U: bad numeric field: %s", point, err)
|
logger.Fatalf("%U: bad numeric field: %s", point, err)
|
||||||
}
|
}
|
||||||
case "Lu":
|
case "Lu":
|
||||||
char.letter(field[FCodePoint], field[FSimpleLowercaseMapping], field[FSimpleTitlecaseMapping])
|
char.letter(field[FCodePoint], field[FSimpleLowercaseMapping], field[FSimpleTitlecaseMapping])
|
||||||
@ -208,7 +208,7 @@ func (char *Char) letterValue(s string, cas string) int {
|
|||||||
v, err := strconv.Btoui64(s, 16)
|
v, err := strconv.Btoui64(s, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
char.dump(cas)
|
char.dump(cas)
|
||||||
logger.Exitf("%U: bad letter(%s): %s", char.codePoint, s, err)
|
logger.Fatalf("%U: bad letter(%s): %s", char.codePoint, s, err)
|
||||||
}
|
}
|
||||||
return int(v)
|
return int(v)
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ func version() string {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Exit("unknown version")
|
logger.Fatal("unknown version")
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,10 +260,10 @@ func loadChars() {
|
|||||||
}
|
}
|
||||||
resp, _, err := http.Get(*dataURL)
|
resp, _, err := http.Get(*dataURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exit(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
logger.Exit("bad GET status for UnicodeData.txt", resp.Status)
|
logger.Fatal("bad GET status for UnicodeData.txt", resp.Status)
|
||||||
}
|
}
|
||||||
input := bufio.NewReader(resp.Body)
|
input := bufio.NewReader(resp.Body)
|
||||||
var first uint32 = 0
|
var first uint32 = 0
|
||||||
@ -273,21 +273,21 @@ func loadChars() {
|
|||||||
if err == os.EOF {
|
if err == os.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logger.Exit(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
switch parseCategory(line[0 : len(line)-1]) {
|
switch parseCategory(line[0 : len(line)-1]) {
|
||||||
case SNormal:
|
case SNormal:
|
||||||
if first != 0 {
|
if first != 0 {
|
||||||
logger.Exitf("bad state normal at U+%04X", lastChar)
|
logger.Fatalf("bad state normal at U+%04X", lastChar)
|
||||||
}
|
}
|
||||||
case SFirst:
|
case SFirst:
|
||||||
if first != 0 {
|
if first != 0 {
|
||||||
logger.Exitf("bad state first at U+%04X", lastChar)
|
logger.Fatalf("bad state first at U+%04X", lastChar)
|
||||||
}
|
}
|
||||||
first = lastChar
|
first = lastChar
|
||||||
case SLast:
|
case SLast:
|
||||||
if first == 0 {
|
if first == 0 {
|
||||||
logger.Exitf("bad state last at U+%04X", lastChar)
|
logger.Fatalf("bad state last at U+%04X", lastChar)
|
||||||
}
|
}
|
||||||
for i := first + 1; i <= lastChar; i++ {
|
for i := first + 1; i <= lastChar; i++ {
|
||||||
chars[i] = chars[first]
|
chars[i] = chars[first]
|
||||||
@ -336,7 +336,7 @@ func printCategories() {
|
|||||||
ndecl := 0
|
ndecl := 0
|
||||||
for _, name := range list {
|
for _, name := range list {
|
||||||
if _, ok := category[name]; !ok {
|
if _, ok := category[name]; !ok {
|
||||||
logger.Exit("unknown category", name)
|
logger.Fatal("unknown category", name)
|
||||||
}
|
}
|
||||||
// We generate an UpperCase name to serve as concise documentation and an _UnderScored
|
// We generate an UpperCase name to serve as concise documentation and an _UnderScored
|
||||||
// name to store the data. This stops godoc dumping all the tables but keeps them
|
// name to store the data. This stops godoc dumping all the tables but keeps them
|
||||||
@ -437,11 +437,11 @@ func dumpRange(header string, inCategory Op) {
|
|||||||
func fullCategoryTest(list []string) {
|
func fullCategoryTest(list []string) {
|
||||||
for _, name := range list {
|
for _, name := range list {
|
||||||
if _, ok := category[name]; !ok {
|
if _, ok := category[name]; !ok {
|
||||||
logger.Exit("unknown category", name)
|
logger.Fatal("unknown category", name)
|
||||||
}
|
}
|
||||||
r, ok := unicode.Categories[name]
|
r, ok := unicode.Categories[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Exit("unknown table", name)
|
logger.Fatal("unknown table", name)
|
||||||
}
|
}
|
||||||
if name == "letter" {
|
if name == "letter" {
|
||||||
verifyRange(name, letterOp, r)
|
verifyRange(name, letterOp, r)
|
||||||
@ -475,21 +475,21 @@ func parseScript(line string, scripts map[string][]Script) {
|
|||||||
}
|
}
|
||||||
field := strings.Split(line, ";", -1)
|
field := strings.Split(line, ";", -1)
|
||||||
if len(field) != 2 {
|
if len(field) != 2 {
|
||||||
logger.Exitf("%s: %d fields (expected 2)\n", line, len(field))
|
logger.Fatalf("%s: %d fields (expected 2)\n", line, len(field))
|
||||||
}
|
}
|
||||||
matches := scriptRe.FindStringSubmatch(line)
|
matches := scriptRe.FindStringSubmatch(line)
|
||||||
if len(matches) != 4 {
|
if len(matches) != 4 {
|
||||||
logger.Exitf("%s: %d matches (expected 3)\n", line, len(matches))
|
logger.Fatalf("%s: %d matches (expected 3)\n", line, len(matches))
|
||||||
}
|
}
|
||||||
lo, err := strconv.Btoui64(matches[1], 16)
|
lo, err := strconv.Btoui64(matches[1], 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exitf("%.5s...: %s", line, err)
|
logger.Fatalf("%.5s...: %s", line, err)
|
||||||
}
|
}
|
||||||
hi := lo
|
hi := lo
|
||||||
if len(matches[2]) > 2 { // ignore leading ..
|
if len(matches[2]) > 2 { // ignore leading ..
|
||||||
hi, err = strconv.Btoui64(matches[2][2:], 16)
|
hi, err = strconv.Btoui64(matches[2][2:], 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exitf("%.5s...: %s", line, err)
|
logger.Fatalf("%.5s...: %s", line, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
name := matches[3]
|
name := matches[3]
|
||||||
@ -515,11 +515,11 @@ func foldAdjacent(r []Script) []unicode.Range {
|
|||||||
func fullScriptTest(list []string, installed map[string][]unicode.Range, scripts map[string][]Script) {
|
func fullScriptTest(list []string, installed map[string][]unicode.Range, scripts map[string][]Script) {
|
||||||
for _, name := range list {
|
for _, name := range list {
|
||||||
if _, ok := scripts[name]; !ok {
|
if _, ok := scripts[name]; !ok {
|
||||||
logger.Exit("unknown script", name)
|
logger.Fatal("unknown script", name)
|
||||||
}
|
}
|
||||||
_, ok := installed[name]
|
_, ok := installed[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
logger.Exit("unknown table", name)
|
logger.Fatal("unknown table", name)
|
||||||
}
|
}
|
||||||
for _, script := range scripts[name] {
|
for _, script := range scripts[name] {
|
||||||
for r := script.lo; r <= script.hi; r++ {
|
for r := script.lo; r <= script.hi; r++ {
|
||||||
@ -551,10 +551,10 @@ func printScriptOrProperty(doProps bool) {
|
|||||||
var err os.Error
|
var err os.Error
|
||||||
resp, _, err := http.Get(*url + file)
|
resp, _, err := http.Get(*url + file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Exit(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
logger.Exit("bad GET status for ", file, ":", resp.Status)
|
logger.Fatal("bad GET status for ", file, ":", resp.Status)
|
||||||
}
|
}
|
||||||
input := bufio.NewReader(resp.Body)
|
input := bufio.NewReader(resp.Body)
|
||||||
for {
|
for {
|
||||||
@ -563,7 +563,7 @@ func printScriptOrProperty(doProps bool) {
|
|||||||
if err == os.EOF {
|
if err == os.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logger.Exit(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
parseScript(line[0:len(line)-1], table)
|
parseScript(line[0:len(line)-1], table)
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ func printCaseRange(lo, hi *caseState) {
|
|||||||
fmt.Printf("\t{0x%04X, 0x%04X, d{UpperLower, UpperLower, UpperLower}},\n",
|
fmt.Printf("\t{0x%04X, 0x%04X, d{UpperLower, UpperLower, UpperLower}},\n",
|
||||||
lo.point, hi.point)
|
lo.point, hi.point)
|
||||||
case hi.point > lo.point && lo.isLowerUpper():
|
case hi.point > lo.point && lo.isLowerUpper():
|
||||||
logger.Exitf("LowerUpper sequence: should not happen: U+%04X. If it's real, need to fix To()", lo.point)
|
logger.Fatalf("LowerUpper sequence: should not happen: U+%04X. If it's real, need to fix To()", lo.point)
|
||||||
fmt.Printf("\t{0x%04X, 0x%04X, d{LowerUpper, LowerUpper, LowerUpper}},\n",
|
fmt.Printf("\t{0x%04X, 0x%04X, d{LowerUpper, LowerUpper, LowerUpper}},\n",
|
||||||
lo.point, hi.point)
|
lo.point, hi.point)
|
||||||
default:
|
default:
|
||||||
|
@ -24,7 +24,7 @@ func echoServer(ws *Conn) { io.Copy(ws, ws) }
|
|||||||
func startServer() {
|
func startServer() {
|
||||||
l, e := net.Listen("tcp", "127.0.0.1:0") // any available address
|
l, e := net.Listen("tcp", "127.0.0.1:0") // any available address
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Exitf("net.Listen tcp :0 %v", e)
|
log.Fatalf("net.Listen tcp :0 %v", e)
|
||||||
}
|
}
|
||||||
serverAddr = l.Addr().String()
|
serverAddr = l.Addr().String()
|
||||||
log.Print("Test WebSocket server listening on ", serverAddr)
|
log.Print("Test WebSocket server listening on ", serverAddr)
|
||||||
|
@ -127,7 +127,7 @@ func main() {
|
|||||||
gcstats("BenchmarkParser", *n, t1-t0)
|
gcstats("BenchmarkParser", *n, t1-t0)
|
||||||
|
|
||||||
if *serve != "" {
|
if *serve != "" {
|
||||||
log.Exit(http.ListenAndServe(*serve, nil))
|
log.Fatal(http.ListenAndServe(*serve, nil))
|
||||||
println(lastParsed)
|
println(lastParsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user