diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-11-21 07:03:38 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-11-21 07:03:38 +0000 |
commit | fabcaa8df3d6eb852b87821ef090d31d222870b7 (patch) | |
tree | 72455aea0286937aa08cc141e5efc800e4626577 /libgo/go/time | |
parent | a51fb17f48428e7cfc96a72a9f9f87901363bb6b (diff) | |
download | gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.zip gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.gz gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.bz2 |
libgo: Update to current version of master library.
From-SVN: r193688
Diffstat (limited to 'libgo/go/time')
-rw-r--r-- | libgo/go/time/format.go | 11 | ||||
-rw-r--r-- | libgo/go/time/sleep.go | 2 | ||||
-rw-r--r-- | libgo/go/time/tick.go | 4 | ||||
-rw-r--r-- | libgo/go/time/time_test.go | 2 | ||||
-rw-r--r-- | libgo/go/time/zoneinfo_read.go | 2 | ||||
-rw-r--r-- | libgo/go/time/zoneinfo_windows.go | 4 |
6 files changed, 16 insertions, 9 deletions
diff --git a/libgo/go/time/format.go b/libgo/go/time/format.go index 46f4fbc..aab4a4d 100644 --- a/libgo/go/time/format.go +++ b/libgo/go/time/format.go @@ -323,7 +323,8 @@ func atoi(s string) (x int, err error) { neg = true s = s[1:] } - x, rem, err := leadingInt(s) + q, rem, err := leadingInt(s) + x = int(q) if err != nil || rem != "" { return 0, atoiError } @@ -954,18 +955,18 @@ func parseNanoseconds(value string, nbytes int) (ns int, rangeErrString string, var errLeadingInt = errors.New("time: bad [0-9]*") // never printed // leadingInt consumes the leading [0-9]* from s. -func leadingInt(s string) (x int, rem string, err error) { +func leadingInt(s string) (x int64, rem string, err error) { i := 0 for ; i < len(s); i++ { c := s[i] if c < '0' || c > '9' { break } - if x >= (1<<31-10)/10 { + if x >= (1<<63-10)/10 { // overflow return 0, "", errLeadingInt } - x = x*10 + int(c) - '0' + x = x*10 + int64(c) - '0' } return x, s[i:], nil } @@ -1010,7 +1011,7 @@ func ParseDuration(s string) (Duration, error) { for s != "" { g := float64(0) // this element of the sequence - var x int + var x int64 var err error // The next character must be [0-9.] diff --git a/libgo/go/time/sleep.go b/libgo/go/time/sleep.go index 27820b0..657e254 100644 --- a/libgo/go/time/sleep.go +++ b/libgo/go/time/sleep.go @@ -36,6 +36,8 @@ type Timer struct { // Stop prevents the Timer from firing. // It returns true if the call stops the timer, false if the timer has already // expired or stopped. +// Stop does not close the channel, to prevent a read from the channel succeeding +// incorrectly. func (t *Timer) Stop() (ok bool) { return stopTimer(&t.r) } diff --git a/libgo/go/time/tick.go b/libgo/go/time/tick.go index 8c6b9bc..b92c339 100644 --- a/libgo/go/time/tick.go +++ b/libgo/go/time/tick.go @@ -6,7 +6,7 @@ package time import "errors" -// A Ticker holds a synchronous channel that delivers `ticks' of a clock +// A Ticker holds a channel that delivers `ticks' of a clock // at intervals. type Ticker struct { C <-chan Time // The channel on which the ticks are delivered. @@ -39,6 +39,8 @@ func NewTicker(d Duration) *Ticker { } // Stop turns off a ticker. After Stop, no more ticks will be sent. +// Stop does not close the channel, to prevent a read from the channel succeeding +// incorrectly. func (t *Ticker) Stop() { stopTimer(&t.r) } diff --git a/libgo/go/time/time_test.go b/libgo/go/time/time_test.go index 23bb6a5..9888d0d 100644 --- a/libgo/go/time/time_test.go +++ b/libgo/go/time/time_test.go @@ -999,6 +999,8 @@ var parseDurationTests = []struct { {"-2m3.4s", true, -(2*Minute + 3*Second + 400*Millisecond)}, {"1h2m3s4ms5us6ns", true, 1*Hour + 2*Minute + 3*Second + 4*Millisecond + 5*Microsecond + 6*Nanosecond}, {"39h9m14.425s", true, 39*Hour + 9*Minute + 14*Second + 425*Millisecond}, + // large value + {"52763797000ns", true, 52763797000 * Nanosecond}, // errors {"", false, 0}, diff --git a/libgo/go/time/zoneinfo_read.go b/libgo/go/time/zoneinfo_read.go index d57c09e..0eb20c7 100644 --- a/libgo/go/time/zoneinfo_read.go +++ b/libgo/go/time/zoneinfo_read.go @@ -284,7 +284,7 @@ func loadZoneZip(zipfile, name string) (l *Location, err error) { // 42 off[4] // 46 name[namelen] // 46+namelen+xlen+fclen - next header - // + // if get4(buf) != zcheader { break } diff --git a/libgo/go/time/zoneinfo_windows.go b/libgo/go/time/zoneinfo_windows.go index d596fab..a8d3dcb 100644 --- a/libgo/go/time/zoneinfo_windows.go +++ b/libgo/go/time/zoneinfo_windows.go @@ -15,9 +15,9 @@ import ( // BUG(brainman,rsc): On Windows, the operating system does not provide complete // time zone information. // The implementation assumes that this year's rules for daylight savings -// time apply to all previous and future years as well. +// time apply to all previous and future years as well. // Also, time zone abbreviations are unavailable. The implementation constructs -// them using the capital letters from a longer time zone description. +// them using the capital letters from a longer time zone description. // abbrev returns the abbreviation to use for the given zone name. func abbrev(name []uint16) string { |