1. 21 Feb, 2017 1 commit
  2. 19 Feb, 2017 1 commit
  3. 26 Oct, 2016 1 commit
  4. 18 Oct, 2016 1 commit
  5. 07 Oct, 2016 1 commit
    • Russ Cox's avatar
      fmt: document and adjust Scanf space handling to eliminate a few paradoxes · 0db9518a
      Russ Cox authored
      This CL makes minor adjustment to the handling of spaces and newlines
      and then documents the result.
      
      The semantic adjustment mainly concerns the handling of a run of
      spaces following a newline in the format, like in "\n ".
      Previously, that run of spaces was ignored entirely, leading to paradoxes
      like the format "1 \n 2" not matching itself as input.
      Now, spaces following a newline in the format match zero or more
      spaces following the corresponding newline in the input.
      
      The changes to the test suite show how minor the semantic adjustments are
      and how they make the behavior more regular than previously.
      
      This CL also updates the documentation to explain the handling of
      spaces more precisely, incorporating the draft from CL 17723 but
      describing the newly introduced behavior.
      
      Fixes #13565.
      
      Change-Id: I129666e9ba42de3c28b67f75cb47488e9a4c1867
      Reviewed-on: https://go-review.googlesource.com/30611
      
      Reviewed-by: default avatarRob Pike <r@golang.org>
      0db9518a
  6. 09 Sep, 2016 1 commit
  7. 12 May, 2016 1 commit
  8. 17 Apr, 2016 1 commit
  9. 14 Apr, 2016 1 commit
  10. 19 Oct, 2015 1 commit
  11. 31 Aug, 2015 1 commit
  12. 29 Jun, 2015 1 commit
    • Rob Pike's avatar
      fmt: restore padding for %x on byte slices and strings · a76c1a5c
      Rob Pike authored
      Also improve the documentation. A prior fix in this release
      changed the properties for empty strings and slices, incorrectly.
      Previous behavior is now restored and better documented.
      
      Add lots of tests.
      
      The behavior is that when using a string-like format (%s %q %x %X)
      a byte slice is equivalent to a string, and printed as a unit. The padding
      applies to the entire object. (The space and sharp flags apply
      elementwise.)
      
      Fixes #11422.
      Fixes #10430.
      
      Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
      Reviewed-on: https://go-review.googlesource.com/11600
      
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      a76c1a5c
  13. 13 Jun, 2015 1 commit
  14. 12 Jun, 2015 1 commit
    • Rob Pike's avatar
      fmt: require newlines to match when scanning with a format · 57f4b430
      Rob Pike authored
      The documentation says that newlines behave like this:
      
      Scan etc.: newlines are spaces.
      Scanln etc.: newlines terminate the scan.
      Scanf etc.: newlines must match in input and format.
      
      The code did not implement this behavior in all cases,
      especially for Scanf. Make it behave:
      
      - Fix the handling of spaces and newlines in ss.Advance.
      The code is longer but now behaves as it should.
      
      - Delete the reuse of the current ss in newScanState.
      There is really no need, since it's only used in recursive
      calls to Scan etc., and the flags are likely wrong. Simpler
      just to allocate a new one every time, and likelier to
      be correct.
      
      Fixes #10862.
      
      Change-Id: If060ac021017346723b0d62de4e5a305da898f68
      Reviewed-on: https://go-review.googlesource.com/10991
      
      Reviewed-by: default avatarAndrew Gerrand <adg@golang.org>
      57f4b430
  15. 15 Apr, 2015 1 commit
    • Rob Pike's avatar
      fmt: treat reflect.Value specially - as the value it holds · 049b89dc
      Rob Pike authored
      When a reflect.Value is passed to Printf (etc.), fmt called the
      String method, which does not disclose its contents. To get the
      contents, one could call Value.Interface(), but that is illegal
      if the Value is not exported or otherwise forbidden.
      
      This CL improves the situation with a trivial change to the
      fmt package: when we see a reflect.Value as an argument,
      we treat it exactly as we treat a reflect.Value we make inside
      the package. This means that we always print the
      contents of the Value as if _that_ was the argument to Printf.
      
      This is arguably a breaking change but I think it is a genuine
      improvement and no greater a break than many other tweaks
      we have made to formatted output from this package.
      
      Fixes #8965.
      
      Change-Id: Ifc2a4ce3c1134ad5160e101d2196c22f1542faab
      Reviewed-on: https://go-review.googlesource.com/8731
      
      Reviewed-by: default avatarroger peppe <rogpeppe@gmail.com>
      Reviewed-by: default avatarRuss Cox <rsc@golang.org>
      049b89dc
  16. 01 Mar, 2015 1 commit
  17. 19 Jan, 2015 1 commit
  18. 04 Jan, 2015 1 commit
  19. 29 Oct, 2014 2 commits
  20. 04 Oct, 2014 1 commit
  21. 24 Sep, 2014 1 commit
  22. 22 Sep, 2014 1 commit
  23. 08 Sep, 2014 1 commit
  24. 24 Jun, 2014 1 commit
  25. 29 Apr, 2014 1 commit
  26. 11 Apr, 2014 1 commit
  27. 26 Mar, 2014 1 commit
  28. 19 Mar, 2014 1 commit
    • Rob Pike's avatar
      fmt: make %F a synonym for %f · b00d9677
      Rob Pike authored
      Rationale:
              It already is for scanning.
              It is accepted for complexes already, but doesn't work.
              It's analogous to %G and %E.
              C accepts it too, and we try to be roughly compatible.
      Fixes #7518.
      
      LGTM=bradfitz
      R=golang-codereviews, bradfitz
      CC=golang-codereviews
      https://golang.org/cl/77580044
      b00d9677
  29. 18 Mar, 2014 1 commit
  30. 12 Mar, 2014 1 commit
  31. 31 Jul, 2013 3 commits
  32. 29 May, 2013 1 commit
  33. 24 May, 2013 1 commit
    • Rob Pike's avatar
      fmt.Printf: introduce notation for random access to arguments. · 7472ce0e
      Rob Pike authored
      This text is added to doc.go:
      
              Explicit argument indexes:
      
              In Printf, Sprintf, and Fprintf, the default behavior is for each
              formatting verb to format successive arguments passed in the call.
              However, the notation [n] immediately before the verb indicates that the
              nth one-indexed argument is to be formatted instead. The same notation
              before a '*' for a width or precision selects the argument index holding
              the value. After processing a bracketed expression [n], arguments n+1,
              n+2, etc. will be processed unless otherwise directed.
      
              For example,
                      fmt.Sprintf("%[2]d %[1]d\n", 11, 22)
              will yield "22, 11", while
                      fmt.Sprintf("%[3]*[2].*[1]f", 12.0, 2, 6),
              equivalent to
                      fmt.Sprintf("%6.2f", 12.0),
              will yield " 12.00". Because an explicit index affects subsequent verbs,
              this notation can be used to print the same values multiple times
              by resetting the index for the first argument to be repeated:
                      fmt.Sprintf("%d %d %#[1]x %#x", 16, 17)
              will yield "16 17 0x10 0x11".
      
      The notation chosen differs from that in C, but I believe it's easier to read
      and to remember (we're indexing the arguments), and compatibility with
      C's printf was never a strong goal anyway.
      
      While we're here, change the word "field" to "arg" or "argument" in the
      code; it was being misused and was confusing.
      
      R=rsc, bradfitz, rogpeppe, minux.ma, peter.armitage
      CC=golang-dev
      https://golang.org/cl/9680043
      7472ce0e
  34. 29 Apr, 2013 1 commit
  35. 25 Feb, 2013 1 commit
  36. 22 Dec, 2012 1 commit
  37. 30 Oct, 2012 1 commit