1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:31:22 -06:00
Commit Graph

145 Commits

Author SHA1 Message Date
Michael T. Jones
d94e350f48 fmt: Added SkipSpace() function to fmt's ScanState interface.
Users of the Scan() infrastructure that employ ReadRune() rather than
Token() need a way to skip leading spaces and newlines as set by the
the parent, Fscan(), Fscanln, or Fscanf(). As the internal methods and
boolean flags are not exported, this new function was added here and
in the Int and Nat Scan() functions of the big package. (fmt.Rat did
not need change since it uses Token()) Also added Printf style format
code support to int types and tests for same to int_test.go

R=r, r, gri, mtj
CC=golang-dev
https://golang.org/cl/4634074
2011-06-24 17:26:45 -07:00
Robert Griesemer
712fb6dcd3 os.Error API: don't export os.ErrorString, use os.NewError consistently
This is a core API change.

1) gofix misc src
2) Manual adjustments to the following files under src/pkg:
   gob/decode.go
   rpc/client.go
   os/error.go
   io/io.go
   bufio/bufio.go
   http/request.go
   websocket/client.go
as well as:
   src/cmd/gofix/testdata/*.go.in (reverted)
   test/fixedbugs/bug243.go
3) Implemented gofix patch (oserrorstring.go) and test case (oserrorstring_test.go)

Compiles and runs all tests.

R=r, rsc, gri
CC=golang-dev
https://golang.org/cl/4607052
2011-06-22 10:52:47 -07:00
Rob Pike
97a929aac9 fmt: catch panics from calls to String etc.
This change causes Print et al. to catch panics generated by
calls to String, GoString, and Format.  The panic is formatted
into the output stream as an error, but the program continues.
As a special case, if the argument was a nil pointer, the
result is just "<nil>", because that's almost certainly enough
information and handles the very common case of String
methods that don't guard against nil.

Scan does not want this change. Input must work; output can
be for debugging and it's nice to get output even when you
make a mistake.

R=dsymonds, r, adg, gri, rsc, gri
CC=golang-dev
https://golang.org/cl/4640043
2011-06-21 08:31:02 +10:00
Russ Cox
21e75da486 respect goto restrictions
R=gri
CC=golang-dev
https://golang.org/cl/4625044
2011-06-17 06:07:13 -04:00
Rob Pike
d152fe74e1 fmt: debugging formats for characters: %+q %#U
%+q uses strconv.Quote[Rune]ToASCII, guaranteeing ASCII-only output.
%#U a quoted character if the rune is printable: 'x'=U+0078; otherwise
it's as before: U+000A.

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/4589047
2011-06-11 00:03:02 +00:00
Rob Pike
f2f3b8fa99 strconv: change Quote to be Unicode-friendly,
add QuoteToASCII.
The Quote and QuoteRune functions now let printable
runes (as defined by unicode.IsPrint) through.  When
true 7-bit clean stuff is necessary, there are now two
new functions: QuoteToASCII and QuoteRuneToASCII.

Printf("%q") uses Quote. To get the old behavior, it
will now be necessary to say
        Printf("%s", strconv.QuoteToASCII(s))
but that should rarely be necessary.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/4561061
2011-06-07 12:23:08 +00:00
Rob Pike
ce5c1cf036 fmt: fix bug in UnreadRune: must clear memory of previous
rune if input implements UnreadRune; otherwise the lookahead
will lie.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4548082
2011-06-03 07:53:50 +10:00
Rob Pike
60dddc6db1 fmt: return EOF when out of input in Scan*.
Fixes #1840.

R=rsc
CC=golang-dev
https://golang.org/cl/4548077
2011-06-02 10:51:31 +10:00
Robert Griesemer
e8c87a7ddd fix build: temporarily disable the use of strings.Reader UnreadRune in fmt
R=r
CC=golang-dev
https://golang.org/cl/4532090
2011-05-26 11:54:10 -07:00
Rob Pike
7b03f2a990 fmt: make %q work for integers, printing a quoted character literal.
R=rsc
CC=golang-dev
https://golang.org/cl/4556060
2011-05-25 21:25:15 +10:00
Evan Shaw
3230fd1469 fmt: scanning doc fix
R=r
CC=golang-dev
https://golang.org/cl/4539073
2011-05-21 07:38:01 +10:00
Robert Griesemer
bda36cf3ab fmt: fix minor documentation nits
R=r, rsc
CC=golang-dev
https://golang.org/cl/4556041
2011-05-18 11:34:19 -07:00
Russ Cox
07abf1c732 fix tree for reflect rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
2011-04-25 13:39:36 -04:00
Rob Pike
f3113ee9b9 fmt: tweak the doc for %U.
Fixes #1727.

R=rsc
CC=golang-dev
https://golang.org/cl/4437069
2011-04-23 11:25:27 -07:00
Ian Lance Taylor
14531fbaa5 fmt: decrease recursion depth
This permits the test to run when using gccgo on system
without split-stack support.  See
http://gcc.gnu.org/ml/gcc-patches/2011-04/msg01420.html
http://gcc.gnu.org/PR48553

R=r
CC=golang-dev
https://golang.org/cl/4440062
2011-04-22 16:59:21 -07:00
Rob Pike
4fe9f57413 fmt: allow %U for unsigned integers.
Suggested by jan.mercl@nic.cz.

R=rsc, jnml
CC=golang-dev
https://golang.org/cl/4376054
2011-04-12 11:03:05 -07:00
Russ Cox
db5c5d6fa6 update go tree for reflect changes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4353043
2011-04-08 12:27:58 -04:00
Rob Pike
3907031358 fmt: implement precs for %q.
Also fix a bug: precision was in terms of bytes; should be runes.
Fixes #1652.

R=rsc, bradfitzgo, r2, bradfitzwork
CC=golang-dev
https://golang.org/cl/4280086
2011-03-31 14:56:01 -07:00
Russ Cox
b66b22cdd4 fmt: remove uintptrGetter type checks
This will make the fmt code easier to gofix
when the new reflect interface is ready.

R=r
CC=golang-dev
https://golang.org/cl/4324043
2011-03-30 22:12:30 -04:00
Rob Pike
7f9acb53cb testing: shorten some more tests
R=rsc
CC=golang-dev
https://golang.org/cl/4314044
2011-03-26 11:25:22 -07:00
Rob Pike
a16af59fd1 fmt: heaven forfend we export EOF = -1
R=adg
CC=golang-dev
https://golang.org/cl/4248076
2011-03-09 16:53:32 -08:00
Roger Peppe
3a95587e01 fmt: make ScanState.Token more general.
When writing custom scanners, I found that
Token itself was rarely useful, as I did not always
want to stop at white space. This change makes
it possible to stop at any class of characters
while reusing the buffer within State.
(also fix a bug in Token)

R=r, r2
CC=golang-dev
https://golang.org/cl/4243055
2011-03-09 10:01:47 -08:00
Rob Pike
8138654aa8 govet: handle '*' in print format strings.
While we're on govet, fix a couple of mistakes in a test.

Fixes #1592.

R=rsc
CC=golang-dev
https://golang.org/cl/4239071
2011-03-08 14:36:56 -08:00
Robert Hencke
ff3ef8a963 fmt: trivial cleanup
R=golang-dev, bradfitzgo
CC=golang-dev
https://golang.org/cl/4235052
2011-03-05 17:55:53 -08:00
Roger Peppe
5bd284e868 fmt: make recursive scan more efficient.
Detect when scan is being called recursively and
re-use the same scan state.

On my machine, for a recursion-heavy benchmark, this
results in 44x speed up. This does impose a 4% penalty
on the non-recursive case, which can be removed by
heap-allocating the saved state, at 40% performance penalty
on the recursive case. Either way is fine with me.

R=r
CC=golang-dev
https://golang.org/cl/4253049
2011-03-03 10:43:29 -08:00
Roger Peppe
81bfbe9333 fmt: allow recursive calls to Fscan etc.
Add a new Read method to ScanState so that it
satisfies the io.Reader interface; rename
Getrune and Ungetrune to ReadRune and UnreadRune.
Make sure ReadRune does not read past width restrictions;
remove now-unnecessary Width method from ScanState.
Also make the documentation a little clearer as to
how ReadRune and UnreadRune are used.

R=r, r2
CC=golang-dev
https://golang.org/cl/4240056
2011-03-02 10:54:23 -08:00
Rob Pike
a77744f488 fmt: delete debugging print that crept in to test.
(you'd never see it, but ouch.)
Spotted by Florian Weimer.

R=rsc
CC=golang-dev
https://golang.org/cl/4259044
2011-03-01 13:39:44 -08:00
Rob Pike
2b9ab22732 fmt: make %#p suppress leading 0x
Fixes bug 1567.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4245048
2011-03-01 13:25:52 -08:00
Rob Pike
87fe958a49 fmt: stop giving characters to the Scan method of Scanner
when we hit a newline during *scanln routines.

Fixes #1490.

R=rsc
CC=golang-dev
https://golang.org/cl/4209042
2011-02-24 10:14:19 -08:00
Roger Peppe
b935728a17 fmt: fix minor typo
R=r, r2
CC=golang-dev
https://golang.org/cl/4187041
2011-02-10 11:01:05 -08:00
Rob Pike
6e615a57af scan: permit base prefixes 0nnn and 0xnn when scanning
signed or unsigned integers using %v or the formatless scanner.
That is, Sscan("0x11", &i) or Sscanf("0x11", "%v", &i) will now
set i to 17.   If a format other than %v is presented, the behavior
is as before.

Fixes #1469.

R=rsc
CC=golang-dev
https://golang.org/cl/4131042
2011-02-04 13:14:38 -08:00
Rob Pike
8bf0bc2754 fmt: document %%
R=rsc, gri
CC=golang-dev
https://golang.org/cl/4130044
2011-02-03 11:55:33 -08:00
Robert Griesemer
c5fc3b6972 fmt: rename internal interfaces
readRuner -> runeReader
unreadRuner -> runeUnreader

R=r, rsc
CC=golang-dev
https://golang.org/cl/4000054
2011-02-02 15:00:14 -08:00
Rob Pike
029bbe18e0 fmt.Scan: scan binary-exponent floating format, 2.4p-3
R=rsc, rog, r2
CC=golang-dev
https://golang.org/cl/4128049
2011-02-02 12:38:48 -08:00
Rob Pike
03a93158d2 fmt: document %b for floating point
R=rsc
CC=golang-dev
https://golang.org/cl/4073051
2011-02-01 21:10:16 -08:00
Russ Cox
f4e76d8309 replace non-blocking send, receive syntax with select
R=golang-dev, nigeltao, niemeyer, r
CC=golang-dev
https://golang.org/cl/4079053
2011-01-31 18:36:28 -05:00
Rob Pike
4e2218968c fmt/doc: define width and precision for strings.
R=rsc
CC=golang-dev
https://golang.org/cl/4061045
2011-01-26 11:10:41 -08:00
Russ Cox
f2b5a07453 delete float, complex - code changes
also:
	cmplx -> complex
	float64(1.0) -> 1.0
	float64(1) -> 1.0

R=gri, r, gri1, r2
CC=golang-dev
https://golang.org/cl/3991043
2011-01-19 23:09:00 -05:00
Russ Cox
61a4e9812e fmt: document %X of string, []byte
suggested by Mark Summerfield

R=r
CC=golang-dev
https://golang.org/cl/4018042
2011-01-19 13:35:45 -05:00
Kyle Consalus
754f0402c3 Made format string handling more efficient.
R=rsc, r, r2
CC=golang-dev
https://golang.org/cl/3421042
2011-01-05 11:42:35 -08:00
Rob Pike
c0332fc93f fmt: normalize processing of format string
The old loop was a bit odd; change it to be more regular.
This also enables a diagnostic for Printf("%", 3): %!(NOVERB)

R=rsc, Kyle C
CC=golang-dev
https://golang.org/cl/3749044
2011-01-05 10:11:34 -08:00
Rob Pike
1ce6245d6c throughout: fix broken calls to Printf etc.
I have written a tool to verify Printf calls, and although it's not
ready to be reviewed yet it's already uncovered a spate of problems
in the repository.  I'm sending this CL to break the changes into
pieces; as the tool improves it will find more, I'm sure.

R=rsc
CC=golang-dev
https://golang.org/cl/3427043
2010-12-07 16:42:54 -05:00
Rob Pike
730e39cd13 fmt: add %U format for standard Unicode representation of integer values.
fmt.Printf("%U", 1) yields "U+0001"
It's essentially "U+%.4x" but lets you override the precision works in scan, too.

R=rsc
CC=golang-dev
https://golang.org/cl/3423043
2010-12-06 14:23:37 -05:00
Rob Pike
fdeda13f9e fmt: fix documentation format glitch. no content to change.
Fixes #1313.

R=gri
CC=golang-dev
https://golang.org/cl/3361041
2010-11-30 14:28:33 -08:00
Adam Langley
3cb4bdb9ce utf8: make EncodeRune's destination the first argument.
R=r
CC=golang-dev
https://golang.org/cl/3364041
2010-11-30 16:59:43 -05:00
Rob Pike
6540c85c7f fmt.Scan: accept Inf and NaN
Fixes #1308.

R=rsc, r2
CC=golang-dev
https://golang.org/cl/3280045
2010-11-30 12:59:52 -08:00
Rob Pike
d90d0ede3f fmt: allow "% X" as well as "% x"
R=rsc, cw, PeterGo
CC=golang-dev
https://golang.org/cl/3319042
2010-11-29 07:30:36 -08:00
Brad Fitzpatrick
e198a5086a strings: Contains
Tiny helper to avoid strings.Index(s, sub) != -1

R=rsc, r2, r
CC=golang-dev
https://golang.org/cl/2265044
2010-11-01 14:32:48 -07:00
Rob Pike
4e9cc085d2 testing: eliminate testing/regexp
Rather than updating the stripped-down regexp implementation embedded
in testing, delete it by passing the one function we need from the package
main file created by gotest.

R=rsc
CC=golang-dev
https://golang.org/cl/2761043
2010-10-28 16:54:24 -07:00
Robert Griesemer
3478891d12 gofmt -s -w src misc
R=r, rsc
CC=golang-dev
https://golang.org/cl/2662041
2010-10-22 10:06:33 -07:00